Langevin Dynamics and Thermostats
Run a molecular dynamics simulation with plain Newtonian forces and it conserves total energy exactly — a microcanonical world with no way to hold temperature fixed. Almost every real experiment happens in a room at constant temperature, exchanging heat freely with its surroundings. Thermostats are the extra terms added to the equations of motion that let a simulation do the same: exchange energy with an implicit bath so the system settles into the correct Boltzmann distribution at a chosen temperature. This article covers the two workhorse thermostats — stochastic Langevin dynamics and deterministic Nosé-Hoover — and the fluctuation-dissipation constraint that makes both of them work.
1. Why Molecular Dynamics Needs a Thermostat
Newton's equations of motion, integrated with a symplectic scheme like velocity Verlet, conserve total energy to high precision. That gives you the microcanonical ensemble (NVE): fixed particle number N, volume V, and energy E. It is the natural output of pure Newtonian dynamics, but it is rarely what you want to compare against a real experiment, which is almost always held at constant temperature, not constant energy — a test tube in a water bath, a protein in solution, a gas in a room.
The canonical ensemble (NVT) fixes N, V, and T instead, letting energy fluctuate as the system exchanges heat with an implicit reservoir. A thermostat is the piece of a simulation engine that reproduces this exchange without literally simulating billions of solvent or wall-collision molecules. The two dominant families are:
Stochastic (Langevin)
Random kicks plus friction model collisions with an implicit heat bath directly in the equation of motion for each particle.
Deterministic (Nosé-Hoover)
One extra dynamical variable feeds back on the whole system's kinetic energy, with no randomness at all.
2. The Langevin Equation: Friction and Noise
The Langevin thermostat modifies each particle's equation of motion by adding a drag force proportional to velocity and a random thermal force representing the aggregate effect of unmodelled collisions with an implicit solvent or bath:
Physically, γ represents the rate at which the implicit bath removes kinetic energy through collisions, while ξ(t) represents the random momentum kicks from those same collisions. On their own, either term alone would push the system away from equilibrium — pure friction would freeze all motion to v = 0, pure noise would heat the system without bound. Only the right combination of the two produces a stable equilibrium temperature.
3. The Fluctuation-Dissipation Constraint
The friction coefficient γ and the noise amplitude cannot be chosen independently if you want the system to equilibrate at a specific target temperature T. They are locked together by the same relation covered in the fluctuation-dissipation theorem:
This is the deep reason Langevin dynamics is a correct thermostat rather than an ad-hoc hack: friction alone would violate detailed balance and drain all energy from the system; adding noise at exactly the fluctuation-dissipation strength restores detailed balance with respect to the canonical (Boltzmann) distribution, so time-averages over a long Langevin trajectory equal canonical ensemble averages.
4. Choosing the Friction Coefficient
γ is a free parameter that controls the trade-off between thermostatting strength and fidelity to the underlying Newtonian dynamics:
- Small γ (weak coupling): the trajectory stays close to a true NVE trajectory between rare thermostat corrections, preserving dynamical quantities like diffusion coefficients and velocity autocorrelation functions well, but temperature drift is corrected slowly.
- Large γ (strong coupling): temperature is controlled tightly and equilibration is fast, but the dynamics becomes overdamped — closer to Brownian motion than to ballistic molecular motion — which distorts any dynamical property you might want to measure.
- Rule of thumb: set 1/γ to several times the shortest relaxation time of the property you care about preserving; for measuring purely static/structural quantities (radial distribution functions, free energies), large γ is fine and often preferred for faster equilibration.
5. The Nosé-Hoover Thermostat
Nosé (1984) and Hoover (1985) took a different approach: instead of injecting random noise, add one extra deterministic variable to the system that represents an effective coupling strength to a heat bath, and let its own equation of motion drive the system's kinetic energy toward the target value:
When the instantaneous kinetic energy K exceeds the target 3Nk_BT/2, ξ increases and extra friction slows the particles down; when K falls below target, ξ can go negative and actually accelerate the particles. This feedback loop is entirely deterministic and time-reversible, and — crucially — it can be shown to sample the exact canonical distribution, not merely to control the average temperature.
The parameter Q sets the thermostat's own inertia: small Q gives a "stiff," fast-responding thermostat that can overshoot and oscillate; large Q gives a "soft" thermostat that drifts slowly toward the target temperature, closer to microcanonical dynamics in the short term.
6. Nosé-Hoover Chains and Ergodicity
A single Nosé-Hoover variable has a known failure mode: for small or stiff systems (a single harmonic oscillator is the textbook example), the coupled system-plus-thermostat dynamics can become quasi-periodic rather than ergodic, oscillating around the target temperature without ever properly sampling the full canonical distribution.
Martyna, Klein, and Tuckerman's fix — the Nosé-Hoover chain — couples the original thermostat variable ξ₁ to a second thermostat variable ξ₂ that damps ξ₁'s own fluctuations, which can in turn be coupled to a ξ₃, and so on for a short chain (length 3-5 is typical). Each link absorbs the residual non-ergodicity of the one before it, and in practice a short chain restores correct canonical sampling for essentially any system size, at negligible extra computational cost.
7. JavaScript Integrator (BAOAB)
// BAOAB splitting scheme for Langevin dynamics — samples the exact
// canonical distribution even at fairly large timesteps.
function baoabStep(x, v, m, force, gamma, kT, dt, randn) {
const halfDt = dt / 2;
// B: half-kick from forces
v += (force(x) / m) * halfDt;
// A: half-drift in position
x += v * halfDt;
// O: exact Ornstein-Uhlenbeck update — friction + noise together
const c1 = Math.exp(-gamma * dt);
const c2 = Math.sqrt((1 - c1 * c1) * kT / m);
v = c1 * v + c2 * randn();
// A: second half-drift
x += v * halfDt;
// B: second half-kick from (updated) forces
v += (force(x) / m) * halfDt;
return { x, v };
}
// Nosé-Hoover: deterministic feedback, no randomness at all
function noseHooverStep(x, v, xi, m, force, Q, kT, dof, dt) {
const K = 0.5 * m * v * v;
const dxi = (2 * K - dof * kT) / Q;
xi += dxi * dt;
v += (force(x) / m - xi * v) * dt;
x += v * dt;
return { x, v, xi };
}
8. Applications and Pitfalls
- Protein and biomolecular simulation: Langevin thermostats with modest friction are the default choice for equilibrating solvated biomolecules because they are robust and cheap; production runs computing dynamical properties often switch to Nosé-Hoover chains or weaker coupling.
- Transport coefficients: both thermostats can distort Green-Kubo transport coefficients if coupled too strongly — always check that results converge as thermostat coupling is weakened.
- The "flying ice cube": a known Nosé-Hoover artifact where energy is unphysically funneled into the centre-of-mass translational/rotational modes of a rigid or near-rigid molecule, requiring periodic removal of centre-of-mass motion as a separate correction.
- Small systems: a single Nosé-Hoover thermostat can fail to be ergodic for stiff, low-dimensional systems — use a Nosé-Hoover chain (see Section 6) or switch to Langevin.
- Connection to Monte Carlo: the site's Ising model simulation samples the same canonical (Boltzmann) distribution using discrete Metropolis moves instead of continuous-time dynamics — a useful contrast to see the same statistical target reached by a very different route.
Frequently Asked Questions
What problem do MD thermostats actually solve?
Plain Newtonian molecular dynamics conserves total energy exactly (the microcanonical, NVE ensemble), but most experiments happen at constant temperature (the canonical, NVT ensemble), not constant energy. A thermostat is an extra term added to the equations of motion that lets the simulated system exchange energy with an implicit heat bath so its time-averaged kinetic energy corresponds to a chosen target temperature, while still sampling the correct Boltzmann distribution of configurations.
What is the Langevin equation in one sentence?
It is Newton's second law with two extra terms added to every particle: a velocity-proportional friction force −γv that removes kinetic energy, and a random thermal force ξ(t) that injects it back in, with the two terms' strengths locked together by the fluctuation-dissipation theorem so the particle settles into the correct temperature at equilibrium.
How does the Nosé-Hoover thermostat differ from Langevin?
Nosé-Hoover is deterministic and time-reversible: it introduces one extra dynamical variable, a friction coefficient ξ, whose own equation of motion pushes the system's instantaneous kinetic energy toward the target value, overshooting and correcting smoothly rather than by random kicks. Langevin dynamics is stochastic: it adds explicit random noise at every step, simpler to implement and more robust for stiff systems, but not time-reversible and it adds some artificial diffusion.