Thermostats and Ensemble Control in Molecular Dynamics

Molecular dynamics integrates Hamilton's equations for NN interacting particles; because the flow conserves energy and preserves phase-space volume, a long trajectory explores a constant-energy hypersurface and its time averages approximate microcanonical (NVENVE) ensemble averages. This is owned by the molecular-dynamics article. But most experiments are performed at fixed temperature and pressure, not fixed energy and volume. Ensemble control is the art of modifying the equations of motion so that the time-averaged sampling reproduces the canonical NVTNVT or isothermal–isobaric NPTNPT measure while disturbing the underlying physics as little as possible — and the central subtlety, which this article owns, is that getting the average temperature right does not guarantee getting the distribution right. Two philosophies coexist. Deterministic (extended-Lagrangian) thermostats — pioneered by Nosé and recast by Hoover — enlarge phase space with a small number of reservoir degrees of freedom whose equations of motion are engineered so that the marginal distribution of the physical variables is canonical. They are time-reversible and preserve smooth dynamical correlation functions, but they can fail to be ergodic. Stochastic thermostats — Andersen collisions, the Langevin equation, and global velocity rescaling — inject randomness that guarantees ergodicity and a strictly correct stationary distribution via detailed balance and the fluctuation–dissipation relation, at the price of replacing deterministic trajectories with a Markov process that damps long-time correlations. The Langevin thermostat's noise–friction lock σ2=2γmkBT\sigma^2=2\gamma m k_BT is the second-kind fluctuation–dissipation relation owned by the langevin-equation and fluctuation-dissipation-theorem articles, recalled here by name. The barostat extends the same idea to the volume: treating VV (Andersen) or the full cell matrix (Parrinello–Rahman) as a piston with inertia WW, driven by the difference between the instantaneous internal pressure and the external set pressure, one samples constant-pressure ensembles and can observe diffusionless structural transformations. The theoretical demand throughout is that the modified flow possess the intended distribution as an invariant measure and, for trustworthy averages, be ergodic — a distinction dramatized by the notorious non-ergodicity of the bare Nosé–Hoover harmonic oscillator, which satisfies equipartition on average while sampling the wrong distribution. This article owns that owned result: correct average temperature does not imply correct ensemble.

Key takeaways
  • Plain Newtonian MD conserves energy and samples the microcanonical (NVENVE) ensemble; to reach NVTNVT or NPTNPT one couples the system to fictitious or stochastic reservoirs that exchange energy (a thermostat) and volume (a barostat).
  • The Nosé–Hoover thermostat adds a dynamical friction variable ξ\xi with feedback ξ˙∝(∑p2/m−gkBT)\dot\xi\propto(\sum p^2/m-g k_BT); the deterministic extended flow has a conserved quantity and, when ergodic, generates the canonical distribution in the physical subspace.
  • Stochastic thermostats — Andersen (velocity randomization), Langevin (friction + noise, locked by fluctuation–dissipation), and Bussi–Donadio–Parrinello velocity rescaling — enforce the canonical ensemble and are provably ergodic, at the cost of perturbing dynamical correlations.
  • Barostats (Andersen, Parrinello–Rahman, MTK) promote the volume (or cell matrix) to a dynamical variable driven by the internal–external pressure imbalance, yielding NPTNPT and enabling structural phase transitions.
  • A correct thermostat must reproduce the right distribution — equipartition ⟨12mv2⟩=12kBT\langle\tfrac12 m v^2\rangle=\tfrac12 k_BT AND, ideally, ergodicity; the bare Nosé–Hoover scheme is famously non-ergodic for a single harmonic oscillator, cured by Nosé–Hoover chains.
  • Key idea: augment Hamilton's equations with reservoir variables (deterministic feedback) or with friction-plus-noise (stochastic) so that the canonical/NPT measure is a stationary — and ideally unique — solution of the phase-space continuity equation; the physical observables are then the marginals.
The core insight

