openmmtools.mcmc.LangevinDynamicsMove

class openmmtools.mcmc.LangevinDynamicsMove(timestep=Quantity(value=1.0, unit=femtosecond), collision_rate=Quantity(value=10.0, unit=/picosecond), n_steps=1000, reassign_velocities=False, **kwargs)[source]

Langevin dynamics segment as a (pseudo) Monte Carlo move.

This move assigns a velocity from the Maxwell-Boltzmann distribution and executes a number of Maxwell-Boltzmann steps to propagate dynamics. This is not a true Monte Carlo move, in that the generation of the correct distribution is only exact in the limit of infinitely small timestep; in other words, the discretization error is assumed to be negligible. Use HybridMonteCarloMove instead to ensure the exact distribution is generated.

Warning

No Metropolization is used to ensure the correct phase space distribution is sampled. This means that timestep-dependent errors will remain uncorrected, and are amplified with larger timesteps. Use this move at your own risk!

Parameters:
timestep : simtk.unit.Quantity, optional

The timestep to use for Langevin integration (time units, default is 1*simtk.unit.femtosecond).

collision_rate : simtk.unit.Quantity, optional

The collision rate with fictitious bath particles (1/time units, default is 10/simtk.unit.picoseconds).

n_steps : int, optional

The number of integration timesteps to take each time the move is applied (default is 1000).

reassign_velocities : bool, optional

If True, the velocities will be reassigned from the Maxwell-Boltzmann distribution at the beginning of the move (default is False).

context_cache : openmmtools.cache.ContextCache, optional

The ContextCache to use for Context creation. If None, the global cache openmmtools.cache.global_context_cache is used (default is None).

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 simtk import unit
>>> from openmmtools import testsystems
>>> from openmmtools.states import SamplerState, ThermodynamicState
>>> test = testsystems.AlanineDipeptideVacuum()
>>> sampler_state = SamplerState(positions=test.positions)
>>> thermodynamic_state = ThermodynamicState(system=test.system, temperature=298*unit.kelvin)

Create a Langevin move with default parameters

>>> move = LangevinDynamicsMove()

or create a Langevin move with specified parameters.

>>> move = LangevinDynamicsMove(timestep=0.5*unit.femtoseconds,
...                             collision_rate=20.0/unit.picoseconds, 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)
>>> 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)
>>> np.allclose(sampler_state.positions, test.positions)
False
Attributes:
timestep : simtk.unit.Quantity

The timestep to use for Langevin integration (time units).

collision_rate : simtk.unit.Quantity

The collision rate with fictitious bath particles (1/time units).

n_steps : int

The number of integration timesteps to take each time the move is applied.

reassign_velocities : bool

If True, the velocities will be reassigned from the Maxwell-Boltzmann distribution at the beginning of the move.

context_cache : openmmtools.cache.ContextCache

The ContextCache to use for Context creation. If None, the global cache openmmtools.cache.global_context_cache is used.

Methods

apply(thermodynamic_state, sampler_state) Apply the Langevin dynamics MCMC move.
__init__(timestep=Quantity(value=1.0, unit=femtosecond), collision_rate=Quantity(value=10.0, unit=/picosecond), n_steps=1000, reassign_velocities=False, **kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

Methods

__init__([timestep, unit, collision_rate, …]) x.__init__(…) initializes x; see help(type(x)) for signature
apply(thermodynamic_state, sampler_state) Apply the Langevin dynamics MCMC move.
apply(thermodynamic_state, sampler_state)[source]

Apply the Langevin dynamics MCMC move.

This modifies the given sampler_state. The temperature of the thermodynamic state is used in Langevin dynamics.

Parameters:
thermodynamic_state : openmmtools.states.ThermodynamicState

The thermodynamic state to use to propagate dynamics.

sampler_state : openmmtools.states.SamplerState

The sampler state to apply the move to. This is modified.