State

class 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__(-> State)

Construct an empty State containing no data.

getDataTypes(self)

Get which data types are stored in this State.

getEnergyParameterDerivatives(self)

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)

Get the total kinetic energy of the system.

getParameters(self)

Get a map containing the values of all parameters.

getPeriodicBoxVectors([asNumpy])

Get the vectors defining the axes of the periodic box.

getPeriodicBoxVolume(self)

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

getPositions([asNumpy])

Get the position of each particle with units.

getPotentialEnergy(self)

Get the total potential energy of the system.

getStepCount(self)

Get the number of integration steps that had been performed when this State was created.

getTime(self)

Get the time for which this State was created.

getVelocities([asNumpy])

Get the velocity of each particle with units.

Attributes

Energy

Forces

IntegratorParameters

ParameterDerivatives

Parameters

Positions

Velocities

thisown

The membership flag

property thisown

The membership flag

getTime(self)double

Get the time for which this State was created.

getStepCount(self)long long

Get the number of integration steps that had been performed when 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 mv2/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