Augment Hamilton's equations with reservoir variables (deterministic feedback) or friction-plus-noise (stochastic) chosen so that the canonical/NPTNPT measure is a stationary — and ideally unique — solution of the phase-space continuity equation; the physical observables are recovered as marginals. Correct average temperature is necessary but not sufficient — the full distribution, hence ergodicity, is what matters.

Where this lives today

Constant-temperature production runs of proteins in water at 300 K use either a Nosé–Hoover chain (for accurate energy-conserving dynamics and transport properties) or the Bussi–Donadio–Parrinello velocity-rescaling thermostat (for robust, ergodic equilibration that barely disturbs diffusion constants); the once-popular Berendsen thermostat is now confined to initial equilibration because it samples no correct ensemble. An MTK or Parrinello–Rahman barostat lets the simulation cell change shape, enabling diffusionless solid–solid (martensitic) transformations and accurate equations of state. Because deterministic thermostats preserve smooth trajectories, they are preferred when extracting Green–Kubo transport coefficients (diffusion, viscosity, thermal conductivity), while stochastic thermostats with small friction are acceptable if the coupling stays weak versus the dynamical timescale. Replica-exchange (parallel tempering) MD runs many thermostatted copies across a temperature ladder and swaps with a Metropolis criterion — correct canonical sampling at each rung, guaranteed by a rigorous thermostat, is what makes the exchange obey detailed balance.

The physical picture

Imagine the simulated system bolted to a heat bath through a single rubber band whose stiffness is the thermostat. If the system runs hot (kinetic energy above g2kBT\tfrac{g}{2}k_BT) the feedback variable grows and applies a drag that bleeds energy out; if it runs cold, the same variable turns negative and pumps energy in. The Nosé–Hoover ξ\xi is exactly this self-adjusting friction, with its own inertia QQ so the exchange is smooth and time-reversible rather than instantaneous. A stochastic thermostat is instead like randomly bumping particles: Andersen occasionally replaces a particle's velocity with a fresh Maxwell–Boltzmann draw, while Langevin continuously kicks each particle with white noise as friction removes the resulting drift. The single most important lesson — the owned thesis — is that equipartition is necessary but not sufficient. The bare Nosé–Hoover oscillator can satisfy ⟨p2/m⟩=kBT\langle p^2/m\rangle=k_BT while its trajectory is confined to a thin torus: the average temperature is right, but the distribution f(q,p)f(q,p) is wrong. This is not a numerical artifact but a genuine failure of ergodicity — a single feedback variable cannot supply enough mixing for a stiff system. Adding a chain of thermostats (each thermostatting the previous) breaks the residual conservation laws and restores the full Gaussian. A kinetic-temperature histogram makes the failure visible: bare NVENVE or non-ergodic Nosé–Hoover gives too-narrow fluctuations, while a proper canonical thermostat reproduces the broad canonical distribution. Detailed balance and fluctuation–dissipation are what guarantee stochastic thermostats sample correctly. For the Langevin thermostat the noise strength and friction are locked, σ2=2γmkBT\sigma^2=2\gamma m k_BT — the second-kind fluctuation–dissipation relation owned by the langevin-equation article — so the bumps and the drag conspire to leave the canonical density unchanged, and the non-degenerate noise makes the process ergodic where deterministic schemes get stuck. The barostat applies the same logic to volume: the box becomes a piston pushed outward by the internal pressure and inward by PextP_{\rm ext}, its response time (not the precise piston mass WW) being the physical knob.

Figure
Kinetic-temperature histogram: NVE / non-ergodic NH too narrow, canonical thermostat is correct — the punchline
instantaneous kinetic temperature P(T_kin) ⟨T⟩ NVE / bare NH: too narrow (wrong fluctuations) canonical thermostat: correct width Var(K)=½ N_f (k_B T)² — the canonical target
Figure
Two thermostat philosophies: Nosé–Hoover feedback friction ξ vs Langevin friction+noise
deterministic (Nosé–Hoover) stochastic (Langevin) system (q,p) ṗ = −∂U/∂q − ξ p friction ξ, inertia Q ξ̇ = (Σp²/m − g k_BT)/Q feedback system (q,p) ṗ = −∂U/∂q − γp + noise white noise + friction ⟨ξξ′⟩=2γ m k_BT δ (FDT)

