OpenMM
|
A State object records a snapshot of the current state of a simulation at a point in time. More...
#include <State.h>
Public Types | |
enum | DataType { Positions =1, Velocities =2, Forces =4, Energy =8, Parameters =16 } |
This is an enumeration of the types of data which may be stored in a State. More... | |
Public Member Functions | |
State () | |
Construct an empty State containing no data. More... | |
double | getTime () const |
Get the time for which this State was created. More... | |
const std::vector< Vec3 > & | getPositions () const |
Get the position of each particle. More... | |
const std::vector< Vec3 > & | getVelocities () const |
Get the velocity of each particle. More... | |
const std::vector< Vec3 > & | getForces () const |
Get the force acting on each particle. More... | |
double | getKineticEnergy () const |
Get the total kinetic energy of the system. More... | |
double | getPotentialEnergy () const |
Get the total potential energy of the system. More... | |
void | getPeriodicBoxVectors (Vec3 &a, Vec3 &b, Vec3 &c) const |
Get the vectors defining the axes of the periodic box (measured in nm). More... | |
double | getPeriodicBoxVolume () const |
Get the volume of the periodic box (measured in nm^3). More... | |
const std::map< std::string, double > & | getParameters () const |
Get a map containing the values of all parameters. More... | |
StateBuilder (double time) | |
State | getState () |
void | setPositions (const std::vector< Vec3 > &pos) |
void | setVelocities (const std::vector< Vec3 > &vel) |
void | setForces (const std::vector< Vec3 > &force) |
void | setParameters (const std::map< std::string, double > ¶ms) |
void | setEnergy (double ke, double pe) |
void | setPeriodicBoxVectors (const Vec3 &a, const Vec3 &b, const Vec3 &c) |
A State object records a snapshot of the current state of a simulation at a point in time.
Internal class used to construct new State objects.
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.
enum DataType |
State | ( | ) |
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 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.
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.
Get the vectors defining the axes of the periodic box (measured in nm).
a | on exit, this contains the vector defining the first edge of the periodic box |
b | on exit, this contains the vector defining the second edge of the periodic box |
c | on exit, this contains 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::vector<Vec3>& getPositions | ( | ) | const |
Get the position of each particle.
If this State does not contain positions, this will throw an exception.
double getPotentialEnergy | ( | ) | const |
Get the total potential energy of the system.
If this State does not contain energies, this will throw an exception.
State getState | ( | ) |
double getTime | ( | ) | const |
Get the time for which this State was created.
const std::vector<Vec3>& getVelocities | ( | ) | const |
Get the velocity of each particle.
If this State does not contain velocities, this will throw an exception.
void setEnergy | ( | double | ke, |
double | pe | ||
) |
void setForces | ( | const std::vector< Vec3 > & | force | ) |
void setParameters | ( | const std::map< std::string, double > & | params | ) |
void setPositions | ( | const std::vector< Vec3 > & | pos | ) |
void setVelocities | ( | const std::vector< Vec3 > & | vel | ) |
StateBuilder | ( | double | time | ) |