Commit c4877bec authored by peastman's avatar peastman
Browse files

Merge pull request #413 from peastman/master

Include force groups when serializing forces
parents 780bbf8f ede48b85
......@@ -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");
......
......@@ -44,6 +44,7 @@ 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());
......@@ -101,6 +102,7 @@ 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));
......
......@@ -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;
}
......
......@@ -44,6 +44,7 @@ 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());
......@@ -79,6 +80,7 @@ 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));
......
......@@ -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];
......
......@@ -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 @@ RBTorsionForceProxy::RBTorsionForceProxy() : SerializationProxy("RBTorsionForce"
void RBTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
const RBTorsionForce& force = *reinterpret_cast<const RBTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
SerializationNode& torsions = node.createChildNode("Torsions");
for (int i = 0; i < force.getNumTorsions(); i++) {
int particle1, particle2, particle3, particle4;
......@@ -58,6 +59,7 @@ void* RBTorsionForceProxy::deserialize(const SerializationNode& node) const {
throw OpenMMException("Unsupported version number");
RBTorsionForce* force = new RBTorsionForce();
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];
......
......@@ -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: *
* *
......@@ -42,6 +42,7 @@ void testSerialization() {
// Create a Force.
AndersenThermostat force(250.0, 0.2);
force.setForceGroup(3);
force.setRandomNumberSeed(3);
// Serialize and then deserialize it.
......@@ -53,6 +54,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical.
AndersenThermostat& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.getDefaultTemperature(), force2.getDefaultTemperature());
ASSERT_EQUAL(force.getDefaultCollisionFrequency(), force2.getDefaultCollisionFrequency());
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