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 * Copyright (c) 2013,2014, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
41 #ifdef GMX_QMMM_GAMESS
46 #include "gromacs/utility/smalloc.h"
49 #include "gromacs/math/vec.h"
52 #include "gromacs/fileio/confio.h"
64 #include "gromacs/utility/fatalerror.h"
69 /* QMMM sub routines */
70 /* mopac interface routines */
74 F77_FUNC(inigms, IMIGMS) (void);
77 F77_FUNC(endgms, ENDGMS) (void);
80 F77_FUNC(grads, GRADS) (int *nrqmat, real *qmcrd, int *nrmmat, real *mmchrg,
81 real *mmcrd, real *qmgrad, real *mmgrad, real *energy);
85 void init_gamess(t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
87 /* it works hopelessly complicated :-)
88 * first a file is written. Then the standard gamess input/output
89 * routine is called (no system()!) to set up all fortran arrays.
90 * this routine writes a punch file, like in a normal gamess run.
91 * via this punch file the other games routines, needed for gradient
92 * and energy evaluations are called. This setup works fine for
93 * dynamics simulations. 7-6-2002 (London)
100 periodic_system[37][3] = {
101 "XX", "H ", "He", "Li", "Be", "B ", "C ", "N ",
102 "O ", "F ", "Ne", "Na", "Mg", "Al", "Si", "P ",
103 "S ", "Cl", "Ar", "K ", "Ca", "Sc", "Ti", "V ",
104 "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga",
105 "Ge", "As", "Se", "Br", "Kr"
113 out = fopen("FOR009", "w");
114 /* of these options I am not completely sure.... the overall
115 * preformance on more than 4 cpu's is rather poor at the moment.
117 fprintf(out, "memory 48000000\nPARALLEL IOMODE SCREENED\n");
118 fprintf(out, "ELEC %d\nMULT %d\nSUPER ON\nNOSYM\nGEOMETRY ANGSTROM\n",
119 qm->nelectrons, qm->multiplicity);
120 for (i = 0; i < qm->nrQMatoms; i++)
123 fprintf(out, "%10.7lf %10.7lf %10.7lf %5.3lf %2s\n",
127 qm->atomicnumberQM[i]*1.0,
128 periodic_system[qm->atomicnumberQM[i]]);
130 fprintf(out, "%10.7f %10.7f %10.7f %5.3f %2s\n",
134 qm->atomicnumberQM[i]*1.0,
135 periodic_system[qm->atomicnumberQM[i]]);
140 for (j = i; j < i+2; j++)
143 fprintf(out, "%10.7lf %10.7lf %10.7lf %5.3lf BQ\n",
149 fprintf(out, "%10.7f %10.7f %10.7f %5.3f BQ\n",
159 fprintf(out, "END\nBASIS %s\nRUNTYPE GRADIENT\nSCFTYPE %s\n",
160 eQMbasis_names[qm->QMbasis],
161 eQMmethod_names[qm->QMmethod]); /* see enum.h */
165 fprintf(out, "END\nBASIS %s\nRUNTYPE SADDLE\nSCFTYPE %s\n",
166 eQMbasis_names[qm->QMbasis],
167 eQMmethod_names[qm->QMmethod]); /* see enum.h */
172 F77_FUNC(inigms, IMIGMS) ();
174 else /* normal serial run */
177 out = fopen("FOR009", "w");
178 /* of these options I am not completely sure.... the overall
179 * preformance on more than 4 cpu's is rather poor at the moment.
181 fprintf(out, "ELEC %d\nMULT %d\nSUPER ON\nNOSYM\nGEOMETRY ANGSTROM\n",
182 qm->nelectrons, qm->multiplicity);
183 for (i = 0; i < qm->nrQMatoms; i++)
186 fprintf(out, "%10.7lf %10.7lf %10.7lf %5.3lf %2s\n",
190 qm->atomicnumberQM[i]*1.0,
191 periodic_system[qm->atomicnumberQM[i]]);
193 fprintf(out, "%10.7f %10.7f %10.7f %5.3f %2s\n",
197 qm->atomicnumberQM[i]*1.0,
198 periodic_system[qm->atomicnumberQM[i]]);
203 for (j = i; j < i+2; j++)
206 fprintf(out, "%10.7lf %10.7lf %10.7lf %5.3lf BQ\n",
212 fprintf(out, "%10.7f %10.7f %10.7f %5.3f BQ\n",
222 fprintf(out, "END\nBASIS %s\nRUNTYPE GRADIENT\nSCFTYPE %s\n",
223 eQMbasis_names[qm->QMbasis],
224 eQMmethod_names[qm->QMmethod]); /* see enum.h */
228 fprintf(out, "END\nBASIS %s\nRUNTYPE SADDLE\nSCFTYPE %s\n",
229 eQMbasis_names[qm->QMbasis],
230 eQMmethod_names[qm->QMmethod]); /* see enum.h */
232 F77_FUNC(inigms, IMIGMS) ();
236 real call_gamess(t_commrec *cr, t_forcerec *fr, t_QMrec *qm, t_MMrec *mm,
237 rvec f[], rvec fshift[])
239 /* do the actual QMMM calculation using GAMESS-UK. In this
240 * implementation (3-2001) a system call is made to the GAMESS-UK
241 * binary. Now we are working to get the electron integral, SCF, and
242 * gradient routines linked directly
247 QMener = 0.0, *qmgrad, *mmgrad, *mmcrd, *qmcrd, energy;
251 /* copy the QMMMrec pointer */
253 snew(qmcrd, 3*(qm->nrQMatoms));
254 snew(mmcrd, 3*(mm->nrMMatoms));
255 snew(qmgrad, 3*(qm->nrQMatoms));
256 snew(mmgrad, 3*(mm->nrMMatoms));
258 /* copy the data from qr into the arrays that are going to be used
259 * in the fortran routines of gamess
261 for (i = 0; i < qm->nrQMatoms; i++)
263 for (j = 0; j < DIM; j++)
265 qmcrd[DIM*i+j] = 1/BOHR2NM*qm->xQM[i][j];
268 for (i = 0; i < mm->nrMMatoms; i++)
270 for (j = 0; j < DIM; j++)
272 mmcrd[DIM*i+j] = 1/BOHR2NM*mm->xMM[i][j];
275 for (i = 0; i < 3*qm->nrQMatoms; i += 3)
277 fprintf(stderr, "%8.5f, %8.5f, %8.5f\n",
283 F77_FUNC(grads, GRADS) (&qm->nrQMatoms, qmcrd, &mm->nrMMatoms, mm->MMcharges,
284 mmcrd, qmgrad, mmgrad, &energy);
286 for (i = 0; i < qm->nrQMatoms; i++)
288 for (j = 0; j < DIM; j++)
290 f[i][j] = HARTREE_BOHR2MD*qmgrad[3*i+j];
291 fshift[i][j] = HARTREE_BOHR2MD*qmgrad[3*i+j];
294 for (i = 0; i < mm->nrMMatoms; i++)
296 for (j = 0; j < DIM; j++)
298 f[i][j] = HARTREE_BOHR2MD*mmgrad[3*i+j];
299 fshift[i][j] = HARTREE_BOHR2MD*mmgrad[3*i+j];
302 /* convert a.u to kJ/mol */
303 QMener = energy*HARTREE2KJ*AVOGADRO;
309 gmx_qmmm_gamess_empty;