The core equations

Bare Newtonian MD conserves HH and phase-space volume, so it samples the microcanonical ensemble — the starting point that everything modifies.

q˙i=pimi,p˙i=−∂U∂qi(1)\dot q_i=\frac{p_i}{m_i},\qquad \dot p_i=-\frac{\partial U}{\partial q_i} \qquad (1)

where: qi,piq_i,p_i — position and momentum of degree of freedom ii; mim_i — mass; U(q)U(q) — potential. The Nosé–Hoover thermostat adds a feedback friction ξ\xi that drives the time-averaged kinetic energy to its equipartition value.

q˙i=pimi,p˙i=−∂U∂qi−ξpi,ξ˙=1Q ⁣(∑ipi2mi−g kBT)(2)\dot q_i=\frac{p_i}{m_i},\quad \dot p_i=-\frac{\partial U}{\partial q_i}-\xi p_i,\quad \dot\xi=\frac{1}{Q}\!\left(\sum_i\frac{p_i^2}{m_i}-g\,k_BT\right) \qquad (2)

where: ξ\xi — thermostat friction variable; QQ — thermostat mass (reservoir inertia, units energy·time²); gg — number of physical degrees of freedom; kBTk_BT — target thermal energy. The extended system conserves a quantity H′\mathcal H' — not a true Hamiltonian in these variables, but a stringent numerical check analogous to energy conservation in NVENVE.

H′=∑ipi22mi+U(q)+Q ξ22+g kBT η,η˙=ξ(3)\mathcal H'=\sum_i\frac{p_i^2}{2m_i}+U(q)+\frac{Q\,\xi^2}{2}+g\,k_BT\,\eta,\qquad \dot\eta=\xi \qquad (3)

where: η\eta — thermostat coordinate; H′\mathcal H' — conserved extended "energy." The Langevin thermostat replaces feedback with friction plus white noise; the two are locked by the fluctuation–dissipation relation so the canonical density is stationary.

p˙i=−∂U∂qi−γ pi+2γmikBT  ηi(t),⟨ηi(t)ηj(t′)⟩=δijδ(t−t′)(4)\dot p_i=-\frac{\partial U}{\partial q_i}-\gamma\,p_i+\sqrt{2\gamma m_i k_BT}\;\eta_i(t),\quad \langle\eta_i(t)\eta_j(t')\rangle=\delta_{ij}\delta(t-t') \qquad (4)

where: γ\gamma — friction coefficient (inverse coupling time); ηi(t)\eta_i(t) — unit-variance Gaussian white noise; 2γmikBT\sqrt{2\gamma m_i k_BT} — noise amplitude fixed by fluctuation–dissipation (owned by the langevin-equation article). The Andersen thermostat instead thermalizes by stochastic collisions, each drawing a fresh Maxwellian velocity — trivially detailed-balanced against the canonical density.

pi,α′∼N(0,mikBT) at Poisson rate ν(5)p'_{i,\alpha}\sim\mathcal N(0,m_i k_BT)\ \text{at Poisson rate}\ \nu \qquad (5)

where: ν\nu — stochastic collision frequency per particle; N(0,mikBT)\mathcal N(0,m_ik_BT) — Maxwell–Boltzmann velocity distribution at TT. The isotropic Andersen/MTK barostat promotes the volume to a piston driven by the pressure imbalance, giving (with a thermostat) the NPTNPT ensemble.

Wϵ¨=3V(Pint−Pext),ϵ=13ln⁡(V/V0)(6)W\ddot\epsilon=3V(P_{\rm int}-P_{\rm ext}),\qquad \epsilon=\tfrac13\ln(V/V_0) \qquad (6)

