Commit 9a83528b authored by John Chodera (MSKCC)'s avatar John Chodera (MSKCC)
Browse files

Added defaults for backward compatibility.

parent f755a61a
...@@ -102,10 +102,10 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons ...@@ -102,10 +102,10 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
try { try {
CustomNonbondedForce* force = new CustomNonbondedForce(node.getStringProperty("energy")); CustomNonbondedForce* force = new CustomNonbondedForce(node.getStringProperty("energy"));
force->setNonbondedMethod((CustomNonbondedForce::NonbondedMethod) node.getIntProperty("method")); force->setNonbondedMethod((CustomNonbondedForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff")); force->setCutoffDistance(node.getDoubleProperty("cutoff", 1.0));
force->setUseSwitchingFunction(node.getBoolProperty("useSwitchingFunction")); force->setUseSwitchingFunction(node.getBoolProperty("useSwitchingFunction", false));
force->setSwitchingDistance(node.getDoubleProperty("switchingDistance")); force->setSwitchingDistance(node.getDoubleProperty("switchingDistance", -1.0));
force->setUseLongRangeCorrection(node.getBoolProperty("useLongRangeCorrection")); force->setUseLongRangeCorrection(node.getBoolProperty("useLongRangeCorrection", false));
const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters"); const SerializationNode& perParticleParams = node.getChildNode("PerParticleParameters");
for (int i = 0; i < (int) perParticleParams.getChildren().size(); i++) { for (int i = 0; i < (int) perParticleParams.getChildren().size(); i++) {
const SerializationNode& parameter = perParticleParams.getChildren()[i]; const SerializationNode& parameter = perParticleParams.getChildren()[i];
...@@ -149,6 +149,8 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons ...@@ -149,6 +149,8 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
force->addTabulatedFunction(function.getStringProperty("name"), new Continuous1DFunction(values, function.getDoubleProperty("min"), function.getDoubleProperty("max"))); force->addTabulatedFunction(function.getStringProperty("name"), new Continuous1DFunction(values, function.getDoubleProperty("min"), function.getDoubleProperty("max")));
} }
} }
// Catch exceptions if InteractionGroups node is missing, in order to give backwards compatibility.
try{
const SerializationNode& interactionGroups = node.getChildNode("InteractionGroups"); const SerializationNode& interactionGroups = node.getChildNode("InteractionGroups");
for (int i = 0; i < (int) interactionGroups.getChildren().size(); i++) { for (int i = 0; i < (int) interactionGroups.getChildren().size(); i++) {
const SerializationNode& interactionGroup = interactionGroups.getChildren()[i]; const SerializationNode& interactionGroup = interactionGroups.getChildren()[i];
...@@ -164,6 +166,9 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons ...@@ -164,6 +166,9 @@ void* CustomNonbondedForceProxy::deserialize(const SerializationNode& node) cons
set2.insert(set2node.getChildren()[j].getIntProperty("index")); set2.insert(set2node.getChildren()[j].getIntProperty("index"));
force->addInteractionGroup(set1, set2); force->addInteractionGroup(set1, set2);
} }
} catch (...) {
// do nothing to allow backwards-compatibility
}
return force; return force;
} }
catch (...) { catch (...) {
......
...@@ -80,20 +80,20 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const { ...@@ -80,20 +80,20 @@ void* NonbondedForceProxy::deserialize(const SerializationNode& node) const {
NonbondedForce* force = new NonbondedForce(); NonbondedForce* force = new NonbondedForce();
try { try {
force->setNonbondedMethod((NonbondedForce::NonbondedMethod) node.getIntProperty("method")); force->setNonbondedMethod((NonbondedForce::NonbondedMethod) node.getIntProperty("method"));
force->setCutoffDistance(node.getDoubleProperty("cutoff")); force->setCutoffDistance(node.getDoubleProperty("cutoff",1.0));
force->setUseSwitchingFunction(node.getDoubleProperty("useSwitchingFunction")); force->setUseSwitchingFunction(node.getDoubleProperty("useSwitchingFunction",false));
force->setSwitchingDistance(node.getDoubleProperty("switchingDistance")); force->setSwitchingDistance(node.getDoubleProperty("switchingDistance",-1.0));
force->setEwaldErrorTolerance(node.getDoubleProperty("ewaldTolerance")); force->setEwaldErrorTolerance(node.getDoubleProperty("ewaldTolerance",5e-4));
force->setReactionFieldDielectric(node.getDoubleProperty("rfDielectric")); force->setReactionFieldDielectric(node.getDoubleProperty("rfDielectric",78.3));
force->setUseDispersionCorrection(node.getIntProperty("dispersionCorrection")); force->setUseDispersionCorrection(node.getIntProperty("dispersionCorrection",true));
double alpha; double alpha;
int nx, ny, nz; int nx, ny, nz;
alpha = node.getDoubleProperty("alpha"); alpha = node.getDoubleProperty("alpha",0.0);
nx = node.getIntProperty("nx"); nx = node.getIntProperty("nx",0);
ny = node.getIntProperty("ny"); ny = node.getIntProperty("ny",0);
nz = node.getIntProperty("nz"); nz = node.getIntProperty("nz",0);
force->setPMEParameters(alpha, nx, ny, nz); force->setPMEParameters(alpha, nx, ny, nz);
force->setReciprocalSpaceForceGroup(node.getIntProperty("recipForceGroup")); force->setReciprocalSpaceForceGroup(node.getIntProperty("recipForceGroup",-1));
const SerializationNode& particles = node.getChildNode("Particles"); const SerializationNode& particles = node.getChildNode("Particles");
for (int i = 0; i < (int) particles.getChildren().size(); i++) { for (int i = 0; i < (int) particles.getChildren().size(); i++) {
const SerializationNode& particle = particles.getChildren()[i]; const SerializationNode& particle = particles.getChildren()[i];
......
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