Package ffx.openmm
Class Context
java.lang.Object
ffx.openmm.Context
- Direct Known Subclasses:
OpenMMContext
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
-
Constructor Summary
ConstructorDescriptionContext()
Constructor.Context
(System system, Integrator integrator, Platform platform) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyConstraints
(double tol) Apply constraints to the current positions.void
destroy()
Destroy the context.com.sun.jna.ptr.PointerByReference
Get the pointer to the context.getState
(int types, int enforcePeriodicBox) Get the state of the context.boolean
Does the context have a pointer?void
reinitialize
(int preserveState) Reinitialize the context.void
setParameter
(String name, double value) Set a parameter value.void
setPeriodicBoxVectors
(edu.uiowa.jopenmm.OpenMM_Vec3 a, edu.uiowa.jopenmm.OpenMM_Vec3 b, edu.uiowa.jopenmm.OpenMM_Vec3 c) Set the periodic box vectors.void
setPositions
(double[] positions) Set the atomic positions.void
setVelocities
(double[] velocities) Set the atomic velocities.void
updateContext
(System system, Integrator integrator, Platform platform) Update the context.
-
Constructor Details
-
Context
public Context()Constructor. -
Context
Constructor.- Parameters:
system
- The system to simulate.integrator
- The integrator to use for simulating the system.platform
- The platform to use for performing computations.
-
-
Method Details
-
updateContext
Update the context.- Parameters:
system
- The system to simulate.integrator
- The integrator to use for simulating the system.platform
- The platform to use for performing computations.
-
getPointer
public com.sun.jna.ptr.PointerByReference getPointer()Get the pointer to the context.- Returns:
- The pointer to the context.
-
hasContextPointer
public boolean hasContextPointer()Does the context have a pointer?- Returns:
- True if the context pointer is not null.
-
getState
Get the state of the context.- Parameters:
types
- The bit-flag of properties to include in the state.enforcePeriodicBox
- If true, the positions will be adjusted so atoms are inside the main periodic box.- Returns:
- The state of the context.
-
reinitialize
public void reinitialize(int preserveState) Reinitialize the context.When a Context is created, it may cache information about the System being simulated and the Force objects contained in it. This means that, if the System or Forces are then modified, the Context might not see all changes. Call reinitialize() to force the Context to rebuild its internal representation of the System and pick up any changes that have been made.
This is an expensive operation, so you should try to avoid calling it too frequently.
- Parameters:
preserveState
- If true, the state will be restored to the same state it had before the call.
-
setParameter
Set a parameter value.- Parameters:
name
- The name of the parameter.value
- The value of the parameter.
-
setPeriodicBoxVectors
public void setPeriodicBoxVectors(edu.uiowa.jopenmm.OpenMM_Vec3 a, edu.uiowa.jopenmm.OpenMM_Vec3 b, edu.uiowa.jopenmm.OpenMM_Vec3 c) Set the periodic box vectors.- Parameters:
a
- The first vector.b
- The second vector.c
- The third vector.
-
setPositions
public void setPositions(double[] positions) Set the atomic positions.- Parameters:
positions
- The atomic positions.
-
setVelocities
public void setVelocities(double[] velocities) Set the atomic velocities.- Parameters:
velocities
- The atomic velocities.
-
applyConstraints
public void applyConstraints(double tol) Apply constraints to the current positions.- Parameters:
tol
- The constraint tolerance.
-
destroy
public void destroy()Destroy the context.
-