Osman Goni Ridwan

VASP cheat sheet · Applications

VASP AIMD and machine-learned force fields

Molecular dynamics with VASP: choosing the thermostat and ensemble, the defaults that silently give NVE, time steps, restarting and analysing a trajectory, and training VASP's own machine-learned force fields during the run.

Checked against VASP 6.6.1 · Updated

The short version

  1. MD is IBRION = 0 with NSW steps of POTIM fs; POTIM has no default, and VASP stops without it.
  2. Always set MDALGO and its coupling tag: every thermostat's coupling defaults to “off”, so a run that sets only MDALGO is silently NVE.
  3. The default MDALGO = 0 folds atoms back into the cell, which rules out a mean-squared displacement. Use MDALGO 1–5.
  4. Constant pressure (NpT) only works with Langevin: MDALGO = 3, ISIF = 3.
  5. Use ISYM = 0, a time step of about 1 fs (0.5–0.7 fs with hydrogen), and check the drift of the conserved energy.
  6. VASP's machine-learned force fields (6.3 and later) train on the fly during MD: train, refit, then run.

Thermostats and ensembles

MDALGOThermostatEnsemblesCoupling tag (default = off)
0legacy Nosé (deprecated)NVE, NVTSMASS (−3 = NVE); wraps coordinates
1AndersenNVE, NVTANDERSEN_PROB (0)
2Nosé–HooverNVE, NVTSMASS (−3)
3Langevin (+ Parrinello–Rahman cell)NVT, NpT, NpHLANGEVIN_GAMMA (0), LANGEVIN_GAMMA_L (0), PMASS
4Nosé–Hoover chain (6.4.0)NVE, NVTNHC_NCHAINS (0), NHC_PERIOD
5CSVR, stochastic velocity rescaling (6.4.3)NVE, NVTCSVR_PERIOD (0)

NVE: MDALGO = 1 with ANDERSEN_PROB = 0 is the simplest. NVT: any MDALGO with its coupling switched on, ISIF = 2. NpT: Langevin with ISIF = 3 only, at a cutoff of about 1.3 × ENMAX (the cell changes). NpH: as NpT with both frictions 0.

INCAR recipes

Add your converged electronic settings (ENCUT, PREC, EDIFF, smearing) to each block.

NVT, Nosé-Hoover chain (VASP 6.4.0 and later)
IBRION      = 0
MDALGO      = 4
ISIF        = 2
ISYM        = 0
NSW         = 10000
POTIM       = 1.0        ! fs; 0.5-0.7 with hydrogen
TEBEG       = 300 ; TEEND = 300
NHC_NCHAINS = 3          ! the default 0 means no thermostat
NHC_PERIOD  = 40         ! in MD steps
RANDOM_SEED = 248489752 0 0
NVT, Langevin (good for sampling and force-field training)
IBRION         = 0
MDALGO         = 3
ISIF           = 2
ISYM           = 0
NSW            = 10000
POTIM          = 1.0
TEBEG          = 300
LANGEVIN_GAMMA = 10.0 10.0   ! ps^-1, one value per species
NpT, Langevin with Parrinello-Rahman cell dynamics
IBRION           = 0
MDALGO           = 3
ISIF             = 3
ISYM             = 0
NSW              = 10000
POTIM            = 1.0
TEBEG            = 300
LANGEVIN_GAMMA   = 10.0 10.0 10.0   ! three species
LANGEVIN_GAMMA_L = 10.0
PMASS            = 1000
PSTRESS          = 0        ! target pressure in kB
NVE production run
IBRION        = 0
MDALGO        = 1
ANDERSEN_PROB = 0.0      ! Andersen switched off: plain NVE
ISIF          = 2
ISYM          = 0
NSW           = 10000
POTIM         = 1.0
TEBEG         = 300
Faster electronic settings for long AIMD
PREC   = Normal
EDIFF  = 1E-5
ALGO   = Fast
LREAL  = Auto
MAXMIX = 40              ! reuse the mixer between steps (not when training force fields)
LWAVE  = .FALSE. ; LCHARG = .FALSE.
NBLOCK = 10              ! one XDATCAR frame every 10 steps

With a single Γ point, run vasp_gam. Split long simulations into runs of at most about 20000 steps.

