A Context stores the complete state of a simulation. More...
Inherits simtk::openmm::openmm::_object.
Public Member Functions | |
def | __del__ |
__del__(self) | |
def | getSystem |
getSystem(self) -> System getSystem(self) -> System | |
def | getIntegrator |
getIntegrator(self) -> Integrator getIntegrator(self) -> Integrator | |
def | getPlatform |
getPlatform(self) -> Platform getPlatform(self) -> Platform | |
def | setTime |
setTime(self, double time) | |
def | setPositions |
setPositions(self, positions) | |
def | setVelocities |
setVelocities(self, velocities) | |
def | getParameter |
getParameter(self, string name) -> double | |
def | setParameter |
setParameter(self, string name, double value) | |
def | setPeriodicBoxVectors |
setPeriodicBoxVectors(self, Vec3 a, Vec3 b, Vec3 c) | |
def | applyConstraints |
applyConstraints(self, double tol) | |
def | computeVirtualSites |
computeVirtualSites(self) | |
def | reinitialize |
reinitialize(self) | |
def | getState |
getState(self, getPositions = False, getVelocities = False, getForces = False, getEnergy = False, getParameters = False, enforcePeriodicBox = False, groups = -1) -> State Get a State object recording the current state information stored in this context. | |
def | __init__ |
__init__(self, System system, Integrator integrator) -> Context __init__(self, System system, Integrator integrator, Platform platform) -> Context __init__(self, System system, Integrator integrator, Platform platform, mapstringstring properties) -> Context __init__(self, Context other) -> Context | |
Public Attributes | |
this |
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.
def __del__ | ( | self | ) |
__del__(self)
def __init__ | ( | self, | ||
args | ||||
) |
__init__(self, System system, Integrator integrator) -> Context __init__(self, System system, Integrator integrator, Platform platform) -> Context __init__(self, System system, Integrator integrator, Platform platform, mapstringstring properties) -> Context __init__(self, Context other) -> Context
Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used to perform calculations and the values of platform-specific properties.
system | the System which will be simulated | |
integrator | the Integrator which will be used to simulate the System | |
platform | the Platform to use for calculations | |
properties | a set of values for platform-specific properties. Keys are the property names. |
def applyConstraints | ( | self, | ||
args | ||||
) |
applyConstraints(self, double tol)
Update the positions of particles so that all distance constraints are satisfied. This also recomputes the locations of all virtual sites.
tol | the distance tolerance within which constraints must be satisfied. |
def computeVirtualSites | ( | self | ) |
computeVirtualSites(self)
Recompute the locations of all virtual sites. There is rarely a reason to call this, since virtual sites are also updated by applyConstraints(). This is only for the rare situations when you want to enforce virtual sites but not constraints.
def getIntegrator | ( | self, | ||
args | ||||
) |
getIntegrator(self) -> Integrator getIntegrator(self) -> Integrator
Get Integrator being used to by this context.
def getParameter | ( | self, | ||
args | ||||
) |
def getPlatform | ( | self, | ||
args | ||||
) |
def getState | ( | self, | ||
getPositions = False , |
||||
getVelocities = False , |
||||
getForces = False , |
||||
getEnergy = False , |
||||
getParameters = False , |
||||
enforcePeriodicBox = False , |
||||
groups = -1 | ||||
) |
getState(self, getPositions = False, getVelocities = False, getForces = False, getEnergy = False, getParameters = False, enforcePeriodicBox = False, groups = -1) -> State Get a State object recording the current state information stored in this context.
getPositions -- whether to store particle positions in the State getVelocities -- whether to store particle velocities in the State getForces -- whether to store the forces acting on particles in the State getEnergy -- whether to store potential and kinetic energy in the State getParameter -- whether to store context parameters in the State enforcePeriodicBox -- if false, the position of each particle will be whatever position is stored in the Context, regardless of periodic boundary conditions. If true, particle positions will be translated so the center of every molecule lies in the same periodic box. groups -- a set of bit flags for which force groups to include when computing forces and energies. Group i will be included if (groups&(1<<i)) != 0. The default value includes all groups.
def getSystem | ( | self, | ||
args | ||||
) |
def reinitialize | ( | self | ) |
reinitialize(self)
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 of the 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.
def setParameter | ( | self, | ||
args | ||||
) |
def setPeriodicBoxVectors | ( | self, | ||
args | ||||
) |
setPeriodicBoxVectors(self, Vec3 a, Vec3 b, Vec3 c)
Set the vectors defining the axes of the periodic box (measured in nm). They will affect any Force that uses periodic boundary conditions.
Currently, only rectangular boxes are supported. This means that a, b, and c must be aligned with the x, y, and z axes respectively. Future releases may support arbitrary triclinic boxes.
a | the vector defining the first edge of the periodic box | |
b | the vector defining the second edge of the periodic box | |
c | the vector defining the third edge of the periodic box |
def setPositions | ( | self, | ||
args | ||||
) |
setPositions(self, positions)
Set the positions of all particles in the System (measured in nm). This method simply sets the positions without checking to see whether they satisfy distance constraints. If you want constraints to be enforced, call applyConstraints() after setting the positions.
positions | a vector whose length equals the number of particles in the System. The i'th element contains the position of the i'th particle. |
def setTime | ( | self, | ||
args | ||||
) |
setTime(self, double time)
Set the current time of the simulation (in picoseconds).
def setVelocities | ( | self, | ||
args | ||||
) |