Package ffx.openmm

Class Context

java.lang.Object
ffx.openmm.Context
Direct Known Subclasses:
OpenMMContext

public class Context extends Object
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 Details

    • Context

      public Context()
      Constructor.
    • Context

      public Context(System system, Integrator integrator, Platform platform)
      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

      public void updateContext(System system, Integrator integrator, Platform platform)
      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

      public State getState(int types, int enforcePeriodicBox)
      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

      public void setParameter(String name, double value)
      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.