The MD tags

TagWhat it doesDefaultWhat to useWatch out
MDALGOThermostat: 1 Andersen, 2 Nosé–Hoover, 3 Langevin, 4 Nosé–Hoover chain (6.4.0), 5 CSVR (6.4.3).0 (legacy Nosé)Set it explicitly (1–5); only 3 (Langevin) with ISIF = 3 gives NpT.MDALGO = 0 wraps the atoms back into the cell, which rules out a mean-squared displacement.
TEBEGStarting temperature (K); velocities are drawn from it if POSCAR has none.0The target temperature.
TEENDFinal temperature (K) of a linear ramp.TEBEGLarger than TEBEG to heat gradually, e.g. for force-field training.
SMASSNosé mass for MDALGO = 0 and 2 (−3 = NVE, −1 = velocity rescaling, ≥ 0 = Nosé thermostat); damping for IBRION = 3.−3MDALGO = 2: 0 or a small positive value for NVT.The default −3 means no thermostat (NVE).
ANDERSEN_PROBAndersen collision probability per atom per step (MDALGO = 1).00 for NVE; positive for NVT.Rescale it if POTIM changes.
LANGEVIN_GAMMALangevin friction per species in ps⁻¹ (MDALGO = 3).0 for each speciesAbout 10 ps⁻¹ per species for NVT or NpT.0 means NVE; very large values overdamp the motion.
LANGEVIN_GAMMA_LLangevin friction of the lattice in ps⁻¹ (MDALGO = 3, ISIF = 3).0About 10 for NpT.
PMASSFictitious mass of the lattice for NpT (MDALGO = 3, ISIF = 3), in amu.1000Start at 1000 and test.Too small: violent volume swings; too large: the cell barely responds.
NHC_NCHAINSLength of the Nosé–Hoover chain (MDALGO = 4).0 (= NVE)3 is a common choice.The default gives NVE.
NHC_PERIODTime scale of the Nosé–Hoover chain thermostat, in MD steps.4020–200 steps.
CSVR_PERIOD 6.4.3+Time scale of the CSVR thermostat (MDALGO = 5).0 (= NVE)Set it to get NVT.The VASP Wiki gives its unit both as fs and as MD steps.
NBLOCKEvery NBLOCK steps VASP writes an XDATCAR frame and updates averages.11 for short AIMD; 10–100 for long runs.
KBLOCKAverages (PCDAT, DOSCAR) are written every KBLOCK × NBLOCK steps.NSWLeave the default.
POMASSAtomic masses (amu) per species, overriding the POTCAR values.from the POTCARA heavier H (e.g. 8) allows a longer time step when only equilibrium properties matter.It changes the dynamics: avoid it when time-dependent or mass-dependent results matter.
RANDOM_SEEDSeed of the random numbers (initial velocities, stochastic thermostats).from the system clockSet it to make a run reproducible.
VELOCITYWrite the velocities to vaspout.h5 (VASP 6.4 and later)..FALSE..TRUE. for velocity autocorrelation and vibrational DOS.

Restarting and changing ensemble

  • cp CONTCAR POSCAR continues the trajectory: CONTCAR carries the velocities and the integrator's predictor–corrector data.
  • Switching ensemble (NVT to NpT, say): delete the predictor–corrector block at the end of the file, or the run crashes; keep the velocities.
  • Equilibrate first, then count only the production part. Starting velocities come from TEBEG unless POSCAR has them; set RANDOM_SEED for reproducible runs.

Analysis

Temperature and energies from OSZICAR (MD runs)
grep "T=" OSZICAR | awk '{print $1, $3, $5}' > T_E.dat   # step, temperature, conserved energy E
tail -3 OSZICAR                                         # the latest steps
  • OSZICAR's MD line: T= temperature, E= total energy including kinetic and thermostat terms (the conserved quantity), F= and E0= as in relaxations, EK= kinetic energy, SP= and SK= thermostat energies.
  • In NVE and Nosé–Hoover runs, E must not drift systematically; drift means too large a time step or noisy forces (a poorly converged SCF). Stochastic thermostats do not conserve it exactly.
  • XDATCAR holds a frame every NBLOCK steps; with MDALGO ≥ 1 the coordinates are not folded back into the cell. In ASE read all frames with read("XDATCAR", index=":"); without the index you get only the last one.
  • Diffusion: D from the mean-squared displacement, ⟨|r(t) − r(0)|²⟩ = 2 n D t in n dimensions; pymatgen's DiffusionAnalyzer reads vasprun.xml files directly. Radial distribution: PCDAT (averaged) or ASE's get_rdf. Vibrational DOS: Fourier transform of the velocity autocorrelation (VELOCITY = .TRUE.).
  • MDAnalysis has no VASP reader: convert with ASE first.

