openmmtools.mcmc.LangevinSplittingDynamicsMove¶
-
class
openmmtools.mcmc.LangevinSplittingDynamicsMove(timestep=Quantity(value=1.0, unit=femtosecond), collision_rate=Quantity(value=10.0, unit=/picosecond), n_steps=1000, reassign_velocities=False, splitting='V R O R V', constraint_tolerance=1e-08, measure_shadow_work=False, measure_heat=False, **kwargs)[source]¶ Langevin dynamics segment with custom splitting of the operators and optional Metropolized Monte Carlo validation.
Besides all the normal properties of the
LangevinDynamicsMove, this class implements the custom splitting sequence of theopenmmtools.integrators.LangevinIntegrator. Additionally, the steps can be wrapped around a proper Generalized Hybrid Monte Carlo step to ensure that the exact distribution is generated.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).
- splitting : string, default: “V R O R V”
Sequence of “R”, “V”, “O” (and optionally “{“, “}”, “V0”, “V1”, …) substeps to be executed each timestep.
Forces are only used in V-step. Handle multiple force groups by appending the force group index to V-steps, e.g. “V0” will only use forces from force group 0. “V” will perform a step using all forces. “{” will cause metropolization, and must be followed later by a “}”.
- constraint_tolerance : float, default: 1.0e-8
Tolerance for constraint solver
- measure_shadow_work : boolean, default: False
Accumulate the shadow work performed by the symplectic substeps, in the global shadow_work
- measure_heat : boolean, default: False
Accumulate the heat exchanged with the bath in each step, in the global heat
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 = LangevinSplittingDynamicsMove()
or create a Langevin move with specified splitting.
>>> move = LangevinSplittingDynamicsMove(splitting="O { V R V } O")
Where this splitting is a 5 step symplectic integrator:
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.
- splitting : str
Splitting applied to this integrator represented as a string.
- constraint_tolerance : float, default: 1.0e-8
Tolerance for constraint solver
- measure_shadow_work : boolean, default: False
Accumulate the shadow work performed by the symplectic substeps, in the global shadow_work
- measure_heat : boolean, default: False
Accumulate the heat exchanged with the bath in each step, in the global heat
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, splitting='V R O R V', constraint_tolerance=1e-08, measure_shadow_work=False, measure_heat=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)¶ 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.