State

class simtk.openmm.openmm.State(simTime=None, energy=None, coordList=None, velList=None, forceList=None, periodicBoxVectorsList=None, paramMap=None, paramDerivMap=None)

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)

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

Methods

__init__([simTime, energy, coordList, ...])
getEnergyParameterDerivatives() Get a map containing derivatives of the potential energy with respect to context parameters.
getForces([asNumpy]) Get the force acting on each particle with units.
getKineticEnergy() Get the total kinetic energy of the system with units.
getParameters() Get a map containing the values of all parameters.
getPeriodicBoxVectors([asNumpy]) Get the three periodic box vectors if this state is from a simulation using PBC .
getPeriodicBoxVolume() Get the volume of the periodic box.
getPositions([asNumpy]) Get the position of each particle with units.
getPotentialEnergy() Get the total potential energy of the system with units.
getTime() Get the time for which this State was created.
getVelocities([asNumpy]) Get the velocity of each particle with units.
getTime()

Get the time for which this State was created.

getPeriodicBoxVectors(asNumpy=False)

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

getPeriodicBoxVolume()

Get the volume of the periodic box.

getPositions(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

getVelocities(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

getForces(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

getKineticEnergy()

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

getPotentialEnergy()

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

getParameters()

Get a map containing the values of all parameters.

getEnergyParameterDerivatives()

Get a map containing derivatives of the potential energy with respect to context parameters.

In most cases derivatives are only calculated if the corresponding Force objects have been specifically told to compute them. Otherwise, the values in the map will be zero. Likewise, if multiple Forces depend on the same parameter but only some have been told to compute derivatives with respect to it, the returned value will include only the contributions from the Forces that were told to compute it.