openmmtools.mcmc.HMCMove

class openmmtools.mcmc.HMCMove(timestep=Quantity(value=1.0, unit=femtosecond), n_steps=1000, **kwargs)[source]

Hybrid Monte Carlo dynamics.

This move assigns a velocity from the Maxwell-Boltzmann distribution and executes a number of velocity Verlet steps to propagate dynamics.

Parameters:
timestepopenmm.unit.Quantity, optional

The timestep to use for HMC dynamics, which uses velocity Verlet following velocity randomization (time units, default is 1*openmm.unit.femtosecond)

n_stepsint, optional

The number of dynamics steps to take before Metropolis acceptance/rejection (default is 1000).

Examples

First we need to create the thermodynamic state and the sampler state to propagate. Here we create an alanine dipeptide system in vacuum.

>>> from openmm import unit
>>> from openmmtools import testsystems
>>> from openmmtools.states import ThermodynamicState, SamplerState
>>> test = testsystems.AlanineDipeptideVacuum()
>>> sampler_state = SamplerState(positions=test.positions)
>>> thermodynamic_state = ThermodynamicState(system=test.system, temperature=298*unit.kelvin)

Create a GHMC move with default parameters.

>>> move = HMCMove()

or create a GHMC move with specified parameters.

>>> move = HMCMove(timestep=0.5*unit.femtoseconds, n_steps=10)

Perform one update of the sampler state. The sampler state is updated with the new state.

>>> move.apply(thermodynamic_state,sampler_state,context_cache=context_cache)
>>> np.allclose(sampler_state.positions, test.positions)
False

The same move can be applied to a different state, here an ideal gas.

>>> test = testsystems.IdealGas()
>>> sampler_state = SamplerState(positions=test.positions)
>>> thermodynamic_state = ThermodynamicState(system=test.system,
...                                          temperature=298*unit.kelvin)
>>> move.apply(thermodynamic_state,sampler_state,context_cache=context_cache)
>>> np.allclose(sampler_state.positions, test.positions)
False
Attributes:
timestepopenmm.unit.Quantity

The timestep to use for HMC dynamics, which uses velocity Verlet following velocity randomization (time units).

n_stepsint

The number of dynamics steps to take before Metropolis acceptance/rejection.

Methods

apply(thermodynamic_state, sampler_state[, ...])

Apply the MCMC move.

__init__(timestep=Quantity(value=1.0, unit=femtosecond), n_steps=1000, **kwargs)[source]

Methods

__init__([timestep, n_steps])

apply(thermodynamic_state, sampler_state[, ...])

Apply the MCMC move.

Attributes

context_cache