State

class simtk.openmm.openmm.State(*args)

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 throw an exception.

__init__(self) → State

__init__(self, other) -> State

Construct an empty State containing no data. This exists so State objects can be used in STL containers.

Methods

__init__((self) -> State) __init__(self, other) -> State
getDataTypes((self) -> int) Get which data types are stored in this State.
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((self) -> double) Get the total kinetic energy of the system.
getParameters((self) -> mapstringdouble) Get a map containing the values of all parameters.
getPeriodicBoxVectors([asNumpy]) Get the vectors defining the axes of the periodic box.
getPeriodicBoxVolume((self) -> double) Get the volume of the periodic box (measured in nm^3).
getPositions([asNumpy]) Get the position of each particle with units.
getPotentialEnergy((self) -> double) Get the total potential energy of the system.
getTime((self) -> double) Get the time for which this State was created.
getVelocities([asNumpy]) Get the velocity of each particle with units.

Attributes

Energy
Forces
ParameterDerivatives
Parameters
Positions
Velocities
getTime(self) → double

Get the time for which this State was created.

getKineticEnergy(self) → double

Get the total kinetic energy of the system. If this State does not contain energies, this will throw an exception.

Note that this may be different from simply mv/2 summed over all particles. For example, a leapfrog integrator will store velocities offset by half a step, so they must be adjusted before computing the kinetic energy. This routine returns the kinetic energy at the current time, computed in a way that is appropriate for whatever Integrator is being used.

getPotentialEnergy(self) → double

Get the total potential energy of the system. If this State does not contain energies, this will throw an exception.

getPeriodicBoxVolume(self) → double

Get the volume of the periodic box (measured in nm^3).

getParameters(self) → mapstringdouble

Get a map containing the values of all parameters. If this State does not contain parameters, this will throw an exception.

getEnergyParameterDerivatives(self) → mapstringdouble

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.

If this State does not contain parameter derivatives, this will throw an exception.

getDataTypes(self) → int

Get which data types are stored in this State. The return value is a sum of DataType flags.

getPeriodicBoxVectors(asNumpy=False)

Get the vectors defining the axes of the periodic box.

getPositions(asNumpy=False)

Get the position of each particle with units. Raises an exception if positions where not requested in the context.getState() call. Returns a list of Vec3s, unless asNumpy is True, in which case a Numpy array of arrays will be returned.

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 Vec3s if asNumpy is False, or a Numpy array if asNumpy is True.

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 Vec3s if asNumpy is False, or a Numpy array if asNumpy is True.

__copy__(self) → State
__delattr__

x.__delattr__(‘name’) <==> del x.name

__format__()

default object formatter

__getattribute__

x.__getattribute__(‘name’) <==> x.name

__hash__
__reduce__()

helper for pickle

__reduce_ex__()

helper for pickle

__sizeof__() → int

size of object in memory, in bytes

__str__