swap_mc_init¶
- torch_sim.monte_carlo.swap_mc_init(state, model)[source]¶
Initialize a swap Monte Carlo state from input data.
Creates an initial state for swap Monte Carlo simulations by computing initial energy and setting up the permutation tracking. The simulation uses the Metropolis criterion to accept or reject proposed swaps based on energy differences.
Make sure that if the trajectory is being reported, the TorchSimTrajectory.write_state method is called with variable_masses=True.
- Parameters:
model (ModelInterface) – Energy model that takes a SimState and returns a dict containing ‘energy’ as a key
state (SimState) – The simulation state to initialize from
- Returns:
- Initialized state for swap Monte Carlo simulation containing
positions, energy, and permutation tracking
- Return type:
Examples
>>> mc_state = swap_monte_carlo_init(model=energy_model, state=initial_state) >>> for _ in range(100): >>> mc_state = swap_monte_carlo_step(model, mc_state, kT=0.1)