Commit 51828eaa authored by Peter Eastman's avatar Peter Eastman
Browse files

Merge branch 'master' into qc

parents cf8a03e8 5ed9dd65
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ CMMotionRemoverProxy::CMMotionRemoverProxy() : SerializationProxy("CMMotionRemov ...@@ -44,6 +44,7 @@ CMMotionRemoverProxy::CMMotionRemoverProxy() : SerializationProxy("CMMotionRemov
void CMMotionRemoverProxy::serialize(const void* object, SerializationNode& node) const { void CMMotionRemoverProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CMMotionRemover& force = *reinterpret_cast<const CMMotionRemover*>(object); const CMMotionRemover& force = *reinterpret_cast<const CMMotionRemover*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("frequency", force.getFrequency()); node.setIntProperty("frequency", force.getFrequency());
} }
...@@ -53,6 +54,7 @@ void* CMMotionRemoverProxy::deserialize(const SerializationNode& node) const { ...@@ -53,6 +54,7 @@ void* CMMotionRemoverProxy::deserialize(const SerializationNode& node) const {
CMMotionRemover* force = NULL; CMMotionRemover* force = NULL;
try { try {
CMMotionRemover* force = new CMMotionRemover(node.getIntProperty("frequency")); CMMotionRemover* force = new CMMotionRemover(node.getIntProperty("frequency"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
return force; return force;
} }
catch (...) { catch (...) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ CustomAngleForceProxy::CustomAngleForceProxy() : SerializationProxy("CustomAngle ...@@ -44,6 +44,7 @@ CustomAngleForceProxy::CustomAngleForceProxy() : SerializationProxy("CustomAngle
void CustomAngleForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomAngleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CustomAngleForce& force = *reinterpret_cast<const CustomAngleForce*>(object); const CustomAngleForce& force = *reinterpret_cast<const CustomAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction()); node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perAngleParams = node.createChildNode("PerAngleParameters"); SerializationNode& perAngleParams = node.createChildNode("PerAngleParameters");
for (int i = 0; i < force.getNumPerAngleParameters(); i++) { for (int i = 0; i < force.getNumPerAngleParameters(); i++) {
...@@ -74,6 +75,7 @@ void* CustomAngleForceProxy::deserialize(const SerializationNode& node) const { ...@@ -74,6 +75,7 @@ void* CustomAngleForceProxy::deserialize(const SerializationNode& node) const {
CustomAngleForce* force = NULL; CustomAngleForce* force = NULL;
try { try {
CustomAngleForce* force = new CustomAngleForce(node.getStringProperty("energy")); CustomAngleForce* force = new CustomAngleForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perAngleParams = node.getChildNode("PerAngleParameters"); const SerializationNode& perAngleParams = node.getChildNode("PerAngleParameters");
for (int i = 0; i < (int) perAngleParams.getChildren().size(); i++) { for (int i = 0; i < (int) perAngleParams.getChildren().size(); i++) {
const SerializationNode& parameter = perAngleParams.getChildren()[i]; const SerializationNode& parameter = perAngleParams.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ CustomBondForceProxy::CustomBondForceProxy() : SerializationProxy("CustomBondFor ...@@ -44,6 +44,7 @@ CustomBondForceProxy::CustomBondForceProxy() : SerializationProxy("CustomBondFor
void CustomBondForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CustomBondForce& force = *reinterpret_cast<const CustomBondForce*>(object); const CustomBondForce& force = *reinterpret_cast<const CustomBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction()); node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perBondParams = node.createChildNode("PerBondParameters"); SerializationNode& perBondParams = node.createChildNode("PerBondParameters");
for (int i = 0; i < force.getNumPerBondParameters(); i++) { for (int i = 0; i < force.getNumPerBondParameters(); i++) {
...@@ -74,6 +75,7 @@ void* CustomBondForceProxy::deserialize(const SerializationNode& node) const { ...@@ -74,6 +75,7 @@ void* CustomBondForceProxy::deserialize(const SerializationNode& node) const {
CustomBondForce* force = NULL; CustomBondForce* force = NULL;
try { try {
CustomBondForce* force = new CustomBondForce(node.getStringProperty("energy")); CustomBondForce* force = new CustomBondForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perBondParams = node.getChildNode("PerBondParameters"); const SerializationNode& perBondParams = node.getChildNode("PerBondParameters");
for (int i = 0; i < (int) perBondParams.getChildren().size(); i++) { for (int i = 0; i < (int) perBondParams.getChildren().size(); i++) {
const SerializationNode& parameter = perBondParams.getChildren()[i]; const SerializationNode& parameter = perBondParams.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ CustomCompoundBondForceProxy::CustomCompoundBondForceProxy() : SerializationProx ...@@ -44,6 +44,7 @@ CustomCompoundBondForceProxy::CustomCompoundBondForceProxy() : SerializationProx
void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CustomCompoundBondForce& force = *reinterpret_cast<const CustomCompoundBondForce*>(object); const CustomCompoundBondForce& force = *reinterpret_cast<const CustomCompoundBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("particles", force.getNumParticlesPerBond()); node.setIntProperty("particles", force.getNumParticlesPerBond());
node.setStringProperty("energy", force.getEnergyFunction()); node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perBondParams = node.createChildNode("PerBondParameters"); SerializationNode& perBondParams = node.createChildNode("PerBondParameters");
...@@ -84,6 +85,7 @@ void* CustomCompoundBondForceProxy::deserialize(const SerializationNode& node) c ...@@ -84,6 +85,7 @@ void* CustomCompoundBondForceProxy::deserialize(const SerializationNode& node) c
CustomCompoundBondForce* force = NULL; CustomCompoundBondForce* force = NULL;
try { try {
CustomCompoundBondForce* force = new CustomCompoundBondForce(node.getIntProperty("particles"), node.getStringProperty("energy")); CustomCompoundBondForce* force = new CustomCompoundBondForce(node.getIntProperty("particles"), node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perBondParams = node.getChildNode("PerBondParameters"); const SerializationNode& perBondParams = node.getChildNode("PerBondParameters");
for (int i = 0; i < (int) perBondParams.getChildren().size(); i++) { for (int i = 0; i < (int) perBondParams.getChildren().size(); i++) {
const SerializationNode& parameter = perBondParams.getChildren()[i]; const SerializationNode& parameter = perBondParams.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ CustomExternalForceProxy::CustomExternalForceProxy() : SerializationProxy("Custo ...@@ -44,6 +44,7 @@ CustomExternalForceProxy::CustomExternalForceProxy() : SerializationProxy("Custo
void CustomExternalForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomExternalForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CustomExternalForce& force = *reinterpret_cast<const CustomExternalForce*>(object); const CustomExternalForce& force = *reinterpret_cast<const CustomExternalForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction()); node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters"); SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters");
for (int i = 0; i < force.getNumPerParticleParameters(); i++) { for (int i = 0; i < force.getNumPerParticleParameters(); i++) {
...@@ -74,6 +75,7 @@ void* CustomExternalForceProxy::deserialize(const SerializationNode& node) const ...@@ -74,6 +75,7 @@ void* CustomExternalForceProxy::deserialize(const SerializationNode& node) const
CustomExternalForce* force = NULL; CustomExternalForce* force = NULL;
try { try {
CustomExternalForce* force = new CustomExternalForce(node.getStringProperty("energy")); CustomExternalForce* force = new CustomExternalForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters"); const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters");
for (int i = 0; i < (int) perParticleParams.getChildren().size(); i++) { for (int i = 0; i < (int) perParticleParams.getChildren().size(); i++) {
const SerializationNode& parameter = perParticleParams.getChildren()[i]; const SerializationNode& parameter = perParticleParams.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ CustomGBForceProxy::CustomGBForceProxy() : SerializationProxy("CustomGBForce") { ...@@ -44,6 +44,7 @@ CustomGBForceProxy::CustomGBForceProxy() : SerializationProxy("CustomGBForce") {
void CustomGBForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomGBForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CustomGBForce& force = *reinterpret_cast<const CustomGBForce*>(object); const CustomGBForce& force = *reinterpret_cast<const CustomGBForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance()); node.setDoubleProperty("cutoff", force.getCutoffDistance());
SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters"); SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters");
...@@ -97,6 +98,7 @@ void* CustomGBForceProxy::deserialize(const SerializationNode& node) const { ...@@ -97,6 +98,7 @@ void* CustomGBForceProxy::deserialize(const SerializationNode& node) const {
CustomGBForce* force = NULL; CustomGBForce* force = NULL;
try { try {
CustomGBForce* force = new CustomGBForce(); CustomGBForce* force = new CustomGBForce();
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((CustomGBForce::NonbondedMethod) node.getIntProperty("method")); force->setNonbondedMethod((CustomGBForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff")); force->setCutoffDistance(node.getDoubleProperty("cutoff"));
const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters"); const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ CustomHbondForceProxy::CustomHbondForceProxy() : SerializationProxy("CustomHbond ...@@ -44,6 +44,7 @@ CustomHbondForceProxy::CustomHbondForceProxy() : SerializationProxy("CustomHbond
void CustomHbondForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomHbondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CustomHbondForce& force = *reinterpret_cast<const CustomHbondForce*>(object); const CustomHbondForce& force = *reinterpret_cast<const CustomHbondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction()); node.setStringProperty("energy", force.getEnergyFunction());
node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance()); node.setDoubleProperty("cutoff", force.getCutoffDistance());
...@@ -102,6 +103,7 @@ void* CustomHbondForceProxy::deserialize(const SerializationNode& node) const { ...@@ -102,6 +103,7 @@ void* CustomHbondForceProxy::deserialize(const SerializationNode& node) const {
CustomHbondForce* force = NULL; CustomHbondForce* force = NULL;
try { try {
CustomHbondForce* force = new CustomHbondForce(node.getStringProperty("energy")); CustomHbondForce* force = new CustomHbondForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((CustomHbondForce::NonbondedMethod) node.getIntProperty("method")); force->setNonbondedMethod((CustomHbondForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff")); force->setCutoffDistance(node.getDoubleProperty("cutoff"));
const SerializationNode& perDonorParams = node.getChildNode("PerDonorParameters"); const SerializationNode& perDonorParams = node.getChildNode("PerDonorParameters");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,9 +44,13 @@ CustomNonbondedForceProxy::CustomNonbondedForceProxy() : SerializationProxy("Cus ...@@ -44,9 +44,13 @@ CustomNonbondedForceProxy::CustomNonbondedForceProxy() : SerializationProxy("Cus
void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CustomNonbondedForce& force = *reinterpret_cast<const CustomNonbondedForce*>(object); const CustomNonbondedForce& force = *reinterpret_cast<const CustomNonbondedForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction()); node.setStringProperty("energy", force.getEnergyFunction());
node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance()); 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"); SerializationNode& perParticleParams = node.createChildNode("PerParticleParameters");
for (int i = 0; i < force.getNumPerParticleParameters(); i++) { for (int i = 0; i < force.getNumPerParticleParameters(); i++) {
perParticleParams.createChildNode("Parameter").setStringProperty("name", force.getPerParticleParameterName(i)); perParticleParams.createChildNode("Parameter").setStringProperty("name", force.getPerParticleParameterName(i));
...@@ -76,6 +80,20 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode& ...@@ -76,6 +80,20 @@ void CustomNonbondedForceProxy::serialize(const void* object, SerializationNode&
SerializationNode& functions = node.createChildNode("Functions"); SerializationNode& functions = node.createChildNode("Functions");
for (int i = 0; i < force.getNumTabulatedFunctions(); i++) for (int i = 0; i < force.getNumTabulatedFunctions(); i++)
functions.createChildNode("Function", &force.getTabulatedFunction(i)).setStringProperty("name", force.getTabulatedFunctionName(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 { void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) const {
...@@ -84,8 +102,12 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons ...@@ -84,8 +102,12 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
CustomNonbondedForce* force = NULL; CustomNonbondedForce* force = NULL;
try { try {
CustomNonbondedForce* force = new CustomNonbondedForce(node.getStringProperty("energy")); CustomNonbondedForce* force = new CustomNonbondedForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((CustomNonbondedForce::NonbondedMethod) node.getIntProperty("method")); force->setNonbondedMethod((CustomNonbondedForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff")); 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"); const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters");
for (int i = 0; i < (int) perParticleParams.getChildren().size(); i++) { for (int i = 0; i < (int) perParticleParams.getChildren().size(); i++) {
const SerializationNode& parameter = perParticleParams.getChildren()[i]; const SerializationNode& parameter = perParticleParams.getChildren()[i];
...@@ -121,7 +143,7 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons ...@@ -121,7 +143,7 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
} }
else { else {
// This is an old file created before TabulatedFunction existed. // This is an old file created before TabulatedFunction existed.
const SerializationNode& valuesNode = function.getChildNode("Values"); const SerializationNode& valuesNode = function.getChildNode("Values");
vector<double> values; vector<double> values;
for (int j = 0; j < (int) valuesNode.getChildren().size(); j++) for (int j = 0; j < (int) valuesNode.getChildren().size(); j++)
...@@ -129,6 +151,28 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons ...@@ -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"))); 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; return force;
} }
catch (...) { catch (...) {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ CustomTorsionForceProxy::CustomTorsionForceProxy() : SerializationProxy("CustomT ...@@ -44,6 +44,7 @@ CustomTorsionForceProxy::CustomTorsionForceProxy() : SerializationProxy("CustomT
void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const CustomTorsionForce& force = *reinterpret_cast<const CustomTorsionForce*>(object); const CustomTorsionForce& force = *reinterpret_cast<const CustomTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setStringProperty("energy", force.getEnergyFunction()); node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perTorsionParams = node.createChildNode("PerTorsionParameters"); SerializationNode& perTorsionParams = node.createChildNode("PerTorsionParameters");
for (int i = 0; i < force.getNumPerTorsionParameters(); i++) { for (int i = 0; i < force.getNumPerTorsionParameters(); i++) {
...@@ -74,6 +75,7 @@ void* CustomTorsionForceProxy::deserialize(const SerializationNode& node) const ...@@ -74,6 +75,7 @@ void* CustomTorsionForceProxy::deserialize(const SerializationNode& node) const
CustomTorsionForce* force = NULL; CustomTorsionForce* force = NULL;
try { try {
CustomTorsionForce* force = new CustomTorsionForce(node.getStringProperty("energy")); CustomTorsionForce* force = new CustomTorsionForce(node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& perTorsionParams = node.getChildNode("PerTorsionParameters"); const SerializationNode& perTorsionParams = node.getChildNode("PerTorsionParameters");
for (int i = 0; i < (int) perTorsionParams.getChildren().size(); i++) { for (int i = 0; i < (int) perTorsionParams.getChildren().size(); i++) {
const SerializationNode& parameter = perTorsionParams.getChildren()[i]; const SerializationNode& parameter = perTorsionParams.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ GBSAOBCForceProxy::GBSAOBCForceProxy() : SerializationProxy("GBSAOBCForce") { ...@@ -44,6 +44,7 @@ GBSAOBCForceProxy::GBSAOBCForceProxy() : SerializationProxy("GBSAOBCForce") {
void GBSAOBCForceProxy::serialize(const void* object, SerializationNode& node) const { void GBSAOBCForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const GBSAOBCForce& force = *reinterpret_cast<const GBSAOBCForce*>(object); const GBSAOBCForce& force = *reinterpret_cast<const GBSAOBCForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance()); node.setDoubleProperty("cutoff", force.getCutoffDistance());
node.setDoubleProperty("soluteDielectric", force.getSoluteDielectric()); node.setDoubleProperty("soluteDielectric", force.getSoluteDielectric());
...@@ -61,6 +62,7 @@ void* GBSAOBCForceProxy::deserialize(const SerializationNode& node) const { ...@@ -61,6 +62,7 @@ void* GBSAOBCForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
GBSAOBCForce* force = new GBSAOBCForce(); GBSAOBCForce* force = new GBSAOBCForce();
try { try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((GBSAOBCForce::NonbondedMethod) node.getIntProperty("method")); force->setNonbondedMethod((GBSAOBCForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff")); force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric")); force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric"));
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ GBVIForceProxy::GBVIForceProxy() : SerializationProxy("GBVIForce") { ...@@ -44,6 +44,7 @@ GBVIForceProxy::GBVIForceProxy() : SerializationProxy("GBVIForce") {
void GBVIForceProxy::serialize(const void* object, SerializationNode& node) const { void GBVIForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 2); node.setIntProperty("version", 2);
const GBVIForce& force = *reinterpret_cast<const GBVIForce*>(object); const GBVIForce& force = *reinterpret_cast<const GBVIForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setIntProperty("scalingMethod", (int) force.getBornRadiusScalingMethod()); node.setIntProperty("scalingMethod", (int) force.getBornRadiusScalingMethod());
node.setDoubleProperty("quinticLowerLimitFactor", force.getQuinticLowerLimitFactor()); node.setDoubleProperty("quinticLowerLimitFactor", force.getQuinticLowerLimitFactor());
...@@ -71,6 +72,7 @@ void* GBVIForceProxy::deserialize(const SerializationNode& node) const { ...@@ -71,6 +72,7 @@ void* GBVIForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
GBVIForce* force = new GBVIForce(); GBVIForce* force = new GBVIForce();
try { try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((GBVIForce::NonbondedMethod) node.getIntProperty("method")); force->setNonbondedMethod((GBVIForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff")); force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric")); force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric"));
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ HarmonicAngleForceProxy::HarmonicAngleForceProxy() : SerializationProxy("Harmoni ...@@ -44,6 +44,7 @@ HarmonicAngleForceProxy::HarmonicAngleForceProxy() : SerializationProxy("Harmoni
void HarmonicAngleForceProxy::serialize(const void* object, SerializationNode& node) const { void HarmonicAngleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const HarmonicAngleForce& force = *reinterpret_cast<const HarmonicAngleForce*>(object); const HarmonicAngleForce& force = *reinterpret_cast<const HarmonicAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& bonds = node.createChildNode("Angles"); SerializationNode& bonds = node.createChildNode("Angles");
for (int i = 0; i < force.getNumAngles(); i++) { for (int i = 0; i < force.getNumAngles(); i++) {
int particle1, particle2, particle3; int particle1, particle2, particle3;
...@@ -58,6 +59,7 @@ void* HarmonicAngleForceProxy::deserialize(const SerializationNode& node) const ...@@ -58,6 +59,7 @@ void* HarmonicAngleForceProxy::deserialize(const SerializationNode& node) const
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
HarmonicAngleForce* force = new HarmonicAngleForce(); HarmonicAngleForce* force = new HarmonicAngleForce();
try { try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& angles = node.getChildNode("Angles"); const SerializationNode& angles = node.getChildNode("Angles");
for (int i = 0; i < (int) angles.getChildren().size(); i++) { for (int i = 0; i < (int) angles.getChildren().size(); i++) {
const SerializationNode& angle = angles.getChildren()[i]; const SerializationNode& angle = angles.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ HarmonicBondForceProxy::HarmonicBondForceProxy() : SerializationProxy("HarmonicB ...@@ -44,6 +44,7 @@ HarmonicBondForceProxy::HarmonicBondForceProxy() : SerializationProxy("HarmonicB
void HarmonicBondForceProxy::serialize(const void* object, SerializationNode& node) const { void HarmonicBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const HarmonicBondForce& force = *reinterpret_cast<const HarmonicBondForce*>(object); const HarmonicBondForce& force = *reinterpret_cast<const HarmonicBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& bonds = node.createChildNode("Bonds"); SerializationNode& bonds = node.createChildNode("Bonds");
for (int i = 0; i < force.getNumBonds(); i++) { for (int i = 0; i < force.getNumBonds(); i++) {
int particle1, particle2; int particle1, particle2;
...@@ -58,6 +59,7 @@ void* HarmonicBondForceProxy::deserialize(const SerializationNode& node) const { ...@@ -58,6 +59,7 @@ void* HarmonicBondForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
HarmonicBondForce* force = new HarmonicBondForce(); HarmonicBondForce* force = new HarmonicBondForce();
try { try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& bonds = node.getChildNode("Bonds"); const SerializationNode& bonds = node.getChildNode("Bonds");
for (int i = 0; i < (int) bonds.getChildren().size(); i++) { for (int i = 0; i < (int) bonds.getChildren().size(); i++) {
const SerializationNode& bond = bonds.getChildren()[i]; const SerializationNode& bond = bonds.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ MonteCarloBarostatProxy::MonteCarloBarostatProxy() : SerializationProxy("MonteCa ...@@ -44,6 +44,7 @@ MonteCarloBarostatProxy::MonteCarloBarostatProxy() : SerializationProxy("MonteCa
void MonteCarloBarostatProxy::serialize(const void* object, SerializationNode& node) const { void MonteCarloBarostatProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const MonteCarloBarostat& force = *reinterpret_cast<const MonteCarloBarostat*>(object); const MonteCarloBarostat& force = *reinterpret_cast<const MonteCarloBarostat*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setDoubleProperty("pressure", force.getDefaultPressure()); node.setDoubleProperty("pressure", force.getDefaultPressure());
node.setDoubleProperty("temperature", force.getTemperature()); node.setDoubleProperty("temperature", force.getTemperature());
node.setIntProperty("frequency", force.getFrequency()); node.setIntProperty("frequency", force.getFrequency());
...@@ -56,6 +57,7 @@ void* MonteCarloBarostatProxy::deserialize(const SerializationNode& node) const ...@@ -56,6 +57,7 @@ void* MonteCarloBarostatProxy::deserialize(const SerializationNode& node) const
MonteCarloBarostat* force = NULL; MonteCarloBarostat* force = NULL;
try { try {
MonteCarloBarostat* force = new MonteCarloBarostat(node.getDoubleProperty("pressure"), node.getDoubleProperty("temperature"), node.getIntProperty("frequency")); MonteCarloBarostat* force = new MonteCarloBarostat(node.getDoubleProperty("pressure"), node.getDoubleProperty("temperature"), node.getIntProperty("frequency"));
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setRandomNumberSeed(node.getIntProperty("randomSeed")); force->setRandomNumberSeed(node.getIntProperty("randomSeed"));
return force; return force;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,11 +44,22 @@ NonbondedForceProxy::NonbondedForceProxy() : SerializationProxy("NonbondedForce" ...@@ -44,11 +44,22 @@ NonbondedForceProxy::NonbondedForceProxy() : SerializationProxy("NonbondedForce"
void NonbondedForceProxy::serialize(const void* object, SerializationNode& node) const { void NonbondedForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const NonbondedForce& force = *reinterpret_cast<const NonbondedForce*>(object); const NonbondedForce& force = *reinterpret_cast<const NonbondedForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance()); node.setDoubleProperty("cutoff", force.getCutoffDistance());
node.setBoolProperty("useSwitchingFunction", force.getUseSwitchingFunction());
node.setDoubleProperty("switchingDistance", force.getSwitchingDistance());
node.setDoubleProperty("ewaldTolerance", force.getEwaldErrorTolerance()); node.setDoubleProperty("ewaldTolerance", force.getEwaldErrorTolerance());
node.setDoubleProperty("rfDielectric", force.getReactionFieldDielectric()); node.setDoubleProperty("rfDielectric", force.getReactionFieldDielectric());
node.setIntProperty("dispersionCorrection", force.getUseDispersionCorrection()); 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"); SerializationNode& particles = node.createChildNode("Particles");
for (int i = 0; i < force.getNumParticles(); i++) { for (int i = 0; i < force.getNumParticles(); i++) {
double charge, sigma, epsilon; double charge, sigma, epsilon;
...@@ -69,11 +80,20 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const { ...@@ -69,11 +80,20 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
NonbondedForce* force = new NonbondedForce(); NonbondedForce* force = new NonbondedForce();
try { try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
force->setNonbondedMethod((NonbondedForce::NonbondedMethod) node.getIntProperty("method")); force->setNonbondedMethod((NonbondedForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff")); force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setUseSwitchingFunction(node.getBoolProperty("useSwitchingFunction", false));
force->setSwitchingDistance(node.getDoubleProperty("switchingDistance", -1.0));
force->setEwaldErrorTolerance(node.getDoubleProperty("ewaldTolerance")); force->setEwaldErrorTolerance(node.getDoubleProperty("ewaldTolerance"));
force->setReactionFieldDielectric(node.getDoubleProperty("rfDielectric")); force->setReactionFieldDielectric(node.getDoubleProperty("rfDielectric"));
force->setUseDispersionCorrection(node.getIntProperty("dispersionCorrection")); 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"); const SerializationNode& particles = node.getChildNode("Particles");
for (int i = 0; i < (int) particles.getChildren().size(); i++) { for (int i = 0; i < (int) particles.getChildren().size(); i++) {
const SerializationNode& particle = particles.getChildren()[i]; const SerializationNode& particle = particles.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ PeriodicTorsionForceProxy::PeriodicTorsionForceProxy() : SerializationProxy("Per ...@@ -44,6 +44,7 @@ PeriodicTorsionForceProxy::PeriodicTorsionForceProxy() : SerializationProxy("Per
void PeriodicTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { void PeriodicTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const PeriodicTorsionForce& force = *reinterpret_cast<const PeriodicTorsionForce*>(object); const PeriodicTorsionForce& force = *reinterpret_cast<const PeriodicTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& torsions = node.createChildNode("Torsions"); SerializationNode& torsions = node.createChildNode("Torsions");
for (int i = 0; i < force.getNumTorsions(); i++) { for (int i = 0; i < force.getNumTorsions(); i++) {
int particle1, particle2, particle3, particle4, periodicity; int particle1, particle2, particle3, particle4, periodicity;
...@@ -58,6 +59,7 @@ void* PeriodicTorsionForceProxy::deserialize(const SerializationNode& node) cons ...@@ -58,6 +59,7 @@ void* PeriodicTorsionForceProxy::deserialize(const SerializationNode& node) cons
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
PeriodicTorsionForce* force = new PeriodicTorsionForce(); PeriodicTorsionForce* force = new PeriodicTorsionForce();
try { try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& torsions = node.getChildNode("Torsions"); const SerializationNode& torsions = node.getChildNode("Torsions");
for (int i = 0; i < (int) torsions.getChildren().size(); i++) { for (int i = 0; i < (int) torsions.getChildren().size(); i++) {
const SerializationNode& torsion = torsions.getChildren()[i]; const SerializationNode& torsion = torsions.getChildren()[i];
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -44,6 +44,7 @@ RBTorsionForceProxy::RBTorsionForceProxy() : SerializationProxy("RBTorsionForce" ...@@ -44,6 +44,7 @@ RBTorsionForceProxy::RBTorsionForceProxy() : SerializationProxy("RBTorsionForce"
void RBTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { void RBTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 1);
const RBTorsionForce& force = *reinterpret_cast<const RBTorsionForce*>(object); const RBTorsionForce& force = *reinterpret_cast<const RBTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& torsions = node.createChildNode("Torsions"); SerializationNode& torsions = node.createChildNode("Torsions");
for (int i = 0; i < force.getNumTorsions(); i++) { for (int i = 0; i < force.getNumTorsions(); i++) {
int particle1, particle2, particle3, particle4; int particle1, particle2, particle3, particle4;
...@@ -58,6 +59,7 @@ void* RBTorsionForceProxy::deserialize(const SerializationNode& node) const { ...@@ -58,6 +59,7 @@ void* RBTorsionForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
RBTorsionForce* force = new RBTorsionForce(); RBTorsionForce* force = new RBTorsionForce();
try { try {
force->setForceGroup(node.getIntProperty("forceGroup", 0));
const SerializationNode& torsions = node.getChildNode("Torsions"); const SerializationNode& torsions = node.getChildNode("Torsions");
for (int i = 0; i < (int) torsions.getChildren().size(); i++) { for (int i = 0; i < (int) torsions.getChildren().size(); i++) {
const SerializationNode& torsion = torsions.getChildren()[i]; const SerializationNode& torsion = torsions.getChildren()[i];
......
...@@ -121,6 +121,32 @@ SerializationNode& SerializationNode::setIntProperty(const string& name, int val ...@@ -121,6 +121,32 @@ SerializationNode& SerializationNode::setIntProperty(const string& name, int val
return *this; return *this;
} }
bool SerializationNode::getBoolProperty(const string& name) const {
map<string, string>::const_iterator iter = properties.find(name);
if (iter == properties.end())
throw OpenMMException("Unknown property '"+name+"' in node '"+getName()+"'");
bool value;
stringstream(iter->second) >> value;
return value;
}
bool SerializationNode::getBoolProperty(const string& name, bool defaultValue) const {
map<string, string>::const_iterator iter = properties.find(name);
if (iter == properties.end())
return defaultValue;
bool value;
stringstream(iter->second) >> value;
return value;
}
SerializationNode& SerializationNode::setBoolProperty(const string& name, bool value) {
stringstream s;
s << value;
properties[name] = s.str();
return *this;
}
double SerializationNode::getDoubleProperty(const string& name) const { double SerializationNode::getDoubleProperty(const string& name) const {
map<string, string>::const_iterator iter = properties.find(name); map<string, string>::const_iterator iter = properties.find(name);
if (iter == properties.end()) if (iter == properties.end())
......
...@@ -67,6 +67,18 @@ void SystemProxy::serialize(const void* object, SerializationNode& node) const { ...@@ -67,6 +67,18 @@ void SystemProxy::serialize(const void* object, SerializationNode& node) const {
const OutOfPlaneSite& site = dynamic_cast<const OutOfPlaneSite&>(system.getVirtualSite(i)); const OutOfPlaneSite& site = dynamic_cast<const OutOfPlaneSite&>(system.getVirtualSite(i));
particle.createChildNode("OutOfPlaneSite").setIntProperty("p1", site.getParticle(0)).setIntProperty("p2", site.getParticle(1)).setIntProperty("p3", site.getParticle(2)).setDoubleProperty("w12", site.getWeight12()).setDoubleProperty("w13", site.getWeight13()).setDoubleProperty("wc", site.getWeightCross()); particle.createChildNode("OutOfPlaneSite").setIntProperty("p1", site.getParticle(0)).setIntProperty("p2", site.getParticle(1)).setIntProperty("p3", site.getParticle(2)).setDoubleProperty("w12", site.getWeight12()).setDoubleProperty("w13", site.getWeight13()).setDoubleProperty("wc", site.getWeightCross());
} }
else if (typeid(system.getVirtualSite(i)) == typeid(LocalCoordinatesSite)) {
const LocalCoordinatesSite& site = dynamic_cast<const LocalCoordinatesSite&>(system.getVirtualSite(i));
Vec3 wo = site.getOriginWeights();
Vec3 wx = site.getXWeights();
Vec3 wy = site.getYWeights();
Vec3 p = site.getLocalPosition();
particle.createChildNode("LocalCoordinatesSite").setIntProperty("p1", site.getParticle(0)).setIntProperty("p2", site.getParticle(1)).setIntProperty("p3", site.getParticle(2)).
setDoubleProperty("wo1", wo[0]).setDoubleProperty("wo2", wo[1]).setDoubleProperty("wo3", wo[2]).
setDoubleProperty("wx1", wx[0]).setDoubleProperty("wx2", wx[1]).setDoubleProperty("wx3", wx[2]).
setDoubleProperty("wy1", wy[0]).setDoubleProperty("wy2", wy[1]).setDoubleProperty("wy3", wy[2]).
setDoubleProperty("pos1", p[0]).setDoubleProperty("pos2", p[1]).setDoubleProperty("pos3", p[2]);
}
} }
} }
SerializationNode& constraints = node.createChildNode("Constraints"); SerializationNode& constraints = node.createChildNode("Constraints");
...@@ -105,6 +117,13 @@ void* SystemProxy::deserialize(const SerializationNode& node) const { ...@@ -105,6 +117,13 @@ void* SystemProxy::deserialize(const SerializationNode& node) const {
system->setVirtualSite(i, new ThreeParticleAverageSite(vsite.getIntProperty("p1"), vsite.getIntProperty("p2"), vsite.getIntProperty("p3"), vsite.getDoubleProperty("w1"), vsite.getDoubleProperty("w2"), vsite.getDoubleProperty("w3"))); system->setVirtualSite(i, new ThreeParticleAverageSite(vsite.getIntProperty("p1"), vsite.getIntProperty("p2"), vsite.getIntProperty("p3"), vsite.getDoubleProperty("w1"), vsite.getDoubleProperty("w2"), vsite.getDoubleProperty("w3")));
else if (vsite.getName() == "OutOfPlaneSite") else if (vsite.getName() == "OutOfPlaneSite")
system->setVirtualSite(i, new OutOfPlaneSite(vsite.getIntProperty("p1"), vsite.getIntProperty("p2"), vsite.getIntProperty("p3"), vsite.getDoubleProperty("w12"), vsite.getDoubleProperty("w13"), vsite.getDoubleProperty("wc"))); system->setVirtualSite(i, new OutOfPlaneSite(vsite.getIntProperty("p1"), vsite.getIntProperty("p2"), vsite.getIntProperty("p3"), vsite.getDoubleProperty("w12"), vsite.getDoubleProperty("w13"), vsite.getDoubleProperty("wc")));
else if (vsite.getName() == "LocalCoordinatesSite") {
Vec3 wo(vsite.getDoubleProperty("wo1"), vsite.getDoubleProperty("wo2"), vsite.getDoubleProperty("wo3"));
Vec3 wx(vsite.getDoubleProperty("wx1"), vsite.getDoubleProperty("wx2"), vsite.getDoubleProperty("wx3"));
Vec3 wy(vsite.getDoubleProperty("wy1"), vsite.getDoubleProperty("wy2"), vsite.getDoubleProperty("wy3"));
Vec3 p(vsite.getDoubleProperty("pos1"), vsite.getDoubleProperty("pos2"), vsite.getDoubleProperty("pos3"));
system->setVirtualSite(i, new LocalCoordinatesSite(vsite.getIntProperty("p1"), vsite.getIntProperty("p2"), vsite.getIntProperty("p3"), wo, wx, wy, p));
}
} }
} }
const SerializationNode& constraints = node.getChildNode("Constraints"); const SerializationNode& constraints = node.getChildNode("Constraints");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,6 +42,7 @@ void testSerialization() { ...@@ -42,6 +42,7 @@ void testSerialization() {
// Create a Force. // Create a Force.
AndersenThermostat force(250.0, 0.2); AndersenThermostat force(250.0, 0.2);
force.setForceGroup(3);
force.setRandomNumberSeed(3); force.setRandomNumberSeed(3);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -53,6 +54,7 @@ void testSerialization() { ...@@ -53,6 +54,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical. // Compare the two forces to see if they are identical.
AndersenThermostat& force2 = *copy; AndersenThermostat& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature()); ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature());
ASSERT_EQUAL(force.getDefaultCollisionFrequency(), force2.getDefaultCollisionFrequency()); ASSERT_EQUAL(force.getDefaultCollisionFrequency(), force2.getDefaultCollisionFrequency());
ASSERT_EQUAL(force.getRandomNumberSeed(), force2.getRandomNumberSeed()); ASSERT_EQUAL(force.getRandomNumberSeed(), force2.getRandomNumberSeed());
......
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