Structure optimization: Difference between revisions

From VASP Wiki
No edit summary
 
(25 intermediate revisions by 2 users not shown)
Line 5: Line 5:
Therefore, we typically limit ourselves to the simpler problem of finding the closest local minimum for a given starting structure.
Therefore, we typically limit ourselves to the simpler problem of finding the closest local minimum for a given starting structure.
As user, this limitation has two important consequences:
As user, this limitation has two important consequences:
(i) You need to make sure that the starting structure is close enough too a minimum for the optimizers to work.
(i) You need to make sure that the starting structure is close enough to a minimum for the optimizers to work.
(ii) You may need to consider a diverse set of starting structures, if you are not sure about the most reasonable one.
(ii) You may need to consider a diverse set of starting structures, if you are not sure about the most reasonable one.


Line 18: Line 18:


Next, you need to decide on an algorithm by setting the {{TAG|IBRION}} tag.
Next, you need to decide on an algorithm by setting the {{TAG|IBRION}} tag.
In the figure 1, we show some heuristic rules that may help to decide with this selection.
In Figure 1, we show some heuristic rules that may help to decide with this selection.
These guidelines are a compromise between speed and robustness of the algorithms.
These guidelines are a compromise between speed and robustness of the algorithms.
The [[#RMM-DIIS|RMM-DIIS algorithm]] ({{TAGO|IBRION|1}}) is very efficient because it uses the history of many steps to obtain the best next guess.
The [[#RMM-DIIS|RMM-DIIS algorithm]] ({{TAGO|IBRION|1}}) is very efficient because it uses the history of many steps to obtain the best next guess.
Line 27: Line 27:
Even simpler are [[#Damped molecular dynamics|damped molcular dynamics]] ({{TAGO|IBRION|3}}).
Even simpler are [[#Damped molecular dynamics|damped molcular dynamics]] ({{TAGO|IBRION|3}}).
This algorithm propagates through time using the forces and friction on the velocities.
This algorithm propagates through time using the forces and friction on the velocities.


All relaxation algorithms ({{TAG|IBRION}}=1, 2, and 3) rely on a step size {{TAG|POTIM}}.
All relaxation algorithms ({{TAG|IBRION}}=1, 2, and 3) rely on a step size {{TAG|POTIM}}.
Line 33: Line 32:
For many systems, the optimal {{TAG|POTIM}} is around 0.5.
For many systems, the optimal {{TAG|POTIM}} is around 0.5.
Since the RMM-DIIS algorithm and the damped molecular dynamics are sensitive this parameter, use the conjugate gradient algorithm ({{TAGO|IBRION}}=2), if you are not sure how large the optimal {{TAG|POTIM}} is.
Since the RMM-DIIS algorithm and the damped molecular dynamics are sensitive this parameter, use the conjugate gradient algorithm ({{TAGO|IBRION}}=2), if you are not sure how large the optimal {{TAG|POTIM}} is.
In this case, the {{FILE|OUTCAR}} file and <tt>stdout</tt> will contain a line indicating a reliable {{TAG|POTIM}}.
In this case, the {{FILE|OUTCAR}} file and <tt>stdout</tt> will contain a line indicating a reliable {{TAG|POTIM}}.
For {{TAGO|IBRION|2}}, the following lines will be written to <tt>stdout</tt> after each corrector step (usually each odd step):
For {{TAGO|IBRION|2}}, the following lines will be written to <tt>stdout</tt> after each corrector step (usually each odd step):


  trial: gam= .00000 g(F)=   .152E+01 g(S)=  .000E+00 ort = .000E+00
trial: gam= 0.20820 g(F)= 0.494E+00 g(S)=  0.000E+00 ort = 0.728E-03 (trialstep = 0.881E+00)
  (trialstep = .82)


The quantity <tt>trialstep</tt> is the size of the current trialstep.  
The quantity <tt>trialstep</tt> is the size of the current trialstep.  
Line 45: Line 42:
== RMM-DIIS ==
== RMM-DIIS ==


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 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 {{TAG|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.
For {{TAGO|IBRION|1}}, VASP uses a RMM-DIIS algorithm to relax the ions into their instantaneous groundstate.
RMM-DIIS stands for ''residual-minimization method, direct inversion of the iterative subspace''.{{cite|pulay:cpl:1980}}
The forces and the stress tensor 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 a local minimum, but fails badly if the initial positions are a bad guess (use [[#Conjugate gradient|conjugate gradient]] instead).
 
RMM-DIIS implicitly calculates an approximation of the inverse Hessian matrix by taking into account information from previous iterations.
The approximation of the Hessian matrix requires very accurate forces, otherwise the algorithm will fail to converge.
Enforcing a minimum of electronic steps between each ionic step ({{TAG|NELMIN}}) converges forces efficiently.
For simple bulk materials {{TAGO|NELMIN|4}} is usually adequate, whereas complex surfaces, where the charge density converges very slowly, might require {{TAGO|NELMIN|8}}.
 
On startup, the initial Hessian matrix is diagonal and equal to {{TAG|POTIM}}.
In each iteration a new vector is added to the history.
The length of the history determines the rank of the Hessian and must not exceed the degrees of freedom.
Naively, one has three degrees of freedom for every ion and nine for the unit cell, but translational invariance, symmetry arguments and constraints can reduce this number significantly.
If old steps lead to linear dependencies, they will be automatically removed from the iteration history.
When further fine tuning is desired, you can set the {{TAG|NFREE}} tag to adjust the size of the history.
 
A reasonable {{TAG|POTIM}} can speed up calculations significantly.
We recommend to find an optimal {{TAG|POTIM}} using {{TAGO|IBRION|2}} or performing a few test calculations (see above).
 
=== Understanding the output ===
 
RMM-DIIS will produce output similar to the following to ''stdout''


The implemented algorithm is called RMM-DIIS.{{cite|pulay:cpl:1980}} 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 {{TAG|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.
BRION: g(F)=  0.463E-01 g(S)=  0.000E+00 retain N=  2 mean eig= 5.94
eig:  5.940  5.940


There are two algorithms built in to remove information from the iteration history:
and the {{FILE|OUTCAR}} file
#If {{TAG|NFREE}} is set in the {{FILE|INCAR}} file, only up to {{TAG|NFREE}} ionic steps are kept in the iteration history (the rank of the approximate Hessian matrix is not larger than {{TAG|NFREE}}).
#If {{TAG|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 {{TAG|NFREE}} can usually be set to a rather large value (i.e. 10-20), however systems of low dimensionality require a careful setting of {{TAG|NFREE}} (or preferably an exact counting of the number of degrees of freedom). To increase {{TAG|NFREE}} beyond 20 rarely improves convergence. If {{TAG|NFREE}} is set to too large, the RMM-DIIS algorithm might diverge.
  Quasi-Newton relaxation of ions (Broydens 2nd method)                                                                                                                                                                                     
g(Force)  = 0.463E-01  g(Stress)= 0.000E+00
 
  retain information from N=  2 steps
  eigenvalues of (default step * inverse Hessian matrix)
  average eigenvalue of G=  5.9397
  eigenvalue spectrum of G is  5.9397  5.9397


The choice of a reasonable {{TAG|POTIM}} is also important and can speed up calculations significantly, we recommend to find an optimal {{TAG|POTIM}} using {{TAG|IBRION}}=2 or performing a few test calculations (see below).
The ''g'' values correspond to the norm of the forces and the stress, respectively.
VASP also reports the eigenvalues of the approximate Hessian and how many vectors are currently stored in the iteration history.


== Conjugate gradient ==
== Conjugate gradient ==


A conjugate-gradient algorithm (a discussion of this algorithm can be found for instance in ''Numerical Recipes'', by Press ''et al.''{{cite|press:book:1986}}) 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:
In the conjugate-gradient algorithm {{TAGO|IBRION|2}}, we optimize the structure along a search direction.
#First a trial step into the search direction (scaled gradients) is done, with the length of the trial step controlled by the {{TAG|POTIM}} tag. Then the energy and the forces are recalculated.
The initial search direction is given by forces and stress;
#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.
in subsequent steps, we require that the search is conjugate (perpendicular) to the previous direction.
#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.{{cite|press:book:1986}}
Once the search direction is chosen, a line search along this direction determines the optimal step size.
''Numerical Recipes'' by Press ''et al.'' contains more details about conjugate gradient.{{cite|press:book:1986}}  
 
In VASP, the line search along the search direction uses the following steps
#We perform a ''trial step'' into the search direction. {{TAG|POTIM}} controls the length of the trial step.
#We recompute the energy, forces, and stress.
#Based on the initial energy, the energy after the trial step, and the change of the forces, we fit a cubic or quadratic polynomial to determine the expected minimum (''corrector step'').
#We recompute the energy, forces, and stress.
#If after the corrector step the forces and stress parallel to the current search direction vanish, we perform the next trial step. Otherwise, we improve the line minimization by further corrector steps using a variant of Brent's algorithm.{{cite|press:book:1986}}
{{NB|tip|If your structure is well suited for the conjugate-gradient algorithm, you should see one initial calculation for the structure in the {{FILE|POSCAR}} file. Then, VASP should alternate between trial and corrector step.}}
 
=== Understanding the output ===
 
In a trial step, you will see similar output like this in the ''stdout''
 
trial-energy change:  -0.415121  1 .order  -0.385587  -0.435540  -0.335634
step:  3.5233(harm=  3.8400)  dis= 0.29442  next Energy=  -133.730354 (dE=-0.949E+00)
 
and the {{FILE|OUTCAR}} file
 
Conjugate gradient step on ions:
trial-energy change:  -0.415121  1 .order  -0.385587  -0.435540  -0.335634
  (g-gl).g = 0.511E+00      g.g  = 0.494E+00  gl.gl    = 0.245E+01
g(Force)  = 0.494E+00  g(Stress)= 0.000E+00 ortho    = 0.728E-03
gamma    =  0.20820
trial    =  0.88083
opt step  =  3.52334  (harmonic =  3.84000) maximal distance =0.29442102
next E    =  -133.730354  (d E  =  -0.94937)
 
Of particular interest are the current errors ''g(Force)'' and ''g(Stress)'', the step size (here 0.88083) in units of {{TAG|POTIM}}, and the largest distance any ion moves (here 0.29442).
You can also compare the expected energy (''next E'' or ''next Energy'') with the energy you obtain in the corrector step.
 
The other values have the following meaning:
* The ''trial-energy change'' is the change of the energy in the trial step
* The values after ''1 .order'' describe the expected energy change resulting from the inner product of gradient and change of the structure. The three different values use the average gradient, the gradient of the previous, and the gradient of the current step, respectively.
* The values ''step'' and ''opt step''  are the step size of a cubic interpolation; ''harm'' and ''harmonic'' uses a quadratic interpolation. Close to the minimum these values should agree.
* ''dE'' is the expected energy change.
 
 
In the corrector step, you will get only output to ''stdout''
 
curvature:  -0.78 expect dE=-0.387E+00 dE for cont linesearch -0.104E-06
trial: gam= 0.20820 g(F)=  0.494E+00 g(S)=  0.000E+00 ort = 0.728E-03 (trialstep = 0.881E+00)
search vector abs. value=  0.667E+00


To summarize: In the first ionic step the forces are calculated for the initial configuration read from the {{FILE|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.
You can look at the norm of the forces ''g(F)'' and the stress ''g(S)''.
The ''ort'' value tests whether the forces and stress are orthogonal to the previous search direction (should be small).
As mentioned above, ''trialstep'' is the step size in units of {{TAG|POTIM}}.


:NSTEP:
Occasionally, you may get output from ''ZBRENT''.
:# initial positions
This indicates that the error in the corrector step was too large and the line search is further refined.
:# trial step
:# corrector step, i.e. positions corresponding to anticipated minimum
:# trial step
:# corrector step
::...


== Damped molecular dynamics ==
== Damped molecular dynamics ==
If a damping factor is supplied in the {{FILE|INCAR}} file by means of the {{TAG|SMASS}} tag, a damped second order equation of motion is used for the update of the ionic degrees of freedom:
With {{TAGO|IBRION|3}} and {{TAG|SMASS}}, VASP will execute a damped second order equation of motion for the degrees of freedom
:<math>
:<math>
{\ddot {\vec x}} = -2 \alpha {\vec F} - \mu  {\dot {\vec x}},
{\ddot {\vec x}} = -2 \alpha {\vec F} - \mu  {\dot {\vec x}},
</math>
</math>
where {{TAG|SMASS}} supplies the damping factor &mu;, and {{TAG|POTIM}} controls &alpha;. A simple velocity Verlet algorithm is used to integrate the equation, the discretised equation reads:
where {{TAG|SMASS}} supplies the damping factor &mu; and {{TAG|POTIM}} controls &alpha;.
Discretising the differential equation with a simple velocity Verlet algorithm yields
:<math>
:<math>
\begin{align}
\begin{align}
{\vec v_{N+1/2}} =&  \Big((1-\mu/2) {\vec v_{N-1/2}} - 2\alpha {\vec F_N} \Big)/(1+\mu/2)\\
{\vec v_{N+1/2}} =&  \frac{(2-\mu) {\vec v_{N-1/2}} - 4\alpha {\vec F_N}} {2+\mu}\\
{\vec x_{N+1}} =&  {\vec x_{N}} + {\vec v_{N+1/2}}
{\vec x_{N+1}} =&  {\vec x_{N}} + {\vec v_{N+1/2}}
\end{align}
\end{align}
</math>
</math>
One may immediately recognize, that &mu;=2 is equivalent to a simple steepest descent algorithm (of course without line optimization). Hence, &mu;=2 corresponds to maximal damping, &mu;=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 &mu; is usually 0.4.
One may immediately recognize, that &mu;=2 is equivalent to a simple steepest descent algorithm without line optimization.
Hence, &mu;=2 corresponds to maximal damping, &mu;=0 corresponds to no damping.
The optimal damping factor depends on the second derivatives of the energy with respect to the degrees of freedom.
A reasonable first guess for &mu; is usually 0.4.


Mind that our implementation is particular user-friendly, since changing &mu; usually does not require to re-adjust the time step {{TAG|POTIM}}. To choose an optimal time step and damping factor, we recommend the following two step procedure: First fix &mu; (for instance to 1) and adjust {{TAG|POTIM}}. {{TAG|POTIM}} should be chosen as large as possible without getting divergence in the total energy. Then decrease &mu; and keep {{TAG|POTIM}} fixed. If {{TAG|POTIM}} and {{TAG|SMASS}} are chosen correctly, the damped molecular dynamics mode usually outperforms the conjugate gradient method by a factor of two.
Mind that our implementation is particularly user-friendly, since changing &mu; usually does not require to re-adjust the time step {{TAG|POTIM}}.
 
To choose an optimal time step and damping factor, we recommend the following two step procedure:
If {{TAG|SMASS}} is not set in the {{FILE|INCAR}} file (respectively {{TAG|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 &alpha; equals {{TAG|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.
# Fix &mu; (for instance to 1) and adjust {{TAG|POTIM}}. {{TAG|POTIM}} should be chosen as large as possible without getting divergence in the total energy.
 
# Decrease &mu; and keep {{TAG|POTIM}} fixed.
'''Mind''': For {{TAG|IBRION}}=3, a reasonable time step ''must'' be supplied by the {{TAG|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.
If {{TAG|POTIM}} and {{TAG|SMASS}} are chosen correctly, the damped molecular dynamics mode may outperform the conjugate gradient method by a factor of two.


If {{TAGO|SMASS|0|op=<}} a velocity quench algorithm is used.
:<math>
  \vec v_{\rm quench} = \rm{max}((\vec v + \alpha \vec F) \cdot \vec F, 0) \frac{\vec F}{F^2} + \alpha \vec F
</math>
You can see that velocities are projected onto the forces and only remain if that projection is a positive number.
{{NB|mind|For {{TAGO|IBRION|3}}, a reasonable time step {{TAG|POTIM}} ''must'' be supplied. Too large time steps will result in divergence, too small ones will slow down the convergence. A good choice is usually twice the ''smallest'' step size you would observe with the conjugate gradient algorithm.}}


== Understanding the output ==
=== Understanding the output ===


The quantity <tt>gam</tt> is the conjugation parameter to the previous step, <tt>g(F)</tt> and <tt>g(S)</tt> are the norm of the force respectively the norm of the stress tensor. The quantity <tt>ort</tt> 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 <tt>(g(F) + g(S))</tt>. The quantity <tt>trialstep</tt> 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 {{TAG|POTIM}} can be determined, by multiplying the current {{TAG|POTIM}} with the quantity trialstep.
Damped molecular dynamics produces relatively little output compared to the other two algorithms.
 
If {{TAG|SMASS}} is set to a value larger than 0, you will see output like this in ''stdout''
After at the end of a trial step, the following lines are written to <tt>stdout</tt>:
dampedg(F)=  0.159E+01 g(S)= 0.000E+00 dE (1.order)=-0.254E+01
 
otherwise for the quenched velocity algorithm you get output similar to this
  trial-energy change:   -1.153185 1.order  -1.133  -1.527  -.739
   summed vel is now   0.0000000000000000        0.0000000000000000        5.5511151231257827E-017
  step:  1.7275(harm=  2.0557) dis=  .12277 
  quench: g(F)=  0.191E+02 g(S)=  0.000E+00 dE (1.order)=-0.311E+02
                            next Energy= -1341.57 (dE= -.142E+01)
In both cases ''g(F)'' and ''g(S)'' are the norm of forces and stress.
 
The extra line in the latter case is a sanity check on the average velocities and should produce vanishingly small numbers.
The quantity <tt>trial-energy</tt> change is the change of the energy in the trial step. The first value after <tt>1.order</tt> is the expected energy change calculated from the forces: ('''F'''(start)+'''F'''(trial))/2&times;change of positions. The second and third value corresponds to '''F'''(start)&times;change of positions, and '''F'''(trial)&times;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). <tt>harm</tt> 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. <tt>dis</tt> is the maximum distance moved by the ions in fractional (direct) coordinates. <tt>next Energy</tt> 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 {{FILE|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 <tt>trial-energy change</tt> was already discussed. <tt>g(Force)</tt> corresponds to <tt>g(F)</tt>, <tt>g(Stress)</tt> to <tt>g(S)</tt>, <tt>ortho</tt> to <tt>ort</tt>, <tt>gamma</tt> to <tt>gam</tt>. The values after <tt>gamma</tt> correspond to the second line (<tt>step:</tt> ...) previously described.


== Related tags and articles ==
{{TAG|IBRION}},
{{TAG|POTIM}},
{{TAG|NSW}},
{{TAG|SMASS}}


== References ==
== References ==
<references/>
<references/>
[[Category:Ionic minimization]][[Category:Howto]][[Category:Forces]]

Latest revision as of 11:15, 18 October 2024

Overview

Structure optimization describes the task of finding the lattice vectors and atom positions that minimize the energy of the system. In its most general form, this optimization problem is extremely challenging because there are usually many local minima. Therefore, we typically limit ourselves to the simpler problem of finding the closest local minimum for a given starting structure. As user, this limitation has two important consequences: (i) You need to make sure that the starting structure is close enough to a minimum for the optimizers to work. (ii) You may need to consider a diverse set of starting structures, if you are not sure about the most reasonable one.

Common considerations

Figure 1: Heuristics for choosing a suitable structure optimization algorithm.

Typically, optimization problems are more difficult to solve, the more free parameters they have. In VASP, you can control the degrees of freedom in different ways: First, use ISIF to determine whether the position of the ions, the shape of the cell, and the volume of the cell change. Second, set selective dynamics in the POSCAR file to decide which ion positions may change.

Next, you need to decide on an algorithm by setting the IBRION tag. In Figure 1, we show some heuristic rules that may help to decide with this selection. These guidelines are a compromise between speed and robustness of the algorithms. The RMM-DIIS algorithm (IBRION = 1) is very efficient because it uses the history of many steps to obtain the best next guess. However, if your structure is still far from the minimum, it is not wise too include the information from these points far from the minimum and the algorithm struggles. The conjugate-gradient (CG) algorithm (IBRION = 2) chooses a search direction conjugate to previous ones. Then it selects an optimal step size along this search direction. This algorithm is a good default choice because of its robustness. Even simpler are damped molcular dynamics (IBRION = 3). This algorithm propagates through time using the forces and friction on the velocities.

All relaxation algorithms (IBRION=1, 2, and 3) rely on a step size POTIM. This step size has no direct physical meaning but scales the forces internally before calling the minimization routine. For many systems, the optimal POTIM is around 0.5. Since the RMM-DIIS algorithm and the damped molecular dynamics are sensitive this parameter, use the conjugate gradient algorithm (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= 0.20820 g(F)=  0.494E+00 g(S)=  0.000E+00 ort = 0.728E-03 (trialstep = 0.881E+00)

The quantity trialstep is the size of the current trialstep. Multiply the current value of POTIM with this number to obtain the optimal step size.

RMM-DIIS

For IBRION = 1, VASP uses a RMM-DIIS algorithm to relax the ions into their instantaneous groundstate. RMM-DIIS stands for residual-minimization method, direct inversion of the iterative subspace.[1] The forces and the stress tensor 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 a local minimum, but fails badly if the initial positions are a bad guess (use conjugate gradient instead).

RMM-DIIS implicitly calculates an approximation of the inverse Hessian matrix by taking into account information from previous iterations. The approximation of the Hessian matrix requires very accurate forces, otherwise the algorithm will fail to converge. Enforcing a minimum of electronic steps between each ionic step (NELMIN) converges forces efficiently. For simple bulk materials NELMIN = 4 is usually adequate, whereas complex surfaces, where the charge density converges very slowly, might require NELMIN = 8.

On startup, the initial Hessian matrix is diagonal and equal to POTIM. In each iteration a new vector is added to the history. The length of the history determines the rank of the Hessian and must not exceed the degrees of freedom. Naively, one has three degrees of freedom for every ion and nine for the unit cell, but translational invariance, symmetry arguments and constraints can reduce this number significantly. If old steps lead to linear dependencies, they will be automatically removed from the iteration history. When further fine tuning is desired, you can set the NFREE tag to adjust the size of the history.

A reasonable POTIM can speed up calculations significantly. We recommend to find an optimal POTIM using IBRION = 2 or performing a few test calculations (see above).

Understanding the output

RMM-DIIS will produce output similar to the following to stdout

BRION: g(F)=  0.463E-01 g(S)=  0.000E+00 retain N=  2 mean eig= 5.94
eig:   5.940  5.940

and the OUTCAR file

 Quasi-Newton relaxation of ions (Broydens 2nd method)                                                                                                                                                                                       
g(Force)  = 0.463E-01   g(Stress)= 0.000E+00
 
 retain information from N=  2 steps
 eigenvalues of (default step * inverse Hessian matrix)
  average eigenvalue of G=   5.9397
 eigenvalue spectrum of G is  5.9397  5.9397

The g values correspond to the norm of the forces and the stress, respectively. VASP also reports the eigenvalues of the approximate Hessian and how many vectors are currently stored in the iteration history.

Conjugate gradient

In the conjugate-gradient algorithm IBRION = 2, we optimize the structure along a search direction. The initial search direction is given by forces and stress; in subsequent steps, we require that the search is conjugate (perpendicular) to the previous direction. Once the search direction is chosen, a line search along this direction determines the optimal step size. Numerical Recipes by Press et al. contains more details about conjugate gradient.[2]

In VASP, the line search along the search direction uses the following steps

  1. We perform a trial step into the search direction. POTIM controls the length of the trial step.
  2. We recompute the energy, forces, and stress.
  3. Based on the initial energy, the energy after the trial step, and the change of the forces, we fit a cubic or quadratic polynomial to determine the expected minimum (corrector step).
  4. We recompute the energy, forces, and stress.
  5. If after the corrector step the forces and stress parallel to the current search direction vanish, we perform the next trial step. Otherwise, we improve the line minimization by further corrector steps using a variant of Brent's algorithm.[2]
Tip: If your structure is well suited for the conjugate-gradient algorithm, you should see one initial calculation for the structure in the POSCAR file. Then, VASP should alternate between trial and corrector step.

Understanding the output

In a trial step, you will see similar output like this in the stdout

trial-energy change:   -0.415121  1 .order   -0.385587   -0.435540   -0.335634
step:   3.5233(harm=  3.8400)  dis= 0.29442  next Energy=  -133.730354 (dE=-0.949E+00)

and the OUTCAR file

Conjugate gradient step on ions:
trial-energy change:   -0.415121  1 .order   -0.385587   -0.435540   -0.335634
 (g-gl).g = 0.511E+00      g.g   = 0.494E+00  gl.gl    = 0.245E+01
g(Force)  = 0.494E+00   g(Stress)= 0.000E+00 ortho     = 0.728E-03
gamma     =   0.20820
trial     =   0.88083
opt step  =   3.52334  (harmonic =   3.84000) maximal distance =0.29442102
next E    =  -133.730354   (d E  =  -0.94937)

Of particular interest are the current errors g(Force) and g(Stress), the step size (here 0.88083) in units of POTIM, and the largest distance any ion moves (here 0.29442). You can also compare the expected energy (next E or next Energy) with the energy you obtain in the corrector step.

The other values have the following meaning:

  • The trial-energy change is the change of the energy in the trial step
  • The values after 1 .order describe the expected energy change resulting from the inner product of gradient and change of the structure. The three different values use the average gradient, the gradient of the previous, and the gradient of the current step, respectively.
  • The values step and opt step are the step size of a cubic interpolation; harm and harmonic uses a quadratic interpolation. Close to the minimum these values should agree.
  • dE is the expected energy change.


In the corrector step, you will get only output to stdout

curvature:  -0.78 expect dE=-0.387E+00 dE for cont linesearch -0.104E-06
trial: gam= 0.20820 g(F)=  0.494E+00 g(S)=  0.000E+00 ort = 0.728E-03 (trialstep = 0.881E+00)
search vector abs. value=  0.667E+00

You can look at the norm of the forces g(F) and the stress g(S). The ort value tests whether the forces and stress are orthogonal to the previous search direction (should be small). As mentioned above, trialstep is the step size in units of POTIM.

Occasionally, you may get output from ZBRENT. This indicates that the error in the corrector step was too large and the line search is further refined.

Damped molecular dynamics

With IBRION = 3 and SMASS, VASP will execute a damped second order equation of motion for the degrees of freedom

where SMASS supplies the damping factor μ and POTIM controls α. Discretising the differential equation with a simple velocity Verlet algorithm yields

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

Mind that our implementation is particularly 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:

  1. Fix μ (for instance to 1) and adjust POTIM. POTIM should be chosen as large as possible without getting divergence in the total energy.
  2. Decrease μ and keep POTIM fixed.

If POTIM and SMASS are chosen correctly, the damped molecular dynamics mode may outperform the conjugate gradient method by a factor of two.

If SMASS < 0 a velocity quench algorithm is used.

You can see that velocities are projected onto the forces and only remain if that projection is a positive number.

Mind: For IBRION = 3, a reasonable time step POTIM must be supplied. Too large time steps will result in divergence, too small ones will slow down the convergence. A good choice is usually twice the smallest step size you would observe with the conjugate gradient algorithm.

Understanding the output

Damped molecular dynamics produces relatively little output compared to the other two algorithms. If SMASS is set to a value larger than 0, you will see output like this in stdout

damped:  g(F)=  0.159E+01 g(S)=  0.000E+00 dE (1.order)=-0.254E+01 

otherwise for the quenched velocity algorithm you get output similar to this

 summed vel is now   0.0000000000000000        0.0000000000000000        5.5511151231257827E-017
quench:  g(F)=  0.191E+02 g(S)=  0.000E+00 dE (1.order)=-0.311E+02

In both cases g(F) and g(S) are the norm of forces and stress. The extra line in the latter case is a sanity check on the average velocities and should produce vanishingly small numbers.

Related tags and articles

IBRION, POTIM, NSW, SMASS

References