Class OpenMMContext

java.lang.Object
ffx.openmm.Context
ffx.potential.openmm.OpenMMContext

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

    • OpenMMContext

      public OpenMMContext(Platform requestedPlatform, Atom[] atoms, int enforcePBC, OpenMMEnergy openMMEnergy)
      Create an OpenMM Context.
      Parameters:
      requestedPlatform - Platform requested.
      atoms - Array of atoms.
      enforcePBC - Enforce periodic boundary conditions.
      openMMEnergy - ForceFieldEnergyOpenMM instance.
  • Method Details

    • update

      public void update(String integratorName, double timeStep, double temperature, boolean forceCreation, OpenMMEnergy openMMEnergy)
      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.
      openMMEnergy - ForceFieldEnergyOpenMM instance.
    • update

      public void update()
      Update the Context if necessary.
    • getOpenMMState

      public OpenMMState getOpenMMState(int mask)
      Get an OpenMM State from the Context.
      Parameters:
      mask - A mask specifying which information to retrieve.
      Returns:
      State pointer.
    • getPlatform

      public Platform getPlatform()
    • 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 class Context
      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 class Context
      Parameters:
      v - Velocity array for active atoms.
    • setPeriodicBoxVectors

      public void setPeriodicBoxVectors(Crystal crystal)
      Set the periodic box vectors for a context based on the crystal instance.
      Parameters:
      crystal - The crystal instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • free

      public void free()
      Free OpenMM memory for the current Context and Integrator.