Article
Thermodynamics · ⏱ ~12 min read · Last updated: 9 July 2026

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.

TL;DR: Plain Newtonian simulations conserve energy, not temperature, so thermostats add extra terms to hold temperature fixed instead. Langevin dynamics does this with random noise plus friction, locked together by the fluctuation-dissipation theorem; Nosé-Hoover does it deterministically with one feedback variable (chained for stiff systems). Both reproduce the correct constant-temperature statistics, with different trade-offs and failure modes.

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:

m (dv/dt) = F(x) − γv + ξ(t) F(x) — deterministic force from the interatomic potential −γv — friction (dissipative) term, coefficient γ ξ(t) — random thermal force ("noise"), ⟨ξ(t)⟩ = 0

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.

4. Choosing the Friction Coefficient

γ is a free parameter that controls the trade-off between thermostatting strength and fidelity to the underlying Newtonian dynamics:

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:

m (dv/dt) = F(x) − ξ · m v dξ/dt = (2K − 3Nk_BT) / Q ξ — thermostat "friction" variable (can be negative!) K — instantaneous kinetic energy, K = (1/2) Σ m v² Q — thermostat "mass" (a tunable coupling-strength parameter) 3N — degrees of freedom for N particles in 3D (minus constraints)

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

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.

Why must the noise and friction terms be linked?
If you picked friction γ and noise amplitude independently, the system would equilibrate to whatever temperature happens to result from that particular combination — almost never the temperature you intended. The fluctuation-dissipation theorem fixes the noise correlation to ⟨ξ(t)ξ(t′)⟩ = 2γk_BT δ(t−t′): with this exact relationship the stationary velocity distribution is guaranteed to be Maxwell-Boltzmann at temperature T, regardless of the value chosen for γ.
How do you choose the friction coefficient γ in practice?
Small γ (weak coupling) barely perturbs the natural Newtonian dynamics and preserves dynamical properties like diffusion coefficients and correlation times well, but takes longer to correct temperature drift. Large γ thermostats aggressively and suppresses fluctuations quickly but overdamps the dynamics, distorting time-dependent properties such as velocity autocorrelation functions. A common rule of thumb is to set 1/γ to roughly 1-10x the characteristic relaxation time of the property you care least about disturbing.
What is the extended-system Nosé-Hoover Hamiltonian?
Nosé's original formulation adds one extra coordinate s (a fictitious "time-scaling" degree of freedom) with its own mass Q and momentum, coupled to the real system so that its dynamics in an extended phase space conserves a modified Hamiltonian. Hoover reformulated this into real-time equations of motion without needing the rescaled-time variable, giving the now-standard Nosé-Hoover thermostat with a single friction variable ξ evolving as dξ/dt = (2K − 3Nk_BT)/Q.
What is a Nosé-Hoover chain and why is it needed?
A single Nosé-Hoover thermostat can fail to correctly sample the canonical ensemble for stiff or low-dimensional systems (e.g. a single harmonic oscillator), producing non-ergodic, quasi-periodic temperature oscillations instead of proper thermal equilibrium. Martyna, Klein and Tuckerman's fix, the Nosé-Hoover chain, couples a short chain of several such thermostat variables in series, each damping the fluctuations of the one before it, restoring ergodicity for essentially any system size.
Can thermostats distort the physics they are meant to control?
Yes. Any thermostat that couples too strongly, or couples to too few degrees of freedom, can artificially suppress or exaggerate fluctuations, distort transport coefficients computed via Green-Kubo integrals, or introduce spurious periodicities (a known Nosé-Hoover artifact called the "flying ice cube" when applied globally to a system with a drifting centre of mass). Best practice is to thermostat weakly, remove centre-of-mass motion separately, and use Langevin or chains for small or stiff subsystems.
How does a Langevin thermostat connect to the Ising model on this site?
The Ising model's Metropolis Monte Carlo updates and Langevin dynamics solve the same underlying problem — sampling configurations from a Boltzmann distribution at fixed temperature — by different routes. Metropolis moves are discrete, acceptance-based, and have no real dynamics; Langevin dynamics is continuous-time and produces a physically meaningful trajectory, at the cost of needing a numerical integrator and a friction/noise parameter pair, exactly as described here.
How is this simulated numerically?
The most common scheme is the BAOAB splitting of the Langevin equation, which alternates a half-step of momentum update from forces (B), a half-step of position update (A), an exact Ornstein-Uhlenbeck update handling friction and noise together (O), then repeats A and B. BAOAB is popular because it samples the correct Boltzmann distribution even at fairly large timesteps, integrating the noise term exactly rather than with a first-order Euler approximation.
Where else do Langevin-type thermostats show up outside molecular dynamics?
The same friction-plus-noise structure underlies Langevin Monte Carlo and stochastic gradient Langevin dynamics in machine learning (sampling from a posterior distribution by treating it as a Boltzmann distribution), colloidal and active-matter models of self-propelled particles, and financial models with mean-reverting stochastic volatility — anywhere a system needs to relax toward a target distribution while exploring it with controlled randomness.