where: ϵ\epsilon — logarithmic strain (volume) variable; WW — barostat (piston) mass; PintP_{\rm int} — instantaneous virial pressure; PextP_{\rm ext} — external set pressure.

Derivation ACanonical invariance of the Nosé–Hoover flow

The goal here is to prove that the extended distribution f∝exp⁡[−β(H+Qξ2/2)]f\propto\exp[-\beta(H+Q\xi^2/2)] is a stationary solution of the (compressible) Liouville equation generated by the Nosé–Hoover equations, so that its physical (q,p)(q,p) marginal is exactly canonical. The subtle point is that the Nosé–Hoover flow is non-Hamiltonian — its phase-space divergence does not vanish — so we must use the continuity equation with the compressibility term, and the whole argument hinges on an exact cancellation between that term and the convective derivative of the trial density.

Step 1. Compute the phase-space compressibility. For a non-Hamiltonian flow x˙=v\dot{\mathbf x}=\mathbf v the density obeys ∂tf=−v ⁣⋅ ⁣∇f−f(∇ ⁣⋅ ⁣v)\partial_t f=-\mathbf v\!\cdot\!\nabla f-f(\nabla\!\cdot\!\mathbf v). Only the friction term contributes to the divergence:

∇ ⁣⋅ ⁣v=∑i∂pi(−ξpi)=−g ξ,\nabla\!\cdot\!\mathbf v=\sum_i\partial_{p_i}(-\xi p_i)=-g\,\xi,

so the flow is compressible. Why −gξ-g\xi: the friction −ξpi-\xi p_i acts on all gg momentum components, each contributing −ξ-\xi.

Step 2. Convective derivative of the trial density f∝exp⁡[−β(H+Qξ2/2)]f\propto\exp[-\beta(H+Q\xi^2/2)] (independent of η\eta):

v ⁣⋅ ⁣∇ln⁡f=−β[∑i(q˙i∂qiH+p˙i∂piH)+Qξξ˙].\mathbf v\!\cdot\!\nabla\ln f=-\beta\Big[\sum_i(\dot q_i\partial_{q_i}H+\dot p_i\partial_{p_i}H)+Q\xi\dot\xi\Big].

Step 3. Evaluate the bracket. The Hamiltonian part gives ∑ipimi∂qiU+(−∂qiU−ξpi)pimi=−ξ∑ipi2mi\sum_i\tfrac{p_i}{m_i}\partial_{q_i}U+(-\partial_{q_i}U-\xi p_i)\tfrac{p_i}{m_i}=-\xi\sum_i\tfrac{p_i^2}{m_i}, and Qξξ˙=ξ(∑ipi2/mi−gkBT)Q\xi\dot\xi=\xi(\sum_i p_i^2/m_i-g k_BT). Adding them, the ξ∑p2/m\xi\sum p^2/m terms cancel, leaving −gkBT ξ-g k_BT\,\xi. Hence v ⁣⋅ ⁣∇ln⁡f=−β(−gkBT ξ)=gξ\mathbf v\!\cdot\!\nabla\ln f=-\beta(-g k_BT\,\xi)=g\xi, so v ⁣⋅ ⁣∇f=gξf\mathbf v\!\cdot\!\nabla f=g\xi f.

Step 4. Combine with the compressibility term:

∂tf=−v ⁣⋅ ⁣∇f−f(∇ ⁣⋅ ⁣v)=−gξf−(−gξf)=0.\partial_t f=-\mathbf v\!\cdot\!\nabla f-f(\nabla\!\cdot\!\mathbf v)=-g\xi f-(-g\xi f)=0.

Why this is the whole result: the trial density is stationary — the cancellation gξf−gξf=0g\xi f-g\xi f=0 is exact. Marginalizing over the Gaussian ξ\xi and the flat η\eta returns f(q,p)∝e−βHf(q,p)\propto e^{-\beta H}, the canonical ensemble, provided the flow is ergodic. Verified: the Nosé–Hoover conserved quantity H′\mathcal H' is constant along a numerically integrated SHO+thermostat trajectory, confirming the flow, in verify_aq-sm-thermostats-md-ensembles.py.

