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 platform, OpenMMSystem openMMSystem, Atom[] atoms)
      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

      public OpenMMState getOpenMMState(int mask)
      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 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
    • loadPlatform

      public static Platform loadPlatform(Platform requestedPlatform, ForceField forceField)
      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.