Commit 71d33617 authored by John Chodera (MSKCC)'s avatar John Chodera (MSKCC)
Browse files

Merge remote-tracking branch 'upstream/master'

parents eb232608 9da36463
...@@ -410,9 +410,9 @@ void testTriclinic() { ...@@ -410,9 +410,9 @@ void testTriclinic() {
} }
else { else {
const Vec3 force = delta*ONE_4PI_EPS0*(-1.0/(distance*distance*distance)+2.0*krf); const Vec3 force = delta*ONE_4PI_EPS0*(-1.0/(distance*distance*distance)+2.0*krf);
ASSERT_EQUAL_TOL(ONE_4PI_EPS0*(1.0/distance+krf*distance*distance-crf), state.getPotentialEnergy(), TOL); ASSERT_EQUAL_TOL(ONE_4PI_EPS0*(1.0/distance+krf*distance*distance-crf), state.getPotentialEnergy(), 1e-4);
ASSERT_EQUAL_VEC(force, state.getForces()[0], TOL); ASSERT_EQUAL_VEC(force, state.getForces()[0], 1e-4);
ASSERT_EQUAL_VEC(-force, state.getForces()[1], TOL); ASSERT_EQUAL_VEC(-force, state.getForces()[1], 1e-4);
} }
} }
} }
......
...@@ -413,7 +413,7 @@ void testConservationLaws() { ...@@ -413,7 +413,7 @@ void testConservationLaws() {
if (i == 0) if (i == 0)
initialAngularMomentum = angularMomentum; initialAngularMomentum = angularMomentum;
else else
ASSERT_EQUAL_VEC(initialAngularMomentum, angularMomentum, 0.03); ASSERT_EQUAL_VEC(initialAngularMomentum, angularMomentum, 0.05);
integrator.step(1); integrator.step(1);
} }
} }
......
/* Portions copyright (c) 2006-2013 Stanford University and Simbios. /* Portions copyright (c) 2006-2015 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
...@@ -37,6 +37,7 @@ class OPENMM_EXPORT ReferenceCCMAAlgorithm : public ReferenceConstraintAlgorithm ...@@ -37,6 +37,7 @@ class OPENMM_EXPORT ReferenceCCMAAlgorithm : public ReferenceConstraintAlgorithm
protected: protected:
int _maximumNumberOfIterations; int _maximumNumberOfIterations;
RealOpenMM _elementCutoff;
int _numberOfConstraints; int _numberOfConstraints;
std::vector<std::pair<int, int> > _atomIndices; std::vector<std::pair<int, int> > _atomIndices;
...@@ -66,8 +67,9 @@ public: ...@@ -66,8 +67,9 @@ public:
* @param distance distances for constraints * @param distance distances for constraints
* @param masses atom masses * @param masses atom masses
* @param angles angle force field terms * @param angles angle force field terms
* @param elementCutoff the cutoff for which elements of the inverse matrix to keep
*/ */
ReferenceCCMAAlgorithm(int numberOfAtoms, int numberOfConstraints, const std::vector<std::pair<int, int> >& atomIndices, const std::vector<RealOpenMM>& distance, std::vector<RealOpenMM>& masses, std::vector<AngleInfo>& angles); ReferenceCCMAAlgorithm(int numberOfAtoms, int numberOfConstraints, const std::vector<std::pair<int, int> >& atomIndices, const std::vector<RealOpenMM>& distance, std::vector<RealOpenMM>& masses, std::vector<AngleInfo>& angles, RealOpenMM elementCutoff);
~ReferenceCCMAAlgorithm(); ~ReferenceCCMAAlgorithm();
...@@ -107,6 +109,13 @@ public: ...@@ -107,6 +109,13 @@ public:
*/ */
void applyToVelocities(std::vector<OpenMM::RealVec>& atomCoordinates, void applyToVelocities(std::vector<OpenMM::RealVec>& atomCoordinates,
std::vector<OpenMM::RealVec>& velocities, std::vector<RealOpenMM>& inverseMasses, RealOpenMM tolerance); std::vector<OpenMM::RealVec>& velocities, std::vector<RealOpenMM>& inverseMasses, RealOpenMM tolerance);
/**
* Get the inverse constraint matrix. Each element represents one column, and contains a list
* of all non-zero elements in the form (index, value).
*/
const std::vector<std::vector<std::pair<int, RealOpenMM> > >& getMatrix() const;
}; };
class ReferenceCCMAAlgorithm::AngleInfo class ReferenceCCMAAlgorithm::AngleInfo
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,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-2013 Stanford University and the Authors. * * Portions copyright (c) 2008-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -493,6 +493,13 @@ public: ...@@ -493,6 +493,13 @@ public:
* @return the potential energy due to the force * @return the potential energy due to the force
*/ */
double execute(ContextImpl& context, bool includeForces, bool includeEnergy); double execute(ContextImpl& context, bool includeForces, bool includeEnergy);
/**
* Copy changed parameters over to a context.
*
* @param context the context to copy parameters to
* @param force the CMAPTorsionForce to copy the parameters from
*/
void copyParametersToContext(ContextImpl& context, const CMAPTorsionForce& force);
private: private:
std::vector<std::vector<std::vector<RealOpenMM> > > coeff; std::vector<std::vector<std::vector<RealOpenMM> > > coeff;
std::vector<int> torsionMaps; std::vector<int> torsionMaps;
......
...@@ -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-2013 Stanford University and the Authors. * * Portions copyright (c) 2008-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -710,6 +710,40 @@ double ReferenceCalcCMAPTorsionForceKernel::execute(ContextImpl& context, bool i ...@@ -710,6 +710,40 @@ double ReferenceCalcCMAPTorsionForceKernel::execute(ContextImpl& context, bool i
return totalEnergy; return totalEnergy;
} }
void ReferenceCalcCMAPTorsionForceKernel::copyParametersToContext(ContextImpl& context, const CMAPTorsionForce& force) {
int numMaps = force.getNumMaps();
int numTorsions = force.getNumTorsions();
if (coeff.size() != numMaps)
throw OpenMMException("updateParametersInContext: The number of maps has changed");
if (torsionMaps.size() != numTorsions)
throw OpenMMException("updateParametersInContext: The number of CMAP torsions has changed");
// Update the maps.
vector<double> energy;
vector<vector<double> > c;
for (int i = 0; i < numMaps; i++) {
int size;
force.getMapParameters(i, size, energy);
if (coeff[i].size() != size*size)
throw OpenMMException("updateParametersInContext: The size of a map has changed");
CMAPTorsionForceImpl::calcMapDerivatives(size, energy, c);
for (int j = 0; j < size*size; j++)
for (int k = 0; k < 16; k++)
coeff[i][j][k] = c[j][k];
}
// Update the indices.
for (int i = 0; i < numTorsions; i++) {
int index[8];
force.getTorsionParameters(i, torsionMaps[i], index[0], index[1], index[2], index[3], index[4], index[5], index[6], index[7]);
for (int j = 0; j < 8; j++)
if (index[j] != torsionIndices[i][j])
throw OpenMMException("updateParametersInContext: The set of particles in a CMAP torsion has changed");
}
}
ReferenceCalcCustomTorsionForceKernel::~ReferenceCalcCustomTorsionForceKernel() { ReferenceCalcCustomTorsionForceKernel::~ReferenceCalcCustomTorsionForceKernel() {
disposeIntArray(torsionIndexArray, numTorsions); disposeIntArray(torsionIndexArray, numTorsions);
disposeRealArray(torsionParamArray, numTorsions); disposeRealArray(torsionParamArray, numTorsions);
......
...@@ -382,9 +382,9 @@ void ObcParameters::setPeriodic(OpenMM::RealVec* vectors) { ...@@ -382,9 +382,9 @@ void ObcParameters::setPeriodic(OpenMM::RealVec* vectors) {
assert(_cutoff); assert(_cutoff);
assert(boxSize[0][0] >= 2.0*_cutoffDistance); assert(vectors[0][0] >= 2.0*_cutoffDistance);
assert(boxSize[1][1] >= 2.0*_cutoffDistance); assert(vectors[1][1] >= 2.0*_cutoffDistance);
assert(boxSize[2][2] >= 2.0*_cutoffDistance); assert(vectors[2][2] >= 2.0*_cutoffDistance);
_periodic = true; _periodic = true;
_periodicBoxVectors[0] = vectors[0]; _periodicBoxVectors[0] = vectors[0];
......
/* Portions copyright (c) 2006-2013 Stanford University and Simbios. /* Portions copyright (c) 2006-2015 Stanford University and Simbios.
* Contributors: Peter Eastman, Pande Group * Contributors: Peter Eastman, Pande Group
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "quern.h" #include "quern.h"
#include "openmm/OpenMMException.h" #include "openmm/OpenMMException.h"
#include "openmm/Vec3.h" #include "openmm/Vec3.h"
#include "openmm/internal/ThreadPool.h"
#include <map> #include <map>
using std::map; using std::map;
...@@ -39,13 +40,51 @@ using std::vector; ...@@ -39,13 +40,51 @@ using std::vector;
using std::set; using std::set;
using namespace OpenMM; using namespace OpenMM;
// This class extracts columns from the inverse matrix one at a time. It is done in parallel,
// since this can be very slow.
class ExtractMatrixTask : public ThreadPool::Task {
public:
ExtractMatrixTask(int numConstraints, vector<vector<pair<int, RealOpenMM> > >& matrix, const vector<RealOpenMM>& distance, RealOpenMM elementCutoff,
const int* qRowStart, const int* qColIndex, const int* rRowStart, const int* rColIndex, const double* qValue, const double* rValue) :
numConstraints(numConstraints), matrix(matrix), distance(distance), elementCutoff(elementCutoff), qRowStart(qRowStart), qColIndex(qColIndex),
rRowStart(rRowStart), rColIndex(rColIndex), qValue(qValue), rValue(rValue) {
}
void execute(ThreadPool& pool, int threadIndex) {
vector<double> rhs(numConstraints);
for (int i = threadIndex; i < numConstraints; i += pool.getNumThreads()) {
// Extract column i of the inverse matrix.
for (int j = 0; j < numConstraints; j++)
rhs[j] = (i == j ? 1.0 : 0.0);
QUERN_multiply_with_q_transpose(numConstraints, qRowStart, qColIndex, qValue, &rhs[0]);
QUERN_solve_with_r(numConstraints, rRowStart, rColIndex, rValue, &rhs[0], &rhs[0]);
for (int j = 0; j < numConstraints; j++) {
double value = rhs[j]*distance[j]/distance[i];
if (FABS((RealOpenMM) value) > elementCutoff)
matrix[i].push_back(pair<int, RealOpenMM>(j, (RealOpenMM) value));
}
}
}
private:
int numConstraints;
vector<vector<pair<int, RealOpenMM> > >& matrix;
const vector<RealOpenMM>& distance;
RealOpenMM elementCutoff;
const int *qRowStart, *qColIndex, *rRowStart, *rColIndex;
const double *qValue, *rValue;
};
ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms, ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
int numberOfConstraints, int numberOfConstraints,
const vector<pair<int, int> >& atomIndices, const vector<pair<int, int> >& atomIndices,
const vector<RealOpenMM>& distance, const vector<RealOpenMM>& distance,
vector<RealOpenMM>& masses, vector<RealOpenMM>& masses,
vector<AngleInfo>& angles) { vector<AngleInfo>& angles,
RealOpenMM elementCutoff) {
_numberOfConstraints = numberOfConstraints; _numberOfConstraints = numberOfConstraints;
_elementCutoff = elementCutoff;
_atomIndices = atomIndices; _atomIndices = atomIndices;
_distance = distance; _distance = distance;
...@@ -157,19 +196,10 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms, ...@@ -157,19 +196,10 @@ ReferenceCCMAAlgorithm::ReferenceCCMAAlgorithm(int numberOfAtoms,
&qRowStart, &qColIndex, &qValue, &rRowStart, &rColIndex, &rValue); &qRowStart, &qColIndex, &qValue, &rRowStart, &rColIndex, &rValue);
vector<double> rhs(numberOfConstraints); vector<double> rhs(numberOfConstraints);
_matrix.resize(numberOfConstraints); _matrix.resize(numberOfConstraints);
for (int i = 0; i < numberOfConstraints; i++) { ThreadPool threads;
// Extract column i of the inverse matrix. ExtractMatrixTask task(numberOfConstraints, _matrix, _distance, _elementCutoff, qRowStart, qColIndex, rRowStart, rColIndex, qValue, rValue);
threads.execute(task);
for (int j = 0; j < numberOfConstraints; j++) threads.waitForThreads();
rhs[j] = (i == j ? 1.0 : 0.0);
QUERN_multiply_with_q_transpose(numberOfConstraints, qRowStart, qColIndex, qValue, &rhs[0]);
QUERN_solve_with_r(numberOfConstraints, rRowStart, rColIndex, rValue, &rhs[0], &rhs[0]);
for (int j = 0; j < numberOfConstraints; j++) {
double value = rhs[j]*_distance[i]/_distance[j];
if (FABS((RealOpenMM)value) > 0.02)
_matrix[j].push_back(pair<int, RealOpenMM>(i, (RealOpenMM) value));
}
}
QUERN_free_result(qRowStart, qColIndex, qValue); QUERN_free_result(qRowStart, qColIndex, qValue);
QUERN_free_result(rRowStart, rColIndex, rValue); QUERN_free_result(rRowStart, rColIndex, rValue);
} }
...@@ -290,3 +320,7 @@ void ReferenceCCMAAlgorithm::applyConstraints(vector<RealVec>& atomCoordinates, ...@@ -290,3 +320,7 @@ void ReferenceCCMAAlgorithm::applyConstraints(vector<RealVec>& atomCoordinates,
} }
} }
} }
const vector<vector<pair<int, RealOpenMM> > >& ReferenceCCMAAlgorithm::getMatrix() const {
return _matrix;
}
...@@ -180,7 +180,7 @@ ReferenceConstraints::ReferenceConstraints(const System& system) : ccma(NULL), s ...@@ -180,7 +180,7 @@ ReferenceConstraints::ReferenceConstraints(const System& system) : ccma(NULL), s
// Create the CCMA object. // Create the CCMA object.
ccma = new ReferenceCCMAAlgorithm(numParticles, numCCMA, ccmaIndices, ccmaDistance, masses, angles); ccma = new ReferenceCCMAAlgorithm(numParticles, numCCMA, ccmaIndices, ccmaDistance, masses, angles, 0.02);
} }
} }
......
...@@ -48,12 +48,13 @@ ...@@ -48,12 +48,13 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
void testTemperature() { void testTemperature() {
const int numParticles = 8; const int numParticles = 8;
const double temp = 100.0; const double temp = 100.0;
const double collisionFreq = 10.0; const double collisionFreq = 10.0;
const int numSteps = 5000; const int numSteps = 5000;
ReferencePlatform platform;
System system; System system;
VerletIntegrator integrator(0.003); VerletIntegrator integrator(0.003);
NonbondedForce* forceField = new NonbondedForce(); NonbondedForce* forceField = new NonbondedForce();
...@@ -94,7 +95,6 @@ void testConstraints() { ...@@ -94,7 +95,6 @@ void testConstraints() {
const double temp = 100.0; const double temp = 100.0;
const double collisionFreq = 10.0; const double collisionFreq = 10.0;
const int numSteps = 15000; const int numSteps = 15000;
ReferencePlatform platform;
System system; System system;
VerletIntegrator integrator(0.004); VerletIntegrator integrator(0.004);
NonbondedForce* forceField = new NonbondedForce(); NonbondedForce* forceField = new NonbondedForce();
...@@ -147,7 +147,6 @@ void testRandomSeed() { ...@@ -147,7 +147,6 @@ void testRandomSeed() {
const int numParticles = 8; const int numParticles = 8;
const double temp = 100.0; const double temp = 100.0;
const double collisionFreq = 10.0; const double collisionFreq = 10.0;
ReferencePlatform platform;
System system; System system;
VerletIntegrator integrator(0.01); VerletIntegrator integrator(0.01);
NonbondedForce* forceField = new NonbondedForce(); NonbondedForce* forceField = new NonbondedForce();
......
...@@ -48,10 +48,11 @@ ...@@ -48,10 +48,11 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void testSingleBond() { void testSingleBond() {
ReferencePlatform platform;
System system; System system;
system.addParticle(2.0); system.addParticle(2.0);
system.addParticle(2.0); system.addParticle(2.0);
...@@ -88,7 +89,6 @@ void testTemperature() { ...@@ -88,7 +89,6 @@ void testTemperature() {
const int numParticles = 8; const int numParticles = 8;
const int numBonds = numParticles-1; const int numBonds = numParticles-1;
const double temp = 10.0; const double temp = 10.0;
ReferencePlatform platform;
System system; System system;
BrownianIntegrator integrator(temp, 2.0, 0.01); BrownianIntegrator integrator(temp, 2.0, 0.01);
HarmonicBondForce* forceField = new HarmonicBondForce(); HarmonicBondForce* forceField = new HarmonicBondForce();
...@@ -125,7 +125,6 @@ void testTemperature() { ...@@ -125,7 +125,6 @@ void testTemperature() {
void testConstraints() { void testConstraints() {
const int numParticles = 8; const int numParticles = 8;
const double temp = 100.0; const double temp = 100.0;
ReferencePlatform platform;
System system; System system;
BrownianIntegrator integrator(temp, 2.0, 0.001); BrownianIntegrator integrator(temp, 2.0, 0.001);
integrator.setConstraintTolerance(1e-5); integrator.setConstraintTolerance(1e-5);
...@@ -165,7 +164,6 @@ void testConstraints() { ...@@ -165,7 +164,6 @@ void testConstraints() {
} }
void testConstrainedMasslessParticles() { void testConstrainedMasslessParticles() {
ReferencePlatform platform;
System system; System system;
system.addParticle(0.0); system.addParticle(0.0);
system.addParticle(1.0); system.addParticle(1.0);
...@@ -200,7 +198,6 @@ void testRandomSeed() { ...@@ -200,7 +198,6 @@ void testRandomSeed() {
const int numParticles = 8; const int numParticles = 8;
const double temp = 100.0; const double temp = 100.0;
const double collisionFreq = 10.0; const double collisionFreq = 10.0;
ReferencePlatform platform;
System system; System system;
BrownianIntegrator integrator(temp, 2.0, 0.001); BrownianIntegrator integrator(temp, 2.0, 0.001);
NonbondedForce* forceField = new NonbondedForce(); NonbondedForce* forceField = new NonbondedForce();
......
...@@ -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) 2010 Stanford University and the Authors. * * Portions copyright (c) 2010-2015 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void testCMAPTorsions() { void testCMAPTorsions() {
...@@ -56,7 +58,6 @@ void testCMAPTorsions() { ...@@ -56,7 +58,6 @@ void testCMAPTorsions() {
// Create two systems: one with a pair of periodic torsions, and one with a CMAP torsion // Create two systems: one with a pair of periodic torsions, and one with a CMAP torsion
// that approximates the same force. // that approximates the same force.
ReferencePlatform platform;
System system1; System system1;
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
system1.addParticle(1.0); system1.addParticle(1.0);
...@@ -108,9 +109,66 @@ void testCMAPTorsions() { ...@@ -108,9 +109,66 @@ void testCMAPTorsions() {
} }
} }
void testChangingParameters() {
// Create a system with two maps and one torsion.
const int mapSize = 8;
System system;
for (int i = 0; i < 5; i++)
system.addParticle(1.0);
CMAPTorsionForce* cmap = new CMAPTorsionForce();
vector<double> mapEnergy1(mapSize*mapSize);
vector<double> mapEnergy2(mapSize*mapSize);
for (int i = 0; i < mapSize; i++) {
double angle1 = i*2*M_PI/mapSize;
double energy1 = cos(angle1);
for (int j = 0; j < mapSize; j++) {
double angle2 = j*2*M_PI/mapSize;
double energy2 = 10*sin(angle2);
mapEnergy1[i+j*mapSize] = energy1+energy2;
mapEnergy2[i+j*mapSize] = energy1-energy2;
}
}
cmap->addMap(mapSize, mapEnergy1);
cmap->addMap(mapSize, mapEnergy2);
cmap->addTorsion(0, 0, 1, 2, 3, 1, 2, 3, 4);
system.addForce(cmap);
// Set particle positions so angle1=0 and angle2=PI/4.
vector<Vec3> positions(5);
positions[0] = Vec3(0, 0, 1);
positions[1] = Vec3(0, 0, 0);
positions[2] = Vec3(1, 0, 0);
positions[3] = Vec3(1, 0, 1);
positions[4] = Vec3(0.5, -0.5, 1);
VerletIntegrator integrator(0.01);
Context context(system, integrator, platform);
context.setPositions(positions);
// Check that the energy is correct.
double energy = context.getState(State::Energy).getPotentialEnergy();
ASSERT_EQUAL_TOL(1+10*sin(M_PI/4), energy, 1e-5);
// Modify the parameters.
cmap->setTorsionParameters(0, 1, 0, 1, 2, 3, 1, 2, 3, 4);
for (int i = 0; i < mapSize*mapSize; i++)
mapEnergy2[i] *= 2.0;
cmap->setMapParameters(1, mapSize, mapEnergy2);
cmap->updateParametersInContext(context);
// See if the results are correct.
energy = context.getState(State::Energy).getPotentialEnergy();
ASSERT_EQUAL_TOL(2-20*sin(M_PI/4), energy, 1e-5);
}
int main() { int main() {
try { try {
testCMAPTorsions(); testCMAPTorsions();
testChangingParameters();
} }
catch(const exception& e) { catch(const exception& e) {
cout << "exception: " << e.what() << endl; cout << "exception: " << e.what() << endl;
......
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
Vec3 calcCM(const vector<Vec3>& values, System& system) { Vec3 calcCM(const vector<Vec3>& values, System& system) {
Vec3 cm; Vec3 cm;
for (int j = 0; j < system.getNumParticles(); ++j) { for (int j = 0; j < system.getNumParticles(); ++j) {
...@@ -63,7 +65,6 @@ void testMotionRemoval() { ...@@ -63,7 +65,6 @@ void testMotionRemoval() {
const int numParticles = 8; const int numParticles = 8;
const double temp = 100.0; const double temp = 100.0;
const double collisionFreq = 10.0; const double collisionFreq = 10.0;
ReferencePlatform platform;
System system; System system;
VerletIntegrator integrator(0.01); VerletIntegrator integrator(0.01);
HarmonicBondForce* bonds = new HarmonicBondForce(); HarmonicBondForce* bonds = new HarmonicBondForce();
......
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void compareStates(State& s1, State& s2) { void compareStates(State& s1, State& s2) {
...@@ -71,7 +73,6 @@ void testCheckpoint() { ...@@ -71,7 +73,6 @@ void testCheckpoint() {
const int numParticles = 10; const int numParticles = 10;
const double boxSize = 3.0; const double boxSize = 3.0;
const double temperature = 200.0; const double temperature = 200.0;
ReferencePlatform platform;
System system; System system;
system.addForce(new AndersenThermostat(0.0, 100.0)); system.addForce(new AndersenThermostat(0.0, 100.0));
NonbondedForce* nonbonded = new NonbondedForce(); NonbondedForce* nonbonded = new NonbondedForce();
...@@ -125,7 +126,6 @@ void testSetState() { ...@@ -125,7 +126,6 @@ void testSetState() {
const int numParticles = 10; const int numParticles = 10;
const double boxSize = 3.0; const double boxSize = 3.0;
const double temperature = 200.0; const double temperature = 200.0;
ReferencePlatform platform;
System system; System system;
system.addForce(new AndersenThermostat(0.0, 100.0)); system.addForce(new AndersenThermostat(0.0, 100.0));
NonbondedForce* nonbonded = new NonbondedForce(); NonbondedForce* nonbonded = new NonbondedForce();
......
...@@ -47,11 +47,11 @@ ...@@ -47,11 +47,11 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void testAngles() { void testAngles() {
ReferencePlatform platform;
// Create a system using a CustomAngleForce. // Create a system using a CustomAngleForce.
System customSystem; System customSystem;
......
...@@ -46,10 +46,11 @@ ...@@ -46,10 +46,11 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void testBonds() { void testBonds() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
......
...@@ -52,11 +52,11 @@ ...@@ -52,11 +52,11 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void testBond() { void testBond() {
ReferencePlatform platform;
// Create a system using a CustomCompoundBondForce. // Create a system using a CustomCompoundBondForce.
System customSystem; System customSystem;
...@@ -147,7 +147,6 @@ void testBond() { ...@@ -147,7 +147,6 @@ void testBond() {
} }
void testPositionDependence() { void testPositionDependence() {
ReferencePlatform platform;
System customSystem; System customSystem;
customSystem.addParticle(1.0); customSystem.addParticle(1.0);
customSystem.addParticle(1.0); customSystem.addParticle(1.0);
...@@ -179,7 +178,6 @@ void testContinuous2DFunction() { ...@@ -179,7 +178,6 @@ void testContinuous2DFunction() {
const double xmax = 1.1; const double xmax = 1.1;
const double ymin = 0.0; const double ymin = 0.0;
const double ymax = 0.9; const double ymax = 0.9;
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
VerletIntegrator integrator(0.01); VerletIntegrator integrator(0.01);
...@@ -227,7 +225,6 @@ void testContinuous3DFunction() { ...@@ -227,7 +225,6 @@ void testContinuous3DFunction() {
const double ymax = 0.9; const double ymax = 0.9;
const double zmin = 0.2; const double zmin = 0.2;
const double zmax = 1.3; const double zmax = 1.3;
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
VerletIntegrator integrator(0.01); VerletIntegrator integrator(0.01);
...@@ -273,7 +270,6 @@ void testContinuous3DFunction() { ...@@ -273,7 +270,6 @@ void testContinuous3DFunction() {
void testMultipleBonds() { void testMultipleBonds() {
// Two compound bonds using Urey-Bradley example from API doc // Two compound bonds using Urey-Bradley example from API doc
ReferencePlatform platform;
System customSystem; System customSystem;
customSystem.addParticle(1.0); customSystem.addParticle(1.0);
customSystem.addParticle(1.0); customSystem.addParticle(1.0);
......
...@@ -46,10 +46,11 @@ ...@@ -46,10 +46,11 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void testForce() { void testForce() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
......
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void testOBC(GBSAOBCForce::NonbondedMethod obcMethod, CustomGBForce::NonbondedMethod customMethod) { void testOBC(GBSAOBCForce::NonbondedMethod obcMethod, CustomGBForce::NonbondedMethod customMethod) {
...@@ -58,7 +60,6 @@ void testOBC(GBSAOBCForce::NonbondedMethod obcMethod, CustomGBForce::NonbondedMe ...@@ -58,7 +60,6 @@ void testOBC(GBSAOBCForce::NonbondedMethod obcMethod, CustomGBForce::NonbondedMe
const int numParticles = numMolecules*2; const int numParticles = numMolecules*2;
const double boxSize = 10.0; const double boxSize = 10.0;
const double cutoff = 2.0; const double cutoff = 2.0;
ReferencePlatform platform;
// Create two systems: one with a GBSAOBCForce, and one using a CustomGBForce to implement the same interaction. // Create two systems: one with a GBSAOBCForce, and one using a CustomGBForce to implement the same interaction.
...@@ -190,7 +191,6 @@ void testMembrane() { ...@@ -190,7 +191,6 @@ void testMembrane() {
const int numMolecules = 70; const int numMolecules = 70;
const int numParticles = numMolecules*2; const int numParticles = numMolecules*2;
const double boxSize = 10.0; const double boxSize = 10.0;
ReferencePlatform platform;
// Create a system with an implicit membrane. // Create a system with an implicit membrane.
...@@ -280,7 +280,6 @@ void testMembrane() { ...@@ -280,7 +280,6 @@ void testMembrane() {
} }
void testTabulatedFunction() { void testTabulatedFunction() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
...@@ -313,7 +312,6 @@ void testTabulatedFunction() { ...@@ -313,7 +312,6 @@ void testTabulatedFunction() {
} }
void testMultipleChainRules() { void testMultipleChainRules() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
...@@ -341,7 +339,6 @@ void testMultipleChainRules() { ...@@ -341,7 +339,6 @@ void testMultipleChainRules() {
} }
void testPositionDependence() { void testPositionDependence() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
...@@ -405,7 +402,6 @@ void testPositionDependence() { ...@@ -405,7 +402,6 @@ void testPositionDependence() {
} }
void testExclusions() { void testExclusions() {
ReferencePlatform platform;
for (int i = 3; i < 4; i++) { for (int i = 3; i < 4; i++) {
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
...@@ -817,7 +813,6 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet ...@@ -817,7 +813,6 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet
const int numMolecules = 1; const int numMolecules = 1;
const double boxSize = 10.0; const double boxSize = 10.0;
ReferencePlatform platform;
GBVIForce* gbvi = new GBVIForce(); GBVIForce* gbvi = new GBVIForce();
std::vector<Vec3> positions; std::vector<Vec3> positions;
......
...@@ -49,11 +49,11 @@ ...@@ -49,11 +49,11 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
void testHbond() { void testHbond() {
ReferencePlatform platform;
// Create a system using a CustomHbondForce. // Create a system using a CustomHbondForce.
System customSystem; System customSystem;
...@@ -151,7 +151,6 @@ void testHbond() { ...@@ -151,7 +151,6 @@ void testHbond() {
} }
void testExclusions() { void testExclusions() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
...@@ -178,7 +177,6 @@ void testExclusions() { ...@@ -178,7 +177,6 @@ void testExclusions() {
} }
void testCutoff() { void testCutoff() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
...@@ -206,7 +204,6 @@ void testCutoff() { ...@@ -206,7 +204,6 @@ void testCutoff() {
} }
void testCustomFunctions() { void testCustomFunctions() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
......
...@@ -49,13 +49,14 @@ ...@@ -49,13 +49,14 @@
using namespace OpenMM; using namespace OpenMM;
using namespace std; using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5; const double TOL = 1e-5;
/** /**
* Test a simple leapfrog integrator on a single bond. * Test a simple leapfrog integrator on a single bond.
*/ */
void testSingleBond() { void testSingleBond() {
ReferencePlatform platform;
System system; System system;
system.addParticle(2.0); system.addParticle(2.0);
system.addParticle(2.0); system.addParticle(2.0);
...@@ -101,7 +102,6 @@ void testSingleBond() { ...@@ -101,7 +102,6 @@ void testSingleBond() {
void testConstraints() { void testConstraints() {
const int numParticles = 8; const int numParticles = 8;
const double temp = 500.0; const double temp = 500.0;
ReferencePlatform platform;
System system; System system;
CustomIntegrator integrator(0.002); CustomIntegrator integrator(0.002);
integrator.addPerDofVariable("oldx", 0); integrator.addPerDofVariable("oldx", 0);
...@@ -160,7 +160,6 @@ void testConstraints() { ...@@ -160,7 +160,6 @@ void testConstraints() {
*/ */
void testVelocityConstraints() { void testVelocityConstraints() {
const int numParticles = 10; const int numParticles = 10;
ReferencePlatform platform;
System system; System system;
CustomIntegrator integrator(0.002); CustomIntegrator integrator(0.002);
integrator.addPerDofVariable("x1", 0); integrator.addPerDofVariable("x1", 0);
...@@ -236,7 +235,6 @@ void testVelocityConstraints() { ...@@ -236,7 +235,6 @@ void testVelocityConstraints() {
} }
void testConstrainedMasslessParticles() { void testConstrainedMasslessParticles() {
ReferencePlatform platform;
System system; System system;
system.addParticle(0.0); system.addParticle(0.0);
system.addParticle(1.0); system.addParticle(1.0);
...@@ -282,7 +280,6 @@ void testWithThermostat() { ...@@ -282,7 +280,6 @@ void testWithThermostat() {
const double temp = 100.0; const double temp = 100.0;
const double collisionFreq = 10.0; const double collisionFreq = 10.0;
const int numSteps = 5000; const int numSteps = 5000;
ReferencePlatform platform;
System system; System system;
CustomIntegrator integrator(0.003); CustomIntegrator integrator(0.003);
integrator.addUpdateContextState(); integrator.addUpdateContextState();
...@@ -324,7 +321,6 @@ void testWithThermostat() { ...@@ -324,7 +321,6 @@ void testWithThermostat() {
* Test a Monte Carlo integrator that uses global variables and depends on energy. * Test a Monte Carlo integrator that uses global variables and depends on energy.
*/ */
void testMonteCarlo() { void testMonteCarlo() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
system.addParticle(1.0); system.addParticle(1.0);
...@@ -379,7 +375,6 @@ void testMonteCarlo() { ...@@ -379,7 +375,6 @@ void testMonteCarlo() {
void testSum() { void testSum() {
const int numParticles = 200; const int numParticles = 200;
const double boxSize = 10; const double boxSize = 10;
ReferencePlatform platform;
System system; System system;
system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize)); system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize));
NonbondedForce* nb = new NonbondedForce(); NonbondedForce* nb = new NonbondedForce();
...@@ -422,7 +417,6 @@ void testSum() { ...@@ -422,7 +417,6 @@ void testSum() {
* Test an integrator that both uses and modifies a context parameter. * Test an integrator that both uses and modifies a context parameter.
*/ */
void testParameter() { void testParameter() {
ReferencePlatform platform;
System system; System system;
system.addParticle(1.0); system.addParticle(1.0);
AndersenThermostat* thermostat = new AndersenThermostat(0.1, 0.1); AndersenThermostat* thermostat = new AndersenThermostat(0.1, 0.1);
...@@ -448,7 +442,6 @@ void testRandomDistributions() { ...@@ -448,7 +442,6 @@ void testRandomDistributions() {
const int numParticles = 100; const int numParticles = 100;
const int numBins = 20; const int numBins = 20;
const int numSteps = 100; const int numSteps = 100;
ReferencePlatform platform;
System system; System system;
for (int i = 0; i < numParticles; i++) for (int i = 0; i < numParticles; i++)
system.addParticle(1.0); system.addParticle(1.0);
...@@ -516,7 +509,6 @@ void testRandomDistributions() { ...@@ -516,7 +509,6 @@ void testRandomDistributions() {
void testPerDofVariables() { void testPerDofVariables() {
const int numParticles = 200; const int numParticles = 200;
const double boxSize = 10; const double boxSize = 10;
ReferencePlatform platform;
System system; System system;
system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize)); system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize));
NonbondedForce* nb = new NonbondedForce(); NonbondedForce* nb = new NonbondedForce();
...@@ -571,7 +563,6 @@ void testPerDofVariables() { ...@@ -571,7 +563,6 @@ void testPerDofVariables() {
* Test evaluating force groups separately. * Test evaluating force groups separately.
*/ */
void testForceGroups() { void testForceGroups() {
ReferencePlatform platform;
System system; System system;
system.addParticle(2.0); system.addParticle(2.0);
system.addParticle(2.0); system.addParticle(2.0);
...@@ -647,7 +638,6 @@ void testForceGroups() { ...@@ -647,7 +638,6 @@ void testForceGroups() {
*/ */
void testRespa() { void testRespa() {
const int numParticles = 8; const int numParticles = 8;
ReferencePlatform platform;
System system; System system;
system.setDefaultPeriodicBoxVectors(Vec3(4, 0, 0), Vec3(0, 4, 0), Vec3(0, 0, 4)); system.setDefaultPeriodicBoxVectors(Vec3(4, 0, 0), Vec3(0, 4, 0), Vec3(0, 0, 4));
CustomIntegrator integrator(0.002); CustomIntegrator integrator(0.002);
......
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