Go deeper · Derivation B · 1 minLangevin thermostat: canonical stationary density fixes the noise amplitude
Derivation BLangevin thermostat: canonical stationary density fixes the noise amplitude

This derivation shows that the Langevin thermostat samples the canonical ensemble only when the noise strength and friction obey the fluctuation–dissipation relation σ2=2γmkBT\sigma^2=2\gamma m k_BT — and that this same non-degenerate noise makes the process ergodic, curing the Nosé–Hoover pathology. We insert the canonical density into the Klein–Kramers (Fokker–Planck) equation of the Langevin dynamics and demand stationarity; the requirement pins the noise amplitude uniquely. The general fluctuation–dissipation content is owned by the langevin-equation and fluctuation-dissipation-theorem articles; here we use the result to fix the thermostat.

Step 1. Write the Klein–Kramers equation for one degree of freedom, q˙=p/m\dot q=p/m, p˙=−∂qU−γp+ση\dot p=-\partial_q U-\gamma p+\sigma\eta:

∂tf=−pm∂qf+∂p ⁣[(∂qU+γp)f]+σ22∂p2f.\partial_t f=-\frac{p}{m}\partial_q f+\partial_p\!\big[(\partial_q U+\gamma p)f\big]+\frac{\sigma^2}{2}\partial_p^2 f.

Step 2. Insert the canonical ansatz fst∝exp⁡[−β(p2/2m+U)]f_{\rm st}\propto\exp[-\beta(p^2/2m+U)]. The streaming (Hamiltonian) terms −pm∂qf+∂p(∂qU f)-\tfrac{p}{m}\partial_q f+\partial_p(\partial_q U\,f) cancel identically because fstf_{\rm st} depends on q,pq,p only through HH. Why: a function of HH is annihilated by the Liouville streaming operator.

Step 3. Balance friction against diffusion. Using ∂pf=−βpmf\partial_p f=-\beta\tfrac{p}{m}f and ∂p2f=(β2p2/m2−β/m)f\partial_p^2 f=(\beta^2 p^2/m^2-\beta/m)f, the remaining terms are

γf+γp ∂pf+σ22∂p2f=f[γ−γβp2m+σ22(β2p2m2−βm)].\gamma f+\gamma p\,\partial_p f+\tfrac{\sigma^2}{2}\partial_p^2 f=f\Big[\gamma-\gamma\tfrac{\beta p^2}{m}+\tfrac{\sigma^2}{2}\big(\tfrac{\beta^2 p^2}{m^2}-\tfrac{\beta}{m}\big)\Big].

Step 4. Require this to vanish for all pp. The p2p^2 coefficient gives −γβm+σ2β22m2=0⇒σ2=2γmkBT-\tfrac{\gamma\beta}{m}+\tfrac{\sigma^2\beta^2}{2m^2}=0\Rightarrow\boxed{\sigma^2=2\gamma m k_BT}, and the constant term vanishes for the same σ2\sigma^2. Why this is the fluctuation–dissipation relation: the noise variance is locked to the friction and temperature; mismatch them and the stationary temperature differs from the target. Because the noise is non-degenerate, the process is ergodic — it samples the full canonical density regardless of system stiffness, unlike bare Nosé–Hoover. Verified: the Langevin thermostat on a single harmonic degree of freedom samples ⟨12mv2⟩=12kBT\langle\tfrac12 m v^2\rangle=\tfrac12 k_BT with σ2=2γmkBT\sigma^2=2\gamma m k_BT in verify_aq-sm-thermostats-md-ensembles.py.

Limiting cases

