Commit f66c9b61 authored by peastman's avatar peastman
Browse files

Simplification to reference platform tests

parent 2762adf4
......@@ -48,12 +48,13 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
void testTemperature() {
const int numParticles = 8;
const double temp = 100.0;
const double collisionFreq = 10.0;
const int numSteps = 5000;
ReferencePlatform platform;
System system;
VerletIntegrator integrator(0.003);
NonbondedForce* forceField = new NonbondedForce();
......@@ -94,7 +95,6 @@ void testConstraints() {
const double temp = 100.0;
const double collisionFreq = 10.0;
const int numSteps = 15000;
ReferencePlatform platform;
System system;
VerletIntegrator integrator(0.004);
NonbondedForce* forceField = new NonbondedForce();
......@@ -147,7 +147,6 @@ void testRandomSeed() {
const int numParticles = 8;
const double temp = 100.0;
const double collisionFreq = 10.0;
ReferencePlatform platform;
System system;
VerletIntegrator integrator(0.01);
NonbondedForce* forceField = new NonbondedForce();
......
......@@ -48,10 +48,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testSingleBond() {
ReferencePlatform platform;
System system;
system.addParticle(2.0);
system.addParticle(2.0);
......@@ -88,7 +89,6 @@ void testTemperature() {
const int numParticles = 8;
const int numBonds = numParticles-1;
const double temp = 10.0;
ReferencePlatform platform;
System system;
BrownianIntegrator integrator(temp, 2.0, 0.01);
HarmonicBondForce* forceField = new HarmonicBondForce();
......@@ -125,7 +125,6 @@ void testTemperature() {
void testConstraints() {
const int numParticles = 8;
const double temp = 100.0;
ReferencePlatform platform;
System system;
BrownianIntegrator integrator(temp, 2.0, 0.001);
integrator.setConstraintTolerance(1e-5);
......@@ -165,7 +164,6 @@ void testConstraints() {
}
void testConstrainedMasslessParticles() {
ReferencePlatform platform;
System system;
system.addParticle(0.0);
system.addParticle(1.0);
......@@ -200,7 +198,6 @@ void testRandomSeed() {
const int numParticles = 8;
const double temp = 100.0;
const double collisionFreq = 10.0;
ReferencePlatform platform;
System system;
BrownianIntegrator integrator(temp, 2.0, 0.001);
NonbondedForce* forceField = new NonbondedForce();
......
......@@ -49,6 +49,8 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
Vec3 calcCM(const vector<Vec3>& values, System& system) {
Vec3 cm;
for (int j = 0; j < system.getNumParticles(); ++j) {
......@@ -63,7 +65,6 @@ void testMotionRemoval() {
const int numParticles = 8;
const double temp = 100.0;
const double collisionFreq = 10.0;
ReferencePlatform platform;
System system;
VerletIntegrator integrator(0.01);
HarmonicBondForce* bonds = new HarmonicBondForce();
......
......@@ -48,6 +48,8 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void compareStates(State& s1, State& s2) {
......@@ -71,7 +73,6 @@ void testCheckpoint() {
const int numParticles = 10;
const double boxSize = 3.0;
const double temperature = 200.0;
ReferencePlatform platform;
System system;
system.addForce(new AndersenThermostat(0.0, 100.0));
NonbondedForce* nonbonded = new NonbondedForce();
......@@ -125,7 +126,6 @@ void testSetState() {
const int numParticles = 10;
const double boxSize = 3.0;
const double temperature = 200.0;
ReferencePlatform platform;
System system;
system.addForce(new AndersenThermostat(0.0, 100.0));
NonbondedForce* nonbonded = new NonbondedForce();
......
......@@ -47,11 +47,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testAngles() {
ReferencePlatform platform;
// Create a system using a CustomAngleForce.
System customSystem;
......
......@@ -46,10 +46,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testBonds() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......
......@@ -52,11 +52,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testBond() {
ReferencePlatform platform;
// Create a system using a CustomCompoundBondForce.
System customSystem;
......@@ -147,7 +147,6 @@ void testBond() {
}
void testPositionDependence() {
ReferencePlatform platform;
System customSystem;
customSystem.addParticle(1.0);
customSystem.addParticle(1.0);
......@@ -179,7 +178,6 @@ void testContinuous2DFunction() {
const double xmax = 1.1;
const double ymin = 0.0;
const double ymax = 0.9;
ReferencePlatform platform;
System system;
system.addParticle(1.0);
VerletIntegrator integrator(0.01);
......@@ -227,7 +225,6 @@ void testContinuous3DFunction() {
const double ymax = 0.9;
const double zmin = 0.2;
const double zmax = 1.3;
ReferencePlatform platform;
System system;
system.addParticle(1.0);
VerletIntegrator integrator(0.01);
......@@ -273,7 +270,6 @@ void testContinuous3DFunction() {
void testMultipleBonds() {
// Two compound bonds using Urey-Bradley example from API doc
ReferencePlatform platform;
System customSystem;
customSystem.addParticle(1.0);
customSystem.addParticle(1.0);
......
......@@ -46,10 +46,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testForce() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......
......@@ -51,6 +51,8 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testOBC(GBSAOBCForce::NonbondedMethod obcMethod, CustomGBForce::NonbondedMethod customMethod) {
......@@ -58,7 +60,6 @@ void testOBC(GBSAOBCForce::NonbondedMethod obcMethod, CustomGBForce::NonbondedMe
const int numParticles = numMolecules*2;
const double boxSize = 10.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.
......@@ -190,7 +191,6 @@ void testMembrane() {
const int numMolecules = 70;
const int numParticles = numMolecules*2;
const double boxSize = 10.0;
ReferencePlatform platform;
// Create a system with an implicit membrane.
......@@ -280,7 +280,6 @@ void testMembrane() {
}
void testTabulatedFunction() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -313,7 +312,6 @@ void testTabulatedFunction() {
}
void testMultipleChainRules() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -341,7 +339,6 @@ void testMultipleChainRules() {
}
void testPositionDependence() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -405,7 +402,6 @@ void testPositionDependence() {
}
void testExclusions() {
ReferencePlatform platform;
for (int i = 3; i < 4; i++) {
System system;
system.addParticle(1.0);
......@@ -817,7 +813,6 @@ void testGBVI(GBVIForce::NonbondedMethod gbviMethod, CustomGBForce::NonbondedMet
const int numMolecules = 1;
const double boxSize = 10.0;
ReferencePlatform platform;
GBVIForce* gbvi = new GBVIForce();
std::vector<Vec3> positions;
......
......@@ -49,11 +49,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testHbond() {
ReferencePlatform platform;
// Create a system using a CustomHbondForce.
System customSystem;
......@@ -151,7 +151,6 @@ void testHbond() {
}
void testExclusions() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -178,7 +177,6 @@ void testExclusions() {
}
void testCutoff() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -206,7 +204,6 @@ void testCutoff() {
}
void testCustomFunctions() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......
......@@ -49,13 +49,14 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
/**
* Test a simple leapfrog integrator on a single bond.
*/
void testSingleBond() {
ReferencePlatform platform;
System system;
system.addParticle(2.0);
system.addParticle(2.0);
......@@ -101,7 +102,6 @@ void testSingleBond() {
void testConstraints() {
const int numParticles = 8;
const double temp = 500.0;
ReferencePlatform platform;
System system;
CustomIntegrator integrator(0.002);
integrator.addPerDofVariable("oldx", 0);
......@@ -160,7 +160,6 @@ void testConstraints() {
*/
void testVelocityConstraints() {
const int numParticles = 10;
ReferencePlatform platform;
System system;
CustomIntegrator integrator(0.002);
integrator.addPerDofVariable("x1", 0);
......@@ -236,7 +235,6 @@ void testVelocityConstraints() {
}
void testConstrainedMasslessParticles() {
ReferencePlatform platform;
System system;
system.addParticle(0.0);
system.addParticle(1.0);
......@@ -282,7 +280,6 @@ void testWithThermostat() {
const double temp = 100.0;
const double collisionFreq = 10.0;
const int numSteps = 5000;
ReferencePlatform platform;
System system;
CustomIntegrator integrator(0.003);
integrator.addUpdateContextState();
......@@ -324,7 +321,6 @@ void testWithThermostat() {
* Test a Monte Carlo integrator that uses global variables and depends on energy.
*/
void testMonteCarlo() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -379,7 +375,6 @@ void testMonteCarlo() {
void testSum() {
const int numParticles = 200;
const double boxSize = 10;
ReferencePlatform platform;
System system;
system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize));
NonbondedForce* nb = new NonbondedForce();
......@@ -422,7 +417,6 @@ void testSum() {
* Test an integrator that both uses and modifies a context parameter.
*/
void testParameter() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
AndersenThermostat* thermostat = new AndersenThermostat(0.1, 0.1);
......@@ -448,7 +442,6 @@ void testRandomDistributions() {
const int numParticles = 100;
const int numBins = 20;
const int numSteps = 100;
ReferencePlatform platform;
System system;
for (int i = 0; i < numParticles; i++)
system.addParticle(1.0);
......@@ -516,7 +509,6 @@ void testRandomDistributions() {
void testPerDofVariables() {
const int numParticles = 200;
const double boxSize = 10;
ReferencePlatform platform;
System system;
system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize));
NonbondedForce* nb = new NonbondedForce();
......@@ -571,7 +563,6 @@ void testPerDofVariables() {
* Test evaluating force groups separately.
*/
void testForceGroups() {
ReferencePlatform platform;
System system;
system.addParticle(2.0);
system.addParticle(2.0);
......@@ -647,7 +638,6 @@ void testForceGroups() {
*/
void testRespa() {
const int numParticles = 8;
ReferencePlatform platform;
System system;
system.setDefaultPeriodicBoxVectors(Vec3(4, 0, 0), Vec3(0, 4, 0), Vec3(0, 0, 4));
CustomIntegrator integrator(0.002);
......
......@@ -51,6 +51,8 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
Vec3 computeDelta(const Vec3& pos1, const Vec3& pos2, bool periodic, const Vec3* periodicBoxVectors) {
......@@ -93,7 +95,6 @@ void validateAxilrodTeller(CustomManyParticleForce* force, const vector<Vec3>& p
ASSERT(!system.usesPeriodicBoundaryConditions());
}
VerletIntegrator integrator(0.001);
ReferencePlatform platform;
Context context(system, integrator, platform);
context.setPositions(positions);
State state1 = context.getState(State::Forces | State::Energy);
......@@ -155,7 +156,6 @@ void validateStillingerWeber(CustomManyParticleForce* force, const vector<Vec3>&
system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize));
system.addForce(force);
VerletIntegrator integrator(0.001);
ReferencePlatform platform;
Context context(system, integrator, platform);
context.setPositions(positions);
State state1 = context.getState(State::Forces | State::Energy);
......@@ -340,7 +340,6 @@ void testExclusions() {
void testAllTerms() {
int numParticles = 4;
ReferencePlatform platform;
// Create a system with a CustomManyParticleForce.
......@@ -424,7 +423,6 @@ void testParameters() {
}
system.addForce(force);
VerletIntegrator integrator(0.001);
ReferencePlatform platform;
Context context(system, integrator, platform);
context.setPositions(positions);
......@@ -510,7 +508,6 @@ void testTabulatedFunctions() {
}
system.addForce(force);
VerletIntegrator integrator(0.001);
ReferencePlatform platform;
Context context(system, integrator, platform);
context.setPositions(positions);
......@@ -562,7 +559,6 @@ void testTypeFilters() {
force->setTypeFilter(2, f2);
system.addForce(force);
VerletIntegrator integrator(0.001);
ReferencePlatform platform;
Context context(system, integrator, platform);
context.setPositions(positions);
......
......@@ -53,10 +53,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testSimpleExpression() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -79,7 +80,6 @@ void testSimpleExpression() {
}
void testParameters() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -140,7 +140,6 @@ void testParameters() {
}
void testExclusions() {
ReferencePlatform platform;
System system;
VerletIntegrator integrator(0.01);
CustomNonbondedForce* nonbonded = new CustomNonbondedForce("a*r; a=a1+a2");
......@@ -171,7 +170,6 @@ void testExclusions() {
}
void testCutoff() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -201,7 +199,6 @@ void testCutoff() {
}
void testPeriodic() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -232,7 +229,6 @@ void testPeriodic() {
}
void testTriclinic() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -292,7 +288,6 @@ void testTriclinic() {
}
void testContinuous1DFunction() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -337,7 +332,6 @@ void testContinuous2DFunction() {
const double xmax = 1.5;
const double ymin = 0.0;
const double ymax = 2.1;
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -389,7 +383,6 @@ void testContinuous3DFunction() {
const double ymax = 0.7;
const double zmin = 0.2;
const double zmax = 0.9;
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -439,7 +432,6 @@ void testContinuous3DFunction() {
}
void testDiscrete1DFunction() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -469,7 +461,6 @@ void testDiscrete1DFunction() {
void testDiscrete2DFunction() {
const int xsize = 10;
const int ysize = 5;
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -503,7 +494,6 @@ void testDiscrete3DFunction() {
const int xsize = 8;
const int ysize = 5;
const int zsize = 6;
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -540,7 +530,6 @@ void testCoulombLennardJones() {
const int numMolecules = 300;
const int numParticles = numMolecules*2;
const double boxSize = 20.0;
ReferencePlatform platform;
// Create two systems: one with a NonbondedForce, and one using a CustomNonbondedForce to implement the same interaction.
......@@ -614,7 +603,6 @@ void testCoulombLennardJones() {
}
void testSwitchingFunction() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -673,7 +661,6 @@ void testLongRangeCorrection() {
int numParticles = gridSize*gridSize*gridSize;
double boxSize = gridSize*0.7;
double cutoff = boxSize/3;
ReferencePlatform platform;
System standardSystem;
System customSystem;
VerletIntegrator integrator1(0.01);
......@@ -748,7 +735,6 @@ void testLongRangeCorrection() {
void testInteractionGroups() {
const int numParticles = 6;
ReferencePlatform platform;
System system;
VerletIntegrator integrator(0.01);
CustomNonbondedForce* nonbonded = new CustomNonbondedForce("v1+v2");
......@@ -790,7 +776,6 @@ void testLargeInteractionGroup() {
// Create a large system.
ReferencePlatform platform;
System system;
system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize));
for (int i = 0; i < numParticles; i++)
......@@ -868,7 +853,6 @@ void testInteractionGroupLongRangeCorrection() {
const int numParticles = 10;
const double boxSize = 10.0;
const double cutoff = 0.5;
ReferencePlatform platform;
System system;
system.setDefaultPeriodicBoxVectors(Vec3(boxSize, 0, 0), Vec3(0, boxSize, 0), Vec3(0, 0, boxSize));
CustomNonbondedForce* nonbonded = new CustomNonbondedForce("c1*c2*r^-4");
......
......@@ -50,11 +50,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testTorsions() {
ReferencePlatform platform;
// Create a system using a CustomTorsionForce.
System customSystem;
......@@ -141,7 +141,6 @@ void testTorsions() {
}
void testRange() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......
......@@ -48,6 +48,8 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double EWALD_TOL = 1e-5;
const double PME_TOL = 5e-5;
......@@ -59,9 +61,7 @@ void testEwaldExact() {
const double cutoff = 1.0;
const double boxSize = 2.82;
ReferencePlatform platform;
System system;
for (int i = 0; i < numParticles/2; i++)
system.addParticle(22.99);
for (int i = 0; i < numParticles/2; i++)
......@@ -112,7 +112,6 @@ void testEwaldPME() {
// Use amorphous NaCl system
// The particles are simple charges, no VdW interactions
ReferencePlatform platform;
System system;
for (int i = 0; i < numParticles/2; i++)
system.addParticle(22.99);
......@@ -217,7 +216,6 @@ void testEwaldPME() {
}
void testEwald2Ions() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -244,7 +242,6 @@ void testEwald2Ions() {
}
void testWaterSystem() {
ReferencePlatform platform;
System system;
static int numParticles = 648;
const double boxSize = 1.86206;
......@@ -305,7 +302,6 @@ void testWaterSystem() {
void testTriclinic() {
// Create a triclinic box containing eight particles.
ReferencePlatform platform;
System system;
system.setDefaultPeriodicBoxVectors(Vec3(2.5, 0, 0), Vec3(0.5, 3.0, 0), Vec3(0.7, 0.9, 3.5));
for (int i = 0; i < 8; i++)
......@@ -373,7 +369,6 @@ void testErrorTolerance(NonbondedForce::NonbondedMethod method) {
positions[i] = Vec3(boxWidth*genrand_real2(sfmt), boxWidth*genrand_real2(sfmt), boxWidth*genrand_real2(sfmt));
}
force->setNonbondedMethod(method);
ReferencePlatform platform;
// For various values of the cutoff and error tolerance, see if the actual error is reasonable.
......@@ -425,7 +420,6 @@ void testPMEParameters() {
positions[i] = Vec3(boxWidth*genrand_real2(sfmt), boxWidth*genrand_real2(sfmt), boxWidth*genrand_real2(sfmt));
}
force->setNonbondedMethod(NonbondedForce::PME);
ReferencePlatform platform;
// Compute the energy with an error tolerance of 1e-3.
......
......@@ -48,10 +48,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testSingleParticle() {
ReferencePlatform platform;
System system;
system.addParticle(2.0);
LangevinIntegrator integrator(0, 0.1, 0.01);
......@@ -85,7 +86,6 @@ void testSingleParticle() {
}
void testGlobalSettings() {
ReferencePlatform platform;
System system;
system.addParticle(2.0);
LangevinIntegrator integrator(0, 0.1, 0.01);
......@@ -114,7 +114,6 @@ void testGlobalSettings() {
}
void testCutoffAndPeriodic() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......@@ -183,7 +182,6 @@ void testCutoffAndPeriodic() {
}
void testForce() {
ReferencePlatform platform;
const int numParticles = 10;
System system;
LangevinIntegrator integrator(0, 0.1, 0.01);
......
......@@ -50,10 +50,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testSingleParticle() {
ReferencePlatform platform;
System system;
system.addParticle(2.0);
LangevinIntegrator integrator(0, 0.1, 0.01);
......@@ -89,8 +90,6 @@ void testSingleParticle() {
}
void testEnergyEthane(int applyBornRadiiScaling) {
ReferencePlatform platform;
const int numParticles = 8;
System system;
LangevinIntegrator integrator(0, 0.1, 0.01);
......
......@@ -46,10 +46,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testAngles() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......
......@@ -46,10 +46,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testBonds() {
ReferencePlatform platform;
System system;
system.addParticle(1.0);
system.addParticle(1.0);
......
......@@ -44,10 +44,11 @@
using namespace OpenMM;
using namespace std;
ReferencePlatform platform;
const double TOL = 1e-5;
void testCalcKE() {
ReferencePlatform platform;
System system;
for (int i = 0; i < 4; ++i)
system.addParticle(i+1);
......
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