diff --git a/src/KSPACE/ewald.cpp b/src/KSPACE/ewald.cpp index d0a78dd922..f5fb680f51 100644 --- a/src/KSPACE/ewald.cpp +++ b/src/KSPACE/ewald.cpp @@ -157,10 +157,11 @@ void Ewald::init() // zprd used rather than zprd_slab if (!gewaldflag) { + if (accuracy <= 0.0) + error->all(FLERR,"KSpace accuracy must be > 0"); g_ewald = accuracy*sqrt(natoms*cutoff*xprd*yprd*zprd) / (2.0*q2); - if (g_ewald >= 1.0) - error->all(FLERR,"KSpace accuracy too large to estimate G vector"); - g_ewald = sqrt(-log(g_ewald)) / cutoff; + if (g_ewald >= 1.0) g_ewald = (1.35 - 0.15*log(accuracy))/cutoff; + else g_ewald = sqrt(-log(g_ewald)) / cutoff; } // setup Ewald coefficients so can print stats diff --git a/src/KSPACE/ewald.h b/src/KSPACE/ewald.h index 858c475073..f4cd938cac 100644 --- a/src/KSPACE/ewald.h +++ b/src/KSPACE/ewald.h @@ -119,9 +119,9 @@ W: System is not charge neutral, net charge = %g The total charge on all atoms on the system is not 0.0, which is not valid for Ewald or PPPM. -E: KSpace accuracy too large to estimate G vector +E: KSpace accuracy must be > 0 -UNDOCUMENTED +The kspace accuracy designated in the input must be greater than zero. E: Cannot (yet) use Kspace slab correction with compute group/group diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index 560389b1fa..74479551d4 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -1003,10 +1003,11 @@ void PPPM::set_grid() bigint natoms = atom->natoms; if (!gewaldflag) { + if (accuracy <= 0.0) + error->all(FLERR,"KSpace accuracy must be > 0"); g_ewald = accuracy*sqrt(natoms*cutoff*xprd*yprd*zprd) / (2.0*q2); - if (g_ewald >= 1.0) - error->all(FLERR,"KSpace accuracy too large to estimate G vector"); - g_ewald = sqrt(-log(g_ewald)) / cutoff; + if (g_ewald >= 1.0) g_ewald = (1.35 - 0.15*log(accuracy))/cutoff; + else g_ewald = sqrt(-log(g_ewald)) / cutoff; } // set optimal nx_pppm,ny_pppm,nz_pppm based on order and accuracy diff --git a/src/KSPACE/pppm.h b/src/KSPACE/pppm.h index 25407fb7fb..849b08322f 100644 --- a/src/KSPACE/pppm.h +++ b/src/KSPACE/pppm.h @@ -245,9 +245,9 @@ to run, but can reduce the order no further. Try increasing the accuracy of PPPM by reducing the tolerance size, thus inducing a larger PPPM grid. -E: KSpace accuracy too large to estimate G vector +E: KSpace accuracy must be > 0 -UNDOCUMENTED +The kspace accuracy designated in the input must be greater than zero. E: Cannot compute PPPM G