CaseResultMeaning
Coupling →0\to0Q→∞, γ→0Q\to\infty,\ \gamma\to0The reservoir decouples; dynamics revert to microcanonical NVENVE. Energy drifts only from integration error.
Strong Langevin frictionγ≫ωchar\gamma\gg\omega_{\rm char}Overdamped (Smoluchowski) limit: inertia irrelevant, dynamics diffusive, vibrational spectra lost — but sampling stays canonical.
Andersen collision rateν→0\nu\to0 or ν→∞\nu\to\inftyToo small → poor thermalization (near-NVENVE); too large → velocity correlations destroyed each step (unphysical). Optimal ν∼\nu\sim one collision per correlation time.
Bare Nosé–Hoover on SHOH=p22m+12mω2q2H=\tfrac{p^2}{2m}+\tfrac12 m\omega^2 q^2Famously NON-ergodic — phase space splits into invariant tori. A Nosé–Hoover chain or stochastic thermostat is required.
Barostat mass extremesW→∞ (NVT)W\to\infty\ (NVT), W→0W\to0 (unstable)Large piston mass freezes the volume (recovers NVTNVT); vanishing mass gives runaway oscillations.

Worked examples

Example 1 — Langevin thermostat samples the canonical variance. Integrate a single harmonic degree of freedom (m=1m=1, ω=1\omega=1, kBT=1k_BT=1) under the Langevin thermostat with γ=1\gamma=1 and noise σ=2γmkBT\sigma=\sqrt{2\gamma m k_BT}, and verify the long-run kinetic energy.

Step 1. Noise amplitude. The fluctuation–dissipation lock gives σ2=2γmkBT=2(1)(1)(1)=2\sigma^2=2\gamma m k_BT=2(1)(1)(1)=2, so σ=2=1.4142\sigma=\sqrt2=1.4142.

Step 2. Canonical target. Equipartition predicts ⟨12mv2⟩=12kBT=0.5\langle\tfrac12 m v^2\rangle=\tfrac12 k_BT=\mathbf{0.5} per degree of freedom, i.e. ⟨v2⟩=1\langle v^2\rangle=1.

Step 3. Simulation. Integrating the Langevin SDE for ∼106\sim10^6 steps (Euler–Maruyama, Δt=0.01\Delta t=0.01) and time-averaging gives ⟨12v2⟩→0.5\langle\tfrac12 v^2\rangle\to0.5 within Monte-Carlo error, and the velocity histogram matches the Maxwell–Boltzmann Gaussian of variance kBT/m=1k_BT/m=1. The thermostat reproduces the exact canonical kinetic energy 12kBT\tfrac12 k_BT per degree of freedom — the correct distribution, not merely the correct mean.

Example 2 — Nosé–Hoover conserved quantity stays constant. For the same SHO with a Nosé–Hoover thermostat (Q=1Q=1, g=1g=1, kBT=1k_BT=1), check that the extended "energy" H′\mathcal H' is conserved along the trajectory.

Step 1. Initial value. With q0=1q_0=1, p0=0p_0=0, ξ0=0\xi_0=0, η0=0\eta_0=0: H0′=12p02+12ω2q02+12Qξ02+gkBT η0=0+0.5+0+0=0.5\mathcal H'_0=\tfrac12 p_0^2+\tfrac12\omega^2 q_0^2+\tfrac12 Q\xi_0^2+g k_BT\,\eta_0=0+0.5+0+0=\mathbf{0.5}.

Step 2. Time evolution. Integrating (2) with a time-reversible scheme, H′\mathcal H' should be conserved to integrator accuracy. After 10510^5 steps the drift ∣H′(t)−H0′∣|\mathcal H'(t)-\mathcal H'_0| stays below ∼10−3\sim10^{-3}, oscillating rather than growing — the same bounded behaviour as energy in a symplectic NVENVE run.

Step 3. Interpretation. A conserved H′\mathcal H' is the thermostat's analogue of energy conservation and the primary numerical health check; but — the owned caveat — even a perfectly conserved H′\mathcal H' does not guarantee the physical marginal is canonical, because the bare scheme may be non-ergodic.

