Commit 9b083022 authored by Peter Eastman's avatar Peter Eastman
Browse files

Added getPeriodicBoxVolume() to State

parent 41bcc20f
...@@ -99,6 +99,10 @@ public: ...@@ -99,6 +99,10 @@ public:
* @param c on exit, this contains the vector defining the third edge of the periodic box * @param c on exit, this contains the vector defining the third edge of the periodic box
*/ */
void getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const; void getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const;
/**
* Get the volume of the periodic box (measured in nm^3).
*/
double getPeriodicBoxVolume() const;
/** /**
* Get a map containing the values of all parameters. If this State does not contain parameters, this will throw an exception. * Get a map containing the values of all parameters. If this State does not contain parameters, this will throw an exception.
*/ */
......
...@@ -68,6 +68,9 @@ void State::getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const { ...@@ -68,6 +68,9 @@ void State::getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) const {
b = periodicBoxVectors[1]; b = periodicBoxVectors[1];
c = periodicBoxVectors[2]; c = periodicBoxVectors[2];
} }
double State::getPeriodicBoxVolume() const {
return periodicBoxVectors[0].dot(periodicBoxVectors[1].cross(periodicBoxVectors[2]));
}
const map<string, double>& State::getParameters() const { const map<string, double>& State::getParameters() const {
if ((types&Parameters) == 0) if ((types&Parameters) == 0)
throw OpenMMException("Invoked getParameters() on a State which does not contain parameters."); throw OpenMMException("Invoked getParameters() on a State which does not contain parameters.");
......
...@@ -10,6 +10,7 @@ RMIN_PER_SIGMA=math.pow(2, 1/6.0) ...@@ -10,6 +10,7 @@ RMIN_PER_SIGMA=math.pow(2, 1/6.0)
RVDW_PER_SIGMA=math.pow(2, 1/6.0)/2.0 RVDW_PER_SIGMA=math.pow(2, 1/6.0)/2.0
import simtk.unit as unit import simtk.unit as unit
from simtk.openmm.vec3 import Vec3
class State(_object): class State(_object):
""" """
...@@ -103,6 +104,14 @@ class State(_object): ...@@ -103,6 +104,14 @@ class State(_object):
returnValue = unit.Quantity(returnValue, unit.nanometers) returnValue = unit.Quantity(returnValue, unit.nanometers)
return returnValue return returnValue
def getPeriodicBoxVolume(self):
"""Get the volume of the periodic box."""
a = self._periodicBoxVectorsList[0]
b = self._periodicBoxVectorsList[1]
c = self._periodicBoxVectorsList[2]
bcrossc = Vec3(b[1]*c[2]-b[2]*c[1], b[2]*c[0]-b[0]*c[2], b[0]*c[1]-b[1]*c[0])
return unit.Quantity(unit.dot(a, bcrossc), unit.nanometers*unit.nanometers*unit.nanometers)
def getPositions(self, asNumpy=False): def getPositions(self, asNumpy=False):
"""Get the position of each particle with units. """Get the position of each particle with units.
Raises an exception if postions where not requested in Raises an exception if postions where not requested in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment