OpenMM
 All Classes Namespaces Functions Variables Pages
State Class Reference

A State object records a snapshot of the current state of a simulation at a point in time. More...

Inherits _object.

Public Member Functions

def __init__
 
def __getstate__
 
def __setstate__
 
def getTime
 Get the time for which this State was created. More...
 
def getPeriodicBoxVectors
 Get the three periodic box vectors if this state is from a simulation using PBC . More...
 
def getPeriodicBoxVolume
 Get the volume of the periodic box. More...
 
def getPositions
 Get the position of each particle with units. More...
 
def getVelocities
 Get the velocity of each particle with units. More...
 
def getForces
 Get the force acting on each particle with units. More...
 
def getKineticEnergy
 Get the total kinetic energy of the system with units. More...
 
def getPotentialEnergy
 Get the total potential energy of the system with units. More...
 
def getParameters
 Get a map containing the values of all parameters. More...
 

Detailed Description

A State object records a snapshot of the current state of a simulation at a point in time.

You create it by calling getState() on a Context.

When a State is created, you specify what information should be stored in it. This saves time and memory by only copying in the information that you actually want. This is especially important for forces and energies, since they may need to be calculated. If you query a State object for a piece of information which is not available (because it was not requested when the State was created), it will return None.

In general return values are Python Units (https://simtk.org/home/python_units). Among other things Python Units provides a container class, Quantity, which holds a value and a representation of the value's unit. Values can be integers, floats, lists, numarrays, etc. Quantity objects can be used in arithmetic operation just like number, except they also keep track of units. To extract the value from a quantity, us the value_in_unit() method. For example, to extract the value from a length quantity, in units of nanometers, do the following: myLengthQuantity.value_in_unit(unit.nanometer)

Constructor & Destructor Documentation

def __init__ (   self,
  simTime = None,
  energy = None,
  coordList = None,
  velList = None,
  forceList = None,
  periodicBoxVectorsList = None,
  paramMap = None 
)

References State._coordList, State._coordListNumpy, State._eK0, State._eP0, State._forceList, State._forceListNumpy, State._paramMap, State._periodicBoxVectorsList, State._periodicBoxVectorsListNumpy, State._simTime, State._velList, and State._velListNumpy.

Member Function Documentation

def __getstate__ (   self)
def __setstate__ (   self,
  serializationString 
)
def getForces (   self,
  asNumpy = False 
)

Get the force acting on each particle with units.

Raises an exception if forces where not requested in the context.getState() call. Returns a list of tuples, unless asNumpy is True, in which case a Numpy array of arrays will be returned. To remove the units, you can divide the return value by unit.kilojoule_per_mole/unit.angstrom or unit.calorie_per_mole/unit.nanometer, etc. See the following for details: https://simtk.org/home/python_units

References State._forceList, and State._forceListNumpy.

def getKineticEnergy (   self)

Get the total kinetic energy of the system with units.

To remove the units, you can divide the return value by unit.kilojoule_per_mole or unit.calorie_per_mole, etc. See the following for details: https://simtk.org/home/python_units

References State._eK0.

def getParameters (   self)

Get a map containing the values of all parameters.

References State._paramMap.

def getPeriodicBoxVectors (   self,
  asNumpy = False 
)

Get the three periodic box vectors if this state is from a simulation using PBC .

References State._periodicBoxVectorsList, and State._periodicBoxVectorsListNumpy.

def getPeriodicBoxVolume (   self)

Get the volume of the periodic box.

References State._periodicBoxVectorsList.

def getPositions (   self,
  asNumpy = False 
)

Get the position of each particle with units.

Raises an exception if postions where not requested in the context.getState() call. Returns a list of tuples, unless asNumpy is True, in which case a Numpy array of arrays will be returned. To remove the units, divide return value by unit.angstrom or unit.nanometer. See the following for details: https://simtk.org/home/python_units

References State._coordList, and State._coordListNumpy.

def getPotentialEnergy (   self)

Get the total potential energy of the system with units.

To remove the units, you can divide the return value by unit.kilojoule_per_mole or unit.kilocalorie_per_mole, etc. See the following for details: https://simtk.org/home/python_units

References State._eP0.

def getTime (   self)

Get the time for which this State was created.

References State._simTime.

def getVelocities (   self,
  asNumpy = False 
)

Get the velocity of each particle with units.

Raises an exception if velocities where not requested in the context.getState() call. Returns a list of tuples, unless asNumpy is True, in which case a Numpy array of arrays will be returned. To remove the units, you can divide the return value by unit.angstrom/unit.picosecond or unit.meter/unit.second, etc. See the following for details: https://simtk.org/home/python_units

References State._velList, and State._velListNumpy.


The documentation for this class was generated from the following file: