State¶
-
class
OpenMM
::
State
¶ 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 aContext
.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 aState
object for a piece of information which is not available (because it was not requested when theState
was created), it will throw an exception.Internal class used to construct new
State
objects.Methods
Construct an empty
State
containing no data.Get the time for which this
State
was created.Get the position of each particle.
Get the velocity of each particle.
Get the force acting on each particle.
Get the total kinetic energy of the system.
Get the total potential energy of the system.
Get the vectors defining the axes of the periodic box (measured in nm).
Get the volume of the periodic box (measured in nm^3).
Get a map containing the values of all parameters.
Get a map containing derivatives of the potential energy with respect to context parameters.
Get which data types are stored in this
State
.Enum: DataType
Positions
Velocities
Forces
Energy
Parameters
ParameterDerivatives
IntegratorParameters
-
State
()¶ Construct an empty
State()
containing no data. This exists soState()
objects can be used in STL containers.
-
const std::vector<Vec3> &
getPositions
() const¶ Get the position of each particle. If this
State
does not contain positions, this will throw an exception.
-
const std::vector<Vec3> &
getVelocities
() const¶ Get the velocity of each particle. If this
State
does not contain velocities, this will throw an exception.
-
const std::vector<Vec3> &
getForces
() const¶ Get the force acting on each particle. If this
State
does not contain forces, this will throw an exception.
-
double
getKineticEnergy
() const¶ 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:cpp:any:Integrator is being used.
-
double
getPotentialEnergy
() const¶ Get the total potential energy of the system. If this
State
does not contain energies, this will throw an exception.
-
void
getPeriodicBoxVectors
(Vec3 &a, Vec3 &b, Vec3 &c) const¶ Get the vectors defining the axes of the periodic box (measured in nm).
- Parameters
a – [out] the vector defining the first edge of the periodic box
b – [out] the vector defining the second edge of the periodic box
c – [out] the vector defining the third edge of the periodic box
-
double
getPeriodicBoxVolume
() const¶ Get the volume of the periodic box (measured in nm^3).
-
const std::map<std::string, double> &
getParameters
() const¶ Get a map containing the values of all parameters. If this
State
does not contain parameters, this will throw an exception.
-
const std::map<std::string, double> &
getEnergyParameterDerivatives
() const¶ 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.
-
int
getDataTypes
() const¶ Get which data types are stored in this
State
. The return value is a sum of DataType flags.
-
StateBuilder
(double time)¶
-
void
setParameters
(const std::map<std::string, double> ¶ms)¶
-
void
setEnergyParameterDerivatives
(const std::map<std::string, double> ¶ms)¶
-
void
setEnergy
(double ke, double pe)¶
-
SerializationNode &
updateIntegratorParameters
()¶
-