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

Merge branch 'master' into gayberne

parents 8f532e31 a4d327f5
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -354,12 +354,57 @@ void testOneAngle() {
compareWithExpectedForceAndEnergy(context, *amoebaInPlaneAngleForce, TOL, "testOneInPlaneAngle");
}
void testPeriodic() {
// Create a force that uses periodic boundary conditions.
System system;
system.setDefaultPeriodicBoxVectors(Vec3(3, 0, 0), Vec3(0, 3, 0), Vec3(0, 0, 3));
int numberOfParticles = 4;
for (int ii = 0; ii < numberOfParticles; ii++)
system.addParticle(1.0);
LangevinIntegrator integrator(0.0, 0.1, 0.01);
AmoebaInPlaneAngleForce* amoebaInPlaneAngleForce = new AmoebaInPlaneAngleForce();
double angle = 65.0;
double quadraticK = 1.0;
double cubicK = 0.0e-01;
double quarticK = 0.0e-02;
double penticK = 0.0e-03;
double sexticK = 0.0e-04;
amoebaInPlaneAngleForce->addAngle(0, 1, 2, 3, angle, quadraticK);
amoebaInPlaneAngleForce->setAmoebaGlobalInPlaneAngleCubic(cubicK);
amoebaInPlaneAngleForce->setAmoebaGlobalInPlaneAngleQuartic(quarticK);
amoebaInPlaneAngleForce->setAmoebaGlobalInPlaneAnglePentic(penticK);
amoebaInPlaneAngleForce->setAmoebaGlobalInPlaneAngleSextic(sexticK);
amoebaInPlaneAngleForce->setUsesPeriodicBoundaryConditions(true);
system.addForce(amoebaInPlaneAngleForce);
Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numberOfParticles);
positions[0] = Vec3(0, 1, 0);
positions[1] = Vec3(0, 0, 0);
positions[2] = Vec3(0, 0, 1);
positions[3] = Vec3(1, 1, 1);
context.setPositions(positions);
State s1 = context.getState(State::Forces | State::Energy);
// Move one atom to a position that should give identical results.
positions[2] = Vec3(0, 0, -2);
context.setPositions(positions);
State s2 = context.getState(State::Forces | State::Energy);
ASSERT_EQUAL_TOL(s1.getPotentialEnergy(), s2.getPotentialEnergy(), 1e-5);
for (int i = 0; i < numberOfParticles; i++)
ASSERT_EQUAL_VEC(s1.getForces()[i], s2.getForces()[i], 1e-5);
}
int main(int numberOfArguments, char* argv[]) {
try {
std::cout << "TestReferenceAmoebaInPlaneAngleForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories();
testOneAngle();
testPeriodic();
}
catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -461,12 +461,50 @@ void testOneOutOfPlaneBend2(int setId) {
}
}
void testPeriodic() {
// Create a force that uses periodic boundary conditions.
System system;
system.setDefaultPeriodicBoxVectors(Vec3(3, 0, 0), Vec3(0, 3, 0), Vec3(0, 0, 3));
int numberOfParticles = 4;
for (int ii = 0; ii < numberOfParticles; ii++)
system.addParticle(1.0);
LangevinIntegrator integrator(0.0, 0.1, 0.01);
AmoebaOutOfPlaneBendForce* amoebaOutOfPlaneBendForce = new AmoebaOutOfPlaneBendForce();
amoebaOutOfPlaneBendForce->setAmoebaGlobalOutOfPlaneBendCubic( -0.1400000E-01);
amoebaOutOfPlaneBendForce->setAmoebaGlobalOutOfPlaneBendQuartic(0.5600000E-04);
amoebaOutOfPlaneBendForce->setAmoebaGlobalOutOfPlaneBendPentic(-0.7000000E-06);
amoebaOutOfPlaneBendForce->setAmoebaGlobalOutOfPlaneBendSextic( 0.2200000E-07);
double kOutOfPlaneBend = 0.328682196E-01;
amoebaOutOfPlaneBendForce->addOutOfPlaneBend(0, 1, 2, 3, kOutOfPlaneBend);
amoebaOutOfPlaneBendForce->setUsesPeriodicBoundaryConditions(true);
system.addForce(amoebaOutOfPlaneBendForce);
Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numberOfParticles);
positions[0] = Vec3(0, 0, 0);
positions[1] = Vec3(1, 0, 0);
positions[2] = Vec3(0, 1, 0);
positions[3] = Vec3(0, 0, 1);
context.setPositions(positions);
State s1 = context.getState(State::Forces | State::Energy);
// Move one atom to a position that should give identical results.
positions[3] = Vec3(0, 0, -2);
context.setPositions(positions);
State s2 = context.getState(State::Forces | State::Energy);
ASSERT_EQUAL_TOL(s1.getPotentialEnergy(), s2.getPotentialEnergy(), 1e-5);
for (int i = 0; i < numberOfParticles; i++)
ASSERT_EQUAL_VEC(s1.getForces()[i], s2.getForces()[i], 1e-5);
}
int main(int numberOfArguments, char* argv[]) {
try {
std::cout << "TestReferenceAmoebaOutOfPlaneBendForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories();
testOneOutOfPlaneBend();
testPeriodic();
//testOneOutOfPlaneBend2(atoi(argv[1]));
//for (int ii = 1; ii <= 6; ii++) {
// testOneOutOfPlaneBend2(ii);
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -290,12 +290,48 @@ void testOnePiTorsion() {
compareWithExpectedForceAndEnergy(context, *amoebaPiTorsionForce, TOL, "testOnePiTorsion");
}
void testPeriodic() {
// Create a force that uses periodic boundary conditions.
System system;
system.setDefaultPeriodicBoxVectors(Vec3(3, 0, 0), Vec3(0, 3, 0), Vec3(0, 0, 3));
int numberOfParticles = 6;
for (int ii = 0; ii < numberOfParticles; ii++)
system.addParticle(1.0);
LangevinIntegrator integrator(0.0, 0.1, 0.01);
AmoebaPiTorsionForce* amoebaPiTorsionForce = new AmoebaPiTorsionForce();
double kTorsion = 6.85;
amoebaPiTorsionForce->addPiTorsion(0, 1, 2, 3, 4, 5, kTorsion);
amoebaPiTorsionForce->setUsesPeriodicBoundaryConditions(true);
system.addForce(amoebaPiTorsionForce);
Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numberOfParticles);
positions[0] = Vec3(0, 1, 0);
positions[1] = Vec3(0, 0, 0);
positions[2] = Vec3(0, 0, 0.5);
positions[3] = Vec3(0.4, 0.4, 0.4);
positions[4] = Vec3(1, 0, 1);
positions[5] = Vec3(1, 1, 0);
context.setPositions(positions);
State s1 = context.getState(State::Forces | State::Energy);
// Move one atom to a position that should give identical results.
positions[0] = Vec3(0, -2, 0);
context.setPositions(positions);
State s2 = context.getState(State::Forces | State::Energy);
ASSERT_EQUAL_TOL(s1.getPotentialEnergy(), s2.getPotentialEnergy(), 1e-5);
for (int i = 0; i < numberOfParticles; i++)
ASSERT_EQUAL_VEC(s1.getForces()[i], s2.getForces()[i], 1e-5);
}
int main(int numberOfArguments, char* argv[]) {
try {
std::cout << "TestReferenceAmoebaPiTorsionForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories();
testOnePiTorsion();
testPeriodic();
}
catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -270,12 +270,48 @@ void testOneStretchBend() {
compareWithExpectedForceAndEnergy(context, *amoebaStretchBendForce, TOL, "testOneStretchBend");
}
void testPeriodic() {
// Create a force that uses periodic boundary conditions.
System system;
system.setDefaultPeriodicBoxVectors(Vec3(3, 0, 0), Vec3(0, 3, 0), Vec3(0, 0, 3));
int numberOfParticles = 3;
for (int ii = 0; ii < numberOfParticles; ii++)
system.addParticle(1.0);
LangevinIntegrator integrator(0.0, 0.1, 0.01);
AmoebaStretchBendForce* amoebaStretchBendForce = new AmoebaStretchBendForce();
double abLength = 0.144800000E+01;
double cbLength = 0.101500000E+01;
double angleStretchBend = 0.108500000E+03*DegreesToRadians;
double kStretchBend = 1.0;
amoebaStretchBendForce->addStretchBend(0, 1, 2, abLength, cbLength, angleStretchBend, kStretchBend, kStretchBend);
amoebaStretchBendForce->setUsesPeriodicBoundaryConditions(true);
system.addForce(amoebaStretchBendForce);
Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numberOfParticles);
positions[0] = Vec3(0, 1, 0);
positions[1] = Vec3(0, 0, 0);
positions[2] = Vec3(0, 0, 1);
context.setPositions(positions);
State s1 = context.getState(State::Forces | State::Energy);
// Move one atom to a position that should give identical results.
positions[2] = Vec3(0, 0, -2);
context.setPositions(positions);
State s2 = context.getState(State::Forces | State::Energy);
ASSERT_EQUAL_TOL(s1.getPotentialEnergy(), s2.getPotentialEnergy(), 1e-5);
for (int i = 0; i < numberOfParticles; i++)
ASSERT_EQUAL_VEC(s1.getForces()[i], s2.getForces()[i], 1e-5);
}
int main(int numberOfArguments, char* argv[]) {
try {
std::cout << "TestReferenceAmoebaStretchBendForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories();
testOneStretchBend();
testPeriodic();
}
catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
......
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008 Stanford University and the Authors. *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
......@@ -2669,6 +2669,44 @@ void testTorsionTorsion(int systemId, bool includeDerivs) {
ASSERT_EQUAL_TOL(expectedEnergy, state.getPotentialEnergy(), tolerance);
}
void testPeriodic() {
// Create a force that uses periodic boundary conditions.
System system;
system.setDefaultPeriodicBoxVectors(Vec3(3, 0, 0), Vec3(0, 3, 0), Vec3(0, 0, 3));
int numberOfParticles = 6;
for (int ii = 0; ii < numberOfParticles; ii++)
system.addParticle(1.0);
LangevinIntegrator integrator(0.0, 0.1, 0.01);
AmoebaTorsionTorsionForce* amoebaTorsionTorsionForce = new AmoebaTorsionTorsionForce();
int chiralCheckAtomIndex;
int gridIndex;
chiralCheckAtomIndex = 5;
gridIndex = 2;
amoebaTorsionTorsionForce->addTorsionTorsion(0, 1, 2, 3, 4, chiralCheckAtomIndex, 0);
amoebaTorsionTorsionForce->setTorsionTorsionGrid(0, getTorsionGrid(gridIndex, false));
amoebaTorsionTorsionForce->setUsesPeriodicBoundaryConditions(true);
system.addForce(amoebaTorsionTorsionForce);
Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numberOfParticles);
positions[0] = Vec3(0, 1, 0);
positions[1] = Vec3(0, 0, 0);
positions[2] = Vec3(0, 0, 0.5);
positions[3] = Vec3(0.4, 0.4, 0.4);
positions[4] = Vec3(1, 0, 1);
positions[5] = Vec3(1, 1, 0);
context.setPositions(positions);
State s1 = context.getState(State::Forces | State::Energy);
// Move one atom to a position that should give identical results.
positions[0] = Vec3(0, -2, 0);
context.setPositions(positions);
State s2 = context.getState(State::Forces | State::Energy);
ASSERT_EQUAL_TOL(s1.getPotentialEnergy(), s2.getPotentialEnergy(), 1e-5);
for (int i = 0; i < numberOfParticles; i++)
ASSERT_EQUAL_VEC(s1.getForces()[i], s2.getForces()[i], 1e-5);
}
int main(int numberOfArguments, char* argv[]) {
......@@ -2677,6 +2715,7 @@ int main(int numberOfArguments, char* argv[]) {
registerAmoebaReferenceKernelFactories();
testTorsionTorsion(1, true);
testTorsionTorsion(1, false);
testPeriodic();
}
catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl;
......
......@@ -42,11 +42,12 @@ AmoebaAngleForceProxy::AmoebaAngleForceProxy() : SerializationProxy("AmoebaAngle
}
void AmoebaAngleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 2);
node.setIntProperty("version", 3);
const AmoebaAngleForce& force = *reinterpret_cast<const AmoebaAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setDoubleProperty("cubic", force.getAmoebaGlobalAngleCubic());
node.setDoubleProperty("quartic", force.getAmoebaGlobalAngleQuartic());
node.setDoubleProperty("pentic", force.getAmoebaGlobalAnglePentic());
......@@ -63,12 +64,14 @@ void AmoebaAngleForceProxy::serialize(const void* object, SerializationNode& nod
void* AmoebaAngleForceProxy::deserialize(const SerializationNode& node) const {
int version = node.getIntProperty("version");
if (version < 1 || version > 2)
if (version < 1 || version > 3)
throw OpenMMException("Unsupported version number");
AmoebaAngleForce* force = new AmoebaAngleForce();
try {
if (version > 1)
force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 2)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
force->setAmoebaGlobalAngleCubic(node.getDoubleProperty("cubic"));
force->setAmoebaGlobalAngleQuartic(node.getDoubleProperty("quartic"));
force->setAmoebaGlobalAnglePentic(node.getDoubleProperty("pentic"));
......
......@@ -42,10 +42,11 @@ AmoebaBondForceProxy::AmoebaBondForceProxy() : SerializationProxy("AmoebaBondFor
}
void AmoebaBondForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 2);
node.setIntProperty("version", 3);
const AmoebaBondForce& force = *reinterpret_cast<const AmoebaBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setDoubleProperty("cubic", force.getAmoebaGlobalBondCubic());
node.setDoubleProperty("quartic", force.getAmoebaGlobalBondQuartic());
......@@ -60,12 +61,14 @@ void AmoebaBondForceProxy::serialize(const void* object, SerializationNode& node
void* AmoebaBondForceProxy::deserialize(const SerializationNode& node) const {
int version = node.getIntProperty("version");
if (version < 1 || version > 2)
if (version < 1 || version > 3)
throw OpenMMException("Unsupported version number");
AmoebaBondForce* force = new AmoebaBondForce();
try {
if (version > 1)
force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 2)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
force->setAmoebaGlobalBondCubic(node.getDoubleProperty("cubic"));
force->setAmoebaGlobalBondQuartic(node.getDoubleProperty("quartic"));
const SerializationNode& bonds = node.getChildNode("Bonds");
......
......@@ -43,10 +43,11 @@ AmoebaInPlaneAngleForceProxy::AmoebaInPlaneAngleForceProxy() : SerializationProx
void AmoebaInPlaneAngleForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 2);
node.setIntProperty("version", 3);
const AmoebaInPlaneAngleForce& force = *reinterpret_cast<const AmoebaInPlaneAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setDoubleProperty("cubic", force.getAmoebaGlobalInPlaneAngleCubic());
node.setDoubleProperty("quartic", force.getAmoebaGlobalInPlaneAngleQuartic());
node.setDoubleProperty("pentic", force.getAmoebaGlobalInPlaneAnglePentic());
......@@ -63,12 +64,14 @@ void AmoebaInPlaneAngleForceProxy::serialize(const void* object, SerializationNo
void* AmoebaInPlaneAngleForceProxy::deserialize(const SerializationNode& node) const {
int version = node.getIntProperty("version");
if (version < 1 || version > 2)
if (version < 1 || version > 3)
throw OpenMMException("Unsupported version number");
AmoebaInPlaneAngleForce* force = new AmoebaInPlaneAngleForce();
try {
if (version > 1)
force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 2)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
force->setAmoebaGlobalInPlaneAngleCubic( node.getDoubleProperty("cubic"));
force->setAmoebaGlobalInPlaneAngleQuartic(node.getDoubleProperty("quartic"));
force->setAmoebaGlobalInPlaneAnglePentic(node.getDoubleProperty("pentic"));
......
......@@ -42,9 +42,10 @@ AmoebaOutOfPlaneBendForceProxy::AmoebaOutOfPlaneBendForceProxy() : Serialization
}
void AmoebaOutOfPlaneBendForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 2);
node.setIntProperty("version", 3);
const AmoebaOutOfPlaneBendForce& force = *reinterpret_cast<const AmoebaOutOfPlaneBendForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setDoubleProperty("cubic", force.getAmoebaGlobalOutOfPlaneBendCubic());
node.setDoubleProperty("quartic", force.getAmoebaGlobalOutOfPlaneBendQuartic());
node.setDoubleProperty("pentic", force.getAmoebaGlobalOutOfPlaneBendPentic());
......@@ -61,12 +62,14 @@ void AmoebaOutOfPlaneBendForceProxy::serialize(const void* object, Serialization
void* AmoebaOutOfPlaneBendForceProxy::deserialize(const SerializationNode& node) const {
int version = node.getIntProperty("version");
if (version < 1 || version > 2)
if (version < 1 || version > 3)
throw OpenMMException("Unsupported version number");
AmoebaOutOfPlaneBendForce* force = new AmoebaOutOfPlaneBendForce();
try {
if (version > 1)
force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 2)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
force->setAmoebaGlobalOutOfPlaneBendCubic(node.getDoubleProperty("cubic"));
force->setAmoebaGlobalOutOfPlaneBendQuartic(node.getDoubleProperty("quartic"));
force->setAmoebaGlobalOutOfPlaneBendPentic(node.getDoubleProperty("pentic"));
......
......@@ -42,9 +42,10 @@ AmoebaPiTorsionForceProxy::AmoebaPiTorsionForceProxy() : SerializationProxy("Amo
}
void AmoebaPiTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 2);
node.setIntProperty("version", 3);
const AmoebaPiTorsionForce& force = *reinterpret_cast<const AmoebaPiTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
SerializationNode& bonds = node.createChildNode("PiTorsion");
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force.getNumPiTorsions()); ii++) {
int particle1, particle2, particle3, particle4, particle5, particle6;
......@@ -56,12 +57,14 @@ void AmoebaPiTorsionForceProxy::serialize(const void* object, SerializationNode&
void* AmoebaPiTorsionForceProxy::deserialize(const SerializationNode& node) const {
int version = node.getIntProperty("version");
if (version < 1 || version > 2)
if (version < 1 || version > 3)
throw OpenMMException("Unsupported version number");
AmoebaPiTorsionForce* force = new AmoebaPiTorsionForce();
try {
if (version > 1)
force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 2)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
const SerializationNode& bonds = node.getChildNode("PiTorsion");
for (unsigned int ii = 0; ii < bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[ii];
......
......@@ -42,9 +42,10 @@ AmoebaStretchBendForceProxy::AmoebaStretchBendForceProxy() : SerializationProxy(
}
void AmoebaStretchBendForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 3);
node.setIntProperty("version", 4);
const AmoebaStretchBendForce& force = *reinterpret_cast<const AmoebaStretchBendForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
SerializationNode& bonds = node.createChildNode("StretchBendAngles");
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force.getNumStretchBends()); ii++) {
int particle1, particle2, particle3;
......@@ -57,12 +58,14 @@ void AmoebaStretchBendForceProxy::serialize(const void* object, SerializationNod
void* AmoebaStretchBendForceProxy::deserialize(const SerializationNode& node) const {
int version = node.getIntProperty("version");
if (version < 1 || version > 3)
if (version < 1 || version > 4)
throw OpenMMException("Unsupported version number");
AmoebaStretchBendForce* force = new AmoebaStretchBendForce();
try {
if (version > 2)
force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 3)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
const SerializationNode& bonds = node.getChildNode("StretchBendAngles");
for (unsigned int ii = 0; ii < (int) bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[ii];
......
......@@ -63,9 +63,10 @@ static void loadGrid(const SerializationNode& grid, std::vector< std::vector< st
}
void AmoebaTorsionTorsionForceProxy::serialize(const void* object, SerializationNode& node) const {
node.setIntProperty("version", 2);
node.setIntProperty("version", 3);
const AmoebaTorsionTorsionForce& force = *reinterpret_cast<const AmoebaTorsionTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
// grid[xIdx][yIdx][6 values]
......@@ -118,13 +119,15 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization
void* AmoebaTorsionTorsionForceProxy::deserialize(const SerializationNode& node) const {
int version = node.getIntProperty("version");
if (version < 1 || version > 2)
if (version < 1 || version > 3)
throw OpenMMException("Unsupported version number");
AmoebaTorsionTorsionForce* force = new AmoebaTorsionTorsionForce();
try {
if (version > 1)
force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 2)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
const SerializationNode& grids = node.getChildNode("TorsionTorsionGrids");
const std::vector<SerializationNode>& gridList = grids.getChildren();
for (unsigned int ii = 0; ii < gridList.size(); ii++) {
......
......@@ -54,6 +54,7 @@ void testSerialization() {
force1.addAngle(0, 2, 3, 2.0, 2.1);
force1.addAngle(2, 3, 5, 3.0, 2.2);
force1.addAngle(5, 1, 8, 4.0, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it.
......@@ -64,6 +65,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical.
AmoebaAngleForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getAmoebaGlobalAngleCubic(), force2.getAmoebaGlobalAngleCubic());
ASSERT_EQUAL(force1.getAmoebaGlobalAngleQuartic(), force2.getAmoebaGlobalAngleQuartic());
ASSERT_EQUAL(force1.getAmoebaGlobalAnglePentic(), force2.getAmoebaGlobalAnglePentic());
......
......@@ -52,6 +52,7 @@ void testSerialization() {
force1.addBond(0, 2, 2.0, 2.1);
force1.addBond(2, 3, 3.0, 2.2);
force1.addBond(5, 1, 4.0, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it.
......@@ -62,6 +63,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical.
AmoebaBondForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getAmoebaGlobalBondCubic(), force2.getAmoebaGlobalBondCubic());
ASSERT_EQUAL(force1.getAmoebaGlobalBondQuartic(), force2.getAmoebaGlobalBondQuartic());
ASSERT_EQUAL(force1.getNumBonds(), force2.getNumBonds());
......
......@@ -56,6 +56,7 @@ void testSerialization() {
force1.addAngle(0, 2, 3, 5, 2.0, 2.1);
force1.addAngle(2, 3, 5, 6, 3.0, 2.2);
force1.addAngle(5, 1, 8, 8, 4.0, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it.
......@@ -67,6 +68,7 @@ void testSerialization() {
AmoebaInPlaneAngleForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAngleCubic(), force2.getAmoebaGlobalInPlaneAngleCubic());
ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAngleQuartic(), force2.getAmoebaGlobalInPlaneAngleQuartic());
ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAnglePentic(), force2.getAmoebaGlobalInPlaneAnglePentic());
......
......@@ -56,6 +56,7 @@ void testSerialization() {
force1.addOutOfPlaneBend(0, 2, 3, 5, 2.1);
force1.addOutOfPlaneBend(2, 3, 5, 6, 2.2);
force1.addOutOfPlaneBend(5, 1, 8, 8, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it.
......@@ -67,6 +68,7 @@ void testSerialization() {
AmoebaOutOfPlaneBendForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendCubic(), force2.getAmoebaGlobalOutOfPlaneBendCubic());
ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendQuartic(), force2.getAmoebaGlobalOutOfPlaneBendQuartic());
ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendPentic(), force2.getAmoebaGlobalOutOfPlaneBendPentic());
......
......@@ -50,6 +50,7 @@ void testSerialization() {
force1.addPiTorsion(0, 2, 3, 5, 12, 13, 2.1);
force1.addPiTorsion(2, 3, 5, 6, 81, 91, 2.2);
force1.addPiTorsion(5, 1, 8, 8, 101, 102, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it.
......@@ -60,6 +61,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical.
AmoebaPiTorsionForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getNumPiTorsions(), force2.getNumPiTorsions());
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumPiTorsions()); ii++) {
int a1, a2, a3, a4, a5, a6, b1, b2, b3, b4, b5, b6;
......
......@@ -49,6 +49,7 @@ void testSerialization() {
force1.addStretchBend(0, 1, 3, 1.0, 1.2, 150.1, 83.2, 100.);
force1.addStretchBend(2, 4, 4, 1.1, 2.2, 180.1, 89.2, 100.);
force1.addStretchBend(5, 0, 1, 3.1, 8.2, 140.1, 98.2, 100.);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it.
......@@ -59,6 +60,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical.
AmoebaStretchBendForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getNumStretchBends(), force2.getNumStretchBends());
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumStretchBends()); ii++) {
int p11, p12, p13;
......
......@@ -90,6 +90,7 @@ void testSerialization() {
for (unsigned int ii = 0; ii < 5; ii++) {
force1.addTorsionTorsion(ii, ii+1,ii+3, ii+4, ii+5, ((ii % 2) ? 1 : 0), (ii % 4));
}
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it.
......@@ -101,6 +102,7 @@ void testSerialization() {
AmoebaTorsionTorsionForce & force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getNumTorsionTorsions(), force2.getNumTorsionTorsions());
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumTorsionTorsions()); ii++) {
......
......@@ -197,7 +197,7 @@ int main(int argc, char* argv[]) {
try {
registerDrudeCudaKernelFactories();
if (argc > 1)
Platform::getPlatformByName("CUDA").setPropertyDefaultValue("CudaPrecision", std::string(argv[1]));
Platform::getPlatformByName("CUDA").setPropertyDefaultValue("Precision", std::string(argv[1]));
testSingleParticle();
testAnisotropicParticle();
testThole();
......
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