Package ffx.potential.openmm
Class OpenMMContext
java.lang.Object
ffx.openmm.Context
ffx.potential.openmm.OpenMMContext
Creates and manage an OpenMM Context.
A Context stores the complete state of a simulation. More specifically, it includes: The current time The position of each particle The velocity of each particle The values of configurable parameters defined by Force objects in the System
You can retrieve a snapshot of the current state at any time by calling getState(). This allows you to record the state of the simulation at various points, either for analysis or for checkpointing. getState() can also be used to retrieve the current forces on each particle and the current energy of the System.
-
Constructor Summary
ConstructorDescriptionOpenMMContext
(Platform platform, OpenMMSystem openMMSystem, Atom[] atoms) Create an OpenMM Context. -
Method Summary
Modifier and TypeMethodDescriptionvoid
free()
Free OpenMM memory for the current Context and Integrator.getOpenMMState
(int mask) Get an OpenMM State from the Context.void
integrate
(int numSteps) Use the Context / Integrator combination to take the requested number of steps.static Platform
loadPlatform
(Platform requestedPlatform, ForceField forceField) Load an OpenMM Platformvoid
optimize
(double eps, int maxIterations) Use the Context to optimize the system to the requested tolerance.void
setPeriodicBoxVectors
(Crystal crystal) Set the periodic box vectors for a context based on the crystal instance.void
setPositions
(double[] x) The array x contains atomic coordinates only for active atoms.void
setVelocities
(double[] v) The array v contains velocity values for active atomic coordinates.toString()
void
update()
Update the Context if necessary.void
Update the Context in which to run a simulation.Methods inherited from class ffx.openmm.Context
applyConstraints, destroy, getPointer, getState, hasContextPointer, reinitialize, setParameter, setPeriodicBoxVectors, updateContext
-
Constructor Details
-
OpenMMContext
Create an OpenMM Context.- Parameters:
platform
- OpenMM Platform.openMMSystem
- OpenMM System.atoms
- Array of atoms.
-
-
Method Details
-
update
public void update(String integratorName, double timeStep, double temperature, boolean forceCreation) Update the Context in which to run a simulation.- Parameters:
integratorName
- Requested integrator.timeStep
- Time step (psec).temperature
- Temperature (K).forceCreation
- Force creation of a new context, even if the current one matches.
-
update
public void update()Update the Context if necessary. -
getOpenMMState
Get an OpenMM State from the Context.- Parameters:
mask
- A mask specifying which information to retrieve.- Returns:
- State pointer.
-
integrate
public void integrate(int numSteps) Use the Context / Integrator combination to take the requested number of steps.- Parameters:
numSteps
- Number of steps to take.
-
optimize
public void optimize(double eps, int maxIterations) Use the Context to optimize the system to the requested tolerance.- Parameters:
eps
- Convergence criteria (kcal/mole/A).maxIterations
- Maximum number of iterations.
-
setPositions
public void setPositions(double[] x) The array x contains atomic coordinates only for active atoms.- Overrides:
setPositions
in classContext
- Parameters:
x
- Atomic coordinate array for only active atoms.
-
setVelocities
public void setVelocities(double[] v) The array v contains velocity values for active atomic coordinates.- Overrides:
setVelocities
in classContext
- Parameters:
v
- Velocity array for active atoms.
-
setPeriodicBoxVectors
Set the periodic box vectors for a context based on the crystal instance.- Parameters:
crystal
- The crystal instance.
-
toString
-
loadPlatform
Load an OpenMM Platform- Parameters:
requestedPlatform
- the requested OpenMM platform.forceField
- the ForceField to query for platform flags.- Returns:
- the loaded Platform.
-
free
public void free()Free OpenMM memory for the current Context and Integrator.
-