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, 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.
47 #include "gmx_fatal.h"
61 real pot(real x,real qq,real c6,real c12)
63 return c12*pow(x,-12)-c6*pow(x,-6)+qq*ONE_4PI_EPS0/x;
66 real dpot(real x,real qq,real c6,real c12)
68 return -(12*c12*pow(x,-13)-6*c6*pow(x,-7)+qq*ONE_4PI_EPS0/sqr(x));
71 int main(int argc,char *argv[])
73 static char *desc[] = {
76 static real c6=1.0e-3,c12=1.0e-6,qi=1,qj=2,sig=0.3,eps=1,sigfac=0.7;
78 { "-c6", FALSE, etREAL, {&c6}, "c6" },
79 { "-c12", FALSE, etREAL, {&c12}, "c12" },
80 { "-sig", FALSE, etREAL, {&sig}, "sig" },
81 { "-eps", FALSE, etREAL, {&eps}, "eps" },
82 { "-qi", FALSE, etREAL, {&qi}, "qi" },
83 { "-qj", FALSE, etREAL, {&qj}, "qj" },
84 { "-sigfac", FALSE, etREAL, {&sigfac}, "Factor in front of sigma for starting the plot" }
87 { efXVG, "-o", "potje", ffWRITE }
89 #define NFILE asize(fnm)
93 real qq,x,oldx,minimum,mval,dp[2],pp[2];
97 /* CopyRight(stdout,argv[0]);*/
98 parse_common_args(&argc,argv,PCA_CAN_VIEW,
99 NFILE,fnm,asize(pa),pa,asize(desc),
102 if (opt2parg_bSet("-sig",asize(pa),pa) ||
103 opt2parg_bSet("-eps",asize(pa),pa)) {
104 c6 = 4*eps*pow(sig,6);
105 c12 = 4*eps*pow(sig,12);
107 else if ((c6 != 0) && (c12 != 0)) {
108 sig = pow(c12/c6,1.0/6.0);
114 printf("c6 = %12.5e, c12 = %12.5e\n",c6,c12);
115 printf("sigma = %12.5f, epsilon = %12.5f\n",sig,eps);
118 fp = xvgropen(ftp2fn(efXVG,NFILE,fnm),"Potential","r (nm)","E (kJ/mol)");
124 for(i=0; (i<100); i++) {
125 x = sigfac*sig+sig*i*0.02;
126 dp[next] = dpot(x,qq,c6,c12);
127 fprintf(fp,"%10g %10g %10g\n",x,pot(x,qq,c6,c12),
129 if ((i > 0) && (dp[cur]*dp[next] < 0)) {
130 minimum = oldx + dp[cur]*(x-oldx)/(dp[cur]-dp[next]);
131 mval = pot(minimum,qq,c6,c12);
132 /*fprintf(stdout,"dp[cur] = %g, dp[next] = %g oldx = %g, dx = %g\n",
133 dp[cur],dp[next],oldx,x-oldx);*/
134 printf("Minimum at r = %g (nm). Value = %g (kJ/mol)\n",
143 do_view(ftp2fn(efXVG,NFILE,fnm),NULL);