nvalchemi.dynamics.NVTLangevin#
- class nvalchemi.dynamics.NVTLangevin(model, dt, temperature, friction, random_seed=42, n_steps=None, hooks=None, convergence_hook=None, **kwargs)[source]#
NVT integrator via BAOAB Langevin dynamics.
Samples the canonical ensemble via a stochastic Ornstein-Uhlenbeck process that acts as an exact thermostat.
- Parameters:
model (BaseModelMixin) – The neural network potential model.
dt (float or torch.Tensor) – Integration timestep in femtoseconds
[M]or scalar.temperature (float or torch.Tensor) – Target temperature in Kelvin
[M]or scalar.friction (float or torch.Tensor) – Langevin friction coefficient \(\gamma\) in
1/fs[M]or scalar. Controls thermostat coupling strength.random_seed (int, optional) – Global RNG seed for the stochastic O step. Default 42.
n_steps (int, optional) – Total steps for
run().hooks (list[Hook], optional) – Initial hooks.
convergence_hook (ConvergenceHook or dict, optional) – Convergence criterion.
**kwargs – Forwarded to
BaseDynamics.
- __needs_keys__#
{"forces"}.- Type:
set[str]
- __provides_keys__#
{"positions", "velocities"}.- Type:
set[str]
- apply_per_system_params(params, batch)[source]#
Rebind each walker’s target temperature and rescale its velocities.
Langevin has no thermostat memory to transform — its noise amplitude is read from the per-system
temperatureevery step — so the rebinding is the target update plus the velocity rescaling that keeps the kinetic energy consistent with the new target. Velocities scale bysqrt(T_new / T_old), in the same call, because the two together are the indivisible change.- Parameters:
params (Mapping[str, torch.Tensor]) – Must contain
"temperature"in Kelvin per graph, shape[B].batch (Batch) – The live batch;
velocitiesis modified in place.
- Raises:
RuntimeError – If called before the integrator state exists.
KeyError – If params names something this integrator cannot rebind.
- Return type:
None
- post_update(batch)[source]#
BAOAB post-force final B step.
- Parameters:
batch (Batch) – Current batch; velocities updated in-place.
- Return type:
None
- pre_update(batch)[source]#
BAOAB pre-force half: B-A-O-A sequence.
- Parameters:
batch (Batch) – Current batch; positions and velocities updated in-place.
- Return type:
None
- property random_seed: int#
Base seed of the thermostat noise, which every step offsets by
step_count.