Structure optimization

From VASP Wiki
Revision as of 09:05, 15 October 2024 by Schlipf (talk | contribs) (Created page with "=== RMM-DIIS ({{TAG|IBRION}}=1) === For {{TAG|IBRION}}=1, a quasi-Newton (variable metric) algorithm is used to relax the ions into their instantaneous groundstate. The forces and the stress tensor are used to determine the search directions for finding the equilibrium positions (the total energy is not taken into account). This algorithm is very fast and efficient close to local minima, but fails badly if the initial positions are a bad guess (use {{TAG|IBRION}}=2 in t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

RMM-DIIS (IBRION=1)

For IBRION=1, a quasi-Newton (variable metric) algorithm is used to relax the ions into their instantaneous groundstate. The forces and the stress tensor are used to determine the search directions for finding the equilibrium positions (the total energy is not taken into account). This algorithm is very fast and efficient close to local minima, but fails badly if the initial positions are a bad guess (use IBRION=2 in that case). Since the algorithm builds up an approximation of the Hessian matrix it requires very accurate forces, otherwise it will fail to converge. An efficient way to achieve this is to set NELMIN to a value between 4 and 8 (for simple bulk materials 4 is usually adequate, whereas 8 might be required for complex surfaces where the charge density converges very slowly). This forces a minimum of 4 to 8 electronic steps between each ionic step, and guarantees that the forces are well converged at each step.

The implemented algorithm is called RMM-DIIS.[1] It implicitly calculates an approximation of the inverse Hessian matrix by taking into account information from previous iterations. On startup, the initial Hessian matrix is diagonal and equal to POTIM. Information from old steps (which can lead to linear dependencies) is automatically removed from the iteration history, if required. The number of vectors kept in the iterations history (which corresponds to the rank of the Hessian matrix must not exceed the degrees of freedom. Naively the number of degrees of freedom is 3(NIONS-1). But symmetry arguments or constraints can reduce this number significantly.

There are two algorithms built in to remove information from the iteration history:

  1. If NFREE is set in the INCAR file, only up to NFREE ionic steps are kept in the iteration history (the rank of the approximate Hessian matrix is not larger than NFREE).
  2. If NFREE is not specified, the criterion whether information is removed from the iteration history is based on the eigenvalue spectrum of the inverse Hessian matrix: if one eigenvalue of the inverse Hessian matrix is larger than 8, information from previous steps is discarded.

For complex problems NFREE can usually be set to a rather large value (i.e. 10-20), however systems of low dimensionality require a careful setting of NFREE (or preferably an exact counting of the number of degrees of freedom). To increase NFREE beyond 20 rarely improves convergence. If NFREE is set to too large, the RMM-DIIS algorithm might diverge.

The choice of a reasonable POTIM is also important and can speed up calculations significantly, we recommend to find an optimal POTIM using IBRION=2 or performing a few test calculations (see below).

Conjugate gradient (IBRION=2)

A conjugate-gradient algorithm (a discussion of this algorithm can be found for instance in Numerical Recipes, by Press et al.[2]) is used to relax the ions into their instantaneous groundstate. In the first step ions (and cell shape) are changed along the direction of the steepest descent (i.e. the direction of the calculated forces and stress tensor). The conjugate gradient method requires a line minimization, which is performed in several steps:

  1. First a trial step into the search direction (scaled gradients) is done, with the length of the trial step controlled by the POTIM tag. Then the energy and the forces are recalculated.
  2. The approximate minimum of the total energy is calculated from a cubic (or quadratic) interpolation taking into account the change of the total energy and the change of the forces (3 pieces of information), then a corrector step to the approximate minimum is performed.
  3. After the corrector step the forces and energy are recalculated and it is checked whether the forces contain a significant component parallel to the previous search direction. If this is the case, the line minimization is improved by further corrector steps using a variant of Brent's algorithm.[2]

To summarize: In the first ionic step the forces are calculated for the initial configuration read from the POSCAR file, the second step is a trial (or predictor step), the third step is a corrector step. If the line minimization is sufficiently accurate in this step, the next trial step is performed.

NSTEP:
  1. initial positions
  2. trial step
  3. corrector step, i.e. positions corresponding to anticipated minimum
  4. trial step
  5. corrector step
...

Damped molecular dynamics (IBRION=3)

If a damping factor is supplied in the INCAR file by means of the SMASS tag, a damped second order equation of motion is used for the update of the ionic degrees of freedom:

where SMASS supplies the damping factor μ, and POTIM controls α. A simple velocity Verlet algorithm is used to integrate the equation, the discretised equation reads:

One may immediately recognize, that μ=2 is equivalent to a simple steepest descent algorithm (of course without line optimization). Hence, μ=2 corresponds to maximal damping, μ=0 corresponds to no damping. The optimal damping factor depends on the Hessian matrix (matrix of the second derivatives of the energy with respect to the atomic positions). A reasonable first guess for μ is usually 0.4.

Mind that our implementation is particular user-friendly, since changing μ usually does not require to re-adjust the time step POTIM. To choose an optimal time step and damping factor, we recommend the following two step procedure: First fix μ (for instance to 1) and adjust POTIM. POTIM should be chosen as large as possible without getting divergence in the total energy. Then decrease μ and keep POTIM fixed. If POTIM and SMASS are chosen correctly, the damped molecular dynamics mode usually outperforms the conjugate gradient method by a factor of two.

If SMASS is not set in the INCAR file (respectively SMASS<0), a velocity quench algorithm is used. In this case the ionic positions are updated according using the following algorithm: F are the current forces, and α equals POTIM. This equation implies that, if the forces are antiparallel to the velocities, the velocities are quenched to zero. Otherwise the velocities are made parallel to the present forces, and they are increased by an amount that is proportional to the forces.

Mind: For IBRION=3, a reasonable time step must be supplied by the POTIM parameter. Too large time steps will result in divergence, too small ones will slow down the convergence. The stable time step is usually twice the smallest line minimization step in the conjugate gradient algorithm.

Some general comments

For IBRION=1, 2, and 3, the flag ISIF determines whether the ions and/or the cell shape is changed. Update of the cell shape is supported for molecular dynamics (IBRION=0) only if the dynamics module of Tomas Bucko (precompiler flag -Dtbdyn) is used.

Within all relaxation algorithms (IBRION=1, 2, and 3) the parameter POTIM should be supplied in the INCAR file. For IBRION>0, the forces are scaled internally before calling the minimization routine. Therefore for relaxations, POTIM has no physical meaning and serves only as a scaling factor. For many systems, the optimal POTIM is around 0.5. Because the Quasi-Newton algorithm and the damped algorithms are sensitive to the choice of this parameter, use IBRION=2, if you are not sure how large the optimal POTIM is.

In this case, the OUTCAR file and stdout will contain a line indicating a reliable POTIM. For IBRION=2, the following lines will be written to stdout after each corrector step (usually each odd step):

 trial: gam=  .00000 g(F)=   .152E+01 g(S)=  .000E+00 ort = .000E+00
 (trialstep = .82)

The quantity gam is the conjugation parameter to the previous step, g(F) and g(S) are the norm of the force respectively the norm of the stress tensor. The quantity ort is an indicator whether this search direction is orthogonal to the last search direction (for an optimal step this quantity should be much smaller than (g(F) + g(S)). The quantity trialstep is the size of the current trialstep. This value is the average step size leading to a line minimization in the previous ionic step. An optimal POTIM can be determined, by multiplying the current POTIM with the quantity trialstep.

After at the end of a trial step, the following lines are written to stdout:

 trial-energy change:   -1.153185  1.order   -1.133   -1.527  -.739
 step:   1.7275(harm=  2.0557)  dis=  .12277  
                            next Energy= -1341.57 (dE= -.142E+01)

The quantity trial-energy change is the change of the energy in the trial step. The first value after 1.order is the expected energy change calculated from the forces: (F(start)+F(trial))/2×change of positions. The second and third value corresponds to F(start)×change of positions, and F(trial)×change of positions.

The first value in the second line is the size of the step leading to a line minimization along the current search direction. It is calculated from a third order interpolation formula using data from the start and trial step (forces and energy change). harm is the optimal step using a second order (or harmonic) interpolation. Only information on the forces is used for the harmonic interpolation. Close to the minimum both values should be similar. dis is the maximum distance moved by the ions in fractional (direct) coordinates. next Energy gives an indication how large the next energy should be (i.e. the energy at the minimum of the line minimization), dE is the estimated energy change.

The OUTCAR file will contain the following lines, at the end of each trial step:

 trial-energy change:   -1.148928  1.order   -1.126  -1.518  -.735
  (g-gl).g =  .152E+01      g.g   =  .152E+01  gl.gl    =  .000E+00
 g(Force)  =  .152E+01   g(Stress)=  .000E+00 ortho     =  .000E+00
 gamma     =    .00000
 opt step  =   1.72745  (harmonic =   2.05575) max dist = .12277085
 next E    = -1341.577507   (d E  =   1.42496)

The line trial-energy change was already discussed. g(Force) corresponds to g(F), g(Stress) to g(S), ortho to ort, gamma to gam. The values after gamma correspond to the second line (step: ...) previously described.