Commit 46c5f78f authored by Jason Swails's avatar Jason Swails
Browse files

Merge branch 'master' of https://github.com/SimTk/openmm

parents d825e6ab c4877bec
......@@ -50,6 +50,8 @@ void OPENMM_EXPORT throwException(const char* file, int line, const std::string&
#define ASSERT_EQUAL(expected, found) {if (!((expected) == (found))) {std::stringstream details; details << "Expected "<<(expected)<<", found "<<(found); throwException(__FILE__, __LINE__, details.str());}};
#define ASSERT_EQUAL_CONTAINERS(expected, found) {if (!((expected) == (found))) {std::stringstream details; details << "Containers not equal"; throwException(__FILE__, __LINE__, details.str());}};
#define ASSERT_EQUAL_TOL(expected, found, tol) {double _scale_ = std::abs(expected) > 1.0 ? std::abs(expected) : 1.0; if (!(std::abs((expected)-(found))/_scale_ <= (tol))) {std::stringstream details; details << "Expected "<<(expected)<<", found "<<(found); throwException(__FILE__, __LINE__, details.str());}};
#define ASSERT_EQUAL_VEC(expected, found, tol) {double _norm_ = std::sqrt((expected).dot(expected)); double _scale_ = _norm_ > 1.0 ? _norm_ : 1.0; if ((std::abs(((expected)[0])-((found)[0]))/_scale_ > (tol)) || (std::abs(((expected)[1])-((found)[1]))/_scale_ > (tol)) || (std::abs(((expected)[2])-((found)[2]))/_scale_ > (tol))) {std::stringstream details; details << " Expected "<<(expected)<<", found "<<(found); throwException(__FILE__, __LINE__, details.str());}};
......
......@@ -152,6 +152,28 @@ public:
* @param value the value to set for the property
*/
SerializationNode& setIntProperty(const std::string& name, int value);
/**
* Get the property with a particular name, specified as an bool. If there is no property with
* the specified name, an exception is thrown.
*
* @param name the name of the property to get
*/
bool getBoolProperty(const std::string& name) const;
/**
* Get the property with a particular name, specified as a bool. If there is no property with
* the specified name, a default value is returned instead.
*
* @param name the name of the property to get
* @param defaultValue the value to return if the specified property does not exist
*/
bool getBoolProperty(const std::string& name, bool defaultValue) const;
/**
* Set the value of a property, specified as a bool.
*
* @param name the name of the property to set
* @param value the value to set for the property
*/
SerializationNode& setBoolProperty(const std::string& name, bool value);
/**
* Get the property with a particular name, specified as a double. If there is no property with
* the specified name, an exception is thrown.
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -47,6 +47,7 @@ void AndersenThermostatProxy::serialize(const void* object, SerializationNode& n
node.setDoubleProperty("temperature", force.getDefaultTemperature());
node.setDoubleProperty("frequency", force.getDefaultCollisionFrequency());
node.setIntProperty("randomSeed", force.getRandomNumberSeed());
node.setIntProperty("forceGroup", force.getForceGroup());
}
void* AndersenThermostatProxy::deserialize(const SerializationNode& node) const {
......@@ -55,6 +56,7 @@ void* AndersenThermostatProxy::deserialize(const SerializationNode& node) const
AndersenThermostat* force = NULL;
try {
AndersenThermostat* force = new AndersenThermostat(node.getDoubleProperty("temperature"), node.getDoubleProperty("frequency"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setRandomNumberSeed(node.getIntProperty("randomSeed"));
return force;
}
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CMAPTorsionForceProxy::CMAPTorsionForceProxy() : SerializationProxy("CMAPTorsion
void CMAPTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CMAPTorsionForce& force = *reinterpret_cast<const CMAPTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& maps = node.createChildNode("Maps");
for (int i = 0; i < force.getNumMaps(); i++) {
int size;
......@@ -66,6 +67,7 @@ void* CMAPTorsionForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number");
CMAPTorsionForce* force = new CMAPTorsionForce();
try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& maps = node.getChildNode("Maps");
for (int i = 0; i < (int) maps.getChildren().size(); i++) {
const SerializationNode& map = maps.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CMMotionRemoverProxy::CMMotionRemoverProxy() : SerializationProxy("CMMotionRemov
void CMMotionRemoverProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CMMotionRemover& force = *reinterpret_cast<const CMMotionRemover*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("frequency", force.getFrequency());
}
......@@ -53,6 +54,7 @@ void* CMMotionRemoverProxy::deserialize(const SerializationNode& node) const {
CMMotionRemover* force = NULL;
try {
CMMotionRemover* force = new CMMotionRemover(node.getIntProperty("frequency"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
return force;
}
catch (...) {
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CustomAngleForceProxy::CustomAngleForceProxy() : SerializationProxy("CustomAngle
void CustomAngleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CustomAngleForce& force = *reinterpret_cast<const CustomAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perAngleParams = node.createChildNode("PerAngleParameters");
for (int i = 0; i < force.getNumPerAngleParameters(); i++) {
......@@ -74,6 +75,7 @@ void* CustomAngleForceProxy::deserialize(const SerializationNode& node) const {
CustomAngleForce* force = NULL;
try {
CustomAngleForce* force = new CustomAngleForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perAngleParams = node.getChildNode("PerAngleParameters");
for (int i = 0; i < (int) perAngleParams.getChildren().size(); i++) {
const SerializationNode& parameter = perAngleParams.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CustomBondForceProxy::CustomBondForceProxy() : SerializationProxy("CustomBondFor
void CustomBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CustomBondForce& force = *reinterpret_cast<const CustomBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perBondParams = node.createChildNode("PerBondParameters");
for (int i = 0; i < force.getNumPerBondParameters(); i++) {
......@@ -74,6 +75,7 @@ void* CustomBondForceProxy::deserialize(const SerializationNode& node) const {
CustomBondForce* force = NULL;
try {
CustomBondForce* force = new CustomBondForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perBondParams = node.getChildNode("PerBondParameters");
for (int i = 0; i < (int) perBondParams.getChildren().size(); i++) {
const SerializationNode& parameter = perBondParams.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010-2012 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CustomCompoundBondForceProxy::CustomCompoundBondForceProxy() : SerializationProx
void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CustomCompoundBondForce& force = *reinterpret_cast<const CustomCompoundBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("particles", force.getNumParticlesPerBond());
node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perBondParams = node.createChildNode("PerBondParameters");
......@@ -84,6 +85,7 @@ void* CustomCompoundBondForceProxy::deserialize(const SerializationNode& node) c
CustomCompoundBondForce* force = NULL;
try {
CustomCompoundBondForce* force = new CustomCompoundBondForce(node.getIntProperty("particles"), node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perBondParams = node.getChildNode("PerBondParameters");
for (int i = 0; i < (int) perBondParams.getChildren().size(); i++) {
const SerializationNode& parameter = perBondParams.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CustomExternalForceProxy::CustomExternalForceProxy() : SerializationProxy("Custo
void CustomExternalForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CustomExternalForce& force = *reinterpret_cast<const CustomExternalForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters");
for (int i = 0; i < force.getNumPerParticleParameters(); i++) {
......@@ -74,6 +75,7 @@ void* CustomExternalForceProxy::deserialize(const SerializationNode& node) const
CustomExternalForce* force = NULL;
try {
CustomExternalForce* force = new CustomExternalForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters");
for (int i = 0; i < (int) perParticleParams.getChildren().size(); i++) {
const SerializationNode& parameter = perParticleParams.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CustomGBForceProxy::CustomGBForceProxy() : SerializationProxy("CustomGBForce") {
void CustomGBForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CustomGBForce& force = *reinterpret_cast<const CustomGBForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance());
SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters");
......@@ -97,6 +98,7 @@ void* CustomGBForceProxy::deserialize(const SerializationNode& node) const {
CustomGBForce* force = NULL;
try {
CustomGBForce* force = new CustomGBForce();
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((CustomGBForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff"));
const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters");
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CustomHbondForceProxy::CustomHbondForceProxy() : SerializationProxy("CustomHbond
void CustomHbondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CustomHbondForce& force = *reinterpret_cast<const CustomHbondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction());
node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance());
......@@ -102,6 +103,7 @@ void* CustomHbondForceProxy::deserialize(const SerializationNode& node) const {
CustomHbondForce* force = NULL;
try {
CustomHbondForce* force = new CustomHbondForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((CustomHbondForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff"));
const SerializationNode& perDonorParams = node.getChildNode("PerDonorParameters");
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,9 +44,13 @@ CustomNonbondedForceProxy::CustomNonbondedForceProxy() : SerializationProxy("Cus
void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CustomNonbondedForce& force = *reinterpret_cast<const CustomNonbondedForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction());
node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance());
node.setBoolProperty("useSwitchingFunction", force.getUseSwitchingFunction());
node.setDoubleProperty("switchingDistance", force.getSwitchingDistance());
node.setBoolProperty("useLongRangeCorrection", force.getUseLongRangeCorrection());
SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters");
for (int i = 0; i < force.getNumPerParticleParameters(); i++) {
perParticleParams.createChildNode("Parameter").setStringProperty("name", force.getPerParticleParameterName(i));
......@@ -76,6 +80,20 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode&
SerializationNode& functions = node.createChildNode("Functions");
for (int i = 0; i < force.getNumTabulatedFunctions(); i++)
functions.createChildNode("Function", &force.getTabulatedFunction(i)).setStringProperty("name", force.getTabulatedFunctionName(i));
SerializationNode& interactionGroups = node.createChildNode("InteractionGroups");
for (int i = 0; i < force.getNumInteractionGroups(); i++) {
SerializationNode& interactionGroup = interactionGroups.createChildNode("InteractionGroup");
std::set<int> set1;
std::set<int> set2;
force.getInteractionGroupParameters(i, set1, set2);
SerializationNode& set1node = interactionGroup.createChildNode("Set1");
for (std::set<int>::iterator it = set1.begin(); it != set1.end(); ++it)
set1node.createChildNode("Particle").setIntProperty("index", *it);
SerializationNode& set2node = interactionGroup.createChildNode("Set2");
for (std::set<int>::iterator it = set2.begin(); it != set2.end(); ++it)
set2node.createChildNode("Particle").setIntProperty("index", *it);
}
}
void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) const {
......@@ -84,8 +102,12 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
CustomNonbondedForce* force = NULL;
try {
CustomNonbondedForce* force = new CustomNonbondedForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((CustomNonbondedForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setUseSwitchingFunction(node.getBoolProperty("useSwitchingFunction", false));
force->setSwitchingDistance(node.getDoubleProperty("switchingDistance", -1.0));
force->setUseLongRangeCorrection(node.getBoolProperty("useLongRangeCorrection", false));
const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters");
for (int i = 0; i < (int) perParticleParams.getChildren().size(); i++) {
const SerializationNode& parameter = perParticleParams.getChildren()[i];
......@@ -129,6 +151,28 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
force->addTabulatedFunction(function.getStringProperty("name"), new Continuous1DFunction(values, function.getDoubleProperty("min"), function.getDoubleProperty("max")));
}
}
bool hasInteractionGroups = false; // Older files will be missing this block.
for (int i = 0; i < (int) node.getChildren().size(); i++) {
if (node.getChildren()[i].getName() == "InteractionGroups")
hasInteractionGroups = true;
}
if (hasInteractionGroups) {
const SerializationNode& interactionGroups = node.getChildNode("InteractionGroups");
for (int i = 0; i < (int) interactionGroups.getChildren().size(); i++) {
const SerializationNode& interactionGroup = interactionGroups.getChildren()[i];
// Get set 1.
const SerializationNode& set1node = interactionGroup.getChildNode("Set1");
std::set<int> set1;
for (int j = 0; j < (int) set1node.getChildren().size(); j++)
set1.insert(set1node.getChildren()[j].getIntProperty("index"));
// Get set 2.
const SerializationNode& set2node = interactionGroup.getChildNode("Set2");
std::set<int> set2;
for (int j = 0; j < (int) set2node.getChildren().size(); j++)
set2.insert(set2node.getChildren()[j].getIntProperty("index"));
force->addInteractionGroup(set1, set2);
}
}
return force;
}
catch (...) {
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ CustomTorsionForceProxy::CustomTorsionForceProxy() : SerializationProxy("CustomT
void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const CustomTorsionForce& force = *reinterpret_cast<const CustomTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perTorsionParams = node.createChildNode("PerTorsionParameters");
for (int i = 0; i < force.getNumPerTorsionParameters(); i++) {
......@@ -74,6 +75,7 @@ void* CustomTorsionForceProxy::deserialize(const SerializationNode& node) const
CustomTorsionForce* force = NULL;
try {
CustomTorsionForce* force = new CustomTorsionForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perTorsionParams = node.getChildNode("PerTorsionParameters");
for (int i = 0; i < (int) perTorsionParams.getChildren().size(); i++) {
const SerializationNode& parameter = perTorsionParams.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ GBSAOBCForceProxy::GBSAOBCForceProxy() : SerializationProxy("GBSAOBCForce") {
void GBSAOBCForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const GBSAOBCForce& force = *reinterpret_cast<const GBSAOBCForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance());
node.setDoubleProperty("soluteDielectric", force.getSoluteDielectric());
......@@ -61,6 +62,7 @@ void* GBSAOBCForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number");
GBSAOBCForce* force = new GBSAOBCForce();
try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((GBSAOBCForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric"));
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ GBVIForceProxy::GBVIForceProxy() : SerializationProxy("GBVIForce") {
void GBVIForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 2);
const GBVIForce& force = *reinterpret_cast<const GBVIForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setIntProperty("scalingMethod", (int) force.getBornRadiusScalingMethod());
node.setDoubleProperty("quinticLowerLimitFactor", force.getQuinticLowerLimitFactor());
......@@ -71,6 +72,7 @@ void* GBVIForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number");
GBVIForce* force = new GBVIForce();
try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((GBVIForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric"));
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ HarmonicAngleForceProxy::HarmonicAngleForceProxy() : SerializationProxy("Harmoni
void HarmonicAngleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const HarmonicAngleForce& force = *reinterpret_cast<const HarmonicAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& bonds = node.createChildNode("Angles");
for (int i = 0; i < force.getNumAngles(); i++) {
int particle1, particle2, particle3;
......@@ -58,6 +59,7 @@ void* HarmonicAngleForceProxy::deserialize(const SerializationNode& node) const
throw OpenMMException("Unsupported version number");
HarmonicAngleForce* force = new HarmonicAngleForce();
try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& angles = node.getChildNode("Angles");
for (int i = 0; i < (int) angles.getChildren().size(); i++) {
const SerializationNode& angle = angles.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ HarmonicBondForceProxy::HarmonicBondForceProxy() : SerializationProxy("HarmonicB
void HarmonicBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const HarmonicBondForce& force = *reinterpret_cast<const HarmonicBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& bonds = node.createChildNode("Bonds");
for (int i = 0; i < force.getNumBonds(); i++) {
int particle1, particle2;
......@@ -58,6 +59,7 @@ void* HarmonicBondForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number");
HarmonicBondForce* force = new HarmonicBondForce();
try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& bonds = node.getChildNode("Bonds");
for (int i = 0; i < (int) bonds.getChildren().size(); i++) {
const SerializationNode& bond = bonds.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ MonteCarloBarostatProxy::MonteCarloBarostatProxy() : SerializationProxy("MonteCa
void MonteCarloBarostatProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const MonteCarloBarostat& force = *reinterpret_cast<const MonteCarloBarostat*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setDoubleProperty("pressure", force.getDefaultPressure());
node.setDoubleProperty("temperature", force.getTemperature());
node.setIntProperty("frequency", force.getFrequency());
......@@ -56,6 +57,7 @@ void* MonteCarloBarostatProxy::deserialize(const SerializationNode& node) const
MonteCarloBarostat* force = NULL;
try {
MonteCarloBarostat* force = new MonteCarloBarostat(node.getDoubleProperty("pressure"), node.getDoubleProperty("temperature"), node.getIntProperty("frequency"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setRandomNumberSeed(node.getIntProperty("randomSeed"));
return force;
}
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,11 +44,22 @@ NonbondedForceProxy::NonbondedForceProxy() : SerializationProxy("NonbondedForce"
void NonbondedForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const NonbondedForce& force = *reinterpret_cast<const NonbondedForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance());
node.setBoolProperty("useSwitchingFunction", force.getUseSwitchingFunction());
node.setDoubleProperty("switchingDistance", force.getSwitchingDistance());
node.setDoubleProperty("ewaldTolerance", force.getEwaldErrorTolerance());
node.setDoubleProperty("rfDielectric", force.getReactionFieldDielectric());
node.setIntProperty("dispersionCorrection", force.getUseDispersionCorrection());
double alpha;
int nx, ny, nz;
force.getPMEParameters(alpha, nx, ny, nz);
node.setDoubleProperty("alpha", alpha);
node.setIntProperty("nx", nx);
node.setIntProperty("ny", ny);
node.setIntProperty("nz", nz);
node.setIntProperty("recipForceGroup", force.getReciprocalSpaceForceGroup());
SerializationNode& particles = node.createChildNode("Particles");
for (int i = 0; i < force.getNumParticles(); i++) {
double charge, sigma, epsilon;
......@@ -69,11 +80,20 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number");
NonbondedForce* force = new NonbondedForce();
try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((NonbondedForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setUseSwitchingFunction(node.getBoolProperty("useSwitchingFunction", false));
force->setSwitchingDistance(node.getDoubleProperty("switchingDistance", -1.0));
force->setEwaldErrorTolerance(node.getDoubleProperty("ewaldTolerance"));
force->setReactionFieldDielectric(node.getDoubleProperty("rfDielectric"));
force->setUseDispersionCorrection(node.getIntProperty("dispersionCorrection"));
double alpha = node.getDoubleProperty("alpha", 0.0);
int nx = node.getIntProperty("nx", 0);
int ny = node.getIntProperty("ny", 0);
int nz = node.getIntProperty("nz", 0);
force->setPMEParameters(alpha, nx, ny, nz);
force->setReciprocalSpaceForceGroup(node.getIntProperty("recipForceGroup", -1));
const SerializationNode& particles = node.getChildNode("Particles");
for (int i = 0; i < (int) particles.getChildren().size(); i++) {
const SerializationNode& particle = particles.getChildren()[i];
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2010 Stanford University and the Authors. *
* Portions copyright (c) 2010-2014 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -44,6 +44,7 @@ PeriodicTorsionForceProxy::PeriodicTorsionForceProxy() : SerializationProxy("Per
void PeriodicTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const PeriodicTorsionForce& force = *reinterpret_cast<const PeriodicTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& torsions = node.createChildNode("Torsions");
for (int i = 0; i < force.getNumTorsions(); i++) {
int particle1, particle2, particle3, particle4, periodicity;
......@@ -58,6 +59,7 @@ void* PeriodicTorsionForceProxy::deserialize(const SerializationNode& node) cons
throw OpenMMException("Unsupported version number");
PeriodicTorsionForce* force = new PeriodicTorsionForce();
try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& torsions = node.getChildNode("Torsions");
for (int i = 0; i < (int) torsions.getChildren().size(); i++) {
const SerializationNode& torsion = torsions.getChildren()[i];
......
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