Restarting finite differences calculations: Difference between revisions

From VASP Wiki
Line 151: Line 151:
  {{TAGBL|CHECKPOINT}} = PREPARE
  {{TAGBL|CHECKPOINT}} = PREPARE


This will create {{TAGBL|CONTCAR}}_disp-N files containing each of the displacements in the parent directory:
This will create {{TAGBL|CONTCAR}}_disp-N files containing each of the displacements in the parent directory as you can see in the ''stdout'':
 
Creating CONTCAR files for finite difference displacements
 
and the {{FILE|vaspcheck.h5}} file:


  h5ls vaspcheck.h5
  h5ls vaspcheck.h5
Line 193: Line 197:
  {{TAGBL|CHECKPOINT}} = SINGLE
  {{TAGBL|CHECKPOINT}} = SINGLE


In each individual directory, you can see a single displacement has been recorded to the  
{{NB|important|You can set different {{TAG|NCORE}} settings in these calculations, offering parallelization that is not otherwise currently possible for finite differences.}}
 
In each subdirectory, you can see that a single displacement has been recorded in the ''stdout'':
 
 
 
We assume that this calculation has failed after a certain point or accidentally been cancelled:
 
<syntaxhighlight>
DAV:  9    -0.181350430125E+03  -0.25600E-06  -0.38452E-08  848  0.118E-03    0.774E-04
DAV: 10    -0.181350430581E+03  -0.45554E-06  -0.20686E-08  864  0.738E-04    0.208E-04
DAV:  11    -0.181350430676E+03  -0.94857E-07  -0.22346E-09  704  0.354E-04    0.207E-04
srun: Job step aborted: Waiting up to 32 seconds for job step to finish.
slurmstepd-test01: error: *** JOB 254054 ON test01 CANCELLED AT 2026-01-19T16:25:49 ***
slurmstepd-test01: error: *** STEP 254054.0 ON test01 CANCELLED AT 2026-01-19T16:25:49 ***
</syntaxhighlight>
 


Computing single independent displacement for finite differences


If you look in the directory, you will see the {{FILE|vaspcheck.h5}} file. Inside it will contain the displacement calculations that have been completed up to the point of the crash:
and to the {{FILE|vaspcheck.h5}} file:


  h5ls vaspcheck.h5
  h5ls vaspcheck.h5
 
  data-1                  Group
  data-1                  Group
displacements            Group
symmetry                Group


The calculation can then be restarted by adding {{TAG|CHECKPOINT|CONTINUE}} to the {{FILE|INCAR}}:
Returning to the parent directory, you can combine these separate displacements into one finite difference calculation using the {{TAG|CHECKPOINT|CONTINUE}} tag:


  {{TAGBL|SYSTEM}} = graphene
  {{TAGBL|SYSTEM}} = graphene
Line 239: Line 228:
  {{TAGBL|CHECKPOINT}} = CONTINUE
  {{TAGBL|CHECKPOINT}} = CONTINUE


You can resubmit your calculation in the directory, e.g., with a job script: <code>sbatch job.sh</code>, and the finite differences calculation will continue from there after an SCF step has been done:
{{NB|warning|You can do this calculation in a different directory but you must include the {{FILE|vaspcheck.h5}} from the '''Prepare''' step there as it contains important metadata.}}
Running this calculation, you can see that each of the '''Single''' displacements are combined into one calculation in the ''stdout'':


Found    2 degrees of freedom:
   Combining displacements from subdirectories
Finite differences POTIM= 0.01500 DOF=   2
Continuing from previous run


The calculation will then continue as normal until all displacements have been completed and the phonon modes calculated:
and {{FILE|vaspcheck.h5}} file:


  h5ls vaspcheck.h5
  h5ls vaspcheck.h5
   
   
data-1                  Group
data-2                  Group
data-3                  Group
data-4                  Group
  displacements            Group
  displacements            Group
subdir_prefix            Dataset {SCALAR}
  symmetry                Group
  symmetry                Group
total_count              Dataset {SCALAR}
You can find information about the computed phonon modes under <code>Eigenvectors and eigenvalues of the dynamical matrix</code> as usual.


== Practical hints ==
== Practical hints ==

Revision as of 14:37, 21 January 2026

Mind: Available as of VASP 6.6.0
Important: This feature requires HDF5 support.

Since VASP 6.6.0, it has been possible to restart finite difference calculations using IBRION = 6 and CHECKPOINT. The displacements are written to a vaspcheck.h5 file. For details of a general finite difference calculation, see the phonons from finite differences HowTo. In this HowTo, we will concern ourselves with restarting and splitting finite difference calculations.

Important: This can only be done using IBRION = 6 currently. We recommend using this generally over IBRION = 5.

Input

