torch_sim.monte_carloΒΆ

Propagators for Monte Carlo simulations.

This module provides functionality for performing Monte Carlo simulations, particularly focused on swap Monte Carlo for atomic systems. It includes implementations of the Metropolis criterion, swap generation, and utility functions for handling permutations in batched systems.

The swap_mc_init and swap_mc_step functions can be used with integrate but if a trajectory is being reported, the TorchSimTrajectory.write_state method must be called with variable_masses=True.

Examples

>>> import torch_sim as ts
>>> mc_state = ts.swap_mc_init(model, initial_state, seed=42)
>>> for _ in range(1000):
...     mc_state = ts.swap_mc_step(model, mc_state, kT=0.1 * units.energy)

Functions

generate_swaps

Generate atom swaps for a given batched system.

metropolis_criterion

Apply the Metropolis acceptance criterion for Monte Carlo moves.

swap_mc_init

Initialize a swap Monte Carlo state from input data.

swap_mc_step

Perform a single swap Monte Carlo step.

swaps_to_permutation

Convert atom swap pairs to a full permutation tensor.

Classes

SwapMCState

State for Monte Carlo simulations with swap moves.