Improved rms force error estimate for coulomb tables. Now takes into consideration charge density, cutoff, number of atoms, etc.

git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8463 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
pscrozi
2012-07-03 15:47:48 +00:00
parent 93adc50c75
commit 56ca4db42c
4 changed files with 21 additions and 20 deletions

View File

@ -174,9 +174,9 @@ void Ewald::init()
double lpry = rms(kymax,yprd,natoms,q2); double lpry = rms(kymax,yprd,natoms,q2);
double lprz = rms(kzmax,zprd_slab,natoms,q2); double lprz = rms(kzmax,zprd_slab,natoms,q2);
double lpr = sqrt(lprx*lprx + lpry*lpry + lprz*lprz) / sqrt(3.0); double lpr = sqrt(lprx*lprx + lpry*lpry + lprz*lprz) / sqrt(3.0);
double spr = 2.0*q2 * exp(-g_ewald*g_ewald*cutoff*cutoff) / double q2_over_sqrt = q2 / sqrt(natoms*cutoff*xprd*yprd*zprd_slab);
sqrt(natoms*cutoff*xprd*yprd*zprd_slab); double spr = 2.0 *q2_over_sqrt * exp(-g_ewald*g_ewald*cutoff*cutoff);
double tpr = estimate_table_accuracy(spr); double tpr = estimate_table_accuracy(q2_over_sqrt,spr);
double accuracy = sqrt(lpr*lpr + spr*spr + tpr*tpr); double accuracy = sqrt(lpr*lpr + spr*spr + tpr*tpr);
// stats // stats

View File

@ -1089,9 +1089,9 @@ void PPPM::set_grid()
double lpry = rms(h_y,yprd,natoms,q2,acons); double lpry = rms(h_y,yprd,natoms,q2,acons);
double lprz = rms(h_z,zprd_slab,natoms,q2,acons); double lprz = rms(h_z,zprd_slab,natoms,q2,acons);
double lpr = sqrt(lprx*lprx + lpry*lpry + lprz*lprz) / sqrt(3.0); double lpr = sqrt(lprx*lprx + lpry*lpry + lprz*lprz) / sqrt(3.0);
double spr = 2.0*q2 * exp(-g_ewald*g_ewald*cutoff*cutoff) / double q2_over_sqrt = q2 / sqrt(natoms*cutoff*xprd*yprd*zprd_slab);
sqrt(natoms*cutoff*xprd*yprd*zprd_slab); double spr = 2.0 *q2_over_sqrt * exp(-g_ewald*g_ewald*cutoff*cutoff);
double tpr = estimate_table_accuracy(spr); double tpr = estimate_table_accuracy(q2_over_sqrt,spr);
double accuracy = sqrt(lpr*lpr + spr*spr + tpr*tpr); double accuracy = sqrt(lpr*lpr + spr*spr + tpr*tpr);
// free local memory // free local memory

View File

@ -129,30 +129,31 @@ void KSpace::ev_setup(int eflag, int vflag)
estimate the accuracy of the short-range coulomb tables estimate the accuracy of the short-range coulomb tables
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double KSpace::estimate_table_accuracy(double spr) double KSpace::estimate_table_accuracy(double q2_over_sqrt, double spr)
{ {
double table_accuracy = 0.0; double table_accuracy = 0.0;
int nctb = force->pair->ncoultablebits; int nctb = force->pair->ncoultablebits;
if (nctb) { if (nctb) {
double empirical_precision[17]; double empirical_precision[17];
empirical_precision[6] = 2.12E-04; empirical_precision[6] = 6.99E-03;
empirical_precision[7] = 4.97E-05; empirical_precision[7] = 1.78E-03;
empirical_precision[8] = 1.24E-05; empirical_precision[8] = 4.72E-04;
empirical_precision[9] = 3.04E-06; empirical_precision[9] = 1.17E-04;
empirical_precision[10] = 8.51E-07; empirical_precision[10] = 2.95E-05;
empirical_precision[11] = 1.85E-07; empirical_precision[11] = 7.41E-06;
empirical_precision[12] = 5.87E-08; empirical_precision[12] = 1.76E-06;
empirical_precision[13] = 2.81E-08; empirical_precision[13] = 9.28E-07;
empirical_precision[14] = 2.20E-08; empirical_precision[14] = 7.46E-07;
empirical_precision[15] = 2.13E-08; empirical_precision[15] = 7.32E-07;
empirical_precision[16] = 2.11E-08; empirical_precision[16] = 7.30E-07;
if (nctb <= 6) table_accuracy = empirical_precision[6]; if (nctb <= 6) table_accuracy = empirical_precision[6];
else if (nctb <= 16) table_accuracy = empirical_precision[nctb]; else if (nctb <= 16) table_accuracy = empirical_precision[nctb];
else table_accuracy = empirical_precision[16]; else table_accuracy = empirical_precision[16];
table_accuracy *= two_charge_force; table_accuracy *= q2_over_sqrt;
if (table_accuracy > spr) if (table_accuracy > spr)
error->warning(FLERR,"For better accuracy use 'pair_modify table 0'"); error->warning(FLERR,"For better accuracy use 'pair_modify table 0'");
} }
return table_accuracy; return table_accuracy;
} }

View File

@ -70,7 +70,7 @@ class KSpace : protected Pointers {
int maxeatom,maxvatom; int maxeatom,maxvatom;
void ev_setup(int, int); void ev_setup(int, int);
double estimate_table_accuracy(double); double estimate_table_accuracy(double, double);
}; };
} }