There are several options for the CHECKPOINT tag:

  • CHECKPOINT = LEGACY - finite difference calculation are performed as those in VASP 6.5.1. No vaspcheck.h5 is written.
  • CHECKPOINT = RESET (default) - The vaspcheck.h5 file is overwritten or created, and the displacements are written to it.
  • CHECKPOINT = CONTINUE - used for restarting a finite differences calculation from a vaspcheck.h5 file.
  • CHECKPOINT = PREPARE - used for splitting a finite differences calculation.
  • CHECKPOINT = SINGLE - used for running a single displacement after splitting with CHECKPOINT = PREPARE.

We will describe the restart procedure and splitting a calculation below. As an example, we take a 3x3x1 graphene supercell POSCAR file from the phonon tutorials:

C18
1.0
   7.3521657209830806    0.0000000000000000    0.0000000000000000
  -3.6760828604915403    6.3671622872044793    0.0000000000000000
   0.0000000000000000    0.0000000000000000    8.0000000000000000
C
18
direct
   0.1111111111111133    0.2222222222222200    0.0000000000000000 C
   0.1111111111111133    0.5555555555555532    0.0000000000000000 C
   0.1111111111111133    0.8888888888888866    0.0000000000000000 C
   0.4444444444444466    0.2222222222222200    0.0000000000000000 C
   0.4444444444444466    0.5555555555555532    0.0000000000000000 C
   0.4444444444444466    0.8888888888888866    0.0000000000000000 C
   0.7777777777777801    0.2222222222222200    0.0000000000000000 C
   0.7777777777777799    0.5555555555555532    0.0000000000000000 C
   0.7777777777777799    0.8888888888888866    0.0000000000000000 C
   0.2222222222222200    0.1111111111111133    0.0000000000000000 C
   0.2222222222222200    0.4444444444444466    0.0000000000000000 C
   0.2222222222222199    0.7777777777777799    0.0000000000000000 C
   0.5555555555555532    0.1111111111111133    0.0000000000000000 C
   0.5555555555555534    0.4444444444444466    0.0000000000000000 C
   0.5555555555555532    0.7777777777777799    0.0000000000000000 C
   0.8888888888888866    0.1111111111111133    0.0000000000000000 C
   0.8888888888888866    0.4444444444444466    0.0000000000000000 C
   0.8888888888888866    0.7777777777777799    0.0000000000000000 C

along with a 4x4x1 k-mesh in our KPOINTS file:

K points
 0
Gamma
4  4  1
0  0  0

and PAW C_s 04May1998 POTCAR. We can use the following INCAR file:

SYSTEM = graphene
ENCUT = 400

# electronic
PREC = Accurate
NELMIN = 5
EDIFF = 1e-8
ISMEAR = -1
SIGMA = 0.2
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.

# ionic (finite differences)
IBRION = 6
POTIM = 0.015

Calculations

Restarting a finite difference calculation

We assume that this calculation has failed after a certain point or accidentally been cancelled:

DAV:   9    -0.181350430125E+03   -0.25600E-06   -0.38452E-08   848   0.118E-03    0.774E-04
DAV:  10    -0.181350430581E+03   -0.45554E-06   -0.20686E-08   864   0.738E-04    0.208E-04
DAV:  11    -0.181350430676E+03   -0.94857E-07   -0.22346E-09   704   0.354E-04    0.207E-04
srun: Job step aborted: Waiting up to 32 seconds for job step to finish.
slurmstepd-test01: error: *** JOB 254054 ON test01 CANCELLED AT 2026-01-19T16:25:49 ***
slurmstepd-test01: error: *** STEP 254054.0 ON test01 CANCELLED AT 2026-01-19T16:25:49 ***

If you look in the directory, you will see the vaspcheck.h5 file. Inside, it will contain the displacement calculations that have been completed up to the point of the crash:

h5ls vaspcheck.h5

data-1                   Group
displacements            Group
symmetry                 Group

The calculation can then be restarted by adding CHECKPOINT = CONTINUE to the INCAR:

SYSTEM = graphene
ENCUT = 400

# electronic
PREC = Accurate
NELMIN = 5
EDIFF = 1e-8
ISMEAR = -1
SIGMA = 0.2
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.

# ionic (finite differences)
IBRION = 6
POTIM = 0.015
CHECKPOINT = CONTINUE

You can resubmit your calculation in the directory, e.g., with a job script: sbatch job.sh, and the finite differences calculation will continue from there after an SCF step has been done:

Continuing from previous run

The calculation will then continue as normal until all displacements have been completed and the phonon modes calculated:

h5ls vaspcheck.h5

data-1                   Group
data-2                   Group
data-3                   Group
data-4                   Group
displacements            Group
symmetry                 Group

Splitting a finite difference calculation

For some large structures, it may be easier to split the displacements into separate calculations. This can be done with the CHECKPOINT = PREPARE tag:

SYSTEM = graphene
ENCUT = 400

