swap_mc_step

torch_sim.monte_carlo.swap_mc_step(state, model, *, kT, seed=None, rng=None)[source]

Perform a single swap Monte Carlo step.

Proposes atom swaps, evaluates the energy change, and uses the Metropolis criterion to determine whether to accept the move. Rejected moves are reversed.

Parameters:
  • model (ModelInterface) – Energy model that takes a SimState and returns a dict containing ‘energy’ as a key

  • state (SwapMCState) – The current Monte Carlo state

  • kT (float) – Temperature parameter in energy units

  • seed (int | None) – (Deprecated) Seed for the random number generator. If provided and generator is None, a temporary generator seeded with this value will be used.

  • rng (Generator | None) – Optional torch.Generator to drive all randomness for this step. Prefer passing a persistent generator across steps for reproducibility.

Returns:

Updated Monte Carlo state after applying the step

Return type:

SwapMCState

Notes

The function handles batched systems and ensures that swaps only occur within the same system.