Commit d4441c15 authored by Mark Friedrichs's avatar Mark Friedrichs
Browse files

Added Born radius scaling method and associated parameters

parent ca9e8f8d
......@@ -42,9 +42,12 @@ GBVIForceProxy::GBVIForceProxy() : SerializationProxy("GBVIForce") {
}
void GBVIForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1);
node.setIntProperty("version", 2);
const GBVIForce& force = *reinterpret_cast<const GBVIForce*>(object);
node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setIntProperty("scalingMethod", (int) force.getBornRadiusScalingMethod());
node.setDoubleProperty("quinticLowerLimitFactor", force.getQuinticLowerLimitFactor());
node.setDoubleProperty("quinticUpperBornRadiusLimit", force.getQuinticUpperBornRadiusLimit());
node.setDoubleProperty("cutoff", force.getCutoffDistance());
node.setDoubleProperty("soluteDielectric", force.getSoluteDielectric());
node.setDoubleProperty("solventDielectric", force.getSolventDielectric());
......@@ -64,7 +67,7 @@ void GBVIForceProxy::serialize(const void* object, SerializationNode& node) cons
}
void* GBVIForceProxy::deserialize(const SerializationNode& node) const {
if (node.getIntProperty("version") != 1)
if (node.getIntProperty("version") != 1 && node.getIntProperty("version") != 2)
throw OpenMMException("Unsupported version number");
GBVIForce* force = new GBVIForce();
try {
......@@ -72,6 +75,13 @@ void* GBVIForceProxy::deserialize(const SerializationNode& node) const {
force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric"));
force->setSolventDielectric(node.getDoubleProperty("solventDielectric"));
if( node.getIntProperty("version") >= 2 ){
force->setBornRadiusScalingMethod( (GBVIForce::BornRadiusScalingMethod) node.getIntProperty( "scalingMethod"));
force->setQuinticLowerLimitFactor(node.getDoubleProperty("quinticLowerLimitFactor"));
force->setQuinticUpperBornRadiusLimit(node.getDoubleProperty("quinticUpperBornRadiusLimit"));
}
const SerializationNode& particles = node.getChildNode("Particles");
for (int i = 0; i < (int) particles.getChildren().size(); i++) {
const SerializationNode& particle = particles.getChildren()[i];
......
......@@ -43,6 +43,9 @@ void testSerialization() {
GBVIForce force;
force.setNonbondedMethod(GBVIForce::CutoffPeriodic);
force.setBornRadiusScalingMethod(GBVIForce::QuinticSpline);
force.setQuinticLowerLimitFactor(0.123);
force.setQuinticUpperBornRadiusLimit(5.123);
force.setCutoffDistance(2.0);
force.setSoluteDielectric(5.1);
force.setSolventDielectric(50.0);
......@@ -66,6 +69,9 @@ void testSerialization() {
ASSERT_EQUAL(force.getSoluteDielectric(), force2.getSoluteDielectric());
ASSERT_EQUAL(force.getSolventDielectric(), force2.getSolventDielectric());
ASSERT_EQUAL(force.getNumParticles(), force2.getNumParticles());
ASSERT_EQUAL(force.getQuinticUpperBornRadiusLimit(), force2.getQuinticUpperBornRadiusLimit());
ASSERT_EQUAL(force.getQuinticLowerLimitFactor(), force2.getQuinticLowerLimitFactor());
ASSERT_EQUAL(force.getBornRadiusScalingMethod(), force2.getBornRadiusScalingMethod());
for (int i = 0; i < force.getNumParticles(); i++) {
double charge1, radius1, scale1;
double charge2, radius2, scale2;
......
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