Temperature control
Use a Thermostat with ConstantVolume for canonical molecular dynamics, or Langevin to model friction and stochastic forcing. All temperature inputs are expressed as kT in your chosen energy units.
Stochastic velocity rescaling (CSVR)
CSVR implements Bussi–Donadio–Parrinello canonical sampling through velocity rescaling:
all = Group(:all, AllSelection())
integrator = Integrator(
dt=0.002,
forces=[LennardJones(epsilon=1.0, sigma=1.0, cutoff=2.5)],
methods=[ConstantVolume(all; thermostat=CSVR(kT=1.0, tau=0.1, interval=1))],
)tausets the thermostat relaxation timescale.interval(GROMACSnsttcouple, default1) sets the coupling period in steps, integrating the stochastic rescaling overinterval * dt.nstcomm(default100) periodically removes net center-of-mass linear momentum drift inside the captured CUDA graph (subtractingDtranslational degrees of freedom automatically; passnstcomm=0to disable, or configure on low-level states viaSimulationCore.set_com_removal!(st; interval=100)).CSVRsupports multi-bath setups (differentConstantVolume(group; thermostat=...)entries per group), rigid three-site water (RigidWaterConstraint),ConstraintClusters, and GPU-resident NPT barostats.
See SingleT_2D_MD_CSVR.jl for a complete example combining CSVR with thermodynamic observables and collision counting.
Nosé–Hoover chains
NoseHooverChain provides deterministic extended-system NVT dynamics with internal Float64 chain accumulation (even on Float32 particle states) to preserve the conserved extended Hamiltonian accurately:
ConstantVolume(all; thermostat=NoseHooverChain(
kT=1.0,
tau=0.1,
chain_length=5,
substeps=5,
propagator=:gromacs,
))propagator=:gromacs(default): GPU port of the reversible GROMACS chain propagator using exact 4th-order 5-stage Suzuki–Yoshida (SY5) composition weights (4 w₁ + w₃ = 1, 4 w₁³ + w₃³ = 0) repeated oversubstepsinner repetitions (defaultsubsteps=5).propagator=:lammps: GPU port of the reversible LAMMPS MTTKtloopchain propagator (substeps=1matches the LAMMPS default).propagator=:legacy: retains the original package chain update for backwards comparison.chain_masses: optional custom chain masses; when omitted, initialized from(dof, kT, tau)via the standardQ₁ = g kT τ²,Qⱼ = kT τ²(j > 1) rule automatically accounting for holonomic constraints, held frozen particles, and COM removal.nstcomm(default100): periodic center-of-mass drift removal interval in steps (nstcomm=0disables it).
Monitor equilibration, temperature fluctuations, and the conserved :extended_hamiltonian field of BathExchangeObservable before collecting production averages.
Langevin baths
For Langevin dynamics, specify bath temperature kT and exactly one of:
gamma: uniform Stokes drag coefficientγ(same friction force constant on every atom in the group),friction_rate: uniform collision rateξ = γᵢ / mᵢ(time⁻¹, settingγᵢ = friction_rate * mᵢ— recommended for heteronuclear and HMR biomolecular systems so light hydrogens and heavy atoms share the same velocity relaxation time), ortau: velocity relaxation timeτ = 1 / ξ(friction_rate = 1 / tau),
and select a compatible splitting scheme (BAOAB, BAOABFast, VelocityVerlet, BAOA, or GSM):
integrator = Integrator(
dt=0.002,
scheme=BAOABFast(),
forces=[LennardJones(epsilon=1.0, sigma=1.0, cutoff=2.5)],
methods=[Langevin(all; friction_rate=1.0, kT=1.0)], # or gamma=..., or tau=...
)On low-level states, baoab / baoab_fast / velocityverlet accept friction_rate and tau directly, and Filters.set_friction_rate! updates collision rates per particle group. Different particle groups can couple to different bath temperatures and friction coefficients; see the two-temperature mixture example.
Frozen particles and constraints
Held particles (FreezeGroup(group; mode=:hold)) and holonomic constraints (RigidWaterConstraint, ConstraintClusterSpec, HBondConstraints) automatically reduce the kinetic degrees of freedom used by CSVR, NoseHooverChain, and ThermodynamicObservable.
Equilibrate, then run NVE
After equilibration, replace the integrator's methods with ConstantVolume(all) (no thermostat) and call prepare!(sim). The first simulation shows the complete pattern.
Full thermostat and method signatures are in the Workflow API reference and low-level csvr / nosehooverchain constructors in SimulationCore & Low-Level API.