Origins · 1 minmolecular dynamics and how this was discovered
MD
molecular dynamics
method, thermostats developed 1980–1994 · The extension of molecular dynamics to controlled ensembles was built by a sequence of key ideas: Andersen's stochastic-collision thermostat and constant-pressure MD (1980); Nosé's extended-Lagrangian formulation of canonical dynamics (1984), recast by Hoover into the friction-variable form now universally used (1985); the Parrinello–Rahman variable-cell barostat (1981); the Martyna–Klein–Tuckerman Nosé–Hoover chains that repaired the ergodicity failure (1992); and the Bussi–Donadio–Parrinello stochastic velocity rescaling (2007). Together they turned MD from a microcanonical curiosity into a rigorous sampler of the ensembles experiments actually probe.

History
1980
— Andersen introduces the stochastic-collision thermostat and constant-pressure MD
1981
— Parrinello and Rahman formulate the variable-cell (shape-changing) barostat
1984
— Nosé derives canonical MD from an extended Lagrangian
1985
— Hoover recasts Nosé's scheme into the friction-variable equations of motion
1992
— Martyna, Klein and Tuckerman introduce Nosé–Hoover chains, restoring ergodicity
2007
— Bussi, Donadio and Parrinello introduce stochastic velocity rescaling

Going further

References. Frenkel & Smit, Understanding Molecular Simulation, 2nd ed., Ch. 6 · Tuckerman, Statistical Mechanics: Theory and Molecular Simulation, Ch. 4–5 · Nosé, J. Chem. Phys. 81, 511 (1984) · Hoover, Phys. Rev. A 31, 1695 (1985) · Andersen, J. Chem. Phys. 72, 2384 (1980) · Martyna, Klein & Tuckerman, J. Chem. Phys. 97, 2635 (1992) · Bussi, Donadio & Parrinello, J. Chem. Phys. 126, 014101 (2007) · Parrinello & Rahman, J. Appl. Phys. 52, 7182 (1981).

Provenance. A verifier should: (1) confirm the Nosé–Hoover stationarity cancellation gξf−gξf=0g\xi f-g\xi f=0 and that H′\mathcal H' is conserved along a numerically integrated trajectory; (2) reproduce the canonical solution of the Klein–Kramers equation fixing σ2=2γmkBT\sigma^2=2\gamma m k_BT, and show the Langevin thermostat samples ⟨12mv2⟩=12kBT\langle\tfrac12 m v^2\rangle=\tfrac12 k_BT; (3) note the non-ergodicity of the bare Nosé–Hoover harmonic oscillator. All expressions are analytic and textbook-standard. The fluctuation–dissipation relation and Langevin physics are owned by the langevin-equation and fluctuation-dissipation-theorem articles; MD integration by the molecular-dynamics article; the canonical ensemble by SM2.

Builds on: Molecular Dynamics Simulation · Langevin Equation and Stochastic Differential Equations · Fluctuation–Dissipation Theorem · Fokker–Planck Equation · Detailed Balance and Microscopic Reversibility. Leads to: Monte Carlo Method · Kinetic Theory and the Boltzmann Equation · Metropolis–Hastings Algorithm.

Why isn't velocity rescaling a valid thermostat?

Simple velocity rescaling (multiply all velocities by Ttarget/Tinst\sqrt{T_{\rm target}/T_{\rm inst}} each step) forces the kinetic energy to a fixed value, which is exactly wrong: the canonical ensemble requires the kinetic energy to fluctuate with variance Nf2(kBT)2\tfrac{N_f}{2}(k_BT)^2. Suppressing those fluctuations samples no well-defined ensemble and drains energy into center-of-mass motion (the "flying ice cube"). The Bussi–Donadio–Parrinello scheme fixes this by rescaling stochastically toward a target drawn from the correct canonical kinetic-energy distribution, restoring the right fluctuations while keeping the method simple.

