Commit 3c2a3b1f authored by Kyle Beauchamp's avatar Kyle Beauchamp
Browse files

Add support for customIntegrator serialization and test

parent c2166480
...@@ -107,6 +107,12 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const { ...@@ -107,6 +107,12 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const {
integrator->addConstrainVelocities(); integrator->addConstrainVelocities();
} else if(computationType == CustomIntegrator::UpdateContextState) { } else if(computationType == CustomIntegrator::UpdateContextState) {
integrator->addUpdateContextState(); integrator->addUpdateContextState();
} else if(computationType == CustomIntegrator::IfBlockStart) {
integrator->beginIfBlock(cit->getStringProperty("computationExpression"));
} else if(computationType == CustomIntegrator::WhileBlockStart) {
integrator->beginWhileBlock(cit->getStringProperty("computationExpression"));
} else if(computationType == CustomIntegrator::BlockEnd) {
integrator->endBlock();
} else { } else {
throw(OpenMMException("Custom Integrator Deserialization: Unknown computation type")); throw(OpenMMException("Custom Integrator Deserialization: Unknown computation type"));
} }
...@@ -115,4 +121,4 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const { ...@@ -115,4 +121,4 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const {
integrator->setRandomNumberSeed(node.getIntProperty("randomSeed")); integrator->setRandomNumberSeed(node.getIntProperty("randomSeed"));
integrator->setConstraintTolerance(node.getDoubleProperty("constraintTolerance")); integrator->setConstraintTolerance(node.getDoubleProperty("constraintTolerance"));
return integrator; return integrator;
} }
\ No newline at end of file
...@@ -137,12 +137,20 @@ void testSerializeCustomIntegrator() { ...@@ -137,12 +137,20 @@ void testSerializeCustomIntegrator() {
intg->addGlobalVariable("oute", 0); intg->addGlobalVariable("oute", 0);
intg->addGlobalVariable("oute1", 0); intg->addGlobalVariable("oute1", 0);
intg->addGlobalVariable("oute2", 0); intg->addGlobalVariable("oute2", 0);
intg->addGlobalVariable("conditional_v1", 0);
intg->addGlobalVariable("conditional_v2", 0);
intg->addComputePerDof("outf", "f"); intg->addComputePerDof("outf", "f");
intg->addComputePerDof("outf1", "f1"); intg->addComputePerDof("outf1", "f1");
intg->addComputePerDof("outf2", "f2"); intg->addComputePerDof("outf2", "f2");
intg->addComputeGlobal("oute", "energy"); intg->addComputeGlobal("oute", "energy");
intg->addComputeGlobal("oute1", "energy1"); intg->addComputeGlobal("oute1", "energy1");
intg->addComputeGlobal("oute2", "energy2"); intg->addComputeGlobal("oute2", "energy2");
intg->beginIfBlock("1 > 0");
intg->addComputeGlobal("conditional_v1", "1");
intg->endBlock();
intg->beginWhileBlock("0 > 1");
intg->addComputeGlobal("conditional_v2", "1");
intg->endBlock();
intg->addUpdateContextState(); intg->addUpdateContextState();
intg->addConstrainVelocities(); intg->addConstrainVelocities();
intg->addComputeSum("summand2", "v*v+f*f"); intg->addComputeSum("summand2", "v*v+f*f");
...@@ -216,7 +224,7 @@ int main() { ...@@ -216,7 +224,7 @@ int main() {
testSerializeVerletIntegrator(); testSerializeVerletIntegrator();
testSerializeVariableLangevinIntegrator(); testSerializeVariableLangevinIntegrator();
testSerializeVariableVerletIntegrator(); testSerializeVariableVerletIntegrator();
testSerializeLangevinIntegrator(); testSerializeLangevinIntegrator();
testSerializeCompoundIntegrator(); testSerializeCompoundIntegrator();
} }
catch(const exception& e) { catch(const exception& e) {
...@@ -224,5 +232,3 @@ int main() { ...@@ -224,5 +232,3 @@ int main() {
} }
return 0; return 0;
} }
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