Commit abbf0b67 authored by peastman's avatar peastman
Browse files

Merge pull request #1464 from peastman/serializebonded

Serialization works for periodic boundary conditions on bonded forces
parents 03a92f78 8f1f8af4
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ CMAPTorsionForceProxy::CMAPTorsionForceProxy() : SerializationProxy("CMAPTorsion ...@@ -42,9 +42,10 @@ CMAPTorsionForceProxy::CMAPTorsionForceProxy() : SerializationProxy("CMAPTorsion
} }
void CMAPTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { void CMAPTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 2);
const CMAPTorsionForce& force = *reinterpret_cast<const CMAPTorsionForce*>(object); const CMAPTorsionForce& force = *reinterpret_cast<const CMAPTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
SerializationNode& maps = node.createChildNode("Maps"); SerializationNode& maps = node.createChildNode("Maps");
for (int i = 0; i < force.getNumMaps(); i++) { for (int i = 0; i < force.getNumMaps(); i++) {
int size; int size;
...@@ -63,11 +64,14 @@ void CMAPTorsionForceProxy::serialize(const void* object, SerializationNode& nod ...@@ -63,11 +64,14 @@ void CMAPTorsionForceProxy::serialize(const void* object, SerializationNode& nod
} }
void* CMAPTorsionForceProxy::deserialize(const SerializationNode& node) const { void* CMAPTorsionForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
CMAPTorsionForce* force = new CMAPTorsionForce(); CMAPTorsionForce* force = new CMAPTorsionForce();
try { try {
force->setForceGroup(node.getIntProperty("forceGroup", 0)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
const SerializationNode& maps = node.getChildNode("Maps"); const SerializationNode& maps = node.getChildNode("Maps");
for (int i = 0; i < (int) maps.getChildren().size(); i++) { for (int i = 0; i < (int) maps.getChildren().size(); i++) {
const SerializationNode& map = maps.getChildren()[i]; const SerializationNode& map = maps.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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ CustomAngleForceProxy::CustomAngleForceProxy() : SerializationProxy("CustomAngle ...@@ -42,9 +42,10 @@ 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", 2);
const CustomAngleForce& force = *reinterpret_cast<const CustomAngleForce*>(object); const CustomAngleForce& force = *reinterpret_cast<const CustomAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
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++) {
...@@ -70,12 +71,15 @@ void CustomAngleForceProxy::serialize(const void* object, SerializationNode& nod ...@@ -70,12 +71,15 @@ void CustomAngleForceProxy::serialize(const void* object, SerializationNode& nod
} }
void* CustomAngleForceProxy::deserialize(const SerializationNode& node) const { void* CustomAngleForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
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)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ CustomBondForceProxy::CustomBondForceProxy() : SerializationProxy("CustomBondFor ...@@ -42,9 +42,10 @@ 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", 2);
const CustomBondForce& force = *reinterpret_cast<const CustomBondForce*>(object); const CustomBondForce& force = *reinterpret_cast<const CustomBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
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++) {
...@@ -70,12 +71,15 @@ void CustomBondForceProxy::serialize(const void* object, SerializationNode& node ...@@ -70,12 +71,15 @@ void CustomBondForceProxy::serialize(const void* object, SerializationNode& node
} }
void* CustomBondForceProxy::deserialize(const SerializationNode& node) const { void* CustomBondForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
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)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2015 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ CustomCentroidBondForceProxy::CustomCentroidBondForceProxy() : SerializationProx ...@@ -42,9 +42,10 @@ CustomCentroidBondForceProxy::CustomCentroidBondForceProxy() : SerializationProx
} }
void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNode& node) const { void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 2);
const CustomCentroidBondForce& force = *reinterpret_cast<const CustomCentroidBondForce*>(object); const CustomCentroidBondForce& force = *reinterpret_cast<const CustomCentroidBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setIntProperty("groups", force.getNumGroupsPerBond()); node.setIntProperty("groups", force.getNumGroupsPerBond());
node.setStringProperty("energy", force.getEnergyFunction()); node.setStringProperty("energy", force.getEnergyFunction());
SerializationNode& perBondParams = node.createChildNode("PerBondParameters"); SerializationNode& perBondParams = node.createChildNode("PerBondParameters");
...@@ -93,12 +94,15 @@ void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNo ...@@ -93,12 +94,15 @@ void CustomCentroidBondForceProxy::serialize(const void* object, SerializationNo
} }
void* CustomCentroidBondForceProxy::deserialize(const SerializationNode& node) const { void* CustomCentroidBondForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
CustomCentroidBondForce* force = NULL; CustomCentroidBondForce* force = NULL;
try { try {
CustomCentroidBondForce* force = new CustomCentroidBondForce(node.getIntProperty("groups"), node.getStringProperty("energy")); CustomCentroidBondForce* force = new CustomCentroidBondForce(node.getIntProperty("groups"), node.getStringProperty("energy"));
force->setForceGroup(node.getIntProperty("forceGroup", 0)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ CustomCompoundBondForceProxy::CustomCompoundBondForceProxy() : SerializationProx ...@@ -42,9 +42,10 @@ 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", 2);
const CustomCompoundBondForce& force = *reinterpret_cast<const CustomCompoundBondForce*>(object); const CustomCompoundBondForce& force = *reinterpret_cast<const CustomCompoundBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
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");
...@@ -80,12 +81,15 @@ void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNo ...@@ -80,12 +81,15 @@ void CustomCompoundBondForceProxy::serialize(const void* object, SerializationNo
} }
void* CustomCompoundBondForceProxy::deserialize(const SerializationNode& node) const { void* CustomCompoundBondForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
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)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ CustomTorsionForceProxy::CustomTorsionForceProxy() : SerializationProxy("CustomT ...@@ -42,9 +42,10 @@ 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", 2);
const CustomTorsionForce& force = *reinterpret_cast<const CustomTorsionForce*>(object); const CustomTorsionForce& force = *reinterpret_cast<const CustomTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
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++) {
...@@ -70,12 +71,15 @@ void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& n ...@@ -70,12 +71,15 @@ void CustomTorsionForceProxy::serialize(const void* object, SerializationNode& n
} }
void* CustomTorsionForceProxy::deserialize(const SerializationNode& node) const { void* CustomTorsionForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
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)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ HarmonicAngleForceProxy::HarmonicAngleForceProxy() : SerializationProxy("Harmoni ...@@ -42,9 +42,10 @@ 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", 2);
const HarmonicAngleForce& force = *reinterpret_cast<const HarmonicAngleForce*>(object); const HarmonicAngleForce& force = *reinterpret_cast<const HarmonicAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
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;
...@@ -55,11 +56,14 @@ void HarmonicAngleForceProxy::serialize(const void* object, SerializationNode& n ...@@ -55,11 +56,14 @@ void HarmonicAngleForceProxy::serialize(const void* object, SerializationNode& n
} }
void* HarmonicAngleForceProxy::deserialize(const SerializationNode& node) const { void* HarmonicAngleForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
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)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ HarmonicBondForceProxy::HarmonicBondForceProxy() : SerializationProxy("HarmonicB ...@@ -42,9 +42,10 @@ 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", 2);
const HarmonicBondForce& force = *reinterpret_cast<const HarmonicBondForce*>(object); const HarmonicBondForce& force = *reinterpret_cast<const HarmonicBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
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;
...@@ -55,11 +56,14 @@ void HarmonicBondForceProxy::serialize(const void* object, SerializationNode& no ...@@ -55,11 +56,14 @@ void HarmonicBondForceProxy::serialize(const void* object, SerializationNode& no
} }
void* HarmonicBondForceProxy::deserialize(const SerializationNode& node) const { void* HarmonicBondForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
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)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ PeriodicTorsionForceProxy::PeriodicTorsionForceProxy() : SerializationProxy("Per ...@@ -42,9 +42,10 @@ 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", 2);
const PeriodicTorsionForce& force = *reinterpret_cast<const PeriodicTorsionForce*>(object); const PeriodicTorsionForce& force = *reinterpret_cast<const PeriodicTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
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;
...@@ -55,11 +56,14 @@ void PeriodicTorsionForceProxy::serialize(const void* object, SerializationNode& ...@@ -55,11 +56,14 @@ void PeriodicTorsionForceProxy::serialize(const void* object, SerializationNode&
} }
void* PeriodicTorsionForceProxy::deserialize(const SerializationNode& node) const { void* PeriodicTorsionForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
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)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -42,9 +42,10 @@ RBTorsionForceProxy::RBTorsionForceProxy() : SerializationProxy("RBTorsionForce" ...@@ -42,9 +42,10 @@ 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", 2);
const RBTorsionForce& force = *reinterpret_cast<const RBTorsionForce*>(object); const RBTorsionForce& force = *reinterpret_cast<const RBTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
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;
...@@ -55,11 +56,14 @@ void RBTorsionForceProxy::serialize(const void* object, SerializationNode& node) ...@@ -55,11 +56,14 @@ void RBTorsionForceProxy::serialize(const void* object, SerializationNode& node)
} }
void* RBTorsionForceProxy::deserialize(const SerializationNode& node) const { void* RBTorsionForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1) int version = node.getIntProperty("version");
if (version < 1 || version > 2)
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)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 1)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -55,6 +55,7 @@ void testSerialization() { ...@@ -55,6 +55,7 @@ void testSerialization() {
force.addTorsion(0, 0, 2, 3, 4, 5, 6, 7, 8); force.addTorsion(0, 0, 2, 3, 4, 5, 6, 7, 8);
force.addTorsion(1, 2, 3, 4, 7, 1, 2, 3, 4); force.addTorsion(1, 2, 3, 4, 7, 1, 2, 3, 4);
force.addTorsion(1, 5, 1, 2, 3, 2, 3, 4, 8); force.addTorsion(1, 5, 1, 2, 3, 2, 3, 4, 8);
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -66,6 +67,7 @@ void testSerialization() { ...@@ -66,6 +67,7 @@ void testSerialization() {
CMAPTorsionForce& force2 = *copy; CMAPTorsionForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumMaps(), force2.getNumMaps()); ASSERT_EQUAL(force.getNumMaps(), force2.getNumMaps());
for (int i = 0; i < force.getNumMaps(); i++) { for (int i = 0; i < force.getNumMaps(); i++) {
int size1, size2; int size1, size2;
......
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -53,6 +53,7 @@ void testSerialization() { ...@@ -53,6 +53,7 @@ void testSerialization() {
force.addAngle(4, 0, 1, params); force.addAngle(4, 0, 1, params);
params[0] = 2.1; params[0] = 2.1;
force.addAngle(3, 7, 6, params); force.addAngle(3, 7, 6, params);
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -73,6 +74,7 @@ void testSerialization() { ...@@ -73,6 +74,7 @@ void testSerialization() {
ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i)); ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i));
ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i)); ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i));
} }
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumAngles(), force2.getNumAngles()); ASSERT_EQUAL(force.getNumAngles(), force2.getNumAngles());
for (int i = 0; i < force.getNumAngles(); i++) { for (int i = 0; i < force.getNumAngles(); i++) {
int a1, a2, b1, b2, c1, c2; int a1, a2, b1, b2, c1, c2;
......
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -53,6 +53,7 @@ void testSerialization() { ...@@ -53,6 +53,7 @@ void testSerialization() {
force.addBond(4, 0, params); force.addBond(4, 0, params);
params[0] = 2.1; params[0] = 2.1;
force.addBond(3, 7, params); force.addBond(3, 7, params);
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -73,6 +74,7 @@ void testSerialization() { ...@@ -73,6 +74,7 @@ void testSerialization() {
ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i)); ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i));
ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i)); ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i));
} }
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumBonds(), force2.getNumBonds()); ASSERT_EQUAL(force.getNumBonds(), force2.getNumBonds());
for (int i = 0; i < force.getNumBonds(); i++) { for (int i = 0; i < force.getNumBonds(); i++) {
int a1, a2, b1, b2; int a1, a2, b1, b2;
......
...@@ -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-2015 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -77,6 +77,7 @@ void testSerialization() { ...@@ -77,6 +77,7 @@ void testSerialization() {
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
values[i] = sin((double) i); values[i] = sin((double) i);
force.addTabulatedFunction("f", new Continuous1DFunction(values, 0.5, 1.5)); force.addTabulatedFunction("f", new Continuous1DFunction(values, 0.5, 1.5));
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -98,6 +99,7 @@ void testSerialization() { ...@@ -98,6 +99,7 @@ void testSerialization() {
ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i)); ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i));
ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i)); ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i));
} }
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumGroups(), force2.getNumGroups()); ASSERT_EQUAL(force.getNumGroups(), force2.getNumGroups());
for (int i = 0; i < force.getNumGroups(); i++) { for (int i = 0; i < force.getNumGroups(); i++) {
vector<int> particles1, particles2; vector<int> particles1, particles2;
......
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -67,6 +67,7 @@ void testSerialization() { ...@@ -67,6 +67,7 @@ void testSerialization() {
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
values[i] = sin((double) i); values[i] = sin((double) i);
force.addTabulatedFunction("f", new Continuous1DFunction(values, 0.5, 1.5)); force.addTabulatedFunction("f", new Continuous1DFunction(values, 0.5, 1.5));
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -88,6 +89,7 @@ void testSerialization() { ...@@ -88,6 +89,7 @@ void testSerialization() {
ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i)); ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i));
ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i)); ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i));
} }
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumBonds(), force2.getNumBonds()); ASSERT_EQUAL(force.getNumBonds(), force2.getNumBonds());
for (int i = 0; i < force.getNumBonds(); i++) { for (int i = 0; i < force.getNumBonds(); i++) {
vector<int> particles1, particles2; vector<int> particles1, particles2;
......
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -53,6 +53,7 @@ void testSerialization() { ...@@ -53,6 +53,7 @@ void testSerialization() {
force.addTorsion(4, 0, 1, 5, params); force.addTorsion(4, 0, 1, 5, params);
params[0] = 2.1; params[0] = 2.1;
force.addTorsion(3, 7, 6, 8, params); force.addTorsion(3, 7, 6, 8, params);
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -73,6 +74,7 @@ void testSerialization() { ...@@ -73,6 +74,7 @@ void testSerialization() {
ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i)); ASSERT_EQUAL(force.getGlobalParameterName(i), force2.getGlobalParameterName(i));
ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i)); ASSERT_EQUAL(force.getGlobalParameterDefaultValue(i), force2.getGlobalParameterDefaultValue(i));
} }
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions()); ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions());
for (int i = 0; i < force.getNumTorsions(); i++) { for (int i = 0; i < force.getNumTorsions(); i++) {
int a1, a2, b1, b2, c1, c2, d1, d2; int a1, a2, b1, b2, c1, c2, d1, d2;
......
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -47,6 +47,7 @@ void testSerialization() { ...@@ -47,6 +47,7 @@ void testSerialization() {
force.addAngle(0, 2, 3, 2.0, 2.1); force.addAngle(0, 2, 3, 2.0, 2.1);
force.addAngle(2, 3, 4, 3.0, 2.2); force.addAngle(2, 3, 4, 3.0, 2.2);
force.addAngle(5, 1, 2, 4.0, 2.3); force.addAngle(5, 1, 2, 4.0, 2.3);
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -58,6 +59,7 @@ void testSerialization() { ...@@ -58,6 +59,7 @@ void testSerialization() {
HarmonicAngleForce& force2 = *copy; HarmonicAngleForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumAngles(), force2.getNumAngles()); ASSERT_EQUAL(force.getNumAngles(), force2.getNumAngles());
for (int i = 0; i < force.getNumAngles(); i++) { for (int i = 0; i < force.getNumAngles(); i++) {
int a1, a2, a3, b1, b2, b3; int a1, a2, a3, b1, b2, b3;
......
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -47,6 +47,7 @@ void testSerialization() { ...@@ -47,6 +47,7 @@ void testSerialization() {
force.addBond(0, 2, 2.0, 2.1); force.addBond(0, 2, 2.0, 2.1);
force.addBond(2, 3, 3.0, 2.2); force.addBond(2, 3, 3.0, 2.2);
force.addBond(5, 1, 4.0, 2.3); force.addBond(5, 1, 4.0, 2.3);
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -58,6 +59,7 @@ void testSerialization() { ...@@ -58,6 +59,7 @@ void testSerialization() {
HarmonicBondForce& force2 = *copy; HarmonicBondForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumBonds(), force2.getNumBonds()); ASSERT_EQUAL(force.getNumBonds(), force2.getNumBonds());
for (int i = 0; i < force.getNumBonds(); i++) { for (int i = 0; i < force.getNumBonds(); i++) {
int a1, a2, b1, b2; int a1, a2, b1, b2;
......
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -47,6 +47,7 @@ void testSerialization() { ...@@ -47,6 +47,7 @@ void testSerialization() {
force.addTorsion(0, 2, 3, 4, 2, 2.0, 2.1); force.addTorsion(0, 2, 3, 4, 2, 2.0, 2.1);
force.addTorsion(2, 3, 4, 7, 1, 3.0, 2.2); force.addTorsion(2, 3, 4, 7, 1, 3.0, 2.2);
force.addTorsion(5, 1, 2, 3, 3, 4.0, 2.3); force.addTorsion(5, 1, 2, 3, 3, 4.0, 2.3);
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -58,6 +59,7 @@ void testSerialization() { ...@@ -58,6 +59,7 @@ void testSerialization() {
PeriodicTorsionForce& force2 = *copy; PeriodicTorsionForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions()); ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions());
for (int i = 0; i < force.getNumTorsions(); i++) { for (int i = 0; i < force.getNumTorsions(); i++) {
int a1, a2, a3, a4, b1, b2, b3, b4, perioda, periodb; int a1, a2, a3, a4, b1, b2, b3, b4, perioda, periodb;
......
...@@ -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-2014 Stanford University and the Authors. * * Portions copyright (c) 2010-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -46,6 +46,7 @@ void testSerialization() { ...@@ -46,6 +46,7 @@ void testSerialization() {
force.addTorsion(0, 1, 2, 3, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6); force.addTorsion(0, 1, 2, 3, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6);
force.addTorsion(0, 2, 3, 4, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7); force.addTorsion(0, 2, 3, 4, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7);
force.addTorsion(2, 3, 4, 7, -1, -2, -3, 1.1, 2.2, 3.3); force.addTorsion(2, 3, 4, 7, -1, -2, -3, 1.1, 2.2, 3.3);
force.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -57,6 +58,7 @@ void testSerialization() { ...@@ -57,6 +58,7 @@ void testSerialization() {
RBTorsionForce& force2 = *copy; RBTorsionForce& force2 = *copy;
ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions()); ASSERT_EQUAL(force.getNumTorsions(), force2.getNumTorsions());
for (int i = 0; i < force.getNumTorsions(); i++) { for (int i = 0; i < force.getNumTorsions(); i++) {
int a1, a2, a3, a4, b1, b2, b3, b4; int a1, a2, a3, a4, b1, b2, b3, b4;
......
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