"libraries/lepton/vscode:/vscode.git/clone" did not exist on "27550631f116a3538653447666054e69105c7c75"
Commit 8190f243 authored by peastman's avatar peastman
Browse files

Merge pull request #1467 from peastman/amoebaperiodic

Periodic boundary conditions for AMOEBA bonded forces
parents fd289aae c54126a0
...@@ -63,9 +63,10 @@ static void loadGrid(const SerializationNode& grid, std::vector< std::vector< st ...@@ -63,9 +63,10 @@ static void loadGrid(const SerializationNode& grid, std::vector< std::vector< st
} }
void AmoebaTorsionTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { 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); const AmoebaTorsionTorsionForce& force = *reinterpret_cast<const AmoebaTorsionTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
// grid[xIdx][yIdx][6 values] // grid[xIdx][yIdx][6 values]
...@@ -118,13 +119,15 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization ...@@ -118,13 +119,15 @@ void AmoebaTorsionTorsionForceProxy::serialize(const void* object, Serialization
void* AmoebaTorsionTorsionForceProxy::deserialize(const SerializationNode& node) const { void* AmoebaTorsionTorsionForceProxy::deserialize(const SerializationNode& node) const {
int version = node.getIntProperty("version"); int version = node.getIntProperty("version");
if (version < 1 || version > 2) if (version < 1 || version > 3)
throw OpenMMException("Unsupported version number"); throw OpenMMException("Unsupported version number");
AmoebaTorsionTorsionForce* force = new AmoebaTorsionTorsionForce(); AmoebaTorsionTorsionForce* force = new AmoebaTorsionTorsionForce();
try { try {
if (version > 1) if (version > 1)
force->setForceGroup(node.getIntProperty("forceGroup", 0)); force->setForceGroup(node.getIntProperty("forceGroup", 0));
if (version > 2)
force->setUsesPeriodicBoundaryConditions(node.getBoolProperty("usesPeriodic"));
const SerializationNode& grids = node.getChildNode("TorsionTorsionGrids"); const SerializationNode& grids = node.getChildNode("TorsionTorsionGrids");
const std::vector<SerializationNode>& gridList = grids.getChildren(); const std::vector<SerializationNode>& gridList = grids.getChildren();
for (unsigned int ii = 0; ii < gridList.size(); ii++) { for (unsigned int ii = 0; ii < gridList.size(); ii++) {
......
...@@ -54,6 +54,7 @@ void testSerialization() { ...@@ -54,6 +54,7 @@ void testSerialization() {
force1.addAngle(0, 2, 3, 2.0, 2.1); force1.addAngle(0, 2, 3, 2.0, 2.1);
force1.addAngle(2, 3, 5, 3.0, 2.2); force1.addAngle(2, 3, 5, 3.0, 2.2);
force1.addAngle(5, 1, 8, 4.0, 2.3); force1.addAngle(5, 1, 8, 4.0, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -64,6 +65,7 @@ void testSerialization() { ...@@ -64,6 +65,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical. // Compare the two forces to see if they are identical.
AmoebaAngleForce& force2 = *copy; AmoebaAngleForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getAmoebaGlobalAngleCubic(), force2.getAmoebaGlobalAngleCubic()); ASSERT_EQUAL(force1.getAmoebaGlobalAngleCubic(), force2.getAmoebaGlobalAngleCubic());
ASSERT_EQUAL(force1.getAmoebaGlobalAngleQuartic(), force2.getAmoebaGlobalAngleQuartic()); ASSERT_EQUAL(force1.getAmoebaGlobalAngleQuartic(), force2.getAmoebaGlobalAngleQuartic());
ASSERT_EQUAL(force1.getAmoebaGlobalAnglePentic(), force2.getAmoebaGlobalAnglePentic()); ASSERT_EQUAL(force1.getAmoebaGlobalAnglePentic(), force2.getAmoebaGlobalAnglePentic());
......
...@@ -52,6 +52,7 @@ void testSerialization() { ...@@ -52,6 +52,7 @@ void testSerialization() {
force1.addBond(0, 2, 2.0, 2.1); force1.addBond(0, 2, 2.0, 2.1);
force1.addBond(2, 3, 3.0, 2.2); force1.addBond(2, 3, 3.0, 2.2);
force1.addBond(5, 1, 4.0, 2.3); force1.addBond(5, 1, 4.0, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -62,6 +63,7 @@ void testSerialization() { ...@@ -62,6 +63,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical. // Compare the two forces to see if they are identical.
AmoebaBondForce& force2 = *copy; AmoebaBondForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getAmoebaGlobalBondCubic(), force2.getAmoebaGlobalBondCubic()); ASSERT_EQUAL(force1.getAmoebaGlobalBondCubic(), force2.getAmoebaGlobalBondCubic());
ASSERT_EQUAL(force1.getAmoebaGlobalBondQuartic(), force2.getAmoebaGlobalBondQuartic()); ASSERT_EQUAL(force1.getAmoebaGlobalBondQuartic(), force2.getAmoebaGlobalBondQuartic());
ASSERT_EQUAL(force1.getNumBonds(), force2.getNumBonds()); ASSERT_EQUAL(force1.getNumBonds(), force2.getNumBonds());
......
...@@ -56,6 +56,7 @@ void testSerialization() { ...@@ -56,6 +56,7 @@ void testSerialization() {
force1.addAngle(0, 2, 3, 5, 2.0, 2.1); force1.addAngle(0, 2, 3, 5, 2.0, 2.1);
force1.addAngle(2, 3, 5, 6, 3.0, 2.2); force1.addAngle(2, 3, 5, 6, 3.0, 2.2);
force1.addAngle(5, 1, 8, 8, 4.0, 2.3); force1.addAngle(5, 1, 8, 8, 4.0, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -67,6 +68,7 @@ void testSerialization() { ...@@ -67,6 +68,7 @@ void testSerialization() {
AmoebaInPlaneAngleForce& force2 = *copy; AmoebaInPlaneAngleForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAngleCubic(), force2.getAmoebaGlobalInPlaneAngleCubic()); ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAngleCubic(), force2.getAmoebaGlobalInPlaneAngleCubic());
ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAngleQuartic(), force2.getAmoebaGlobalInPlaneAngleQuartic()); ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAngleQuartic(), force2.getAmoebaGlobalInPlaneAngleQuartic());
ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAnglePentic(), force2.getAmoebaGlobalInPlaneAnglePentic()); ASSERT_EQUAL(force1.getAmoebaGlobalInPlaneAnglePentic(), force2.getAmoebaGlobalInPlaneAnglePentic());
......
...@@ -56,6 +56,7 @@ void testSerialization() { ...@@ -56,6 +56,7 @@ void testSerialization() {
force1.addOutOfPlaneBend(0, 2, 3, 5, 2.1); force1.addOutOfPlaneBend(0, 2, 3, 5, 2.1);
force1.addOutOfPlaneBend(2, 3, 5, 6, 2.2); force1.addOutOfPlaneBend(2, 3, 5, 6, 2.2);
force1.addOutOfPlaneBend(5, 1, 8, 8, 2.3); force1.addOutOfPlaneBend(5, 1, 8, 8, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -67,6 +68,7 @@ void testSerialization() { ...@@ -67,6 +68,7 @@ void testSerialization() {
AmoebaOutOfPlaneBendForce& force2 = *copy; AmoebaOutOfPlaneBendForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendCubic(), force2.getAmoebaGlobalOutOfPlaneBendCubic()); ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendCubic(), force2.getAmoebaGlobalOutOfPlaneBendCubic());
ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendQuartic(), force2.getAmoebaGlobalOutOfPlaneBendQuartic()); ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendQuartic(), force2.getAmoebaGlobalOutOfPlaneBendQuartic());
ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendPentic(), force2.getAmoebaGlobalOutOfPlaneBendPentic()); ASSERT_EQUAL(force1.getAmoebaGlobalOutOfPlaneBendPentic(), force2.getAmoebaGlobalOutOfPlaneBendPentic());
......
...@@ -50,6 +50,7 @@ void testSerialization() { ...@@ -50,6 +50,7 @@ void testSerialization() {
force1.addPiTorsion(0, 2, 3, 5, 12, 13, 2.1); force1.addPiTorsion(0, 2, 3, 5, 12, 13, 2.1);
force1.addPiTorsion(2, 3, 5, 6, 81, 91, 2.2); force1.addPiTorsion(2, 3, 5, 6, 81, 91, 2.2);
force1.addPiTorsion(5, 1, 8, 8, 101, 102, 2.3); force1.addPiTorsion(5, 1, 8, 8, 101, 102, 2.3);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -60,6 +61,7 @@ void testSerialization() { ...@@ -60,6 +61,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical. // Compare the two forces to see if they are identical.
AmoebaPiTorsionForce& force2 = *copy; AmoebaPiTorsionForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getNumPiTorsions(), force2.getNumPiTorsions()); ASSERT_EQUAL(force1.getNumPiTorsions(), force2.getNumPiTorsions());
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumPiTorsions()); ii++) { 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; int a1, a2, a3, a4, a5, a6, b1, b2, b3, b4, b5, b6;
......
...@@ -49,6 +49,7 @@ void testSerialization() { ...@@ -49,6 +49,7 @@ void testSerialization() {
force1.addStretchBend(0, 1, 3, 1.0, 1.2, 150.1, 83.2, 100.); 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(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.addStretchBend(5, 0, 1, 3.1, 8.2, 140.1, 98.2, 100.);
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -59,6 +60,7 @@ void testSerialization() { ...@@ -59,6 +60,7 @@ void testSerialization() {
// Compare the two forces to see if they are identical. // Compare the two forces to see if they are identical.
AmoebaStretchBendForce& force2 = *copy; AmoebaStretchBendForce& force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getNumStretchBends(), force2.getNumStretchBends()); ASSERT_EQUAL(force1.getNumStretchBends(), force2.getNumStretchBends());
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumStretchBends()); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumStretchBends()); ii++) {
int p11, p12, p13; int p11, p12, p13;
......
...@@ -90,6 +90,7 @@ void testSerialization() { ...@@ -90,6 +90,7 @@ void testSerialization() {
for (unsigned int ii = 0; ii < 5; ii++) { 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.addTorsionTorsion(ii, ii+1,ii+3, ii+4, ii+5, ((ii % 2) ? 1 : 0), (ii % 4));
} }
force1.setUsesPeriodicBoundaryConditions(true);
// Serialize and then deserialize it. // Serialize and then deserialize it.
...@@ -101,6 +102,7 @@ void testSerialization() { ...@@ -101,6 +102,7 @@ void testSerialization() {
AmoebaTorsionTorsionForce & force2 = *copy; AmoebaTorsionTorsionForce & force2 = *copy;
ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup()); ASSERT_EQUAL(force1.getForceGroup(), force2.getForceGroup());
ASSERT_EQUAL(force1.usesPeriodicBoundaryConditions(), force2.usesPeriodicBoundaryConditions());
ASSERT_EQUAL(force1.getNumTorsionTorsions(), force2.getNumTorsionTorsions()); ASSERT_EQUAL(force1.getNumTorsionTorsions(), force2.getNumTorsionTorsions());
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumTorsionTorsions()); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(force1.getNumTorsionTorsions()); ii++) {
......
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