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
44 #include "gmx_fatal.h"
58 real
pot(real x
,real qq
,real c6
,real c12
)
60 return c12
*pow(x
,-12)-c6
*pow(x
,-6)+qq
*ONE_4PI_EPS0
/x
;
63 real
dpot(real x
,real qq
,real c6
,real c12
)
65 return -(12*c12
*pow(x
,-13)-6*c6
*pow(x
,-7)+qq
*ONE_4PI_EPS0
/sqr(x
));
68 int main(int argc
,char *argv
[])
70 static char *desc
[] = {
73 static real c6
=1.0e-3,c12
=1.0e-6,qi
=1,qj
=2,sig
=0.3,eps
=1,sigfac
=0.7;
75 { "-c6", FALSE
, etREAL
, {&c6
}, "c6" },
76 { "-c12", FALSE
, etREAL
, {&c12
}, "c12" },
77 { "-sig", FALSE
, etREAL
, {&sig
}, "sig" },
78 { "-eps", FALSE
, etREAL
, {&eps
}, "eps" },
79 { "-qi", FALSE
, etREAL
, {&qi
}, "qi" },
80 { "-qj", FALSE
, etREAL
, {&qj
}, "qj" },
81 { "-sigfac", FALSE
, etREAL
, {&sigfac
}, "Factor in front of sigma for starting the plot" }
84 { efXVG
, "-o", "potje", ffWRITE
}
86 #define NFILE asize(fnm)
90 real qq
,x
,oldx
,minimum
,mval
,dp
[2],pp
[2];
94 /* CopyRight(stdout,argv[0]);*/
95 parse_common_args(&argc
,argv
,PCA_CAN_VIEW
,
96 NFILE
,fnm
,asize(pa
),pa
,asize(desc
),
99 if (opt2parg_bSet("-sig",asize(pa
),pa
) ||
100 opt2parg_bSet("-eps",asize(pa
),pa
)) {
101 c6
= 4*eps
*pow(sig
,6);
102 c12
= 4*eps
*pow(sig
,12);
104 else if ((c6
!= 0) && (c12
!= 0)) {
105 sig
= pow(c12
/c6
,1.0/6.0);
111 printf("c6 = %12.5e, c12 = %12.5e\n",c6
,c12
);
112 printf("sigma = %12.5f, epsilon = %12.5f\n",sig
,eps
);
115 fp
= xvgropen(ftp2fn(efXVG
,NFILE
,fnm
),"Potential","r (nm)","E (kJ/mol)");
121 for(i
=0; (i
<100); i
++) {
122 x
= sigfac
*sig
+sig
*i
*0.02;
123 dp
[next
] = dpot(x
,qq
,c6
,c12
);
124 fprintf(fp
,"%10g %10g %10g\n",x
,pot(x
,qq
,c6
,c12
),
126 if ((i
> 0) && (dp
[cur
]*dp
[next
] < 0)) {
127 minimum
= oldx
+ dp
[cur
]*(x
-oldx
)/(dp
[cur
]-dp
[next
]);
128 mval
= pot(minimum
,qq
,c6
,c12
);
129 /*fprintf(stdout,"dp[cur] = %g, dp[next] = %g oldx = %g, dx = %g\n",
130 dp[cur],dp[next],oldx,x-oldx);*/
131 printf("Minimum at r = %g (nm). Value = %g (kJ/mol)\n",
140 do_view(ftp2fn(efXVG
,NFILE
,fnm
),NULL
);