# electronic
PREC = Accurate
NELMIN = 5
EDIFF = 1e-8
ISMEAR = -1
SIGMA = 0.2
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.

# ionic (finite differences)
IBRION = 6
POTIM = 0.015
CHECKPOINT = PREPARE

This will create CONTCAR_disp-N files containing each of the displacements in the parent directory as you can see in the stdout:

Creating CONTCAR files for finite difference displacements

and the vaspcheck.h5 file:

h5ls vaspcheck.h5

displacements            Group
subdir_prefix            Dataset {SCALAR}
symmetry                 Group
total_count              Dataset {SCALAR}

You can then create different directories for each of these calculations and run them separately. For this, you will need to set CHECKPOINT:

max=$(printf "%s\n" CONTCAR_disp-* | sed 's/.*-//' | sort -n | tail -1)

for i in $(seq 1 $max); do
  mkdir -p disp-$i
  cp CONTCAR_disp-$i disp-$i/POSCAR
  cp INCAR POTCAR KPOINTS CHG CHGCAR WAVECAR vasp.run disp-$i/
  sed -i 's/PREPARE/SINGLE/g' disp-$i/INCAR
done

Each INCAR file in the directories will then look like:

SYSTEM = graphene
ENCUT = 400

# electronic
PREC = Accurate
NELMIN = 5
EDIFF = 1e-8
ISMEAR = -1
SIGMA = 0.2
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.

# ionic (finite differences)
IBRION = 6
POTIM = 0.015
CHECKPOINT = SINGLE


Important: You can set different NCORE settings in these calculations, offering parallelization that is not otherwise currently possible for finite differences.

In each subdirectory, you can see that a single displacement has been recorded in the stdout:

Computing single independent displacement for finite differences

and to the vaspcheck.h5 file:

h5ls vaspcheck.h5
 
data-1                   Group

Returning to the parent directory, you can combine these separate displacements into one finite difference calculation using the CHECKPOINT = CONTINUE tag:

SYSTEM = graphene
ENCUT = 400

# electronic
PREC = Accurate
NELMIN = 5
EDIFF = 1e-8
ISMEAR = -1
SIGMA = 0.2
LREAL = .FALSE.
LWAVE = .FALSE.
LCHARG = .FALSE.

# ionic (finite differences)
IBRION = 6
POTIM = 0.015
CHECKPOINT = CONTINUE


Warning: You can do this calculation in a different directory but you must include the vaspcheck.h5 from the Prepare step there as it contains important metadata.

Running this calculation, you can see that each of the Single displacements are combined into one calculation in the stdout:

 Combining displacements from subdirectories

and vaspcheck.h5 file:

h5ls vaspcheck.h5

displacements            Group
subdir_prefix            Dataset {SCALAR}
symmetry                 Group
total_count              Dataset {SCALAR}

You can find information about the computed phonon modes under Eigenvectors and eigenvalues of the dynamical matrix as usual.

Practical hints

The computation of the second-order force constants requires accurate forces. Therefore, the tag PREC=Accurate is recommended in the INCAR. The ADDGRID=TRUE should not be set without careful testing.

A practical way to check for convergence is to monitor the Γ point (q=0) optical mode frequencies while varying the ENCUT, PREC, and k point density (KPOINTS). Additionally, compare the result to phonons from density-functional-perturbation theory (DFPT).

To get the phonon frequencies quickly on the command line, simply type the following:

grep THz OUTCAR

To get an accurate phonon dispersion, perform the force-constants calculation in a large enough supercell. When increasing the size of the supercell, we recommend decreasing the k-point density in the KPOINTS file to yield the same resolution. For example, for the primitive cell of silicon, a 12x12x12 Gamma-centered k-point mesh is needed to obtain accurate phonon frequencies at the Gamma point. When replicating the unit cell to a 2x2x2 supercell, a 6x6x6 k point mesh will produce an equivalent sampling. For a 4x4x4 supercell, a 3x3x3 k point mesh will suffice.

It is possible to use phonopy[1] to post-process the results of a finite differences calculation done with VASP.[2]

Tip: In contrast to computing phonons within DFPT, the finite difference approach can be used in combination with any Exchange-correlation functional.

IBRION=5, is available as of VASP.4.5, IBRION=6 starting from VASP.5.1. In some older versions (pre VASP.5.1), NSW (number of ionic steps) must be set to 1 in the INCAR file, since NSW=0 sets the IBRION=−1 regardless of the value supplied in the INCAR file. Although VASP.4.6 supports IBRION=5-6, VASP.4.6 does not change the set of k points automatically (often the displaced configurations require a different k-point grid). Hence, the finite difference routine might yield incorrect results in VASP.4.6.

Related tags and sections

IBRION, ISIF, POTIM,

Phonons: Theory

Phonons from density-functional-perturbation theory, Computing the phonon dispersion and DOS

References