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

Bug fix to selection of Ewald parameters

parent 83d57922
......@@ -310,9 +310,15 @@ void CudaCalcNonbondedForceKernel::initialize(const System& system, const Nonbon
double my = boxVectors[1][1]/force.getCutoffDistance();
double mz = boxVectors[2][2]/force.getCutoffDistance();
double pi = 3.1415926535897932385;
int kmaxx = std::ceil(-(mx/pi)*std::log(ewaldErrorTol));;
int kmaxy = std::ceil(-(my/pi)*std::log(ewaldErrorTol));;
int kmaxz = std::ceil(-(mz/pi)*std::log(ewaldErrorTol));;
int kmaxx = std::ceil(-(mx/pi)*std::log(ewaldErrorTol));
int kmaxy = std::ceil(-(my/pi)*std::log(ewaldErrorTol));
int kmaxz = std::ceil(-(mz/pi)*std::log(ewaldErrorTol));
if (kmaxx%2 == 0)
kmaxx++;
if (kmaxy%2 == 0)
kmaxy++;
if (kmaxz%2 == 0)
kmaxz++;
gpuSetEwaldParameters(gpu, alpha, kmaxx, kmaxy, kmaxz);
method = EWALD;
}
......
......@@ -402,6 +402,12 @@ void ReferenceCalcNonbondedForceKernel::initialize(const System& system, const N
kmax[0] = std::ceil(-(mx/pi)*std::log(ewaldErrorTol));
kmax[1] = std::ceil(-(my/pi)*std::log(ewaldErrorTol));
kmax[2] = std::ceil(-(mz/pi)*std::log(ewaldErrorTol));
if (kmax[0]%2 == 0)
kmax[0]++;
if (kmax[1]%2 == 0)
kmax[1]++;
if (kmax[2]%2 == 0)
kmax[2]++;
}
}
......
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