3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * VERSION 3.3.99_development_20071104
10 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12 * Copyright (c) 2001-2006, The GROMACS development team,
13 * check out http://www.gromacs.org for more information.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * If you want to redistribute modifications, please consider that
21 * scientific software is very special. Version control is crucial -
22 * bugs must be traceable. We will be happy to consider code for
23 * inclusion in the official distribution, but derived work must not
24 * be called official GROMACS. Details are found in the README & COPYING
25 * files - if they are missing, get the official version at www.gromacs.org.
27 * To help us fund GROMACS development, we humbly ask that you cite
28 * the papers on the package - you can find them in the top README file.
30 * For more info, check our website at http://www.gromacs.org
33 * Groningen Machine for Chemical Simulation
46 enum { mGuillot2001a
, mAB1
, mLjc
, mMaaren
, mGuillot_Maple
, mHard_Wall
, mGG
, mGG_qd_q
, mGG_qd_qd
, mGG_q_q
, mNR
};
48 static double erf2(double x
)
50 return -(4*x
/(sqrt(M_PI
)))*exp(-x
*x
);
53 static double erf1(double x
)
55 return (2/sqrt(M_PI
))*exp(-x
*x
);
58 static void do_hard(FILE *fp
,int pts_nm
,double efac
,double delta
)
61 double x
,vr
,vr2
,vc
,vc2
;
64 gmx_fatal(FARGS
,"Delta should be >= 0 rather than %f\n",delta
);
67 for(i
=0; (i
<=imax
); i
++) {
71 /* Avoid very high numbers */
78 vr
= erfc(efac
*(x
-delta
))/2;
79 vr2
= (1-erf2(efac
*(x
-delta
)))/2;
80 fprintf(fp
,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
81 x
,vr
,vr2
,0.0,0.0,vc
,vc2
);
86 static void do_AB1(FILE *fp
,int eel
,int pts_nm
,int ndisp
,int nrep
)
89 double myfac
[3] = { 1, -1, 1 };
90 double myexp
[3] = { 1, 6, 0 };
96 for(i
=0; (i
<=imax
); i
++) {
99 fprintf(fp
,"%12.5e",x
);
101 for(k
=0; (k
<3); k
++) {
103 /* Avoid very high numbers */
107 v
= myfac
[k
]*pow(x
,-myexp
[k
]);
108 v2
= (myexp
[k
]+1)*(myexp
[k
])*v
/(x
*x
);
110 fprintf(fp
," %12.5e %12.5e",v
,v2
);
116 static void lo_do_ljc(double r
,
117 double *vc
,double *fc
,
118 double *vd
,double *fd
,
119 double *vr
,double *fr
)
124 r_6
= 1.0/(r2
*r2
*r2
);
127 *vc
= 1.0/r
; /* f(x) Coulomb */
128 *fc
= 1.0/(r2
); /* -f'(x) */
130 *vd
= -r_6
; /* g(c) Dispersion */
131 *fd
= 6.0*(*vd
)/r
; /* -g'(x) */
133 *vr
= r_12
; /* h(x) Repulsion */
134 *fr
= 12.0*(*vr
)/r
; /* -h'(x) */
137 /* use with coulombtype = user */
138 static void lo_do_ljc_pme(double r
,
139 double rcoulomb
, double ewald_rtol
,
140 double *vc
,double *fc
,
141 double *vd
,double *fd
,
142 double *vr
,double *fr
)
145 double isp
= 0.564189583547756;
148 ewc
= calc_ewaldcoeff(rcoulomb
,ewald_rtol
);
151 r_6
= 1.0/(r2
*r2
*r2
);
155 /* *vc2 = 2*erfc(ewc*r)/(r*r2)+4*exp(-(ewc*ewc*r2))*ewc*isp/r2+
156 4*ewc*ewc*ewc*exp(-(ewc*ewc*r2))*isp;*/
157 *fc
= 2*ewc
*exp(-ewc
*ewc
*r2
)*isp
/r
+ erfc(ewc
*r
)/r2
;
166 static void lo_do_guillot(double r
,double xi
, double xir
,
167 double *vc
,double *fc
,
168 double *vd
,double *fd
,
169 double *vr
,double *fr
)
174 double sqpi
= sqrt(M_PI
);
179 r_6
= 1.0/(r2
*r2
*r2
);
182 rxi2
= r
/(sqrt(2)*xi
);
183 *vc
= (1 + f0
*f0
*erf(r
/(2*xi
)) + 2*f0
*erf(r
/(sqrt(2)*xi
)) )/r
;
185 *fc
= f0
*f0
*erf(r
/(2*xi
)) + 2*f0
*erf(r
/(sqrt(2)*xi
));
187 /* MuPad: Uc := erf(r/(2*xi))/r +
191 r2 := r/(Sqrt[2] * xi);
192 Uc[r_] := (1 + f0 * f0 * Erf[r/(2*xi)] + 2 * f0 * Erf[r/(Sqrt[2]*xi)]) / r;
195 -(((2*f0*Sqrt(2/Pi))/(Power(E,Power(r,2)/(2.*Power(xi,2)))*xi) +
196 Power(f0,2)/(Power(E,Power(r,2)/(4.*Power(xi,2)))*Sqrt(Pi)*xi))/r) +
197 (1 + Power(f0,2)*Erf(r/(2.*xi)) + 2*f0*Erf(r/(Sqrt(2)*xi)))/Power(r,2)
205 Uc2[r_] := f0^2 * Erf[r1] / r;
209 Uc3[r_] := 2 * f0 * Erf[r2]/ r;
212 Uc[r_] := Erf[r/(2*xi)] / r
220 *vc
= (1 + sqr(f0
)*erf(rxi1
) + 2*f0
*erf(rxi2
))/r
;
223 + (- 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
)
227 /* *vc2 = ((2/sqr(r))*(*vc -
228 sqr(f0)*erf1(r1)/(2*xi) -
229 4*f0*erf1(r2)/sqrt(2)*xi) +
230 (1/r)*(sqr(f0/(2.0*xi))*erf2(r1) + (2*f0/sqr(xi)))*erf2(r2)); */
238 // *vr2 = (sqpi*(*vr)/(2.0*z*z)+(1.0/(z*z)+1)*exp(-z*z))/(sqpi*sqr(xir));
241 void lo_do_guillot_maple(double r
,double xi
,double xir
,
242 double *vc
,double *vc2
,
243 double *vd
,double *vd2
,
244 double *vr
,double *vr2
)
249 double sqpi
= sqrt(M_PI
);
251 *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
;
252 *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
);
254 *vd
= -1.0/(r
*r
*r
*r
*r
*r
);
255 *vd2
= -42.0/(r
*r
*r
*r
*r
*r
*r
*r
);
256 *vr
= 2.0*erfc(r
/xir
/2.0)/r
*xir
;
257 *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
;
260 static void lo_do_GG(double r
,double xi
,double xir
,
261 double *vc
,double *fc
,
262 double *vd
,double *fd
,
263 double *vr
,double *fr
)
268 double sqpi
= sqrt(M_PI
);
274 *vc
= 1.0/r
+ f0
*f0
*erf(r
/(2*xi
))/r
+ 2*f0
*erf(r
/(sqrt(2)*xi
))/r
;
276 // -D[1/r,r] -D[f0*f0*Erf[r/(2*xi)]/r,r] -D[2*f0*Erf[r/(Sqrt[2]*xi)]/r,r]
279 f0
*f0
*(-exp(-r2
/(4*xi2
))/(sqrt(M_PI
) * r
* xi
) + erf(r
/(2*xi
))/r2
) +
280 2*f0
*(-sqrt(2.0/M_PI
)*exp(-r2
/(2*xi2
))/ (r
*xi
) + erf(r
/(sqrt(2)*xi
))/r2
)
284 *vd
= -1.0/(r
*r
*r
*r
*r
*r
);
287 // -D[2*xir*Erfc[r/(2*xir)]/r,r]
288 *vr
= 2.*xir
*erfc(r
/(2.*xir
))/r
;
289 *fr
= -(-2.*exp(-r2
/(4*xir
*xir
)) / (sqrt(M_PI
)*r
) - 2*xir
*erfc(r
/(2*xir
))/r2
);
293 /* Guillot2001 diffuse charge - diffuse charge interaction
296 In[19]:= Uc[r_] := Erf[r/(2*xi)]/r
303 Out[20]= -(-------------------------) + ---------
308 void lo_do_GG_qd_qd(double r
,double xi
,double xir
,
309 double *vc
,double *fc
,
310 double *vd
,double *fd
,
311 double *vr
,double *fr
)
313 double sqpi
= sqrt(M_PI
);
315 *vc
= erf(r
/(2*xi
))/r
;
316 //erf((r*(1.0/2.0))/xi)/r;
317 *fc
= -(1.0/(exp(r
*r
/(4*xi
*xi
))*sqpi
*r
*xi
)) + (erf(r
/2*xi
)/(r
*r
));
319 //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 ;
326 /* Guillot2001 charge - diffuse charge interaction eqn 4 & 5
328 In[17]:= Uc[r_] := Erf[r/(Sqrt[2]*xi)]/r
333 Sqrt[--] Erf[----------]
335 Out[18]= -(----------------) + ---------------
340 void lo_do_GG_q_qd(double r
,double xi
,double xir
,
341 double *vc
,double *fc
,
342 double *vd
,double *fd
,
343 double *vr
,double *fr
)
345 double sqpi
= sqrt(M_PI
);
347 *vc
= erf(r
/(sqrt(2)*xi
)) / r
;
348 //erf(((1.0/2.0)*pow(2.0, 1.0/2.0)*r)/xi)/r ;
349 *fc
= -(sqrt(2/M_PI
)/(exp(r
*r
/(2*xi
*xi
))*r
*xi
)) + (erf(r
/(sqrt(2)*xi
))/(r
*r
));
350 //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 ;
358 /* Guillot2001 charge - charge interaction (normal coulomb), repulsion and dispersion
361 In[6]:= Uc[r_] := 1.0/r
370 In[8]:= Ud[r_] := -1.0/r^6
379 In[13]:= Ur[r_] := (2*xir)*Erfc[r/(2*xir)]/r
385 Out[16]= ----------------------- + -----------------
392 void lo_do_GG_q_q(double r
,double xi
,double xir
,
393 double *vc
,double *fc
,
394 double *vd
,double *fd
,
395 double *vr
,double *fr
)
397 double sqpi
= sqrt(M_PI
);
402 *vd
= -1.0/(r
*r
*r
*r
*r
*r
);
403 *fd
= -6.0/(r
*r
*r
*r
*r
*r
*r
);
405 *vr
= (2.0*xir
*erfc(r
/(2.0*xir
)))/r
;
406 *fr
= 2.0/(exp((r
*r
)/(4*xir
*xir
)) * sqpi
*r
) + (2*xir
*erfc((r
*xir
)/2.0))/(r
*r
);
407 //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);
410 static void do_guillot(FILE *fp
,int eel
,int pts_nm
,double rc
,double rtol
,double xi
,double xir
)
413 double r
,vc
,fc
,vd
,fd
,vr
,fr
;
416 for(i
=0; (i
<=imax
); i
++) {
418 /* Avoid very large numbers */
420 vc
= fc
= vd
= fd
= vr
= fr
= 0;
424 fprintf(fp
, "Not implemented\n");
425 } else if (eel
== eelCUT
) {
426 lo_do_guillot(r
,xi
,xir
,&vc
,&fc
,&vd
,&fd
,&vr
,&fr
);
428 fprintf(fp
,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
429 r
,vc
,fc
,vd
,fd
,vr
,fr
);
435 PvM: Everything is hardcoded, we should fix that. How?
437 static void do_guillot2001a(const char *file
,int eel
,int pts_nm
,double rc
,double rtol
,double xi
,double xir
)
440 static char buf
[256];
441 static char *atype
[] = { "HW", "OW", "HWd", "OWd", NULL
};
442 int i
,j
,k
,i0
,imax
,atypemax
=4;
443 double r
,vc
,fc
,vd
,fd
,vr
,fr
;
445 /* For Guillot2001a we have four types: HW, OW, HWd and OWd. */
447 for (j
=0;(j
<atypemax
);j
++) { /* loops over types */
448 for (k
=0; (k
<=j
); k
++) {
449 sprintf(buf
,"table_%s_%s.xvg",atype
[k
],atype
[j
]);
451 printf("%d %d %s\n", j
, k
, buf
);
452 /* Guillot2001a eqn 2, 6 and 7 */
453 if (((strcmp(atype
[j
],"HW") == 0) && (strcmp(atype
[k
],"HW") == 0)) ||
454 ((strcmp(atype
[j
],"OW") == 0) && (strcmp(atype
[k
],"HW") == 0)) ||
455 ((strcmp(atype
[j
],"OW") == 0) && (strcmp(atype
[k
],"OW") == 0))) {
457 fp
= ffopen(buf
,"w");
460 for(i
=0; (i
<=imax
); i
++) {
462 /* Avoid very large numbers */
464 vc
= fc
= vd
= fd
= vr
= fr
= 0;
467 if (eel
== eelPME
|| eel
== eelRF
) {
468 fprintf(stderr
, "Not implemented\n");
470 } else if (eel
== eelCUT
) {
471 lo_do_GG_q_q(r
,xi
,xir
,&vc
,&fc
,&vd
,&fd
,&vr
,&fr
);
473 fprintf(fp
,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
474 r
,vc
,fc
,vd
,fd
,vr
,fr
);
479 /* Guillot eqn 4 and 5 */
480 } else if (((strcmp(atype
[j
],"HWd") == 0) && (strcmp(atype
[k
],"HW") == 0)) ||
481 ((strcmp(atype
[j
],"HWd") == 0) && (strcmp(atype
[k
],"OW") == 0)) ||
482 ((strcmp(atype
[j
],"OWd") == 0) && (strcmp(atype
[k
],"HW") == 0)) ||
483 ((strcmp(atype
[j
],"OWd") == 0) && (strcmp(atype
[k
],"OW") == 0))) {
485 fp
= ffopen(buf
,"w");
488 for(i
=0; (i
<=imax
); i
++) {
490 /* Avoid very large numbers */
492 vc
= fc
= vd
= fd
= vr
= fr
= 0;
495 if (eel
== eelPME
|| eel
== eelRF
) {
496 fprintf(stderr
, "Not implemented\n");
498 } else if (eel
== eelCUT
) {
499 lo_do_GG_q_qd(r
,xi
,xir
,&vc
,&fc
,&vd
,&fd
,&vr
,&fr
);
501 fprintf(fp
,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
502 r
,vc
,fc
,vd
,fd
,vr
,fr
);
507 /* Guillot2001a eqn 3 */
508 } else if (((strcmp(atype
[j
],"HWd") == 0) && (strcmp(atype
[k
],"HWd") == 0)) ||
509 ((strcmp(atype
[j
],"OWd") == 0) && (strcmp(atype
[k
],"HWd") == 0)) ||
510 ((strcmp(atype
[j
],"OWd") == 0) && (strcmp(atype
[k
],"OWd") == 0))) {
512 fp
= ffopen(buf
,"w");
515 for(i
=0; (i
<=imax
); i
++) {
517 /* Avoid very large numbers */
519 vc
= fc
= vd
= fd
= vr
= fr
= 0;
522 if (eel
== eelPME
|| eel
== eelRF
) {
523 fprintf(stderr
, "Not implemented\n");
525 } else if (eel
== eelCUT
) {
526 lo_do_GG_qd_qd(r
,xi
,xir
,&vc
,&fc
,&vd
,&fd
,&vr
,&fr
);
528 fprintf(fp
,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
529 r
,vc
,fc
,vd
,fd
,vr
,fr
);
535 gmx_fatal(FARGS
,"Invalid atom type: %s %s", atype
[j
], atype
[k
]);
542 static void do_ljc(FILE *fp
,int eel
,int pts_nm
,real rc
,real rtol
)
545 double r
,vc
,fc
,vd
,fd
,vr
,fr
;
548 for(i
=0; (i
<=imax
); i
++) {
550 /* Avoid very large numbers */
552 vc
= fc
= vd
= fd
= vr
= fr
= 0;
555 lo_do_ljc_pme(r
,rc
,rtol
,&vc
,&fc
,&vd
,&fd
,&vr
,&fr
);
556 } else if (eel
== eelCUT
) {
557 lo_do_ljc(r
,&vc
,&fc
,&vd
,&fd
,&vr
,&fr
);
560 fprintf(fp
,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
561 r
,vc
,fc
,vd
,fd
,vr
,fr
);
565 static void do_guillot_maple(FILE *fp
,int eel
,int pts_nm
,double rc
,double rtol
,double xi
,double xir
)
568 /* double xi = 0.15;*/
569 double r
,vc
,vc2
,vd
,vd2
,vr
,vr2
;
572 for(i
=0; (i
<=imax
); i
++) {
574 /* Avoid very large numbers */
576 vc
= vc2
= vd
= vd2
= vr
= vr2
= 0;
580 fprintf(fp
, "Not implemented\n");
581 } else if (eel
== eelCUT
) {
582 lo_do_guillot_maple(r
,xi
,xir
,&vc
,&vc2
,&vd
,&vd2
,&vr
,&vr2
);
584 fprintf(fp
,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
585 r
,vc
,vc2
,vd
,vd2
,vr
,vr2
);
589 static void do_GG(FILE *fp
,int eel
,int pts_nm
,double rc
,double rtol
,double xi
,double xir
)
592 double r
,vc
,vc2
,vd
,vd2
,vr
,vr2
;
595 for(i
=0; (i
<=imax
); i
++) {
597 /* Avoid very large numbers */
599 vc
= vc2
= vd
= vd2
= vr
= vr2
= 0;
603 fprintf(fp
, "Not implemented\n");
604 } else if (eel
== eelCUT
) {
605 lo_do_GG(r
,xi
,xir
,&vc
,&vc2
,&vd
,&vd2
,&vr
,&vr2
);
607 fprintf(fp
,"%15.10e %15.10e %15.10e %15.10e %15.10e %15.10e %15.10e\n",
608 r
,vc
,vc2
,vd
,vd2
,vr
,vr2
);
612 static void do_GG_q_q(FILE *fp
,int eel
,int pts_nm
,double rc
,double rtol
,double xi
,double xir
)
615 double r
,vc
,vc2
,vd
,vd2
,vr
,vr2
;
618 for(i
=0; (i
<=imax
); i
++) {
620 /* Avoid very large numbers */
622 vc
= vc2
= vd
= vd2
= vr
= vr2
= 0;
626 fprintf(fp
, "Not implemented\n");
627 } else if (eel
== eelCUT
) {
628 lo_do_GG_q_q(r
,xi
,xir
,&vc
,&vc2
,&vd
,&vd2
,&vr
,&vr2
);
630 fprintf(fp
,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
631 r
,vc
,vc2
,vd
,vd2
,vr
,vr2
);
635 static void do_GG_q_qd(FILE *fp
,int eel
,int pts_nm
,double rc
,double rtol
,double xi
,double xir
)
638 /* double xi = 0.15;*/
639 double r
,vc
,vc2
,vd
,vd2
,vr
,vr2
;
642 for(i
=0; (i
<=imax
); i
++) {
644 /* Avoid very large numbers */
646 vc
= vc2
= vd
= vd2
= vr
= vr2
= 0;
650 fprintf(fp
, "Not implemented\n");
651 } else if (eel
== eelCUT
) {
652 lo_do_GG_q_qd(r
,xi
,xir
,&vc
,&vc2
,&vd
,&vd2
,&vr
,&vr2
);
654 fprintf(fp
,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
655 r
,vc
,vc2
,vd
,vd2
,vr
,vr2
);
659 static void do_GG_qd_qd(FILE *fp
,int eel
,int pts_nm
,double rc
,double rtol
,double xi
,double xir
)
662 /* double xi = 0.15;*/
663 double r
,vc
,vc2
,vd
,vd2
,vr
,vr2
;
666 for(i
=0; (i
<=imax
); i
++) {
668 /* Avoid very large numbers */
670 vc
= vc2
= vd
= vd2
= vr
= vr2
= 0;
674 fprintf(fp
, "Not implemented\n");
675 } else if (eel
== eelCUT
) {
676 lo_do_GG_qd_qd(r
,xi
,xir
,&vc
,&vc2
,&vd
,&vd2
,&vr
,&vr2
);
678 fprintf(fp
,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
679 r
,vc
,vc2
,vd
,vd2
,vr
,vr2
);
683 static void do_maaren(FILE *fp
,int eel
,int pts_nm
,int npow
)
688 double r
,vc
,vc2
,vd
,vd2
,vr
,vr2
;
691 for(i
=0; (i
<=imax
); i
++) {
693 /* Avoid very large numbers */
695 vc
= vc2
= vd
= vd2
= vr
= vr2
= 0;
698 lo_do_guillot_maple(r
,xi
,xir
,&vc
,&vc2
,&vd
,&vd2
,&vr
,&vr2
);
699 vr
= pow(r
,-1.0*npow
);
700 vr2
= (npow
+1.0)*(npow
)*vr
/sqr(r
);
702 fprintf(fp
,"%12.5e %12.5e %12.5e %12.5e %12.5e %12.5e %12.5e\n",
703 r
,vc
,vc2
,vd
,vd2
,vr
,vr2
);
707 int main(int argc
,char *argv
[])
709 static char *desc
[] = {
710 "gen_table generates tables for mdrun for use with the USER defined",
711 "potentials. Note that the format has been update for higher",
712 "accuracy in the forces starting with version 4.0. Using older",
713 "tables with 4.0 will silently crash your simulations, as will",
714 "using new tables with an older GROMACS version. This is because in the",
715 "old version the second derevative of the potential was specified",
716 "whereas in the new version the first derivative of the potential",
717 "is used instead.[PAR]"
719 static char *opt
[] = { NULL
, "cut", "rf", "pme", NULL
};
720 /* static char *model[] = { NULL, "guillot", "AB1", "ljc", "maaren", "guillot_maple", "hard_wall", "gg_q_q", "gg_qd_q", "gg_qd_qd", NULL }; */
721 static char *model
[] = { NULL
, "ljc", "gg", "guillot2001a",
723 static real delta
=0,efac
=500,rc
=0.9,rtol
=1e-05,xi
=0.15,xir
=0.0615;
724 static real w1
=20,w2
=20;
725 static int nrow1
=1,nrow2
=1;
726 static int nrep
= 12;
727 static int ndisp
= 6;
728 static int pts_nm
= 500;
730 { "-el", FALSE
, etENUM
, {opt
},
731 "Electrostatics type: cut, rf or pme" },
732 { "-rc", FALSE
, etREAL
, {&rc
},
733 "Cut-off required for rf or pme" },
734 { "-rtol", FALSE
, etREAL
, {&rtol
},
735 "Ewald tolerance required for pme" },
736 { "-xi", FALSE
, etREAL
, {&xi
},
737 "Width of the Gaussian diffuse charge of the G&G model" },
738 { "-xir", FALSE
, etREAL
, {&xir
},
739 "Width of erfc(z)/z repulsion of the G&G model (z=0.5 rOO/xir)" },
740 { "-m", FALSE
, etENUM
, {model
},
741 "Model for the tables" },
742 { "-resol", FALSE
, etINT
, {&pts_nm
},
743 "Resolution of the table (points per nm)" },
744 { "-delta", FALSE
, etREAL
, {&delta
},
745 "Displacement in the Coulomb functions (nm), used as 1/(r+delta). Only for hard wall potential." },
746 { "-efac", FALSE
, etREAL
, {&efac
},
747 "Number indicating the steepness of the hardwall potential." },
748 { "-nrep", FALSE
, etINT
, {&nrep
},
749 "Power for the repulsion potential (with model AB1 or maaren)" },
750 { "-ndisp", FALSE
, etINT
, {&ndisp
},
751 "Power for the dispersion potential (with model AB1 or maaren)" }
753 #define NPA asize(pa)
755 { efXVG
, "-o", "table", ffWRITE
}
757 #define NFILE asize(fnm)
762 CopyRight(stderr
,argv
[0]);
763 parse_common_args(&argc
,argv
,PCA_CAN_VIEW
| PCA_CAN_TIME
| PCA_BE_NICE
,
764 NFILE
,fnm
,NPA
,pa
,asize(desc
),desc
,0,NULL
);
766 if (strcmp(opt
[0],"cut") == 0)
768 else if (strcmp(opt
[0],"rf") == 0)
770 else if (strcmp(opt
[0],"pme") == 0)
773 gmx_fatal(FARGS
,"Invalid argument %s for option -e",opt
[0]);
774 if (strcmp(model
[0],"maaren") == 0)
776 else if (strcmp(model
[0],"AB1") == 0)
778 else if (strcmp(model
[0],"ljc") == 0)
780 else if (strcmp(model
[0],"guillot2001a") == 0)
782 else if (strcmp(model
[0],"guillot_maple") == 0)
784 else if (strcmp(model
[0],"hard_wall") == 0)
786 else if (strcmp(model
[0],"gg") == 0)
788 else if (strcmp(model
[0],"gg_qd_q") == 0)
790 else if (strcmp(model
[0],"gg_qd_qd") == 0)
792 else if (strcmp(model
[0],"gg_q_q") == 0)
795 gmx_fatal(FARGS
,"Invalid argument %s for option -m",opt
[0]);
797 fn
= opt2fn("-o",NFILE
,fnm
);
798 if ((m
!= mGuillot2001a
))
802 do_guillot2001a(fn
,eel
,pts_nm
,rc
,rtol
,xi
,xir
);
805 fprintf(fp
, "#\n# Table Guillot_Maple: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc
,rtol
,xi
,xir
);
806 do_guillot_maple(fp
,eel
,pts_nm
,rc
,rtol
,xi
,xir
);
809 fprintf(fp
, "#\n# Table GG_q_q: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc
,rtol
,xi
,xir
);
810 do_GG_q_q(fp
,eel
,pts_nm
,rc
,rtol
,xi
,xir
);
813 fprintf(fp
, "#\n# Table GG: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc
,rtol
,xi
,xir
);
814 do_GG(fp
,eel
,pts_nm
,rc
,rtol
,xi
,xir
);
817 fprintf(stdout
, "case mGG_qd_q");
818 fprintf(fp
, "#\n# Table GG_qd_q: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc
,rtol
,xi
,xir
);
819 do_GG_q_qd(fp
,eel
,pts_nm
,rc
,rtol
,xi
,xir
);
822 fprintf(stdout
, "case mGG_qd_qd");
823 fprintf(fp
, "#\n# Table GG_qd_qd: rc=%g, rtol=%g, xi=%g, xir=%g\n#\n",rc
,rtol
,xi
,xir
);
824 do_GG_qd_qd(fp
,eel
,pts_nm
,rc
,rtol
,xi
,xir
);
827 do_maaren(fp
,eel
,pts_nm
,nrep
);
830 fprintf(fp
, "#\n# Table AB1: ndisp=%d nrep=%d\n#\n",ndisp
,nrep
);
831 do_AB1(fp
,eel
,pts_nm
,ndisp
,nrep
);
834 fprintf(fp
, "#\n# Table LJC(12-6-1): rc=%g, rtol=%g\n#\n",rc
,rtol
);
835 do_ljc(fp
,eel
,pts_nm
,rc
,rtol
);
838 do_hard(fp
,pts_nm
,efac
,delta
);
841 gmx_fatal(FARGS
,"Model %s not supported yet",model
[0]);
843 if ((m
!= mGuillot2001a
))