2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2006, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012,2013, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
49 enum { mGuillot2001a, mAB1, mLjc, mMaaren, mGuillot_Maple, mHard_Wall, mGG, mGG_qd_q, mGG_qd_qd, mGG_q_q, mNR };
51 static double erf2(double x)
53 return -(2*x*M_2_SQRTPI)*exp(-x*x);
56 static double erf1(double x)
58 return M_2_SQRTPI*exp(-x*x);
61 static void do_hard(FILE *fp,int pts_nm,double efac,double delta)
64 double x,vr,vr2,vc,vc2;
67 gmx_fatal(FARGS,"Delta should be >= 0 rather than %f\n",delta);
70 for(i=0; (i<=imax); i++) {
74 /* Avoid very high numbers */
81 vr = erfc(efac*(x-delta))/2;
82 vr2 = (1-erf2(efac*(x-delta)))/2;
83 fprintf(fp,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
84 x,vr,vr2,0.0,0.0,vc,vc2);
89 static void do_AB1(FILE *fp,int eel,int pts_nm,int ndisp,int nrep)
92 double myfac[3] = { 1, -1, 1 };
93 double myexp[3] = { 1, 6, 0 };
99 for(i=0; (i<=imax); i++) {
102 fprintf(fp,"%12.5e",x);
104 for(k=0; (k<3); k++) {
106 /* Avoid very high numbers */
110 v = myfac[k]*pow(x,-myexp[k]);
111 v2 = (myexp[k]+1)*(myexp[k])*v/(x*x);
113 fprintf(fp," %12.5e %12.5e",v,v2);
119 static void lo_do_ljc(double r,
120 double *vc,double *fc,
121 double *vd,double *fd,
122 double *vr,double *fr)
127 r_6 = 1.0/(r2*r2*r2);
130 *vc = 1.0/r; /* f(x) Coulomb */
131 *fc = 1.0/(r2); /* -f'(x) */
133 *vd = -r_6; /* g(c) Dispersion */
134 *fd = 6.0*(*vd)/r; /* -g'(x) */
136 *vr = r_12; /* h(x) Repulsion */
137 *fr = 12.0*(*vr)/r; /* -h'(x) */
140 /* use with coulombtype = user */
141 static void lo_do_ljc_pme(double r,
142 double rcoulomb, double ewald_rtol,
143 double *vc,double *fc,
144 double *vd,double *fd,
145 double *vr,double *fr)
150 ewc = calc_ewaldcoeff(rcoulomb,ewald_rtol);
153 r_6 = 1.0/(r2*r2*r2);
157 /* *vc2 = 2*erfc(ewc*r)/(r*r2)+2*exp(-(ewc*ewc*r2))*ewc*M_2_SQRTPI/r2+
158 2*ewc*ewc*ewc*exp(-(ewc*ewc*r2))*M_2_SQRTPI;*/
159 *fc = ewc*exp(-ewc*ewc*r2)*M_2_SQRTPI/r + erfc(ewc*r)/r2;
168 static void lo_do_guillot(double r,double xi, double xir,
169 double *vc,double *fc,
170 double *vd,double *fd,
171 double *vr,double *fr)
176 double sqpi = sqrt(M_PI);
181 r_6 = 1.0/(r2*r2*r2);
184 rxi2 = r/(sqrt(2)*xi);
185 *vc = (1 + f0*f0*erf(r/(2*xi)) + 2*f0*erf(r/(sqrt(2)*xi)) )/r;
187 *fc = f0*f0*erf(r/(2*xi)) + 2*f0*erf(r/(sqrt(2)*xi));
189 /* MuPad: Uc := erf(r/(2*xi))/r +
193 r2 := r/(Sqrt[2] * xi);
194 Uc[r_] := (1 + f0 * f0 * Erf[r/(2*xi)] + 2 * f0 * Erf[r/(Sqrt[2]*xi)]) / r;
197 -(((2*f0*Sqrt(2/Pi))/(Power(E,Power(r,2)/(2.*Power(xi,2)))*xi) +
198 Power(f0,2)/(Power(E,Power(r,2)/(4.*Power(xi,2)))*Sqrt(Pi)*xi))/r) +
199 (1 + Power(f0,2)*Erf(r/(2.*xi)) + 2*f0*Erf(r/(Sqrt(2)*xi)))/Power(r,2)
207 Uc2[r_] := f0^2 * Erf[r1] / r;
211 Uc3[r_] := 2 * f0 * Erf[r2]/ r;
214 Uc[r_] := Erf[r/(2*xi)] / r
222 *vc = (1 + sqr(f0)*erf(rxi1) + 2*f0*erf(rxi2))/r;
225 + (- f0 * (2 * sqrt(2) + exp(r2/4*xi*xi)*f0)/(exp(r2/(2*xi*xi))*sqrt(M_PI)*xi) + f0*f0*erf(r/(2*xi)) + 2 *f0 * erf(r/(sqrt(2 * xi))) )/r2)
229 /* *vc2 = ((2/sqr(r))*(*vc -
230 sqr(f0)*erf1(r1)/(2*xi) -
231 4*f0*erf1(r2)/sqrt(2)*xi) +
232 (1/r)*(sqr(f0/(2.0*xi))*erf2(r1) + (2*f0/sqr(xi)))*erf2(r2)); */
240 // *vr2 = (sqpi*(*vr)/(2.0*z*z)+(1.0/(z*z)+1)*exp(-z*z))/(sqpi*sqr(xir));
243 void lo_do_guillot_maple(double r,double xi,double xir,
244 double *vc,double *vc2,
245 double *vd,double *vd2,
246 double *vr,double *vr2)
251 double sqpi = sqrt(M_PI);
253 *vc = pow(-f0/(1.0+f0)+1.0,2.0)/r+pow(-f0/(1.0+f0)+1.0,2.0)*f0*f0*erf(r/xi/2.0)/r+2.0*pow(-f0/(1.0+f0)+1.0,2.0)*f0*erf(r*sqrt(2.0)/xi/2.0)/r;
254 *vc2 = 2.0*pow(-f0/(1.0+f0)+1.0,2.0)/(r*r*r)-pow(-f0/(1.0+f0)+1.0,2.0)*f0*f0/sqrt(M_PI)/(xi*xi*xi)*exp(-r*r/(xi*xi)/4.0)/2.0-2.0*pow(-f0/(1.0+f0)+1.0,2.0)*f0*f0/sqrt(M_PI)*exp(-r*r/(xi*xi)/4.0)/xi/(r*r)+2.0*pow(-f0/(1.0+f0)+1.0,2.0)*f0*f0*erf(r/xi/2.0)/(r*r*r)-2.0*pow(-f0/(1.0+f0)+1.0,2.0)*f0/sqrt(M_PI)/(xi*xi*xi)*exp(-r*r/(xi*xi)/2.0)*sqrt(2.0)-4.0*pow(-f0/(1.0+f0)+1.0,2.0)*f0/sqrt(M_PI)*exp(-r*r/(xi*xi)/2.0)*sqrt(2.0)/xi/(r*r)+4.0*pow(-f0/(1.0+f0)+1.0,2.0)*f0*erf(r*sqrt(2.0)/xi/2.0)/(r*r*r);
256 *vd = -1.0/(r*r*r*r*r*r);
257 *vd2 = -42.0/(r*r*r*r*r*r*r*r);
258 *vr = 2.0*erfc(r/xir/2.0)/r*xir;
259 *vr2 = 1.0/sqrt(M_PI)/(xir*xir)*exp(-r*r/(xir*xir)/4.0)+4.0/sqrt(M_PI)*exp(-r*r/(xir*xir)/4.0)/(r*r)+4.0*erfc(r/xir/2.0)/(r*r*r)*xir;
262 static void lo_do_GG(double r,double xi,double xir,
263 double *vc,double *fc,
264 double *vd,double *fd,
265 double *vr,double *fr)
270 double sqpi = sqrt(M_PI);
276 *vc = 1.0/r + f0*f0*erf(r/(2*xi))/r + 2*f0*erf(r/(sqrt(2)*xi))/r;
278 // -D[1/r,r] -D[f0*f0*Erf[r/(2*xi)]/r,r] -D[2*f0*Erf[r/(Sqrt[2]*xi)]/r,r]
281 f0*f0*(-exp(-r2/(4*xi2))/(sqrt(M_PI) * r * xi) + erf(r/(2*xi))/r2) +
282 2*f0*(-sqrt(2.0/M_PI)*exp(-r2/(2*xi2))/ (r*xi) + erf(r/(sqrt(2)*xi))/r2)
286 *vd = -1.0/(r*r*r*r*r*r);
289 // -D[2*xir*Erfc[r/(2*xir)]/r,r]
290 *vr = 2.*xir*erfc(r/(2.*xir))/r;
291 *fr = -(-2.*exp(-r2/(4*xir*xir)) / (sqrt(M_PI)*r) - 2*xir*erfc(r/(2*xir))/r2 );
295 /* Guillot2001 diffuse charge - diffuse charge interaction
298 In[19]:= Uc[r_] := Erf[r/(2*xi)]/r
305 Out[20]= -(-------------------------) + ---------
310 void lo_do_GG_qd_qd(double r,double xi,double xir,
311 double *vc,double *fc,
312 double *vd,double *fd,
313 double *vr,double *fr)
315 double sqpi = sqrt(M_PI);
317 *vc = erf(r/(2*xi))/r;
318 //erf((r*(1.0/2.0))/xi)/r;
319 *fc = -(1.0/(exp(r*r/(4*xi*xi))*sqpi*r*xi)) + (erf(r/2*xi)/(r*r));
321 //2.0*pow(r, -3.0)*erf((r*(1.0/2.0))/xi) - (1.0/2.0)*pow(M_PI, -1.0/2.0)*pow(xi, -3.0)*exp((-1.0/4.0)*(r*r)*pow(xi, -2.0)) - (2.0*pow(M_PI, -1.0/2.0)*pow(r, -2.0)*exp((-1.0/4.0)*(r*r)*pow(xi, -2.0)))/xi ;
328 /* Guillot2001 charge - diffuse charge interaction eqn 4 & 5
330 In[17]:= Uc[r_] := Erf[r/(Sqrt[2]*xi)]/r
335 Sqrt[--] Erf[----------]
337 Out[18]= -(----------------) + ---------------
342 void lo_do_GG_q_qd(double r,double xi,double xir,
343 double *vc,double *fc,
344 double *vd,double *fd,
345 double *vr,double *fr)
347 double sqpi = sqrt(M_PI);
349 *vc = erf(r/(sqrt(2)*xi)) / r;
350 //erf(((1.0/2.0)*pow(2.0, 1.0/2.0)*r)/xi)/r ;
351 *fc = -(sqrt(2/M_PI)/(exp(r*r/(2*xi*xi))*r*xi)) + (erf(r/(sqrt(2)*xi))/(r*r));
352 //2.0*pow(r, -3.0)*erf(((1.0/2.0)*pow(2.0, 1.0/2.0)*r)/xi) - pow(2.0, 1.0/2.0)*pow(M_PI, -1.0/2.0)*pow(xi, -3.0)*exp((-1.0/2.0)*(r*r)*pow(xi, -2.0)) - (2.0*pow(2.0, 1.0/2.0)*pow(M_PI, -1.0/2.0)*pow(r, -2.0)*exp((-1.0/2.0)*(r*r)*pow(xi, -2.0)))/xi ;
360 /* Guillot2001 charge - charge interaction (normal coulomb), repulsion and dispersion
363 In[6]:= Uc[r_] := 1.0/r
372 In[8]:= Ud[r_] := -1.0/r^6
381 In[13]:= Ur[r_] := (2*xir)*Erfc[r/(2*xir)]/r
387 Out[16]= ----------------------- + -----------------
394 void lo_do_GG_q_q(double r,double xi,double xir,
395 double *vc,double *fc,
396 double *vd,double *fd,
397 double *vr,double *fr)
399 double sqpi = sqrt(M_PI);
404 *vd = -1.0/(r*r*r*r*r*r);
405 *fd = -6.0/(r*r*r*r*r*r*r);
407 *vr = (2.0*xir*erfc(r/(2.0*xir)))/r;
408 *fr = 2.0/(exp((r*r)/(4*xir*xir)) * sqpi *r) + (2*xir*erfc((r*xir)/2.0))/(r*r);
409 //4.0*pow(M_PI, -1.0/2.0)*pow(r, -2.0)*exp((-1.0/4.0)*(r*r)*pow(xir, -2.0)) + pow(M_PI, -1.0/2.0)*pow(xir, -2.0)*exp((-1.0/4.0)*(r*r)*pow(xir, -2.0)) + 4.0*pow(r, -3.0)*xir*erfc((r*(1.0/2.0))/xir);
412 static void do_guillot(FILE *fp,int eel,int pts_nm,double rc,double rtol,double xi,double xir)
415 double r,vc,fc,vd,fd,vr,fr;
418 for(i=0; (i<=imax); i++) {
420 /* Avoid very large numbers */
422 vc = fc = vd = fd = vr = fr = 0;
426 fprintf(fp, "Not implemented\n");
427 } else if (eel == eelCUT) {
428 lo_do_guillot(r,xi,xir,&vc,&fc,&vd,&fd,&vr,&fr);
430 fprintf(fp,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
431 r,vc,fc,vd,fd,vr,fr);
437 PvM: Everything is hardcoded, we should fix that. How?
439 static void do_guillot2001a(const char *file,int eel,int pts_nm,double rc,double rtol,double xi,double xir)
442 static char buf[256];
443 static char *atype[] = { "HW", "OW", "HWd", "OWd", NULL };
444 int i,j,k,i0,imax,atypemax=4;
445 double r,vc,fc,vd,fd,vr,fr;
447 /* For Guillot2001a we have four types: HW, OW, HWd and OWd. */
449 for (j=0;(j<atypemax);j++) { /* loops over types */
450 for (k=0; (k<=j); k++) {
451 sprintf(buf,"table_%s_%s.xvg",atype[k],atype[j]);
453 printf("%d %d %s\n", j, k, buf);
454 /* Guillot2001a eqn 2, 6 and 7 */
455 if (((strcmp(atype[j],"HW") == 0) && (strcmp(atype[k],"HW") == 0)) ||
456 ((strcmp(atype[j],"OW") == 0) && (strcmp(atype[k],"HW") == 0)) ||
457 ((strcmp(atype[j],"OW") == 0) && (strcmp(atype[k],"OW") == 0))) {
459 fp = ffopen(buf,"w");
462 for(i=0; (i<=imax); i++) {
464 /* Avoid very large numbers */
466 vc = fc = vd = fd = vr = fr = 0;
469 if (eel == eelPME || eel == eelRF) {
470 fprintf(stderr, "Not implemented\n");
472 } else if (eel == eelCUT) {
473 lo_do_GG_q_q(r,xi,xir,&vc,&fc,&vd,&fd,&vr,&fr);
475 fprintf(fp,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
476 r,vc,fc,vd,fd,vr,fr);
481 /* Guillot eqn 4 and 5 */
482 } else if (((strcmp(atype[j],"HWd") == 0) && (strcmp(atype[k],"HW") == 0)) ||
483 ((strcmp(atype[j],"HWd") == 0) && (strcmp(atype[k],"OW") == 0)) ||
484 ((strcmp(atype[j],"OWd") == 0) && (strcmp(atype[k],"HW") == 0)) ||
485 ((strcmp(atype[j],"OWd") == 0) && (strcmp(atype[k],"OW") == 0))) {
487 fp = ffopen(buf,"w");
490 for(i=0; (i<=imax); i++) {
492 /* Avoid very large numbers */
494 vc = fc = vd = fd = vr = fr = 0;
497 if (eel == eelPME || eel == eelRF) {
498 fprintf(stderr, "Not implemented\n");
500 } else if (eel == eelCUT) {
501 lo_do_GG_q_qd(r,xi,xir,&vc,&fc,&vd,&fd,&vr,&fr);
503 fprintf(fp,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
504 r,vc,fc,vd,fd,vr,fr);
509 /* Guillot2001a eqn 3 */
510 } else if (((strcmp(atype[j],"HWd") == 0) && (strcmp(atype[k],"HWd") == 0)) ||
511 ((strcmp(atype[j],"OWd") == 0) && (strcmp(atype[k],"HWd") == 0)) ||
512 ((strcmp(atype[j],"OWd") == 0) && (strcmp(atype[k],"OWd") == 0))) {
514 fp = ffopen(buf,"w");
517 for(i=0; (i<=imax); i++) {
519 /* Avoid very large numbers */
521 vc = fc = vd = fd = vr = fr = 0;
524 if (eel == eelPME || eel == eelRF) {
525 fprintf(stderr, "Not implemented\n");
527 } else if (eel == eelCUT) {
528 lo_do_GG_qd_qd(r,xi,xir,&vc,&fc,&vd,&fd,&vr,&fr);
530 fprintf(fp,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
531 r,vc,fc,vd,fd,vr,fr);
537 gmx_fatal(FARGS,"Invalid atom type: %s %s", atype[j], atype[k]);
544 static void do_ljc(FILE *fp,int eel,int pts_nm,real rc,real rtol)
547 double r,vc,fc,vd,fd,vr,fr;
550 for(i=0; (i<=imax); i++) {
552 /* Avoid very large numbers */
554 vc = fc = vd = fd = vr = fr = 0;
557 lo_do_ljc_pme(r,rc,rtol,&vc,&fc,&vd,&fd,&vr,&fr);
558 } else if (eel == eelCUT) {
559 lo_do_ljc(r,&vc,&fc,&vd,&fd,&vr,&fr);
562 fprintf(fp,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
563 r,vc,fc,vd,fd,vr,fr);
567 static void do_guillot_maple(FILE *fp,int eel,int pts_nm,double rc,double rtol,double xi,double xir)
570 /* double xi = 0.15;*/
571 double r,vc,vc2,vd,vd2,vr,vr2;
574 for(i=0; (i<=imax); i++) {
576 /* Avoid very large numbers */
578 vc = vc2 = vd = vd2 = vr = vr2 = 0;
582 fprintf(fp, "Not implemented\n");
583 } else if (eel == eelCUT) {
584 lo_do_guillot_maple(r,xi,xir,&vc,&vc2,&vd,&vd2,&vr,&vr2);
586 fprintf(fp,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
587 r,vc,vc2,vd,vd2,vr,vr2);
591 static void do_GG(FILE *fp,int eel,int pts_nm,double rc,double rtol,double xi,double xir)
594 double r,vc,vc2,vd,vd2,vr,vr2;
597 for(i=0; (i<=imax); i++) {
599 /* Avoid very large numbers */
601 vc = vc2 = vd = vd2 = vr = vr2 = 0;
605 fprintf(fp, "Not implemented\n");
606 } else if (eel == eelCUT) {
607 lo_do_GG(r,xi,xir,&vc,&vc2,&vd,&vd2,&vr,&vr2);
609 fprintf(fp,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
610 r,vc,vc2,vd,vd2,vr,vr2);
614 static void do_GG_q_q(FILE *fp,int eel,int pts_nm,double rc,double rtol,double xi,double xir)
617 double r,vc,vc2,vd,vd2,vr,vr2;
620 for(i=0; (i<=imax); i++) {
622 /* Avoid very large numbers */
624 vc = vc2 = vd = vd2 = vr = vr2 = 0;
628 fprintf(fp, "Not implemented\n");
629 } else if (eel == eelCUT) {
630 lo_do_GG_q_q(r,xi,xir,&vc,&vc2,&vd,&vd2,&vr,&vr2);
632 fprintf(fp,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
633 r,vc,vc2,vd,vd2,vr,vr2);
637 static void do_GG_q_qd(FILE *fp,int eel,int pts_nm,double rc,double rtol,double xi,double xir)
640 /* double xi = 0.15;*/
641 double r,vc,vc2,vd,vd2,vr,vr2;
644 for(i=0; (i<=imax); i++) {
646 /* Avoid very large numbers */
648 vc = vc2 = vd = vd2 = vr = vr2 = 0;
652 fprintf(fp, "Not implemented\n");
653 } else if (eel == eelCUT) {
654 lo_do_GG_q_qd(r,xi,xir,&vc,&vc2,&vd,&vd2,&vr,&vr2);
656 fprintf(fp,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
657 r,vc,vc2,vd,vd2,vr,vr2);
661 static void do_GG_qd_qd(FILE *fp,int eel,int pts_nm,double rc,double rtol,double xi,double xir)
664 /* double xi = 0.15;*/
665 double r,vc,vc2,vd,vd2,vr,vr2;
668 for(i=0; (i<=imax); i++) {
670 /* Avoid very large numbers */
672 vc = vc2 = vd = vd2 = vr = vr2 = 0;
676 fprintf(fp, "Not implemented\n");
677 } else if (eel == eelCUT) {
678 lo_do_GG_qd_qd(r,xi,xir,&vc,&vc2,&vd,&vd2,&vr,&vr2);
680 fprintf(fp,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
681 r,vc,vc2,vd,vd2,vr,vr2);
685 static void do_maaren(FILE *fp,int eel,int pts_nm,int npow)
690 double r,vc,vc2,vd,vd2,vr,vr2;
693 for(i=0; (i<=imax); i++) {
695 /* Avoid very large numbers */
697 vc = vc2 = vd = vd2 = vr = vr2 = 0;
700 lo_do_guillot_maple(r,xi,xir,&vc,&vc2,&vd,&vd2,&vr,&vr2);
701 vr = pow(r,-1.0*npow);
702 vr2 = (npow+1.0)*(npow)*vr/sqr(r);
704 fprintf(fp,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
705 r,vc,vc2,vd,vd2,vr,vr2);
709 int main(int argc,char *argv[])
711 static char *desc[] = {
712 "[TT]gen_table[tt] generates tables for [TT]mdrun[tt] for use with the USER defined",
713 "potentials. Note that the format has been update for higher",
714 "accuracy in the forces starting with version 4.0. Using older",
715 "tables with 4.0 will silently crash your simulations, as will",
716 "using new tables with an older GROMACS version. This is because in the",
717 "old version the second derevative of the potential was specified",
718 "whereas in the new version the first derivative of the potential",
719 "is used instead.[PAR]"
721 static char *opt[] = { NULL, "cut", "rf", "pme", NULL };
722 /* static char *model[] = { NULL, "guillot", "AB1", "ljc", "maaren", "guillot_maple", "hard_wall", "gg_q_q", "gg_qd_q", "gg_qd_qd", NULL }; */
723 static char *model[] = { NULL, "ljc", "gg", "guillot2001a",
725 static real delta=0,efac=500,rc=0.9,rtol=1e-05,xi=0.15,xir=0.0615;
726 static real w1=20,w2=20;
727 static int nrow1=1,nrow2=1;
728 static int nrep = 12;
729 static int ndisp = 6;
730 static int pts_nm = 500;
732 { "-el", FALSE, etENUM, {opt},
733 "Electrostatics type: cut, rf or pme" },
734 { "-rc", FALSE, etREAL, {&rc},
735 "Cut-off required for rf or pme" },
736 { "-rtol", FALSE, etREAL, {&rtol},
737 "Ewald tolerance required for pme" },
738 { "-xi", FALSE, etREAL, {&xi},
739 "Width of the Gaussian diffuse charge of the G&G model" },
740 { "-xir", FALSE, etREAL, {&xir},
741 "Width of erfc(z)/z repulsion of the G&G model (z=0.5 rOO/xir)" },
742 { "-m", FALSE, etENUM, {model},
743 "Model for the tables" },
744 { "-resol", FALSE, etINT, {&pts_nm},
745 "Resolution of the table (points per nm)" },
746 { "-delta", FALSE, etREAL, {&delta},
747 "Displacement in the Coulomb functions (nm), used as 1/(r+delta). Only for hard wall potential." },
748 { "-efac", FALSE, etREAL, {&efac},
749 "Number indicating the steepness of the hardwall potential." },
750 { "-nrep", FALSE, etINT, {&nrep},
751 "Power for the repulsion potential (with model AB1 or maaren)" },
752 { "-ndisp", FALSE, etINT, {&ndisp},
753 "Power for the dispersion potential (with model AB1 or maaren)" }
755 #define NPA asize(pa)
757 { efXVG, "-o", "table", ffWRITE }
759 #define NFILE asize(fnm)
764 CopyRight(stderr,argv[0]);
765 parse_common_args(&argc,argv,PCA_CAN_VIEW | PCA_CAN_TIME | PCA_BE_NICE,
766 NFILE,fnm,NPA,pa,asize(desc),desc,0,NULL);
768 if (strcmp(opt[0],"cut") == 0)
770 else if (strcmp(opt[0],"rf") == 0)
772 else if (strcmp(opt[0],"pme") == 0)
775 gmx_fatal(FARGS,"Invalid argument %s for option -e",opt[0]);
776 if (strcmp(model[0],"maaren") == 0)
778 else if (strcmp(model[0],"AB1") == 0)
780 else if (strcmp(model[0],"ljc") == 0)
782 else if (strcmp(model[0],"guillot2001a") == 0)
784 else if (strcmp(model[0],"guillot_maple") == 0)
786 else if (strcmp(model[0],"hard_wall") == 0)
788 else if (strcmp(model[0],"gg") == 0)
790 else if (strcmp(model[0],"gg_qd_q") == 0)
792 else if (strcmp(model[0],"gg_qd_qd") == 0)
794 else if (strcmp(model[0],"gg_q_q") == 0)
797 gmx_fatal(FARGS,"Invalid argument %s for option -m",opt[0]);
799 fn = opt2fn("-o",NFILE,fnm);
800 if ((m != mGuillot2001a))
804 do_guillot2001a(fn,eel,pts_nm,rc,rtol,xi,xir);
807 fprintf(fp, "#\n# Table Guillot_Maple: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc,rtol,xi,xir);
808 do_guillot_maple(fp,eel,pts_nm,rc,rtol,xi,xir);
811 fprintf(fp, "#\n# Table GG_q_q: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc,rtol,xi,xir);
812 do_GG_q_q(fp,eel,pts_nm,rc,rtol,xi,xir);
815 fprintf(fp, "#\n# Table GG: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc,rtol,xi,xir);
816 do_GG(fp,eel,pts_nm,rc,rtol,xi,xir);
819 fprintf(stdout, "case mGG_qd_q");
820 fprintf(fp, "#\n# Table GG_qd_q: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc,rtol,xi,xir);
821 do_GG_q_qd(fp,eel,pts_nm,rc,rtol,xi,xir);
824 fprintf(stdout, "case mGG_qd_qd");
825 fprintf(fp, "#\n# Table GG_qd_qd: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc,rtol,xi,xir);
826 do_GG_qd_qd(fp,eel,pts_nm,rc,rtol,xi,xir);
829 do_maaren(fp,eel,pts_nm,nrep);
832 fprintf(fp, "#\n# Table AB1: ndisp=%d nrep=%d\n#\n",ndisp,nrep);
833 do_AB1(fp,eel,pts_nm,ndisp,nrep);
836 fprintf(fp, "#\n# Table LJC(12-6-1): rc=%g, rtol=%g\n#\n",rc,rtol);
837 do_ljc(fp,eel,pts_nm,rc,rtol);
840 do_hard(fp,pts_nm,efac,delta);
843 gmx_fatal(FARGS,"Model %s not supported yet",model[0]);
845 if ((m != mGuillot2001a))