Machine-learned force fields in VASP

VASP can learn a force field during MD: it computes a step from first principles only when the model's estimated error is too large, and otherwise predicts.

Train on the fly (NpT Langevin, heating)
ML_LMLFF = .TRUE.
ML_MODE  = train          ! continues from ML_AB if that file is present
IBRION   = 0
MDALGO   = 3
ISIF     = 3
ISYM     = 0
TEBEG    = 200 ; TEEND = 500       ! heat to about 30% above the temperature you need
LANGEVIN_GAMMA   = 10.0 10.0
LANGEVIN_GAMMA_L = 3.0
PMASS    = 100
POTIM    = 1.5
NSW      = 20000
Train, refit, run
cp ML_ABN ML_AB      # continue training (ML_MODE = train) or refit (ML_MODE = refit)
cp ML_FFN ML_FF      # then production: ML_MODE = run
grep ERR ML_LOGFILE | grep -v "#" | awk '{print $2, $4}' > ERR.dat   # force error per step
  • Refit before production: without it the fast prediction mode, 20 to 100 times faster, is not available.
  • Keep the INCAR and POTCAR of the first-principles part identical across training stages; no MAXMIX while training; never train in NVE.
  • Aim for training errors below about 1 meV/atom in energy and 30–100 meV/Å in forces.
  • Surfaces and molecules: a tiny stress weight, ML_WTSIF = 1E-10.
  • A force field describes one potential-energy landscape: for a magnet, train on one consistent magnetic state.
  • Since VASP 6.6.0 a run stops if the model's spilling factor becomes critically large (above 0.9).
TagWhat it doesDefaultWhat to useWatch out
ML_LMLFF 6.3.0+Switch on VASP's machine-learned force field (VASP 6.3.0 and later)..FALSE..TRUE. together with ML_MODE.
ML_MODE 6.4.0+Force-field mode: train, select, refit, run, or delta (6.6.0).none (with ML_LMLFF = .TRUE., VASP then trains)train → refit → run; set it explicitly.Without refit, the fast prediction mode is not available.
ML_CTIFORBayesian error threshold that decides when to compute a step from first principles.0.02 or 0.002, depending on ML_CALGOLower for stricter training.
ML_OUTBLOCKHow often a prediction run (ML_MODE = run) writes output.10 in most cases10–100 for long runs.
ML_WTSIFWeight of the stress in the force-field fit.1.0 (5.0 with ML_IWEIGHT = 1)A tiny value (1E-10) for surfaces and molecules, which have no meaningful stress.

Common mistakes

  • No POTIM: VASP stops at once. No coupling tag: a silent NVE run.
  • MDALGO = 0, then a mean-squared displacement from wrapped coordinates.
  • NpT with a thermostat other than Langevin.
  • Too large a time step for hydrogen; or a heavier hydrogen mass (POMASS) when dynamics matter.
  • Symmetry left on (ISYM).
  • A CONTCAR from an NVT run reused for NpT without removing the predictor–corrector block.
  • Reading XDATCAR with ASE without index=":".
  • Spin-polarized r²SCAN MD or force-field training on VASP 6.6.0.

The physics behind this sheet

  • Lecture 33: Ab initio molecular dynamics (in preparation)
  • Lecture 34: Machine-learning interatomic potentials (in preparation)

Further reading

  1. VASP Wiki, “Molecular-dynamics calculations” (setup, ensembles, analysis). · www.vasp.at
  2. VASP Wiki, “MDALGO” (thermostats and ensembles). · www.vasp.at
  3. VASP Wiki, “Best practices for machine-learned force fields”. · www.vasp.at