Commit 56766760 authored by Peter Eastman's avatar Peter Eastman
Browse files

Tolerate round-off error when checking the box size against the cutoff distance

parent 761b4bbf
......@@ -52,7 +52,7 @@ void CudaCalcForcesAndEnergyKernel::beginComputation(ContextImpl& context, bool
gpuReorderAtoms(gpu);
if ((data.hasNonbonded && data.nonbondedMethod != NO_CUTOFF && data.nonbondedMethod != CUTOFF) ||
(data.hasCustomNonbonded && data.customNonbondedMethod != NO_CUTOFF && data.customNonbondedMethod != CUTOFF)) {
double minAllowedSize = 2*gpu->sim.nonbondedCutoff;
double minAllowedSize = 1.999999*gpu->sim.nonbondedCutoff;
if (gpu->sim.periodicBoxSizeX < minAllowedSize || gpu->sim.periodicBoxSizeY < minAllowedSize || gpu->sim.periodicBoxSizeZ < minAllowedSize)
throw OpenMMException("The periodic box size has decreased to less than twice the nonbonded cutoff.");
}
......
......@@ -320,7 +320,7 @@ void OpenCLNonbondedUtilities::prepareInteractions() {
return;
if (usePeriodic) {
mm_float4 box = context.getPeriodicBoxSize();
double minAllowedSize = 2*cutoff;
double minAllowedSize = 1.999999*cutoff;
if (box.x < minAllowedSize || box.y < minAllowedSize || box.z < minAllowedSize)
throw OpenMMException("The periodic box size has decreased to less than twice the nonbonded cutoff.");
}
......
......@@ -690,7 +690,7 @@ double ReferenceCalcNonbondedForceKernel::execute(ContextImpl& context, bool inc
}
if (periodic || ewald || pme) {
RealVec& box = extractBoxSize(context);
double minAllowedSize = 2*nonbondedCutoff;
double minAllowedSize = 1.999999*nonbondedCutoff;
if (box[0] < minAllowedSize || box[1] < minAllowedSize || box[2] < minAllowedSize)
throw OpenMMException("The periodic box size has decreased to less than twice the nonbonded cutoff.");
clj.setPeriodic(box);
......
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