CSVRIntegrator¶
- class openxps.integrators.CSVRIntegrator(temperature, frictionCoeff, stepSize, forceFirst=False)[source]¶
The Canonical Sampling through Velocity Rescaling integrator [1].
The Canonical Sampling through Velocity Rescaling (CSVR) thermostat scales all velocities by a single factor stochastically determined in order to preserve the canonical distribution at the specified temperature.
Warning
When used outside OpenXPS, the
registerWithSystem()method must be called with isExtension=False before starting a simulation.Note
A system with zero kinetic energy is left at rest. Initialize the velocities before starting a simulation.
- Parameters:
temperature (Quantity) – The temperature.
frictionCoeff (Quantity) – The friction coefficient.
stepSize (Quantity) – The integration step size.
forceFirst (bool) – If True, the integrator will apply a force-first scheme rather than a symmetric operator splitting scheme.
Example
>>> import openxps as xps >>> import openmm as mm >>> from openmm import unit >>> from openmmtools import testsystems
Symmetric scheme (default)
>>> integrator = xps.integrators.CSVRIntegrator( ... temperature=300 * unit.kelvin, ... frictionCoeff=10 / unit.picosecond, ... stepSize=2 * unit.femtoseconds, ... ) >>> integrator Per-dof variables: x1 Global variables: sumRsq = 0.0 mvv = 0.0 kT = 2.49433... friction = 10.0 scaling_factor = 1.0 Computation steps: 0: allow forces to update the context state 1: v <- v + 0.5*dt*f/m 2: constrain velocities 3: x <- x + 0.5*dt*v 4: x1 <- x 5: constrain positions 6: v <- v + (x - x1)/(0.5*dt) 7: constrain velocities 8: mvv <- sum(m*v*v) 9: scaling_factor <- select(mvv, sqrt(A + BC*(R1^2 + ...), 1); R1 = ... 10: v <- v*scaling_factor 11: x <- x + 0.5*dt*v 12: x1 <- x 13: constrain positions 14: v <- v + (x - x1)/(0.5*dt) 15: constrain velocities 16: v <- v + 0.5*dt*f/m 17: constrain velocities
Force-first scheme
>>> integrator_ff = xps.integrators.CSVRIntegrator( ... temperature=300 * unit.kelvin, ... frictionCoeff=10 / unit.picosecond, ... stepSize=2 * unit.femtoseconds, ... forceFirst=True ... ) >>> try: ... integrator_ff.getNumDegreesOfFreedom() ... except ValueError as e: ... print(e) The number of degrees of freedom has not been determined... >>> model = testsystems.AlanineDipeptideVacuum() >>> integrator_ff.registerWithSystem(model.system, False) >>> integrator_ff.getNumDegreesOfFreedom() 51 >>> integrator_ff.setRandomNumberSeed(1234) >>> platform = mm.Platform.getPlatformByName("Reference") >>> context = mm.Context(model.system, integrator_ff, platform) >>> context.setPositions(model.positions) >>> context.setVelocitiesToTemperature(300 * unit.kelvin, 4321) >>> integrator_ff.step(10)
Methods
- getFrictionCoefficient()¶
Get the friction coefficient.
- Returns:
The friction coefficient.
- Return type:
openmm.unit.Quantity
- getNumDegreesOfFreedom()[source]¶
Get the number of degrees of freedom in the system.
- Raises:
ValueError – If registerWithSystem has not been called first.
- Return type:
int
- getTemperature()¶
Get the temperature.
- Returns:
The temperature.
- Return type:
openmm.unit.Quantity
- setFrictionCoefficient(value)¶
Set the friction coefficient.
- Parameters:
value (Quantity | float) – The friction coefficient.
- setRandomNumberSeed(seed)[source]¶
This method overrides the
openmm.CustomIntegratormethod to also seed the generator used to draw the sum of squared Gaussian variates. As in OpenMM, a seed of 0 selects a random, non-reproducible seed.Note
The state of this generator is not stored in context checkpoints.
- Parameters:
seed (int) – The seed to use for the random number generators.
- setTemperature(value)¶
Set the temperature.
- Parameters:
value (Quantity | float) – The temperature.