Commit ead929de authored by peastman's avatar peastman
Browse files

Setting surface area energy works with serialization

parent 438b29b4
...@@ -42,13 +42,14 @@ GBSAOBCForceProxy::GBSAOBCForceProxy() : SerializationProxy("GBSAOBCForce") { ...@@ -42,13 +42,14 @@ GBSAOBCForceProxy::GBSAOBCForceProxy() : SerializationProxy("GBSAOBCForce") {
} }
void GBSAOBCForceProxy::serialize(const void* object, SerializationNode& node) const { void GBSAOBCForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 1); node.setIntProperty("version", 2);
const GBSAOBCForce& force = *reinterpret_cast<const GBSAOBCForce*>(object); const GBSAOBCForce& force = *reinterpret_cast<const GBSAOBCForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setIntProperty("method", (int) force.getNonbondedMethod()); node.setIntProperty("method", (int) force.getNonbondedMethod());
node.setDoubleProperty("cutoff", force.getCutoffDistance()); node.setDoubleProperty("cutoff", force.getCutoffDistance());
node.setDoubleProperty("soluteDielectric", force.getSoluteDielectric()); node.setDoubleProperty("soluteDielectric", force.getSoluteDielectric());
node.setDoubleProperty("solventDielectric", force.getSolventDielectric()); node.setDoubleProperty("solventDielectric", force.getSolventDielectric());
node.setDoubleProperty("surfaceAreaEnergy", force.getSurfaceAreaEnergy());
SerializationNode& particles = node.createChildNode("Particles"); SerializationNode& particles = node.createChildNode("Particles");
for (int i = 0; i < force.getNumParticles(); i++) { for (int i = 0; i < force.getNumParticles(); i++) {
double charge, radius, scale; double charge, radius, scale;
...@@ -58,7 +59,8 @@ void GBSAOBCForceProxy::serialize(const void* object, SerializationNode& node) c ...@@ -58,7 +59,8 @@ void GBSAOBCForceProxy::serialize(const void* object, SerializationNode& node) c
} }
void* GBSAOBCForceProxy::deserialize(const SerializationNode& node) const { void* GBSAOBCForceProxy::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");
GBSAOBCForce* force = new GBSAOBCForce(); GBSAOBCForce* force = new GBSAOBCForce();
try { try {
...@@ -67,6 +69,8 @@ void* GBSAOBCForceProxy::deserialize(const SerializationNode& node) const { ...@@ -67,6 +69,8 @@ void* GBSAOBCForceProxy::deserialize(const SerializationNode& node) const {
force->setCutoffDistance(node.getDoubleProperty("cutoff")); force->setCutoffDistance(node.getDoubleProperty("cutoff"));
force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric")); force->setSoluteDielectric(node.getDoubleProperty("soluteDielectric"));
force->setSolventDielectric(node.getDoubleProperty("solventDielectric")); force->setSolventDielectric(node.getDoubleProperty("solventDielectric"));
if (version > 1)
force->setSurfaceAreaEnergy(node.getDoubleProperty("surfaceAreaEnergy"));
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];
......
...@@ -47,6 +47,7 @@ void testSerialization() { ...@@ -47,6 +47,7 @@ void testSerialization() {
force.setCutoffDistance(2.0); force.setCutoffDistance(2.0);
force.setSoluteDielectric(5.1); force.setSoluteDielectric(5.1);
force.setSolventDielectric(50.0); force.setSolventDielectric(50.0);
force.setSurfaceAreaEnergy(1.7);
force.addParticle(1, 0.1, 0.01); force.addParticle(1, 0.1, 0.01);
force.addParticle(0.5, 0.2, 0.02); force.addParticle(0.5, 0.2, 0.02);
force.addParticle(-0.5, 0.3, 0.03); force.addParticle(-0.5, 0.3, 0.03);
...@@ -65,6 +66,7 @@ void testSerialization() { ...@@ -65,6 +66,7 @@ void testSerialization() {
ASSERT_EQUAL(force.getCutoffDistance(), force2.getCutoffDistance()); ASSERT_EQUAL(force.getCutoffDistance(), force2.getCutoffDistance());
ASSERT_EQUAL(force.getSoluteDielectric(), force2.getSoluteDielectric()); ASSERT_EQUAL(force.getSoluteDielectric(), force2.getSoluteDielectric());
ASSERT_EQUAL(force.getSolventDielectric(), force2.getSolventDielectric()); ASSERT_EQUAL(force.getSolventDielectric(), force2.getSolventDielectric());
ASSERT_EQUAL(force.getSurfaceAreaEnergy(), force2.getSurfaceAreaEnergy());
ASSERT_EQUAL(force.getNumParticles(), force2.getNumParticles()); ASSERT_EQUAL(force.getNumParticles(), force2.getNumParticles());
for (int i = 0; i < force.getNumParticles(); i++) { for (int i = 0; i < force.getNumParticles(); i++) {
double charge1, radius1, scale1; double charge1, radius1, scale1;
......
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