VASP¶
The VASP manual is the "holy bible" of VASP. Read it with care when you have questions. The official VASP tutorials and the official VASP YouTube channel are valuable "getting started" resources.
There are four key input files needed to run a VASP calculation:
- The
INCAR: this contains most of the input flags. - The
POSCAR: this contains the input structure. - The
KPOINTS: this contains details about the k-point grid. - The
POTCAR: this contains the pseudopotential details.
Input files¶
INCAR¶
Level of Theory¶
-
ENCUT: sets the plane-wave kinetic energy cutoff. The higher the value, the more precise your calculations will be at the expense of higher computational cost. At the top of each element'sPOTCARfile is a parameter namedENMAX. The value ofENCUT, if not explicitly set, is the largest ENMAX value across the elements in your system. In practice, you should set ENCUT to at least 1.3 times this maximumENMAXvalue for any structure relaxation involving changes to the cell volume in order to minimize artificial stresses.- Rule of thumb: Try at least 520 eV to start. In practice, you should ensure this is converged.
-
GGA: sets the exchange-correlation functional (i.e. the "level of theory"). This has the largest impact on the results of the calculation.- Rule of thumb: Try
GGA = PEfirst (i.e. the PBE functional), particularly if you are just learning how to use VASP. - If using ASE, the xc keyword can be used to set the functional as described in the documentation. It is often more convenient since it will auto-set all relevant flags for that functional (e.g. xc = "pbe" will auto-set GGA = PE).
- Rule of thumb: Try
-
METAGGA: defines a particular meta-GGA functional, which is generally more accurate than a GGA functional but less accurate than a hybrid functional.- If using ASE, the
xckeyword will take care of this flag. R2SCANis widely used in the group
- If using ASE, the
-
IVDW: sets the van der Waals correction scheme. Grimme's DFT-D methods are common in molecular systems where vdW corrections are particularly important.- The most commonly used in the group are
IVDW=12for D3BJ andIVDW=13for D4
- The most commonly used in the group are
-
LDAU/LDAUJ/LDAUL/LDAUPRINT/LDAUTYPE/LDAUU: specify details related to the DFT+U method, which corrects so-called "self-interaction errors" of GGA functionals. -
LHFCALC/HFSCREEN: these methods specify details related to the use of hybrid functionals. Like DFT+U, this can also correct common "self-interaction errors" of GGA functionals.
SCF¶
-
PREC: specifies the precision used.- Generally set this to
Accurate.
- Generally set this to
-
EDIFF: sets the SCF convergence tolerance (in eV). The lower the value, the more precise your energies and forces will be.- Rule of thumb: Try 1e-5 to start.
-
ALGO: this sets the SCF convergence algorithm. Rule of thumb: Try Fast to start. If you have problems, switch to All. -
ISMEAR: this sets how the partial occupancies are treated (i.e. the smearing method) to smooth out discontinuities near the Fermi level. There are a lot of subtle rules about what value to set for what material as laid out in the VASP manual, which our software stack will try and set for you where appropriate.- Rule of thumb: When in doubt, ISMEAR = 0 is a good bet with a small value of
SIGMA(0.01 - 0.05).
- Rule of thumb: When in doubt, ISMEAR = 0 is a good bet with a small value of
-
SIGMA: specifies the smearing parameter (e.g. width). Like ISMEAR, this is very material-dependent.- Rule of thumb: When in doubt, set this to a small value (0.01 - 0.05) along with
ISMEAR = 0.
- Rule of thumb: When in doubt, set this to a small value (0.01 - 0.05) along with
-
LASPH: this defines whether non-spherical contributions are included in the energy and forces. Do not mix calculations with True and False forLASPH. -
LREAL: setting this value to Auto can speed up calculations for large systems but can reduce the quality of the energy and should always be set back to False for computed properties of interest.- Rule of thumb: Always set this to False (i.e. the default) to make your life easier, even when VASP complains.
Geometry Optimization¶
-
EDIFFG: sets the maximum net force (in eV/Å) for a structure to be considered converged during a geometry optimization. The lower the value, the closer to the true local minimum your structure will be. Note that a negative sign should be used by convention (e.g.EDIFFG = -0.03).- Rule of thumb: Use a value of -0.03 or tighter (e.g. -0.01).
-
ISIF: defines which degrees of freedom should be modified during the structure relaxation.ISIF = 2indicates that the positions are relaxed at fixed cell volume.ISIF = 3indicates that the positions and cell shape/volume are simultaneously relaxed. -
NSW: specifies the maximum number of geometry optimization steps to consider.- Rule of thumb: Set to an arbitrarily large value, e.g. 200.
-
IBRION: selects geometry optimization algorithm.- Rule of thumb: Try
IBRION = 2(conjugate gradient) to start.
- Rule of thumb: Try
-
ISYM: defines whether symmetry constraints should be accounted for.- Rule of thumb: Set to 0 for geometry optimizations to ensure the symmetry is allowed to change, unless you are intentionally looking to model a given symmetry.
Magnetization¶
-
ISPIN: sets whether the calculation should be run without or with spin-polarization. If the system has unpaired electrons, it should be run with spin-polarization.- Rule of thumb: When in doubt, start with ISPIN = 2 to see if there are favorable magnetic states. If there aren't, the default value of ISPIN = 1 is fine.
- If using ASE, setting atoms.
set_initial_magnetic_moments()will automatically toggle ISPIN accordingly. Don't directly specify ISPIN in this case.
-
LORBIT: specifies how much information related to magnetization is written out to the OUTCAR file. Rule of thumb: Always set this toLORBIT = 11to make your life easier. -
MAGMOM: specifies details related to the initial guess for the magnetic moments.- Rule of thumb: Initialize each transition metal with a high-spin magnetic configuration as a first attempt. Then go back and try other magnetic configurations, if applicable.
- If using ASE, setting atoms.
set_initial_magnetic_moments()will automatically toggle MAGMOM accordingly. Don't directly specify MAGMOM in this case.
-
NUPDOWN: forces a particular net number of unpaired electrons.
File I/O¶
-
ISTART: defines if the VASP calculation should restart from a pre-existing wavefunction. If a WAVECAR is present in the same directory, VASP will automatically try to restart from it.- Rule of thumb: No need to change the default value in most cases.
-
LWAVE: this parameter specifies whether the wavefunction is written out to the filesystem. This is especially useful for restarting a calculation but is quite large. -
LCHARG: whether to write out the charge density to the filesystem. This is useful for post-processing but is quite large. -
LAECHG: this specifies whether AECCAR files are written out, which are used by certain post-processing codes. Never use LAECHG if NSW is not set to 0. -
NEDOS: describes how many points are written out in the density of states output file (DOSCAR).
Miscellaneous¶
-
EFERMI: VASP recommends generally just setting this to MIDGAP. That will yield slightly more consistent Fermi energies (and, as a result, band gaps) but otherwise changes nothing.- Rule of thumb: Always set this to MIDGAP to make your life easier if you are using VASP 6.4+.
-
NCORE: this parameter can be tuned for a specific machine and system to speed up calculations by parallelizing over orbitals. The only way to know which value is best is to try them out! It should generally be used in place ofNPAR. -
KPAR: similarly, this parameter tells VASP how to parallelize the k-points. It only makes sense to use if there are many k-points, as a result.
POSCAR¶
The POSCAR file contains all information needed to define the input structure. The easiest way to generate a POSCAR file is using a program like ASE or VESTA. ASE can convert any supported file formats into a POSCAR with the following code:
it can be also converted in the terminal with
KPOINTS¶
VASP now recommends using the parameter KSPACING in the INCAR file in place of a dedicated KPOINTS file. The KSPACING parameter is such that a smaller value corresponds to a higher k-point density (i.e. greater precision). Nonetheless, it is still useful to know what the KPOINTS file looks like, see here for detaied information.
0 # 0 -> determines number of k points automatically
Gamma # generates a Gamma centered mesh
1 1 1 # N_1, N_2 and N_3 division in the reciprocal lattice vectors
0 0 0 # optional shift of the mesh (s_1, s_2, s_3)
Output files¶
OUTCAR¶
The primary output file in VASP is called the OUTCAR file. There is a ton of info in it. Here are the most important things:
-
Iteration: This line specifies the iteration of the geometry optimization procedure and the SCF loop for that given geometry. A value ofIteration 4( 2)would indicate "geometry step 4, SCF iteration 2." -
energy(sigma->0): The value following this line is the current iteration's energy. The unit is eV. -
magnetization (x): IfLORBITis set to >= 11, the atom-wise spin moments are printed in this table, each in units of Bohr-magnetons.
You can also use ASE to easily parse the most critical information (i.e. energy, forces, trajectory) from the OUTCAR as follows:
from ase.io import read
trajectory = read("OUTCAR", index=":") # read all frames
final_image = trajectory[-1] # select the last step
# Get energy of the last step
final_energy = final_image.get_potential_energy()energy
# Get forces of the last step
final_forces = final_image.get_forces()
CONTCAR¶
The CONTCAR file is formatted identically as the POSCAR file but contains the most recent set of atomic positions and cell parameters. To restart a calculation, you can copy the mv CONTCAR POSCAR to continue the geometry optimization process.
Calculate isolated atom¶
Getting a properly converged electronic structure of atoms and molecules in VASP can be challenging, especially for transition metals with partially filled orbitals. Below you can see an example of how the electronic structure optimization of Fe ([Ar] 3d6 4s2) can go wrong and how to achieve the correct result.
Wrong electron distribution
spin component 1
k-point 1 : 0.0000 0.0000 0.0000
band No. band energies occupation
1 -19.4392 1.00000
2 -8.2725 1.00000
3 -8.2725 1.00000
4 -8.2725 1.00000
5 -0.0482 0.00000
6 0.1695 0.00000
...
spin component 2
k-point 1 : 0.0000 0.0000 0.0000
band No. band energies occupation
1 -19.4391 1.00000
2 -8.2725 1.00000
3 -8.2725 1.00000
4 -8.2725 1.00000
5 0.0106 0.00000
6 0.1911 0.00000
...
free energy TOTEN = 160.01683598 eV
Good electron distribution
spin component 1
k-point 1 : 0.0000 0.0000 0.0000
band No. band energies occupation
1 -7.5523 1.00000
2 -7.5514 1.00000
3 -7.5352 1.00000
4 -7.5265 1.00000
5 -7.5136 1.00000
6 -5.3150 1.00000
...
spin component 2
k-point 1 : 0.0000 0.0000 0.0000
band No. band energies occupation
1 -4.3133 0.61186
2 -4.1930 0.28542
3 -4.1901 0.27856
4 -4.1889 0.27587
5 -4.1884 0.27454
6 -4.1880 0.27375
...
free energy TOTEN = -3.16798525 eV
Fe has 8 valence electrons (3d6 4s2) to distribute among 6 orbitals (1 s-orbital and 5 d-orbitals):
-
Wrong case: The s-orbital and 3 d-orbitals are populated with both spin-up and spin-down electrons, while 2 d-orbitals remain unpopulated. This violates Hund's rule and leads to artificially high energy.
-
Correct case: All 6 orbitals are populated with spin-up electrons, and the remaining 2 electrons occupy the energetically most favorable orbitals according to their energy ordering.
An example for how to prepare all this file "automatically" can be found here. For more details read the official VASP tutorial on calculating isolated atoms