Commit 73183c61 authored by ChayaSt's avatar ChayaSt
Browse files

resolved conflict

parents 0e218233 32e08b87
...@@ -28,6 +28,13 @@ ...@@ -28,6 +28,13 @@
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceOutOfPlaneBendForce::setPeriodic(OpenMM::RealVec* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
boxVectors[2] = vectors[2];
}
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba Out-Of-Plane-Bend ixn (force and energy) Calculate Amoeba Out-Of-Plane-Bend ixn (force and energy)
...@@ -78,12 +85,21 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const ...@@ -78,12 +85,21 @@ RealOpenMM AmoebaReferenceOutOfPlaneBendForce::calculateOutOfPlaneBendIxn(const
std::vector<RealOpenMM> deltaR[LastDeltaIndex]; std::vector<RealOpenMM> deltaR[LastDeltaIndex];
for (int ii = 0; ii < LastDeltaIndex; ii++) { for (int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomA, deltaR[AB]); if (usePeriodic) {
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomB, positionAtomA, deltaR[AB], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomD, deltaR[DB]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomB, positionAtomC, deltaR[CB], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomA, deltaR[AD]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomB, positionAtomD, deltaR[DB], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomC, deltaR[CD]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomD, positionAtomA, deltaR[AD], boxVectors);
AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomD, positionAtomC, deltaR[CD], boxVectors);
}
else {
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomA, deltaR[AB]);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomD, deltaR[DB]);
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomA, deltaR[AD]);
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomC, deltaR[CD]);
}
RealOpenMM rDB2 = AmoebaReferenceForce::getNormSquared3(deltaR[DB]); RealOpenMM rDB2 = AmoebaReferenceForce::getNormSquared3(deltaR[DB]);
RealOpenMM rAD2 = AmoebaReferenceForce::getNormSquared3(deltaR[AD]); RealOpenMM rAD2 = AmoebaReferenceForce::getNormSquared3(deltaR[AD]);
......
/* Portions copyright (c) 2006 Stanford University and Simbios. /* Portions copyright (c) 2006-2016 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
AmoebaReferenceOutOfPlaneBendForce() {}; AmoebaReferenceOutOfPlaneBendForce() : usePeriodic(false) {};
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -50,6 +50,16 @@ public: ...@@ -50,6 +50,16 @@ public:
~AmoebaReferenceOutOfPlaneBendForce() {}; ~AmoebaReferenceOutOfPlaneBendForce() {};
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba out-of-plane-bend angle (force and energy) Calculate Amoeba out-of-plane-bend angle (force and energy)
...@@ -86,6 +96,9 @@ public: ...@@ -86,6 +96,9 @@ public:
private: private:
bool usePeriodic;
RealVec boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba Out-Of-Plane-Bend ixn (force and energy) Calculate Amoeba Out-Of-Plane-Bend ixn (force and energy)
......
/* Portions copyright (c) 2006-2016 Stanford University and Simbios.
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -29,6 +28,13 @@ ...@@ -29,6 +28,13 @@
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferencePiTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
boxVectors[2] = vectors[2];
}
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba pi-torsion ixn (force and energy) Calculate Amoeba pi-torsion ixn (force and energy)
...@@ -66,11 +72,19 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p ...@@ -66,11 +72,19 @@ RealOpenMM AmoebaReferencePiTorsionForce::calculatePiTorsionIxn(const RealVec& p
std::vector<RealOpenMM> deltaR[LastDeltaIndex]; std::vector<RealOpenMM> deltaR[LastDeltaIndex];
for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) { for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomA, deltaR[AD]); if (usePeriodic) {
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomB, deltaR[BD]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomD, positionAtomA, deltaR[AD], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomE, deltaR[EC]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomD, positionAtomB, deltaR[BD], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomF, deltaR[FC]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomE, deltaR[EC], boxVectors);
AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomF, deltaR[FC], boxVectors);
}
else {
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomA, deltaR[AD]);
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomB, deltaR[BD]);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomE, deltaR[EC]);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomF, deltaR[FC]);
}
enum { A, B, C, D, E, F, LastAtomIndex }; enum { A, B, C, D, E, F, LastAtomIndex };
std::vector<RealOpenMM> d[LastAtomIndex]; std::vector<RealOpenMM> d[LastAtomIndex];
......
/* Portions copyright (c) 2006 Stanford University and Simbios. /* Portions copyright (c) 2006-2016 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
AmoebaReferencePiTorsionForce() {}; AmoebaReferencePiTorsionForce() : usePeriodic(false) {};
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -50,6 +50,16 @@ public: ...@@ -50,6 +50,16 @@ public:
~AmoebaReferencePiTorsionForce() {}; ~AmoebaReferencePiTorsionForce() {};
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba torsion ixns (force and energy) Calculate Amoeba torsion ixns (force and energy)
...@@ -85,6 +95,9 @@ public: ...@@ -85,6 +95,9 @@ public:
private: private:
bool usePeriodic;
RealVec boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba pi-torsion ixn (force and energy) Calculate Amoeba pi-torsion ixn (force and energy)
......
/* Portions copyright (c) 2006 Stanford University and Simbios. /* Portions copyright (c) 2006-2016 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -29,6 +29,13 @@ ...@@ -29,6 +29,13 @@
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceStretchBendForce::setPeriodic(OpenMM::RealVec* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
boxVectors[2] = vectors[2];
}
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba stretch bend angle ixn (force and energy) Calculate Amoeba stretch bend angle ixn (force and energy)
...@@ -76,8 +83,14 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe ...@@ -76,8 +83,14 @@ RealOpenMM AmoebaReferenceStretchBendForce::calculateStretchBendIxn(const RealVe
for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) { for (unsigned int ii = 0; ii < LastDeltaIndex; ii++) {
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomA, deltaR[AB]); if (usePeriodic) {
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomB, positionAtomA, deltaR[AB], boxVectors);
AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomB, positionAtomC, deltaR[CB], boxVectors);
}
else {
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomA, deltaR[AB]);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]);
}
RealOpenMM rAB2 = AmoebaReferenceForce::getNormSquared3(deltaR[AB]); RealOpenMM rAB2 = AmoebaReferenceForce::getNormSquared3(deltaR[AB]);
RealOpenMM rAB = SQRT(rAB2); RealOpenMM rAB = SQRT(rAB2);
RealOpenMM rCB2 = AmoebaReferenceForce::getNormSquared3(deltaR[CB]); RealOpenMM rCB2 = AmoebaReferenceForce::getNormSquared3(deltaR[CB]);
......
/* Portions copyright (c) 2006 Stanford University and Simbios. /* Portions copyright (c) 2006-2016 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
AmoebaReferenceStretchBendForce() {}; AmoebaReferenceStretchBendForce() : usePeriodic(false) {};
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -50,6 +50,16 @@ public: ...@@ -50,6 +50,16 @@ public:
~AmoebaReferenceStretchBendForce() {}; ~AmoebaReferenceStretchBendForce() {};
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba stretch bend ixns (force and energy) Calculate Amoeba stretch bend ixns (force and energy)
...@@ -84,6 +94,9 @@ public: ...@@ -84,6 +94,9 @@ public:
private: private:
bool usePeriodic;
RealVec boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba stretch bend angle ixn (force and energy) Calculate Amoeba stretch bend angle ixn (force and energy)
......
/* Portions copyright (c) 2006-2016 Stanford University and Simbios.
/* Portions copyright (c) 2006 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -28,6 +27,13 @@ ...@@ -28,6 +27,13 @@
using std::vector; using std::vector;
using namespace OpenMM; using namespace OpenMM;
void AmoebaReferenceTorsionTorsionForce::setPeriodic(OpenMM::RealVec* vectors) {
usePeriodic = true;
boxVectors[0] = vectors[0];
boxVectors[1] = vectors[1];
boxVectors[2] = vectors[2];
}
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Load grid values from rectenclosing angles Load grid values from rectenclosing angles
...@@ -294,9 +300,16 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign( ...@@ -294,9 +300,16 @@ int AmoebaReferenceTorsionTorsionForce::checkTorsionSign(
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomA, deltaR[CA]); if (usePeriodic) {
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomB, deltaR[CB]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomA, deltaR[CA], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomD, deltaR[CD]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomB, deltaR[CB], boxVectors);
AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomD, deltaR[CD], boxVectors);
}
else {
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomA, deltaR[CA]);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomB, deltaR[CB]);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomD, deltaR[CD]);
}
RealOpenMM volume = deltaR[CA][0]*(deltaR[CB][1]*deltaR[CD][2] - deltaR[CB][2]*deltaR[CD][1]) + RealOpenMM volume = deltaR[CA][0]*(deltaR[CB][1]*deltaR[CD][2] - deltaR[CB][2]*deltaR[CD][1]) +
deltaR[CB][0]*(deltaR[CD][1]*deltaR[CA][2] - deltaR[CD][2]*deltaR[CA][1]) + deltaR[CB][0]*(deltaR[CD][1]*deltaR[CA][2] - deltaR[CD][2]*deltaR[CA][1]) +
...@@ -351,13 +364,24 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const ...@@ -351,13 +364,24 @@ RealOpenMM AmoebaReferenceTorsionTorsionForce::calculateTorsionTorsionIxn(const
deltaR[ii].resize(3); deltaR[ii].resize(3);
} }
AmoebaReferenceForce::loadDeltaR(positionAtomA, positionAtomB, deltaR[BA]); if (usePeriodic) {
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomA, positionAtomB, deltaR[BA], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomD, deltaR[DC]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomB, positionAtomC, deltaR[CB], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomE, deltaR[ED]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomD, deltaR[DC], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomA, positionAtomC, deltaR[CA]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomD, positionAtomE, deltaR[ED], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomD, deltaR[DB]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomA, positionAtomC, deltaR[CA], boxVectors);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomE, deltaR[EC]); AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomB, positionAtomD, deltaR[DB], boxVectors);
AmoebaReferenceForce::loadDeltaRPeriodic(positionAtomC, positionAtomE, deltaR[EC], boxVectors);
}
else {
AmoebaReferenceForce::loadDeltaR(positionAtomA, positionAtomB, deltaR[BA]);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomC, deltaR[CB]);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomD, deltaR[DC]);
AmoebaReferenceForce::loadDeltaR(positionAtomD, positionAtomE, deltaR[ED]);
AmoebaReferenceForce::loadDeltaR(positionAtomA, positionAtomC, deltaR[CA]);
AmoebaReferenceForce::loadDeltaR(positionAtomB, positionAtomD, deltaR[DB]);
AmoebaReferenceForce::loadDeltaR(positionAtomC, positionAtomE, deltaR[EC]);
}
std::vector<RealOpenMM> d[LastAtomIndex]; std::vector<RealOpenMM> d[LastAtomIndex];
for (unsigned int ii = 0; ii < LastAtomIndex; ii++) { for (unsigned int ii = 0; ii < LastAtomIndex; ii++) {
......
/* Portions copyright (c) 2006 Stanford University and Simbios. /* Portions copyright (c) 2006-2016 Stanford University and Simbios.
* Contributors: Pande Group * Contributors: Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
AmoebaReferenceTorsionTorsionForce() {}; AmoebaReferenceTorsionTorsionForce() : usePeriodic(false) {};
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
...@@ -50,6 +50,16 @@ public: ...@@ -50,6 +50,16 @@ public:
~AmoebaReferenceTorsionTorsionForce() {}; ~AmoebaReferenceTorsionTorsionForce() {};
/**---------------------------------------------------------------------------------------
Set the force to use periodic boundary conditions.
@param vectors the vectors defining the periodic box
--------------------------------------------------------------------------------------- */
void setPeriodic(OpenMM::RealVec* vectors);
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Calculate Amoeba torsion-torsion ixns (force and energy) Calculate Amoeba torsion-torsion ixns (force and energy)
...@@ -84,6 +94,9 @@ public: ...@@ -84,6 +94,9 @@ public:
private: private:
bool usePeriodic;
RealVec boxVectors[3];
/**--------------------------------------------------------------------------------------- /**---------------------------------------------------------------------------------------
Load grid values from rectangle enclosing angles Load grid values from rectangle enclosing angles
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "openmm/internal/AssertionUtilities.h" #include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h" #include "openmm/Context.h"
#include "openmm/CustomAngleForce.h"
#include "OpenMMAmoeba.h" #include "OpenMMAmoeba.h"
#include "openmm/System.h" #include "openmm/System.h"
#include "openmm/LangevinIntegrator.h" #include "openmm/LangevinIntegrator.h"
...@@ -274,12 +275,63 @@ void testOneAngle() { ...@@ -274,12 +275,63 @@ void testOneAngle() {
compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle"); compareWithExpectedForceAndEnergy(context, *amoebaAngleForce, TOL, "testOneAngle");
} }
void testPeriodic() {
// Create a force that uses periodic boundary conditions, then compare to an identical custom force.
System system;
system.setDefaultPeriodicBoxVectors(Vec3(3, 0, 0), Vec3(0, 3, 0), Vec3(0, 0, 3));
int numParticles = 3;
for (int ii = 0; ii < numParticles; ii++)
system.addParticle(1.0);
LangevinIntegrator integrator(0.0, 0.1, 0.01);
AmoebaAngleForce* amoebaAngleForce = new AmoebaAngleForce();
double angle = 100.0;
double quadraticK = 1.0;
double cubicK = 1.0e-01;
double quarticK = 1.0e-02;
double penticK = 1.0e-03;
double sexticK = 1.0e-04;
amoebaAngleForce->addAngle(0, 1, 2, angle, quadraticK);
amoebaAngleForce->setAmoebaGlobalAngleCubic(cubicK);
amoebaAngleForce->setAmoebaGlobalAngleQuartic(quarticK);
amoebaAngleForce->setAmoebaGlobalAnglePentic(penticK);
amoebaAngleForce->setAmoebaGlobalAngleSextic(sexticK);
amoebaAngleForce->setUsesPeriodicBoundaryConditions(true);
system.addForce(amoebaAngleForce);
CustomAngleForce* customForce = new CustomAngleForce("k2*delta^2 + k3*delta^3 + k4*delta^4 + k5*delta^5 + k6*delta^6; delta=theta-theta0");
customForce->addGlobalParameter("theta0", angle*M_PI/180);
customForce->addGlobalParameter("k2", quadraticK*pow(180/M_PI, 2.0));
customForce->addGlobalParameter("k3", cubicK*pow(180/M_PI, 3.0));
customForce->addGlobalParameter("k4", quarticK*pow(180/M_PI, 4.0));
customForce->addGlobalParameter("k5", penticK*pow(180/M_PI, 5.0));
customForce->addGlobalParameter("k6", sexticK*pow(180/M_PI, 6.0));
customForce->addAngle(0, 1, 2);
customForce->setUsesPeriodicBoundaryConditions(true);
customForce->setForceGroup(1);
system.addForce(customForce);
Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numParticles);
positions[0] = Vec3(0, 1, 0);
positions[1] = Vec3(0, 0, 0);
positions[2] = Vec3(0, 0, 2);
context.setPositions(positions);
State s1 = context.getState(State::Forces | State::Energy, true, 1);
State s2 = context.getState(State::Forces | State::Energy, true, 2);
ASSERT_EQUAL_TOL(s2.getPotentialEnergy(), s1.getPotentialEnergy(), 1e-5);
for (int i = 0; i < numParticles; i++)
ASSERT_EQUAL_VEC(s2.getForces()[i], s1.getForces()[i], 1e-5);
}
int main(int numberOfArguments, char* argv[]) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestCudaAmoebaAngleForce running test..." << std::endl; std::cout << "TestReferenceAmoebaAngleForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
testOneAngle(); testOneAngle();
testPeriodic();
} }
catch(const std::exception& e) { catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "openmm/internal/AssertionUtilities.h" #include "openmm/internal/AssertionUtilities.h"
#include "openmm/Context.h" #include "openmm/Context.h"
#include "openmm/CustomBondForce.h"
#include "OpenMMAmoeba.h" #include "OpenMMAmoeba.h"
#include "openmm/System.h" #include "openmm/System.h"
#include "openmm/LangevinIntegrator.h" #include "openmm/LangevinIntegrator.h"
...@@ -201,6 +202,49 @@ void testTwoBond() { ...@@ -201,6 +202,49 @@ void testTwoBond() {
compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond"); compareWithExpectedForceAndEnergy(context, *amoebaBondForce, TOL, "testTwoBond");
} }
void testPeriodic() {
// Create a force that uses periodic boundary conditions, then compare to an identical custom force.
System system;
system.setDefaultPeriodicBoxVectors(Vec3(3, 0, 0), Vec3(0, 3, 0), Vec3(0, 0, 3));
int numParticles = 2;
for (int ii = 0; ii < numParticles; ii++)
system.addParticle(1.0);
LangevinIntegrator integrator(0.0, 0.1, 0.01);
AmoebaBondForce* amoebaBondForce = new AmoebaBondForce();
double bondLength = 1.5;
double quadraticK = 1.0;
double cubicK = 2.0;
double quarticK = 3.0;
amoebaBondForce->setAmoebaGlobalBondCubic(cubicK);
amoebaBondForce->setAmoebaGlobalBondQuartic(quarticK);
amoebaBondForce->addBond(0, 1, bondLength, quadraticK);
amoebaBondForce->setUsesPeriodicBoundaryConditions(true);
system.addForce(amoebaBondForce);
CustomBondForce* customForce = new CustomBondForce("k2*delta^2 + k3*delta^3 + k4*delta^4; delta=r-r0");
customForce->addGlobalParameter("r0", bondLength);
customForce->addGlobalParameter("k2", quadraticK);
customForce->addGlobalParameter("k3", cubicK);
customForce->addGlobalParameter("k4", quarticK);
customForce->addBond(0, 1);
customForce->setUsesPeriodicBoundaryConditions(true);
customForce->setForceGroup(1);
system.addForce(customForce);
Context context(system, integrator, Platform::getPlatformByName("Reference"));
std::vector<Vec3> positions(numParticles);
positions[0] = Vec3(0, 2, 0);
positions[1] = Vec3(0, 0, 0);
context.setPositions(positions);
State s1 = context.getState(State::Forces | State::Energy, true, 1);
State s2 = context.getState(State::Forces | State::Energy, true, 2);
ASSERT_EQUAL_TOL(s2.getPotentialEnergy(), s1.getPotentialEnergy(), 1e-5);
for (int i = 0; i < numParticles; i++)
ASSERT_EQUAL_VEC(s2.getForces()[i], s1.getForces()[i], 1e-5);
}
int main(int numberOfArguments, char* argv[]) { int main(int numberOfArguments, char* argv[]) {
try { try {
...@@ -208,6 +252,7 @@ int main(int numberOfArguments, char* argv[]) { ...@@ -208,6 +252,7 @@ int main(int numberOfArguments, char* argv[]) {
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
//testOneBond(); //testOneBond();
testTwoBond(); testTwoBond();
testPeriodic();
} }
catch(const std::exception& e) { catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -354,12 +354,57 @@ void testOneAngle() { ...@@ -354,12 +354,57 @@ void testOneAngle() {
compareWithExpectedForceAndEnergy(context, *amoebaInPlaneAngleForce, TOL, "testOneInPlaneAngle"); 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[]) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestReferenceAmoebaInPlaneAngleForce running test..." << std::endl; std::cout << "TestReferenceAmoebaInPlaneAngleForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
testOneAngle(); testOneAngle();
testPeriodic();
} }
catch(const std::exception& e) { catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -461,12 +461,50 @@ void testOneOutOfPlaneBend2(int setId) { ...@@ -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[]) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestReferenceAmoebaOutOfPlaneBendForce running test..." << std::endl; std::cout << "TestReferenceAmoebaOutOfPlaneBendForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
testOneOutOfPlaneBend(); testOneOutOfPlaneBend();
testPeriodic();
//testOneOutOfPlaneBend2(atoi(argv[1])); //testOneOutOfPlaneBend2(atoi(argv[1]));
//for (int ii = 1; ii <= 6; ii++) { //for (int ii = 1; ii <= 6; ii++) {
// testOneOutOfPlaneBend2(ii); // testOneOutOfPlaneBend2(ii);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -290,12 +290,48 @@ void testOnePiTorsion() { ...@@ -290,12 +290,48 @@ void testOnePiTorsion() {
compareWithExpectedForceAndEnergy(context, *amoebaPiTorsionForce, TOL, "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[]) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestReferenceAmoebaPiTorsionForce running test..." << std::endl; std::cout << "TestReferenceAmoebaPiTorsionForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
testOnePiTorsion(); testOnePiTorsion();
testPeriodic();
} }
catch(const std::exception& e) { catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -270,12 +270,48 @@ void testOneStretchBend() { ...@@ -270,12 +270,48 @@ void testOneStretchBend() {
compareWithExpectedForceAndEnergy(context, *amoebaStretchBendForce, TOL, "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[]) { int main(int numberOfArguments, char* argv[]) {
try { try {
std::cout << "TestReferenceAmoebaStretchBendForce running test..." << std::endl; std::cout << "TestReferenceAmoebaStretchBendForce running test..." << std::endl;
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
testOneStretchBend(); testOneStretchBend();
testPeriodic();
} }
catch(const std::exception& e) { catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * 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 * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -2669,6 +2669,44 @@ void testTorsionTorsion(int systemId, bool includeDerivs) { ...@@ -2669,6 +2669,44 @@ void testTorsionTorsion(int systemId, bool includeDerivs) {
ASSERT_EQUAL_TOL(expectedEnergy, state.getPotentialEnergy(), tolerance); 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[]) { int main(int numberOfArguments, char* argv[]) {
...@@ -2677,6 +2715,7 @@ int main(int numberOfArguments, char* argv[]) { ...@@ -2677,6 +2715,7 @@ int main(int numberOfArguments, char* argv[]) {
registerAmoebaReferenceKernelFactories(); registerAmoebaReferenceKernelFactories();
testTorsionTorsion(1, true); testTorsionTorsion(1, true);
testTorsionTorsion(1, false); testTorsionTorsion(1, false);
testPeriodic();
} }
catch(const std::exception& e) { catch(const std::exception& e) {
std::cout << "exception: " << e.what() << std::endl; std::cout << "exception: " << e.what() << std::endl;
......
...@@ -42,11 +42,12 @@ AmoebaAngleForceProxy::AmoebaAngleForceProxy() : SerializationProxy("AmoebaAngle ...@@ -42,11 +42,12 @@ AmoebaAngleForceProxy::AmoebaAngleForceProxy() : SerializationProxy("AmoebaAngle
} }
void AmoebaAngleForceProxy::serialize(const void* object, SerializationNode& node) const { 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); const AmoebaAngleForce& force = *reinterpret_cast<const AmoebaAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setDoubleProperty("cubic", force.getAmoebaGlobalAngleCubic()); node.setDoubleProperty("cubic", force.getAmoebaGlobalAngleCubic());
node.setDoubleProperty("quartic", force.getAmoebaGlobalAngleQuartic()); node.setDoubleProperty("quartic", force.getAmoebaGlobalAngleQuartic());
node.setDoubleProperty("pentic", force.getAmoebaGlobalAnglePentic()); node.setDoubleProperty("pentic", force.getAmoebaGlobalAnglePentic());
...@@ -63,12 +64,14 @@ void AmoebaAngleForceProxy::serialize(const void* object, SerializationNode& nod ...@@ -63,12 +64,14 @@ void AmoebaAngleForceProxy::serialize(const void* object, SerializationNode& nod
void* AmoebaAngleForceProxy::deserialize(const SerializationNode& node) const { void* AmoebaAngleForceProxy::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");
AmoebaAngleForce* force = new AmoebaAngleForce(); AmoebaAngleForce* force = new AmoebaAngleForce();
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"));
force->setAmoebaGlobalAngleCubic(node.getDoubleProperty("cubic")); force->setAmoebaGlobalAngleCubic(node.getDoubleProperty("cubic"));
force->setAmoebaGlobalAngleQuartic(node.getDoubleProperty("quartic")); force->setAmoebaGlobalAngleQuartic(node.getDoubleProperty("quartic"));
force->setAmoebaGlobalAnglePentic(node.getDoubleProperty("pentic")); force->setAmoebaGlobalAnglePentic(node.getDoubleProperty("pentic"));
......
...@@ -42,10 +42,11 @@ AmoebaBondForceProxy::AmoebaBondForceProxy() : SerializationProxy("AmoebaBondFor ...@@ -42,10 +42,11 @@ AmoebaBondForceProxy::AmoebaBondForceProxy() : SerializationProxy("AmoebaBondFor
} }
void AmoebaBondForceProxy::serialize(const void* object, SerializationNode& node) const { 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); const AmoebaBondForce& force = *reinterpret_cast<const AmoebaBondForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setDoubleProperty("cubic", force.getAmoebaGlobalBondCubic()); node.setDoubleProperty("cubic", force.getAmoebaGlobalBondCubic());
node.setDoubleProperty("quartic", force.getAmoebaGlobalBondQuartic()); node.setDoubleProperty("quartic", force.getAmoebaGlobalBondQuartic());
...@@ -60,12 +61,14 @@ void AmoebaBondForceProxy::serialize(const void* object, SerializationNode& node ...@@ -60,12 +61,14 @@ void AmoebaBondForceProxy::serialize(const void* object, SerializationNode& node
void* AmoebaBondForceProxy::deserialize(const SerializationNode& node) const { void* AmoebaBondForceProxy::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");
AmoebaBondForce* force = new AmoebaBondForce(); AmoebaBondForce* force = new AmoebaBondForce();
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"));
force->setAmoebaGlobalBondCubic(node.getDoubleProperty("cubic")); force->setAmoebaGlobalBondCubic(node.getDoubleProperty("cubic"));
force->setAmoebaGlobalBondQuartic(node.getDoubleProperty("quartic")); force->setAmoebaGlobalBondQuartic(node.getDoubleProperty("quartic"));
const SerializationNode& bonds = node.getChildNode("Bonds"); const SerializationNode& bonds = node.getChildNode("Bonds");
......
...@@ -43,10 +43,11 @@ AmoebaInPlaneAngleForceProxy::AmoebaInPlaneAngleForceProxy() : SerializationProx ...@@ -43,10 +43,11 @@ AmoebaInPlaneAngleForceProxy::AmoebaInPlaneAngleForceProxy() : SerializationProx
void AmoebaInPlaneAngleForceProxy::serialize(const void* object, SerializationNode& node) const { 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); const AmoebaInPlaneAngleForce& force = *reinterpret_cast<const AmoebaInPlaneAngleForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setDoubleProperty("cubic", force.getAmoebaGlobalInPlaneAngleCubic()); node.setDoubleProperty("cubic", force.getAmoebaGlobalInPlaneAngleCubic());
node.setDoubleProperty("quartic", force.getAmoebaGlobalInPlaneAngleQuartic()); node.setDoubleProperty("quartic", force.getAmoebaGlobalInPlaneAngleQuartic());
node.setDoubleProperty("pentic", force.getAmoebaGlobalInPlaneAnglePentic()); node.setDoubleProperty("pentic", force.getAmoebaGlobalInPlaneAnglePentic());
...@@ -63,12 +64,14 @@ void AmoebaInPlaneAngleForceProxy::serialize(const void* object, SerializationNo ...@@ -63,12 +64,14 @@ void AmoebaInPlaneAngleForceProxy::serialize(const void* object, SerializationNo
void* AmoebaInPlaneAngleForceProxy::deserialize(const SerializationNode& node) const { void* AmoebaInPlaneAngleForceProxy::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");
AmoebaInPlaneAngleForce* force = new AmoebaInPlaneAngleForce(); AmoebaInPlaneAngleForce* force = new AmoebaInPlaneAngleForce();
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"));
force->setAmoebaGlobalInPlaneAngleCubic( node.getDoubleProperty("cubic")); force->setAmoebaGlobalInPlaneAngleCubic( node.getDoubleProperty("cubic"));
force->setAmoebaGlobalInPlaneAngleQuartic(node.getDoubleProperty("quartic")); force->setAmoebaGlobalInPlaneAngleQuartic(node.getDoubleProperty("quartic"));
force->setAmoebaGlobalInPlaneAnglePentic(node.getDoubleProperty("pentic")); force->setAmoebaGlobalInPlaneAnglePentic(node.getDoubleProperty("pentic"));
......
...@@ -42,9 +42,10 @@ AmoebaOutOfPlaneBendForceProxy::AmoebaOutOfPlaneBendForceProxy() : Serialization ...@@ -42,9 +42,10 @@ AmoebaOutOfPlaneBendForceProxy::AmoebaOutOfPlaneBendForceProxy() : Serialization
} }
void AmoebaOutOfPlaneBendForceProxy::serialize(const void* object, SerializationNode& node) const { 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); const AmoebaOutOfPlaneBendForce& force = *reinterpret_cast<const AmoebaOutOfPlaneBendForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
node.setDoubleProperty("cubic", force.getAmoebaGlobalOutOfPlaneBendCubic()); node.setDoubleProperty("cubic", force.getAmoebaGlobalOutOfPlaneBendCubic());
node.setDoubleProperty("quartic", force.getAmoebaGlobalOutOfPlaneBendQuartic()); node.setDoubleProperty("quartic", force.getAmoebaGlobalOutOfPlaneBendQuartic());
node.setDoubleProperty("pentic", force.getAmoebaGlobalOutOfPlaneBendPentic()); node.setDoubleProperty("pentic", force.getAmoebaGlobalOutOfPlaneBendPentic());
...@@ -61,12 +62,14 @@ void AmoebaOutOfPlaneBendForceProxy::serialize(const void* object, Serialization ...@@ -61,12 +62,14 @@ void AmoebaOutOfPlaneBendForceProxy::serialize(const void* object, Serialization
void* AmoebaOutOfPlaneBendForceProxy::deserialize(const SerializationNode& node) const { void* AmoebaOutOfPlaneBendForceProxy::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");
AmoebaOutOfPlaneBendForce* force = new AmoebaOutOfPlaneBendForce(); AmoebaOutOfPlaneBendForce* force = new AmoebaOutOfPlaneBendForce();
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"));
force->setAmoebaGlobalOutOfPlaneBendCubic(node.getDoubleProperty("cubic")); force->setAmoebaGlobalOutOfPlaneBendCubic(node.getDoubleProperty("cubic"));
force->setAmoebaGlobalOutOfPlaneBendQuartic(node.getDoubleProperty("quartic")); force->setAmoebaGlobalOutOfPlaneBendQuartic(node.getDoubleProperty("quartic"));
force->setAmoebaGlobalOutOfPlaneBendPentic(node.getDoubleProperty("pentic")); force->setAmoebaGlobalOutOfPlaneBendPentic(node.getDoubleProperty("pentic"));
......
...@@ -42,9 +42,10 @@ AmoebaPiTorsionForceProxy::AmoebaPiTorsionForceProxy() : SerializationProxy("Amo ...@@ -42,9 +42,10 @@ AmoebaPiTorsionForceProxy::AmoebaPiTorsionForceProxy() : SerializationProxy("Amo
} }
void AmoebaPiTorsionForceProxy::serialize(const void* object, SerializationNode& node) const { 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); const AmoebaPiTorsionForce& force = *reinterpret_cast<const AmoebaPiTorsionForce*>(object);
node.setIntProperty("forceGroup", force.getForceGroup()); node.setIntProperty("forceGroup", force.getForceGroup());
node.setBoolProperty("usesPeriodic", force.usesPeriodicBoundaryConditions());
SerializationNode& bonds = node.createChildNode("PiTorsion"); SerializationNode& bonds = node.createChildNode("PiTorsion");
for (unsigned int ii = 0; ii < static_cast<unsigned int>(force.getNumPiTorsions()); ii++) { for (unsigned int ii = 0; ii < static_cast<unsigned int>(force.getNumPiTorsions()); ii++) {
int particle1, particle2, particle3, particle4, particle5, particle6; int particle1, particle2, particle3, particle4, particle5, particle6;
...@@ -56,12 +57,14 @@ void AmoebaPiTorsionForceProxy::serialize(const void* object, SerializationNode& ...@@ -56,12 +57,14 @@ void AmoebaPiTorsionForceProxy::serialize(const void* object, SerializationNode&
void* AmoebaPiTorsionForceProxy::deserialize(const SerializationNode& node) const { void* AmoebaPiTorsionForceProxy::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");
AmoebaPiTorsionForce* force = new AmoebaPiTorsionForce(); AmoebaPiTorsionForce* force = new AmoebaPiTorsionForce();
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& bonds = node.getChildNode("PiTorsion"); const SerializationNode& bonds = node.getChildNode("PiTorsion");
for (unsigned int ii = 0; ii < bonds.getChildren().size(); ii++) { for (unsigned int ii = 0; ii < bonds.getChildren().size(); ii++) {
const SerializationNode& bond = bonds.getChildren()[ii]; const SerializationNode& bond = bonds.getChildren()[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