Commit 2e9c418a authored by peastman's avatar peastman
Browse files

Merge branch 'master' into gayberne

parents 8f532e31 a4d327f5
...@@ -183,7 +183,7 @@ int main(int argc, char* argv[]) { ...@@ -183,7 +183,7 @@ int main(int argc, char* argv[]) {
try { try {
registerDrudeCudaKernelFactories(); registerDrudeCudaKernelFactories();
if (argc > 1) if (argc > 1)
Platform::getPlatformByName("CUDA").setPropertyDefaultValue("CudaPrecision", string(argv[1])); Platform::getPlatformByName("CUDA").setPropertyDefaultValue("Precision", string(argv[1]));
testSinglePair(); testSinglePair();
testWater(); testWater();
} }
......
...@@ -110,7 +110,7 @@ void testWater() { ...@@ -110,7 +110,7 @@ void testWater() {
State state = context.getState(State::Energy); State state = context.getState(State::Energy);
double initialEnergy; double initialEnergy;
int numSteps = 1000; int numSteps = 1000;
double maxNorm = (platform.getPropertyValue(context, "CudaPrecision") == "double" ? 1.0 : 5.0); double maxNorm = (platform.getPropertyValue(context, "Precision") == "double" ? 1.0 : 5.0);
for (int i = 0; i < numSteps; i++) { for (int i = 0; i < numSteps; i++) {
integ.step(1); integ.step(1);
state = context.getState(State::Energy | State::Forces); state = context.getState(State::Energy | State::Forces);
...@@ -131,7 +131,7 @@ int main(int argc, char* argv[]) { ...@@ -131,7 +131,7 @@ int main(int argc, char* argv[]) {
try { try {
registerDrudeCudaKernelFactories(); registerDrudeCudaKernelFactories();
if (argc > 1) if (argc > 1)
Platform::getPlatformByName("CUDA").setPropertyDefaultValue("CudaPrecision", string(argv[1])); Platform::getPlatformByName("CUDA").setPropertyDefaultValue("Precision", string(argv[1]));
testWater(); testWater();
} }
catch(const std::exception& e) { catch(const std::exception& e) {
......
...@@ -197,7 +197,7 @@ int main(int argc, char* argv[]) { ...@@ -197,7 +197,7 @@ int main(int argc, char* argv[]) {
try { try {
registerDrudeOpenCLKernelFactories(); registerDrudeOpenCLKernelFactories();
if (argc > 1) if (argc > 1)
Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("OpenCLPrecision", std::string(argv[1])); Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("Precision", std::string(argv[1]));
testSingleParticle(); testSingleParticle();
testAnisotropicParticle(); testAnisotropicParticle();
testThole(); testThole();
......
...@@ -183,7 +183,7 @@ int main(int argc, char* argv[]) { ...@@ -183,7 +183,7 @@ int main(int argc, char* argv[]) {
try { try {
registerDrudeOpenCLKernelFactories(); registerDrudeOpenCLKernelFactories();
if (argc > 1) if (argc > 1)
Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("OpenCLPrecision", string(argv[1])); Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("Precision", string(argv[1]));
testSinglePair(); testSinglePair();
testWater(); testWater();
} }
......
...@@ -110,7 +110,7 @@ void testWater() { ...@@ -110,7 +110,7 @@ void testWater() {
State state = context.getState(State::Energy); State state = context.getState(State::Energy);
double initialEnergy; double initialEnergy;
int numSteps = 1000; int numSteps = 1000;
double maxNorm = (platform.getPropertyValue(context, "OpenCLPrecision") == "double" ? 1.0 : 5.0); double maxNorm = (platform.getPropertyValue(context, "Precision") == "double" ? 1.0 : 5.0);
for (int i = 0; i < numSteps; i++) { for (int i = 0; i < numSteps; i++) {
integ.step(1); integ.step(1);
state = context.getState(State::Energy | State::Forces); state = context.getState(State::Energy | State::Forces);
...@@ -131,7 +131,7 @@ int main(int argc, char* argv[]) { ...@@ -131,7 +131,7 @@ int main(int argc, char* argv[]) {
try { try {
registerDrudeOpenCLKernelFactories(); registerDrudeOpenCLKernelFactories();
if (argc > 1) if (argc > 1)
Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("OpenCLPrecision", string(argv[1])); Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("Precision", string(argv[1]));
testWater(); testWater();
} }
catch(const std::exception& e) { catch(const std::exception& e) {
......
...@@ -554,7 +554,7 @@ int main(int argc, char* argv[]) { ...@@ -554,7 +554,7 @@ int main(int argc, char* argv[]) {
try { try {
registerRPMDCudaKernelFactories(); registerRPMDCudaKernelFactories();
if (argc > 1) if (argc > 1)
Platform::getPlatformByName("CUDA").setPropertyDefaultValue("CudaPrecision", string(argv[1])); Platform::getPlatformByName("CUDA").setPropertyDefaultValue("Precision", string(argv[1]));
testFreeParticles(); testFreeParticles();
testParaHydrogen(); testParaHydrogen();
testCMMotionRemoval(); testCMMotionRemoval();
......
...@@ -555,7 +555,7 @@ int main(int argc, char* argv[]) { ...@@ -555,7 +555,7 @@ int main(int argc, char* argv[]) {
try { try {
registerRPMDOpenCLKernelFactories(); registerRPMDOpenCLKernelFactories();
if (argc > 1) if (argc > 1)
Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("OpenCLPrecision", string(argv[1])); Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("Precision", string(argv[1]));
testFreeParticles(); testFreeParticles();
testParaHydrogen(); testParaHydrogen();
testCMMotionRemoval(); testCMMotionRemoval();
......
...@@ -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: *
* * * *
...@@ -52,7 +52,7 @@ void MonteCarloAnisotropicBarostatProxy::serialize(const void* object, Serializa ...@@ -52,7 +52,7 @@ void MonteCarloAnisotropicBarostatProxy::serialize(const void* object, Serializa
node.setBoolProperty("scalex", force.getScaleX()); node.setBoolProperty("scalex", force.getScaleX());
node.setBoolProperty("scaley", force.getScaleY()); node.setBoolProperty("scaley", force.getScaleY());
node.setBoolProperty("scalez", force.getScaleZ()); node.setBoolProperty("scalez", force.getScaleZ());
node.setDoubleProperty("temperature", force.getTemperature()); node.setDoubleProperty("temperature", force.getDefaultTemperature());
node.setIntProperty("frequency", force.getFrequency()); node.setIntProperty("frequency", force.getFrequency());
node.setIntProperty("randomSeed", force.getRandomNumberSeed()); node.setIntProperty("randomSeed", force.getRandomNumberSeed());
} }
......
...@@ -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,7 +46,7 @@ void MonteCarloBarostatProxy::serialize(const void* object, SerializationNode& n ...@@ -46,7 +46,7 @@ void MonteCarloBarostatProxy::serialize(const void* object, SerializationNode& n
const MonteCarloBarostat& force = *reinterpret_cast<const MonteCarloBarostat*>(object); const MonteCarloBarostat& force = *reinterpret_cast<const MonteCarloBarostat*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setDoubleProperty("pressure", force.getDefaultPressure()); node.setDoubleProperty("pressure", force.getDefaultPressure());
node.setDoubleProperty("temperature", force.getTemperature()); node.setDoubleProperty("temperature", force.getDefaultTemperature());
node.setIntProperty("frequency", force.getFrequency()); node.setIntProperty("frequency", force.getFrequency());
node.setIntProperty("randomSeed", force.getRandomNumberSeed()); node.setIntProperty("randomSeed", force.getRandomNumberSeed());
} }
......
...@@ -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,7 +47,7 @@ void MonteCarloMembraneBarostatProxy::serialize(const void* object, Serializatio ...@@ -47,7 +47,7 @@ void MonteCarloMembraneBarostatProxy::serialize(const void* object, Serializatio
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setDoubleProperty("pressure", force.getDefaultPressure()); node.setDoubleProperty("pressure", force.getDefaultPressure());
node.setDoubleProperty("surfaceTension", force.getDefaultSurfaceTension()); node.setDoubleProperty("surfaceTension", force.getDefaultSurfaceTension());
node.setDoubleProperty("temperature", force.getTemperature()); node.setDoubleProperty("temperature", force.getDefaultTemperature());
node.setIntProperty("xymode", force.getXYMode()); node.setIntProperty("xymode", force.getXYMode());
node.setIntProperty("zmode", force.getZMode()); node.setIntProperty("zmode", force.getZMode());
node.setIntProperty("frequency", force.getFrequency()); node.setIntProperty("frequency", force.getFrequency());
......
...@@ -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];
......
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