Skip to content

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:

julia
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))],
)
  • tau sets the thermostat relaxation timescale.

  • interval (GROMACS nsttcouple, default 1) sets the coupling period in steps, integrating the stochastic rescaling over interval * dt.

  • nstcomm (default 100) periodically removes net center-of-mass linear momentum drift inside the captured CUDA graph (subtracting D translational degrees of freedom automatically; pass nstcomm=0 to disable, or configure on low-level states via SimulationCore.set_com_removal!(st; interval=100)).

  • CSVR supports multi-bath setups (different ConstantVolume(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:

julia
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 over substeps inner repetitions (default substeps=5).

  • propagator=:lammps: GPU port of the reversible LAMMPS MTTK tloop chain propagator (substeps=1 matches 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 standard Q₁ = g kT τ², Qⱼ = kT τ² (j > 1) rule automatically accounting for holonomic constraints, held frozen particles, and COM removal.

  • nstcomm (default 100): periodic center-of-mass drift removal interval in steps (nstcomm=0 disables 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), or

  • tau: velocity relaxation time τ = 1 / ξ (friction_rate = 1 / tau),

and select a compatible splitting scheme (BAOAB, BAOABFast, VelocityVerlet, BAOA, or GSM):

julia
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.

ParticleDynamics v1.2.0 · GPU-native molecular dynamics in pure Julia · MIT License