Commit 4ed151e1 authored by Peter Eastman's avatar Peter Eastman
Browse files

Continuing to refactor tests

parent ccd811da
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -167,6 +167,7 @@ void testPeriodic() { ...@@ -167,6 +167,7 @@ void testPeriodic() {
} }
} }
void runPlatformTests(); void runPlatformTests();
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
......
...@@ -455,16 +455,18 @@ void testExclusions() { ...@@ -455,16 +455,18 @@ void testExclusions() {
for (int i = 0; i < (int) forces.size(); ++i) for (int i = 0; i < (int) forces.size(); ++i)
norm += forces[i].dot(forces[i]); norm += forces[i].dot(forces[i]);
norm = std::sqrt(norm); norm = std::sqrt(norm);
const double stepSize = 1e-3; if (norm > 0) {
double step = stepSize/norm; const double stepSize = 1e-3;
for (int i = 0; i < (int) positions.size(); ++i) { double step = stepSize/norm;
Vec3 p = positions[i]; for (int i = 0; i < (int) positions.size(); ++i) {
Vec3 f = forces[i]; Vec3 p = positions[i];
positions[i] = Vec3(p[0]-f[0]*step, p[1]-f[1]*step, p[2]-f[2]*step); Vec3 f = forces[i];
positions[i] = Vec3(p[0]-f[0]*step, p[1]-f[1]*step, p[2]-f[2]*step);
}
context.setPositions(positions);
State state2 = context.getState(State::Energy);
ASSERT_EQUAL_TOL(norm, (state2.getPotentialEnergy()-state.getPotentialEnergy())/stepSize, 1e-3*abs(state.getPotentialEnergy()));
} }
context.setPositions(positions);
State state2 = context.getState(State::Energy);
ASSERT_EQUAL_TOL(norm, (state2.getPotentialEnergy()-state.getPotentialEnergy())/stepSize, 1e-3*abs(state.getPotentialEnergy()));
} }
} }
......
This diff is collapsed.
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