Guide · LAMMPS · 13 min read
How do I choose a thermostat and barostat in LAMMPS?
Checked against the docs · LAMMPS stable release 30 Sep 2026 and the examples/DIFFUSE README and input of the LAMMPS stable branch and VASP wiki · Last checked 12 November 2026 · Spot a mistake? Tell us
Short answer
For constant temperature, fix nvt (Nosé-Hoover) moves the atoms and controls the temperature in one command; fix langevin, fix temp/berendsen and fix temp/csvr only adjust forces or velocities, so they need fix nve beside them. For constant pressure use fix npt. The manual suggests a damping time of about 100 time steps for a Nosé-Hoover thermostat and about 1000 for a barostat, written in time units, such as $(100.0*dt).
What do a thermostat and a barostat do?
A thermostat holds the temperature of your atoms near a target; a barostat holds the pressure near a target by letting the box change size or shape. The LAMMPS manual's Howto pages define them in those words: thermostatting means controlling the temperature of the particles, barostatting means controlling the pressure. Because pressure has a part that comes from the atoms' velocities, both need the temperature.
Without either, LAMMPS integrates Newton's equations at constant number of atoms, volume and energy (fix nve): the microcanonical or NVE ensemble. With a thermostat you sample at constant temperature instead, the canonical or NVT ensemble; with a thermostat and a barostat, the isothermal-isobaric or NPT ensemble.
In LAMMPS both are fixes: commands that act on a group of atoms at every step.
fix 1 all nvt temp 300.0 300.0 100.0
fix 1 water npt temp 300.0 300.0 100.0 iso 0.0 0.0 1000.0These are the first two examples on the manual's fix nvt page. temp takes a start temperature, an end temperature and a damping time (Tdamp, how quickly the temperature is pulled back to the target); iso takes a start pressure, an end pressure and the barostat's damping time (Pdamp). The target is ramped from start to end over the run, so equal values hold it constant.
Why does the choice matter?
Some fixes move the atoms and some do not. The manual is explicit: not all thermostat fixes perform time integration. fix nvt, npt and nph update positions and velocities themselves. fix langevin only adds forces, and fix temp/berendsen and fix temp/csvr only rescale velocities; each must be paired with an integrator such as fix nve, or the atoms do not move as they should.
They differ in what they do to the dynamics. Nosé-Hoover adds extra variables coupled to the atoms' velocities and is designed to sample the canonical, isothermal-isobaric or isenthalpic ensemble. Langevin adds a friction force proportional to each atom's velocity and a random force, which the manual describes as modeling an interaction with a background implicit solvent; with fix nve it performs Brownian dynamics. The CSVR thermostat rescales all velocities by a factor drawn from a suitably chosen distribution; the manual calls Berendsen, which rescales by a factor set directly by the damping time, "empirical".
A wrong damping time spoils the run without an error. The manual warns that a Nosé-Hoover thermostat "will not work well for arbitrary values of Tdamp": too small and the temperature fluctuates wildly, too large and it takes a very long time to equilibrate. The same holds for the barostat's Pdamp, with the pressure and volume.
Which thermostats and barostats does LAMMPS have?
The Howto pages list them all. These are the ones most atomistic runs use:
| Fix | What it controls | Moves the atoms? | Random? | What the manual notes |
|---|---|---|---|---|
fix nvt | Temperature (Nosé-Hoover, a chain of 3 thermostats by default) | Yes | No | Do not add fix nve on the same atoms, nor another thermostat. |
fix npt | Temperature and pressure (Nosé-Hoover) | Yes | No | The thermostat and barostat together; the box changes in the directions you name. |
fix nph | Pressure only (Nosé-Hoover barostat) | Yes | No | Does no thermostatting; can be combined with a thermostat fix. |
fix langevin | Temperature (friction plus random kicks) | No: use fix nve | Yes, needs a seed | Not identical on different numbers of processors; restarts are not exact. |
fix temp/csvr | Temperature (stochastic velocity rescaling) | No: use fix nve | Yes, needs a seed | Has a conserved effective energy you can watch. |
fix temp/berendsen | Temperature (velocity rescaling) | No: use fix nve | No | Stops with an error if the temperature is exactly zero. |
fix press/berendsen | Pressure (rescales the box) | No: use fix nve or fix nvt | No | Controls the three edges only, never the tilts; its relaxation also depends on a bulk modulus you may need to set. |
Which should I start with?
There is no single right answer; the manual describes each fix and leaves the choice to you. These are starting points, each tied to what the manual says the fix does.
| Your goal | A place to start | Why |
|---|---|---|
| Constant-temperature dynamics of a solid or liquid | fix nvt | One command, deterministic, designed to sample the canonical ensemble. |
| Equilibrate the density at a set temperature and pressure | fix npt | The box finds its volume while the temperature holds. |
| Heat or cool through a range | fix nvt or fix npt with different start and end temperatures | The target ramps over the run. Tstop cannot be 0.0 in the Nosé-Hoover form. |
| Quick, robust equilibration from a rough start | fix langevin with fix nve | The manual's own diffusion example equilibrates this way, then removes the Langevin fix (unfix) before it measures. The manual shows it in that one example and does not advise it in general, so treat it as one option to test on your system. |
| Measure a dynamical property (diffusion, vibrations) | Equilibrate with a thermostat, then measure under fix nve or a gentle thermostat | The friction and random forces of Langevin act on every atom's motion. The VASP wiki's CSVR thermostat page says the stochastic velocity rescaling of Bussi et al., the method fix temp/csvr uses, does not significantly affect dynamical properties such as velocity autocorrelation functions or diffusion coefficients. Neither manual says how much the other thermostats disturb them; if you measure under one, compare with a run under fix nve. |
A starting script in metal units, written with the manual's own way of setting the damping in time steps (each line follows the manual's syntax; the temperatures and pressure are examples):
units metal
# ... read_data and the potential ...
timestep 0.001
velocity all create 300.0 4928459 rot yes dist gaussian
fix 1 all npt temp 300.0 300.0 $(100.0*dt) iso 1.0 1.0 $(1000.0*dt)
thermo_style custom step temp press vol etotal econserve
thermo 100
run 100000velocity ... create draws starting velocities at 300 K from a random seed, as in the manual's first velocity example. $(100.0*dt) is an immediate variable that the manual suggests for the thermostat: it turns "100 time steps" into time units, whatever your timestep is. $(1000.0*dt) does the same for the barostat. In metal units pressure is in bar.
What it depends on:
- What you will measure. Static averages (energies, structure, density) and dynamical ones (diffusion, vibrational spectra) ask different things of the thermostat.
- Whether the box should change. Fixed volume (
nvt) or free (npt), and in which directions. - Your starting structure. The manual warns that a target pressure far from the current stress, or too long a time step, can deform a triclinic box so fast that LAMMPS stops with an error.
- Your time step. The damping times are counted in time steps, so they move when the step does (What time step should I use?).
How do I choose the barostat's directions?
The keyword after the temperature says which parts of the box may change and how they are coupled:
| Keyword | What changes | When the manual's description fits |
|---|---|---|
iso | All three edges together, by the same fraction, driven by the average (hydrostatic) pressure | A liquid, or a crystal whose shape you want kept |
aniso | x, y and z each on its own, driven by their own pressure components | A crystal whose edges may relax differently |
tri | All six: edges and tilt angles | A triclinic cell that may also shear; the box must be triclinic |
x, y, z (and couple) | Only the directions you name | A slab with vacuum: name only the periodic directions |
The manual's restrictions matter here: a direction that is not periodic cannot be barostatted, and tilt can only be barostatted in a triclinic box. It also warns that triclinic barostatting "should be used with care", and that equilibrium liquids cannot support a shear stress, nor equilibrium solids one beyond their yield stress.
How do I set the damping times?
Tdamp and Pdamp are in time units, not steps. With units metal that is picoseconds, with units real femtoseconds. The manual's examples write 100.0 for Tdamp, which is 100 time units: 100 fs in real units, but 100 ps in metal units, a hundred thousand steps at a 1 fs step.
The manual's guidance, as it gives it:
- Nosé-Hoover thermostat: "A good choice for many models is a Tdamp of around 100 timesteps."
- Nosé-Hoover barostat: "A good choice for many models is a Pdamp of around 1000 timesteps."
- Berendsen barostat: the same advice, around 1000 time steps, and its relaxation also scales with the bulk modulus (the
moduluskeyword, default 10.0, which the manual says suits a Lennard-Jones liquid and is "way too small for solids"); experiment to findPdampand the modulus. - Langevin:
dampsets how fast the temperature relaxes and "can be thought of as inversely related to the viscosity of the solvent". The manual gives no value in time steps for it, so try a few values in short tests and watch how the temperature settles.
If the volume or temperature oscillates in a solid under fix npt, the manual names two remedies: the drag keyword ("typically a value between 0.2 to 2.0 is sufficient"), which alters the ensemble and spoils energy conservation, or longer thermostat chains (tchain, pchain, both 3 by default). Its advice is to run short tests and watch the pressure and temperature.
How do I know the thermostat is working?
Print the thermostat's own temperature. The temp column of the default thermo output comes from a compute the thermo command creates itself; the manual says it is not the temperature associated with any thermostat fix. Each thermostat fix creates its own compute, named after the fix ID plus _temp (and, for fix npt and fix nph, _press). For the fix npt with ID 1 in the script above:
thermo_style custom step temp c_1_temp press c_1_press vol econserveWhen a thermostat acts on a group rather than on all atoms, its compute covers that group, so c_1_temp is the temperature it holds.
Watch the conserved quantity. econserve is etotal plus ecouple, the energy the thermostat and barostat have exchanged with their reservoirs. The manual says that in NVT, NPH and NPT runs it "should remain constant over time even though etotal may change". fix nvt, npt, nph and temp/csvr add to it automatically; fix langevin adds to it only with tally yes. A drift points at the time step or the integration (What time step should I use?).
Watch the averages and their size. Over a long stretch the time-averaged temperature and pressure should match the targets; the manual says this is what the Nosé-Hoover fixes achieve "when used correctly". If the temperature swings wildly or creeps toward the target over a very long time, the damping time is too short or too long. How to tell an equilibrated run from a settling one is its own question (How do I know my dynamics is equilibrated?).
What do people mix up about thermostats and barostats?
| Mix-up | What you would see | What to do |
|---|---|---|
fix nve and fix nvt on the same atoms | Two fixes integrating the same atoms; the manual says not to. | Use one integrator per atom: fix nvt and fix npt already integrate. |
fix langevin, temp/berendsen or temp/csvr without fix nve | The temperature fix runs, but nothing moves the atoms. | Add fix nve on the same group. |
Two thermostats on the same atoms, such as fix nvt and fix langevin | Two fixes controlling one temperature; the manual says they should not normally be combined. | Keep one thermostat per group. |
Tdamp written as steps in metal units, such as 100.0 | A thermostat that barely acts: 100 ps. | Write it in time units, or as $(100.0*dt). |
Pdamp far shorter than the manual's 1000 steps | The pressure and the volume swing wildly. | Lengthen Pdamp; for oscillations in a solid, try drag or longer chains. |
Reading the thermostat's temperature from the temp column | A temperature that does not match the target when the thermostat acts on a group. | Print c_ID_temp for the fix's own compute. |
| Barostatting a non-periodic direction, as in a slab | The manual's restrictions do not allow it: that direction cannot be barostatted. | Name only the periodic directions (x, y, with couple xy to tie them). |
Tstop of 0.0 in fix nvt to cool to zero | LAMMPS refuses: zero is not allowed in the Nosé-Hoover formulation. | Cool to a small positive temperature, or minimize instead. |
| Expecting a Langevin run to repeat exactly | Runs on different numbers of processors, and runs continued from a restart, follow different paths. | Expect statistical, not identical, agreement; the manual says a restarted run should behave the same "in a statistical sense". |
Set up offers a Constant temperature preset, which writes fix nvt, and a Constant pressure preset, which writes fix npt, each with its target temperature, the damping times in your units' time unit and, for pressure, the cell freedom (iso, aniso or tri), every one with its explanation beside it. For Langevin, CSVR, Berendsen or a slab barostat, edit the script: Verlet keeps the script as you wrote it until you go back to the generated one. Everything above works without it.