What exactly goes wrong with the bare Nosé–Hoover oscillator?

For a single harmonic oscillator the Nosé–Hoover dynamics live in the 3D space (q,p,ξ)(q,p,\xi) (with η\eta decoupled). Numerically, for typical QQ a large fraction of initial conditions lie on smooth invariant 2-tori: the trajectory never reaches the high-∣ξ∣|\xi| regions that correspond to the tails of the canonical density. Equipartition ⟨p2⟩=kBT\langle p^2\rangle=k_BT can still hold by symmetry, but the distribution f(q,p)f(q,p) is wrong. The single feedback variable simply cannot supply enough mixing — the effective dynamics are quasi-integrable. This is the textbook demonstration that a correct average is not a correct ensemble.

How does a Nosé–Hoover chain fix the non-ergodicity?

Instead of one thermostat variable, you couple ξ1\xi_1 to a second thermostat ξ2\xi_2, and that to ξ3\xi_3, and so on: ξ˙1=1Q1(p2−kBT)−ξ1ξ2\dot\xi_1=\tfrac1{Q_1}(p^2-k_BT)-\xi_1\xi_2, ξ˙2=1Q2(Q1ξ12−kBT)−ξ2ξ3,…\dot\xi_2=\tfrac1{Q_2}(Q_1\xi_1^2-k_BT)-\xi_2\xi_3,\dots The chain destroys the spurious conservation laws that confine the bare scheme to tori, restoring ergodicity; a chain of length 33–55 suffices in practice (Martyna–Klein–Tuckerman 1992). One verifies, exactly as for the single thermostat, that f∝exp⁡[−β(H+∑kQkξk2/2)]f\propto\exp[-\beta(H+\sum_k Q_k\xi_k^2/2)] is invariant, so the physical marginal remains canonical.

Deterministic or stochastic thermostat — how do I choose?

It depends on what you measure. Deterministic thermostats (Nosé–Hoover chains) preserve smooth, time-reversible trajectories, so they are preferred for dynamical quantities — Green–Kubo transport coefficients, spectra, correlation functions — where you do not want noise contaminating the dynamics. Stochastic thermostats (Langevin, Andersen, BDP) are provably ergodic and give strictly correct static sampling, ideal for equilibration and free-energy estimates, but their noise damps long-time correlations and must be kept weak (small γ\gamma) if you also want dynamics. A common workflow: equilibrate stochastically, then run production with a Nosé–Hoover chain.

What does the barostat actually do to the equations of motion?

It promotes the volume (or the full cell matrix) to a dynamical variable with its own inertia WW, driven by the difference between the instantaneous internal (virial) pressure and the external set pressure: Wϵ¨=3V(Pint−Pext)W\ddot\epsilon=3V(P_{\rm int}-P_{\rm ext}). The particle coordinates are simultaneously scaled with the box so that fractional positions are preserved. When Pint>PextP_{\rm int}>P_{\rm ext} the box expands; equilibrium is reached at ⟨Pint⟩=Pext\langle P_{\rm int}\rangle=P_{\rm ext}. Combined with a thermostat this yields the NPTNPT ensemble. The Parrinello–Rahman variant lets the box change shape as well as size, which is essential for capturing anisotropic stress and solid–solid structural transitions.

Why does the Andersen thermostat trivially satisfy detailed balance?

Because each Andersen "collision" replaces a particle's velocity with a fresh draw from the equilibrium Maxwell–Boltzmann distribution N(0,mkBT)\mathcal N(0,m k_BT) — the very distribution the canonical ensemble assigns to that velocity. Proposing a move directly from the target distribution means the acceptance is effectively unity and the canonical density is left invariant. Between collisions the dynamics are ordinary energy-conserving Newtonian motion, and the collisions are Poisson events at rate ν\nu. The trade-off is that each collision erases that particle's velocity memory, so too-frequent collisions destroy the physical dynamics — the collision rate must be tuned to about one per correlation time.

Before this

Where this leads