torch_sim.integrators

Integrators for molecular dynamics simulations.

This module provides a collection of integrators for molecular dynamics simulations, supporting NVE (microcanonical), NVT (canonical), and NPT (isothermal-isobaric) ensembles. Each integrator handles batched simulations efficiently using PyTorch tensors and supports periodic boundary conditions.

NVE:
  • Velocity Verlet integrator for constant energy simulations nve.nve_step()

NVT:
NPT:

References

[1] Bussi G, Donadio D, Parrinello M. “Canonical sampling through velocity rescaling.”

The Journal of chemical physics, 126(1), 014101 (2007).

[2] Leimkuhler B, Matthews C.2016 Efficient molecular dynamics using geodesic

integration and solvent-solute splitting. Proc. R. Soc. A 472: 20160138

[3] Martyna, G. J., Tuckerman, M. E., Tobias, D. J., & Klein, M. L. (1996).

Explicit reversible integrators for extended systems dynamics. Molecular Physics, 87(5), 1117-1157.

[4] Grønbech-Jensen, N., & Farago, O. (2014).

Constant pressure and temperature discrete-time Langevin molecular dynamics. The Journal of chemical physics, 141(19).

[5] LAMMPS: https://docs.lammps.org/fix_press_langevin.html

[6] Bernetti, Mattia, and Giovanni Bussi.

“Pressure control using stochastic cell rescaling.” The Journal of Chemical Physics 153.11 (2020).

[7] Del Tatto, Vittorio, et al. “Molecular dynamics of solids at

constant pressure and stress using anisotropic stochastic cell rescaling.” Applied Sciences 12.3 (2022): 1139.

[8] Bussi Anisotropic C-Rescale SimpleMD implementation:

https://github.com/bussilab/crescale/blob/master/simplemd_anisotropic/simplemd.cpp

[9] Supplementary Information for [6].

[10]Tuckerman, Mark E., et al. “A Liouville-operator derived measure-preserving

integrator for molecular dynamics simulations in the isothermal-isobaric ensemble.” Journal of Physics A: Mathematical and General 39.19 (2006): 5629-5651.

Examples

>>> import torch_sim as ts
>>> state = ts.nvt_langevin_init(initial_state, model, kT=300.0 * units.temperature)
>>> for _ in range(1000):
...     state = ts.nvt_langevin_step(
...         state, model, dt=1e-3 * units.time, kT=300.0 * units.temperature
...     )

Notes

All integrators support batched operations for efficient parallel simulation of multiple systems.

Module Attributes

INTEGRATOR_REGISTRY

Integrator registry - maps integrator names to (init_fn, step_fn) pairs.

INTEGRATOR_KWARG_UNITS

Unit-carrying kwargs of each integrator, derived at import time from the TimeArg/InverseTimeArg/PressureArg/InversePressureArg annotations on the registered init/step functions.

Classes

Integrator

Enumeration of available molecular dynamics (MD) integrators.

IntegratorKwargUnits

Metadata for integrator parameters carrying physical units.

unit_kwargs

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2).

Modules

md

Core molecular dynamics state and operations.

npt

Implementations of NPT integrators.

nve

Implementations of NVE integrators.

nvt

Implementations of NVT integrators.