Lesson 3.2 · 13 min
NVE, NVT and NPT
An ensemble says which quantities a simulation holds fixed. Plain MD conserves energy (NVE); a thermostat gives constant temperature (NVT); adding a barostat gives constant pressure (NPT), like most experiments.
- What NVE, NVT and NPT hold fixed, and what is left to fluctuate
- Which ensemble to use for which question, and the usual NVT → NPT workflow
- How fluctuations give heat capacity and compressibility
The idea
A simulation of N atoms in a box can be connected to the outside world in different ways. Statistical mechanics calls each choice an ensemble, named after the three quantities held fixed.
- NVE (microcanonical). An isolated box: atoms, volume and total energy are fixed. This is what Newton's equations give with no extra terms (Lessons 1.3–1.6). Temperature and pressure fluctuate.
- NVT (canonical). The box exchanges energy with a large heat bath at temperature T. A thermostat imitates the bath by nudging velocities. The energy now fluctuates, and T is fixed only on average; the instantaneous T still fluctuates (Lesson 3.1).
- NPT (isothermal–isobaric). A barostat also lets the box volume change, like a piston, so the pressure is fixed on average. The density is then an output. Most experiments are at fixed pressure and temperature, so this is the ensemble that compares directly with the lab.
For large systems the averages agree between ensembles (at the same state point). What differs is which quantities fluctuate, and how much. Those fluctuations are physics, not noise: energy fluctuations in NVT give the heat capacity, volume fluctuations in NPT give the compressibility.
A typical workflow: minimise the energy → short NVT run to reach the temperature → NPT run until the density is stable → production run (NPT, or NVT at the equilibrated density, or NVE for clean dynamics).
The algorithm
One MD step, and what each ensemble adds to it:
velocity Verlet step # NVE: nothing else
if NVT or NPT:
thermostat(v, T_target) # e.g. Andersen: some atoms get new
# Maxwell-Boltzmann velocities
if NPT:
P = (N kB T + W / 3) / V # virial pressure, W = Σ r·F over pairs
mu = (1 - k (P_target - P))^(1/3) # e.g. Berendsen barostat
positions *= mu; L *= mu # rescale the box and the atoms
- The simple thermostat and barostat used here (Andersen, Berendsen) are easy to understand. Lessons 3.3–3.6 compare them with better choices (Nosé–Hoover, Langevin, Parrinello–Rahman, MTTK, C-rescale).
- In NPT, discard the part of the run where the box is still shrinking or growing. Then average.
- Do not compute dynamical properties (diffusion, viscosity) with a strong thermostat that randomises velocities often: it disturbs the dynamics.
- In LAMMPS these are
fix nve,fix nvtandfix npt. In GROMACS, settcouplandpcouplin the .mdp file.