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-2004, 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.
42 #ifdef GMX_QMMM_GAMESS
68 #include "gmx_fatal.h"
73 /* QMMM sub routines */
74 /* mopac interface routines */
78 F77_FUNC(inigms,IMIGMS)(void);
81 F77_FUNC(endgms,ENDGMS)(void);
84 F77_FUNC(grads,GRADS)(int *nrqmat,real *qmcrd,int *nrmmat, real *mmchrg,
85 real *mmcrd, real *qmgrad,real *mmgrad, real *energy);
89 void init_gamess(t_commrec *cr,t_QMrec *qm, t_MMrec *mm){
90 /* it works hopelessly complicated :-)
91 * first a file is written. Then the standard gamess input/output
92 * routine is called (no system()!) to set up all fortran arrays.
93 * this routine writes a punch file, like in a normal gamess run.
94 * via this punch file the other games routines, needed for gradient
95 * and energy evaluations are called. This setup works fine for
96 * dynamics simulations. 7-6-2002 (London)
103 periodic_system[37][3]={"XX","H ","He","Li","Be","B ","C ","N ",
104 "O ","F ","Ne","Na","Mg","Al","Si","P ",
105 "S ","Cl","Ar","K ","Ca","Sc","Ti","V ",
106 "Cr","Mn","Fe","Co","Ni","Cu","Zn","Ga",
107 "Ge","As","Se","Br","Kr"};
112 out=fopen("FOR009","w");
113 /* of these options I am not completely sure.... the overall
114 * preformance on more than 4 cpu's is rather poor at the moment.
116 fprintf(out,"memory 48000000\nPARALLEL IOMODE SCREENED\n");
117 fprintf(out,"ELEC %d\nMULT %d\nSUPER ON\nNOSYM\nGEOMETRY ANGSTROM\n",
118 qm->nelectrons,qm->multiplicity);
119 for (i=0;i<qm->nrQMatoms;i++){
121 fprintf(out,"%10.7lf %10.7lf %10.7lf %5.3lf %2s\n",
125 qm->atomicnumberQM[i]*1.0,
126 periodic_system[qm->atomicnumberQM[i]]);
128 fprintf(out,"%10.7f %10.7f %10.7f %5.3f %2s\n",
132 qm->atomicnumberQM[i]*1.0,
133 periodic_system[qm->atomicnumberQM[i]]);
139 fprintf(out,"%10.7lf %10.7lf %10.7lf %5.3lf BQ\n",
145 fprintf(out,"%10.7f %10.7f %10.7f %5.3f BQ\n",
154 fprintf(out,"END\nBASIS %s\nRUNTYPE GRADIENT\nSCFTYPE %s\n",
155 eQMbasis_names[qm->QMbasis],
156 eQMmethod_names[qm->QMmethod]); /* see enum.h */
158 fprintf(out,"END\nBASIS %s\nRUNTYPE SADDLE\nSCFTYPE %s\n",
159 eQMbasis_names[qm->QMbasis],
160 eQMmethod_names[qm->QMmethod]); /* see enum.h */
164 F77_FUNC(inigms,IMIGMS)();
166 else{ /* normal serial run */
168 out=fopen("FOR009","w");
169 /* of these options I am not completely sure.... the overall
170 * preformance on more than 4 cpu's is rather poor at the moment.
172 fprintf(out,"ELEC %d\nMULT %d\nSUPER ON\nNOSYM\nGEOMETRY ANGSTROM\n",
173 qm->nelectrons,qm->multiplicity);
174 for (i=0;i<qm->nrQMatoms;i++){
176 fprintf(out,"%10.7lf %10.7lf %10.7lf %5.3lf %2s\n",
180 qm->atomicnumberQM[i]*1.0,
181 periodic_system[qm->atomicnumberQM[i]]);
183 fprintf(out,"%10.7f %10.7f %10.7f %5.3f %2s\n",
187 qm->atomicnumberQM[i]*1.0,
188 periodic_system[qm->atomicnumberQM[i]]);
194 fprintf(out,"%10.7lf %10.7lf %10.7lf %5.3lf BQ\n",
200 fprintf(out,"%10.7f %10.7f %10.7f %5.3f BQ\n",
209 fprintf(out,"END\nBASIS %s\nRUNTYPE GRADIENT\nSCFTYPE %s\n",
210 eQMbasis_names[qm->QMbasis],
211 eQMmethod_names[qm->QMmethod]); /* see enum.h */
213 fprintf(out,"END\nBASIS %s\nRUNTYPE SADDLE\nSCFTYPE %s\n",
214 eQMbasis_names[qm->QMbasis],
215 eQMmethod_names[qm->QMmethod]); /* see enum.h */
216 F77_FUNC(inigms,IMIGMS)();
220 real call_gamess(t_commrec *cr, t_forcerec *fr, t_QMrec *qm, t_MMrec *mm,
221 rvec f[], rvec fshift[])
223 /* do the actual QMMM calculation using GAMESS-UK. In this
224 * implementation (3-2001) a system call is made to the GAMESS-UK
225 * binary. Now we are working to get the electron integral, SCF, and
226 * gradient routines linked directly
231 QMener=0.0,*qmgrad,*mmgrad,*mmcrd,*qmcrd,energy;
235 /* copy the QMMMrec pointer */
237 snew(qmcrd, 3*(qm->nrQMatoms));
238 snew(mmcrd,3*(mm->nrMMatoms));
239 snew(qmgrad,3*(qm->nrQMatoms));
240 snew(mmgrad,3*(mm->nrMMatoms));
242 /* copy the data from qr into the arrays that are going to be used
243 * in the fortran routines of gamess
245 for(i=0;i<qm->nrQMatoms;i++){
247 qmcrd[DIM*i+j] = 1/BOHR2NM*qm->xQM[i][j];
250 for(i=0;i<mm->nrMMatoms;i++){
252 mmcrd[DIM*i+j] = 1/BOHR2NM*mm->xMM[i][j];
255 for (i=0;i<3*qm->nrQMatoms;i+=3){
256 fprintf(stderr,"%8.5f, %8.5f, %8.5f\n",
262 F77_FUNC(grads,GRADS)(&qm->nrQMatoms,qmcrd,&mm->nrMMatoms,mm->MMcharges,
263 mmcrd,qmgrad,mmgrad,&energy);
265 for(i=0;i<qm->nrQMatoms;i++){
267 f[i][j] = HARTREE_BOHR2MD*qmgrad[3*i+j];
268 fshift[i][j] = HARTREE_BOHR2MD*qmgrad[3*i+j];
271 for(i=0;i<mm->nrMMatoms;i++){
273 f[i][j] = HARTREE_BOHR2MD*mmgrad[3*i+j];
274 fshift[i][j] = HARTREE_BOHR2MD*mmgrad[3*i+j];
277 /* convert a.u to kJ/mol */
278 QMener=energy*HARTREE2KJ*AVOGADRO;
284 gmx_qmmm_gamess_empty;