My calculation didn't work!
This is a common complaint when performing molecular modeling simulations. You start the calculation, and come back many hours later to find it didn't finish correctly or didn't converge. This usually means either (1) the calculation crashed (hopefully with error messages that you can google) or (2) the calculation is taking a very long time, perhaps despite restarting the calculation multiple times.
Below we discuss several issues related to converging simulations. Recall that there are two convergence loops that DFT calculations will run through: wavefunction optimization (i.e. scf convergence) and geometry optimization. The program first determines the wavefunction for a given geometry, which gives the forces and energies of that geometry. Then the program will update the geometry to a new structure based on the calculated forces. It will re-calculate the wavefunction, then geometry, and repeat until the system is finally converged and the geometry is optimized.
Geometry Optimization Problems
Geometry optimization aims to find the geometry where the forces are zero (or close enough). The structure with zero forces is the most stable, or ground structure. The problem is that there are usually many variables to change and optimize. Every atom has three coordinates that can be changed (x, y, z coordinates). So finding the ground structure is not always straight-forward. See below for a relatively simple example (water). The ground structure for water occurs at a specific bond angle and bond distance. Larger molecules have many more variables to optimize. Numerical algorithms are used to keep trying geometries until the ground structure is found, and sometimes they don't always work.
What should I do about geometry problems?
- Monitor the energies and forces of your calculation. Are they going up over time? Going down? Oscillating? This can tell you if optimization is proceeding correctly or not. This program grad2 by Peter Larsson may be useful in monitoring the forces during a VASP simulation.
- Check the geometry. Does something look strange or wrong? Are some bonds broken that shouldn't be broken? Has the structure fallen apart, or appear to be converging to some undesired geometry? If things look bad, you probably need to restart the calculation with a better initial geometry.
- Garbage In = Garbage Out. If you start with an initial bad geometry, you'll likely end up with a final bad geometry. So always try to start with a good initial geometry. Set bond distances to reasonable values. Otherwise the optimization could explode or go very wrong. Get good guesses of initial geometries (such as bond distances) from the literature or past calculations.
- You may want to get a geometry from a low-level calculation (like low number of k-points) and use this as starting point for more accurate calculation. This can save time if you don't know what the converged geometry looks like.
- Sometimes an optimization gets stuck in a very shallow energy well, or a local minimum. A perturbation of the geometry may help get out of this well. Move a key atom (or atoms) some distance, like 0.1 to 0.4 Å in some random direction.
- Make sure your cell volume is reasonable. For instance, if the cell volume is too small you may get interactions between mirror atoms, which may make optimization difficult.
- Increase the number of geometry optimization steps (NSW in VASP). Sometimes the default number of allowed geometry optimization steps isn't enough and you need more time to optimize the geometry.
- Change the optimization algorithm/settings. Default settings may not be most efficient or always work. So try different settings in your code. For instance, in VASP you might change IBRION to 1 from 2 (or vice versa).
- Lower the wavefunction tolerance. A good wavefunction is needed to get accurate forces needed for geometry optimization. In some cases you may need to lower the tolerance for wavefunction optimization so that the wavefunction (and hence the forces) are more tightly converged. In VASP you could for instance lower the EDIFF value to 1E-6 or 1E-7.
- Google for help. The internet may have ideas to help.
- Be patient. Sometimes you just need to wait a long time for geometry optimization to converge, especially if you are far from the ground structure.
Electronic SCF Problems
During a DFT simulation, the right wavefunction for the given geometry must be found. The SCF loop keeps trying different wavefunctions using numerical algorithms until the energy stops significantly changing and the wavefunction is self-consistent. Some systems (like metals) can be particularly hard to obtain converged wavefunctions. See this page for specific tips using CP2K. General tips are below.
What should I do about electronic SCF problems?
- Check the energies at each SCF step. Are they going up? Going down? Oscillating? If energies are going down then that's a good sign. If energies are going up or oscillating, then there is cause to worry.
- Check the geometry. If you have a strange or bad geometry, SCF convergence could be hard.
- Check the band occupation. Sometimes you'll get weird band occupation (like fractional occupation) which could be a sign that your wavefunction isn't converging correctly.
- Check the simulation parameters. There are lots of settings that can lead to bad SCF convergence. Too low k-points, insufficient number of bands, too low cutoff energy, bad pseudopotential, etc. You may need to change these parameters to get a more robust calculation.
- Check the smearing scheme. Make sure you have the right smearing approach for the system you're modeling. For example metals work well with Methfessel-Paxton smearing using VASP, while semiconductors work well with Gaussian smearing.
- Increase the number of maximum steps. Some systems take a lot of SCF steps to converge and may require more steps to reach convergence than the default (e.g. NELM in VASP).
- Change the optimization algorithm/settings. The default algorithm may not be best. There are several algorithms in VASP that my be worth trying, such as conjugate gradient, Blocked-Davidson, DIIS, etc. See the IALGO or ALGO settings.
- Change the initial spin. For surfaces/solids this usually isn't a problem, except for magnetic systems. Certain molecules/atoms (like radicals or metals) on the other hand may have most stable spin states different than the default. So try changing the spin (NUPDOWN in VASP).
- Change the geometry. If your geometry is bad, SCF convergence may be difficult. See ideas above.
- Use wavefunctions from previous calculations. If you use a wavefunction that is converged (or even partially converged) as the initial wavefunction for a new calculation, this can help reach convergence faster. Just make sure the old wavefunction is appropriate for the new calculation.
- Google for help. The internet has lots of resources.
- Be patient. Sometimes SCF optimization may take a long time, especially if your geometry is far from converged. You may just need to be patient.
Hardware/Software Problems
Sometimes hardware does fail or has problems. Sometimes software and/or libraries are not correctly installed. If you get strange messages (like "Error EDDDAV: Call to ZHEGV failed. Returncode = 25 248") it's usually best to google the error messages. Ask your IT people to help also. They can probably help troubleshoot what is going on and help you take appropriate steps.