npt_langevin_init

torch_sim.integrators.npt.npt_langevin_init(state, model, *, kT, dt, alpha=None, cell_alpha=None, b_tau=None, seed=None, **_kwargs)[source]

Initialize an NPT Langevin state from input data.

This function creates the initial state for NPT Langevin dynamics, setting up all necessary variables including particle velocities, cell parameters, and barostat variables. It computes initial forces and stress using the provided model.

Parameters:
  • model (ModelInterface) – Neural network model that computes energies, forces, and stress. Must return a dict with ‘energy’, ‘forces’, and ‘stress’ keys.

  • state (MDState | StateDict) – Either a MDState object or a dictionary containing positions, masses, cell, pbc

  • kT (torch.Tensor) – Target temperature in energy units, either scalar or with shape [n_systems]

  • dt (torch.Tensor) – Integration timestep, either scalar or shape [n_systems]

  • alpha (torch.Tensor, optional) – Friction coefficient for particle Langevin thermostat, either scalar or shape [n_systems]. Defaults to 1/(100*dt).

  • cell_alpha (torch.Tensor, optional) – Friction coefficient for cell Langevin thermostat, either scalar or shape [n_systems]. Defaults to same as alpha.

  • b_tau (torch.Tensor, optional) – Barostat time constant controlling how quickly the system responds to pressure differences, either scalar or shape [n_systems]. Defaults to 1/(1000*dt).

  • seed (int, optional) – Random seed for reproducibility. Defaults to None.

  • _kwargs (Any)

Returns:

Initialized state for NPT Langevin integration containing

all required attributes for particle and cell dynamics

Return type:

NPTLangevinState

Notes

  • The model must provide stress tensor calculations for proper pressure coupling