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, 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_GAUSSIAN
68 #include "gmx_fatal.h"
73 /* TODO: this should be made thread-safe */
75 /* Gaussian interface routines */
77 void init_gaussian(t_commrec *cr, t_QMrec *qm, t_MMrec *mm)
80 *rffile=NULL,*out=NULL;
82 basissets[eQMbasisNR]={{0,3,0},
83 {0,3,0},/*added for double sto-3g entry in names.c*/
97 /* using the ivec above to convert the basis read form the mdp file
98 * in a human readable format into some numbers for the gaussian
99 * route. This is necessary as we are using non standard routes to
103 /* per layer we make a new subdir for integral file, checkpoint
104 * files and such. These dirs are stored in the QMrec for
109 if(!qm->nQMcpus){ /* this we do only once per layer
110 * as we call g01 externally
114 qm->SHbasis[i]=basissets[qm->QMbasis][i];
116 /* init gradually switching on of the SA */
118 /* we read the number of cpus and environment from the environment
121 buf = getenv("NCPUS");
123 sscanf(buf,"%d",&qm->nQMcpus);
126 fprintf(stderr,"number of CPUs for gaussian = %d\n",qm->nQMcpus);
129 sscanf(buf,"%d",&qm->QMmem);
132 fprintf(stderr,"memory for gaussian = %d\n",qm->QMmem);
135 sscanf(buf,"%d",&qm->accuracy);
138 fprintf(stderr,"accuracy in l510 = %d\n",qm->accuracy);
140 buf = getenv("CPMCSCF");
144 qm->cpmcscf = (i!=0);
149 fprintf(stderr,"using cp-mcscf in l1003\n");
151 fprintf(stderr,"NOT using cp-mcscf in l1003\n");
152 buf = getenv("SASTEP");
154 sscanf(buf,"%d",&qm->SAstep);
156 /* init gradually switching on of the SA */
158 /* we read the number of cpus and environment from the environment
161 fprintf(stderr,"Level of SA at start = %d\n",qm->SAstep);
162 /* punch the LJ C6 and C12 coefficients to be picked up by
163 * gaussian and usd to compute the LJ interaction between the
166 if(qm->bTS||qm->bOPT){
167 out = fopen("LJ.dat","w");
168 for(i=0;i<qm->nrQMatoms;i++){
171 fprintf(out,"%3d %10.7lf %10.7lf\n",
172 qm->atomicnumberQM[i],qm->c6[i],qm->c12[i]);
174 fprintf(out,"%3d %10.7f %10.7f\n",
175 qm->atomicnumberQM[i],qm->c6[i],qm->c12[i]);
180 /* gaussian settings on the system */
181 buf = getenv("GAUSS_DIR");
182 fprintf(stderr,"%s",buf);
185 qm->gauss_dir=strdup(buf);
188 gmx_fatal(FARGS,"no $GAUSS_DIR, check gaussian manual\n");
190 buf = getenv("GAUSS_EXE");
192 qm->gauss_exe=strdup(buf);
195 gmx_fatal(FARGS,"no $GAUSS_EXE, check gaussian manual\n");
196 buf = getenv("DEVEL_DIR");
198 qm->devel_dir = strdup (buf);
201 gmx_fatal(FARGS,"no $DEVEL_DIR, this is were the modified links reside.\n");
204 /* reactionfield, file is needed using gaussian */
205 /* rffile=fopen("rf.dat","w");*/
206 /* fprintf(rffile,"%f %f\n",fr->epsilon_r,fr->rcoulomb/BOHR2NM);*/
210 fprintf(stderr,"gaussian initialised...\n");
215 void write_gaussian_SH_input(int step,gmx_bool swap,
216 t_forcerec *fr, t_QMrec *qm, t_MMrec *mm)
227 bSA = (qm->SAstep>0);
229 out = fopen("input.com","w");
230 /* write the route */
231 fprintf(out,"%s","%scr=input\n");
232 fprintf(out,"%s","%rwf=input\n");
233 fprintf(out,"%s","%int=input\n");
234 fprintf(out,"%s","%d2e=input\n");
236 * fprintf(out,"%s","%nosave\n");
238 fprintf(out,"%s","%chk=input\n");
239 fprintf(out,"%s%d\n","%mem=",qm->QMmem);
240 fprintf(out,"%s%3d\n","%nprocshare=",qm->nQMcpus);
242 /* use the versions of
243 * l301 that computes the interaction between MM and QM atoms.
244 * l510 that can punch the CI coefficients
245 * l701 that can do gradients on MM atoms
249 fprintf(out,"%s%s%s",
253 fprintf(out,"%s%s%s",
257 fprintf(out,"%s%s%s",
262 fprintf(out,"%s%s%s",
266 fprintf(out,"%s%s%s",
270 /* print the nonstandard route
273 "#P nonstd\n 1/18=10,20=1,38=1/1;\n");
275 " 2/9=110,15=1,17=6,18=5,40=1/2;\n");
278 " 3/5=%d,6=%d,7=%d,25=1,32=1,43=1,94=-2/1,2,3;\n",
281 qm->SHbasis[2]); /*basisset stuff */
284 " 3/5=%d,6=%d,7=%d,25=1,32=1,43=0,94=-2/1,2,3;\n",
287 qm->SHbasis[2]); /*basisset stuff */
289 if (step+1) /* fetch initial guess from check point file */
290 /* hack, to alyays read from chk file!!!!! */
291 fprintf(out,"%s%d,%s%d%s"," 4/5=1,7=6,17=",
293 "18=",qm->CASorbitals,"/1,5;\n");
294 else /* generate the first checkpoint file */
295 fprintf(out,"%s%d,%s%d%s"," 4/5=0,7=6,17=",
297 "18=",qm->CASorbitals,"/1,5;\n");
298 /* the rest of the input depends on where the system is on the PES
300 if(swap && bSA){ /* make a slide to the other surface */
301 if(qm->CASorbitals>6){ /* use direct and no full diag */
302 fprintf(out," 5/5=2,16=-2,17=10000000,28=2,32=2,38=6,97=100/10;\n");
306 fprintf(out," 5/5=2,6=%d,17=31000200,28=2,32=2,38=6,97=100/10;\n",
309 fprintf(out," 7/7=1,16=-2,30=1/1;\n");
310 fprintf(out," 11/31=1,42=1,45=1/1;\n");
311 fprintf(out," 10/6=1,10=700006,28=2,29=1,31=1,97=100/3;\n");
312 fprintf(out," 7/30=1/16;\n 99/10=4/99;\n");
315 fprintf(out," 5/5=2,6=%d,17=11000000,28=2,32=2,38=6,97=100/10;\n",
317 fprintf(out," 7/7=1,16=-2,30=1/1,2,3,16;\n 99/10=4/99;\n");
321 else if(bSA){ /* do a "state-averaged" CAS calculation */
322 if(qm->CASorbitals>6){ /* no full diag */
323 fprintf(out," 5/5=2,16=-2,17=10000000,28=2,32=2,38=6/10;\n");
327 fprintf(out," 5/5=2,6=%d,17=31000200,28=2,32=2,38=6/10;\n",
330 fprintf(out," 7/7=1,16=-2,30=1/1;\n");
331 fprintf(out," 11/31=1,42=1,45=1/1;\n");
332 fprintf(out," 10/6=1,10=700006,28=2,29=1,31=1/3;\n");
333 fprintf(out," 7/30=1/16;\n 99/10=4/99;\n");
336 fprintf(out," 5/5=2,6=%d,17=11000000,28=2,32=2,38=6/10;\n",
338 fprintf(out," 7/7=1,16=-2,30=1/1,2,3,16;\n 99/10=4/99;\n");
342 else if(swap){/* do a "swapped" CAS calculation */
343 if(qm->CASorbitals>6)
344 fprintf(out," 5/5=2,16=-2,17=0,28=2,32=2,38=6,97=100/10;\n");
346 fprintf(out," 5/5=2,6=%d,17=1000000,28=2,32=2,38=6,97=100/10;\n",
348 fprintf(out," 7/7=1,16=-2,30=1/1,2,3,16;\n 99/10=4/99;\n");
350 else {/* do a "normal" CAS calculation */
351 if(qm->CASorbitals>6)
352 fprintf(out," 5/5=2,16=-2,17=0,28=2,32=2,38=6/10;\n");
354 fprintf(out," 5/5=2,6=%d,17=1000000,28=2,32=2,38=6/10;\n",
356 fprintf(out," 7/7=1,16=-2,30=1/1,2,3,16;\n 99/10=4/99;\n");
358 fprintf(out, "\ninput-file generated by gromacs\n\n");
359 fprintf(out,"%2d%2d\n",qm->QMcharge,qm->multiplicity);
360 for (i=0;i<qm->nrQMatoms;i++){
362 fprintf(out,"%3d %10.7lf %10.7lf %10.7lf\n",
363 qm->atomicnumberQM[i],
364 qm->xQM[i][XX]/BOHR2NM,
365 qm->xQM[i][YY]/BOHR2NM,
366 qm->xQM[i][ZZ]/BOHR2NM);
368 fprintf(out,"%3d %10.7f %10.7f %10.7f\n",
369 qm->atomicnumberQM[i],
370 qm->xQM[i][XX]/BOHR2NM,
371 qm->xQM[i][YY]/BOHR2NM,
372 qm->xQM[i][ZZ]/BOHR2NM);
375 /* MM point charge data */
376 if(QMMMrec->QMMMscheme!=eQMMMschemeoniom && mm->nrMMatoms){
378 for(i=0;i<mm->nrMMatoms;i++){
380 fprintf(out,"%10.7lf %10.7lf %10.7lf %8.4lf\n",
381 mm->xMM[i][XX]/BOHR2NM,
382 mm->xMM[i][YY]/BOHR2NM,
383 mm->xMM[i][ZZ]/BOHR2NM,
386 fprintf(out,"%10.7f %10.7f %10.7f %8.4f\n",
387 mm->xMM[i][XX]/BOHR2NM,
388 mm->xMM[i][YY]/BOHR2NM,
389 mm->xMM[i][ZZ]/BOHR2NM,
394 if(bSA) {/* put the SA coefficients at the end of the file */
396 fprintf(out,"\n%10.8lf %10.8lf\n",
397 qm->SAstep*0.5/qm->SAsteps,
398 1-qm->SAstep*0.5/qm->SAsteps);
400 fprintf(out,"\n%10.8f %10.8f\n",
401 qm->SAstep*0.5/qm->SAsteps,
402 1-qm->SAstep*0.5/qm->SAsteps);
404 fprintf(stderr,"State Averaging level = %d/%d\n",qm->SAstep,qm->SAsteps);
408 } /* write_gaussian_SH_input */
410 void write_gaussian_input(int step ,t_forcerec *fr, t_QMrec *qm, t_MMrec *mm)
420 out = fopen("input.com","w");
421 /* write the route */
423 if(qm->QMmethod>=eQMmethodRHF)
430 fprintf(out,"%s%3d\n",
431 "%nprocshare=",qm->nQMcpus);
432 fprintf(out,"%s%d\n",
434 /* use the modified links that include the LJ contribution at the QM level */
435 if(qm->bTS||qm->bOPT){
436 fprintf(out,"%s%s%s",
437 "%subst l701 ",qm->devel_dir,"/l701_LJ\n");
438 fprintf(out,"%s%s%s",
439 "%subst l301 ",qm->devel_dir,"/l301_LJ\n");
442 fprintf(out,"%s%s%s",
443 "%subst l701 ",qm->devel_dir,"/l701\n");
444 fprintf(out,"%s%s%s",
445 "%subst l301 ",qm->devel_dir,"/l301\n");
447 fprintf(out,"%s%s%s",
448 "%subst l9999 ",qm->devel_dir,"/l9999\n");
456 if(qm->QMmethod==eQMmethodB3LYPLAN){
458 "B3LYP/GEN Pseudo=Read");
462 eQMmethod_names[qm->QMmethod]);
464 if(qm->QMmethod>=eQMmethodRHF){
465 if(qm->QMmethod==eQMmethodCASSCF){
466 /* in case of cas, how many electrons and orbitals do we need?
468 fprintf(out,"(%d,%d)",
469 qm->CASelectrons,qm->CASorbitals);
472 eQMbasis_names[qm->QMbasis]);
475 if(QMMMrec->QMMMscheme==eQMMMschemenormal && mm->nrMMatoms){
479 if (step || qm->QMmethod==eQMmethodCASSCF){
480 /* fetch guess from checkpoint file, always for CASSCF */
481 fprintf(out,"%s"," guess=read");
483 fprintf(out,"\nNosymm units=bohr\n");
486 fprintf(out,"OPT=(Redundant,TS,noeigentest,ModRedundant) Punch=(Coord,Derivatives) ");
489 fprintf(out,"OPT=(Redundant,ModRedundant) Punch=(Coord,Derivatives) ");
492 fprintf(out,"FORCE Punch=(Derivatives) ");
494 fprintf(out,"iop(3/33=1)\n\n");
495 fprintf(out, "input-file generated by gromacs\n\n");
496 fprintf(out,"%2d%2d\n",qm->QMcharge,qm->multiplicity);
497 for (i=0;i<qm->nrQMatoms;i++){
499 fprintf(out,"%3d %10.7lf %10.7lf %10.7lf\n",
500 qm->atomicnumberQM[i],
501 qm->xQM[i][XX]/BOHR2NM,
502 qm->xQM[i][YY]/BOHR2NM,
503 qm->xQM[i][ZZ]/BOHR2NM);
505 fprintf(out,"%3d %10.7f %10.7f %10.7f\n",
506 qm->atomicnumberQM[i],
507 qm->xQM[i][XX]/BOHR2NM,
508 qm->xQM[i][YY]/BOHR2NM,
509 qm->xQM[i][ZZ]/BOHR2NM);
513 /* Pseudo Potential and ECP are included here if selected (MEthod suffix LAN) */
514 if(qm->QMmethod==eQMmethodB3LYPLAN){
516 for(i=0;i<qm->nrQMatoms;i++){
517 if(qm->atomicnumberQM[i]<21){
518 fprintf(out,"%d ",i+1);
521 fprintf(out,"\n%s\n****\n",eQMbasis_names[qm->QMbasis]);
523 for(i=0;i<qm->nrQMatoms;i++){
524 if(qm->atomicnumberQM[i]>21){
525 fprintf(out,"%d ",i+1);
528 fprintf(out,"\n%s\n****\n\n","lanl2dz");
530 for(i=0;i<qm->nrQMatoms;i++){
531 if(qm->atomicnumberQM[i]>21){
532 fprintf(out,"%d ",i+1);
535 fprintf(out,"\n%s\n","lanl2dz");
540 /* MM point charge data */
541 if(QMMMrec->QMMMscheme!=eQMMMschemeoniom && mm->nrMMatoms){
542 fprintf(stderr,"nr mm atoms in gaussian.c = %d\n",mm->nrMMatoms);
544 if(qm->bTS||qm->bOPT){
545 /* freeze the frontier QM atoms and Link atoms. This is
546 * important only if a full QM subsystem optimization is done
547 * with a frozen MM environmeent. For dynamics, or gromacs's own
548 * optimization routines this is not important.
550 for(i=0;i<qm->nrQMatoms;i++){
551 if(qm->frontatoms[i]){
552 fprintf(out,"%d F\n",i+1); /* counting from 1 */
555 /* MM point charges include LJ parameters in case of QM optimization
557 for(i=0;i<mm->nrMMatoms;i++){
559 fprintf(out,"%10.7lf %10.7lf %10.7lf %8.4lf 0.0 %10.7lf %10.7lf\n",
560 mm->xMM[i][XX]/BOHR2NM,
561 mm->xMM[i][YY]/BOHR2NM,
562 mm->xMM[i][ZZ]/BOHR2NM,
564 mm->c6[i],mm->c12[i]);
566 fprintf(out,"%10.7f %10.7f %10.7f %8.4f 0.0 %10.7f %10.7f\n",
567 mm->xMM[i][XX]/BOHR2NM,
568 mm->xMM[i][YY]/BOHR2NM,
569 mm->xMM[i][ZZ]/BOHR2NM,
571 mm->c6[i],mm->c12[i]);
577 for(i=0;i<mm->nrMMatoms;i++){
579 fprintf(out,"%10.7lf %10.7lf %10.7lf %8.4lf\n",
580 mm->xMM[i][XX]/BOHR2NM,
581 mm->xMM[i][YY]/BOHR2NM,
582 mm->xMM[i][ZZ]/BOHR2NM,
585 fprintf(out,"%10.7f %10.7f %10.7f %8.4f\n",
586 mm->xMM[i][XX]/BOHR2NM,
587 mm->xMM[i][YY]/BOHR2NM,
588 mm->xMM[i][ZZ]/BOHR2NM,
599 } /* write_gaussian_input */
601 real read_gaussian_output(rvec QMgrad[],rvec MMgrad[],int step,
602 t_QMrec *qm, t_MMrec *mm)
613 in=fopen("fort.7","r");
617 /* in case of an optimization, the coordinates are printed in the
618 * fort.7 file first, followed by the energy, coordinates and (if
619 * required) the CI eigenvectors.
621 if(qm->bTS||qm->bOPT){
622 for(i=0;i<qm->nrQMatoms;i++){
623 if( NULL == fgets(buf,300,in))
625 gmx_fatal(FARGS,"Error reading Gaussian output - not enough atom lines?");
629 sscanf(buf,"%d %lf %lf %lf\n",
635 sscanf(buf,"%d %f %f %f\n",
642 qm->xQM[i][j]*=BOHR2NM;
646 /* the next line is the energy and in the case of CAS, the energy
647 * difference between the two states.
649 if(NULL == fgets(buf,300,in))
651 gmx_fatal(FARGS,"Error reading Gaussian output");
655 sscanf(buf,"%lf\n",&QMener);
657 sscanf(buf,"%f\n", &QMener);
659 /* next lines contain the gradients of the QM atoms */
660 for(i=0;i<qm->nrQMatoms;i++){
661 if(NULL == fgets(buf,300,in))
663 gmx_fatal(FARGS,"Error reading Gaussian output");
666 sscanf(buf,"%lf %lf %lf\n",
671 sscanf(buf,"%f %f %f\n",
677 /* the next lines are the gradients of the MM atoms */
678 if(qm->QMmethod>=eQMmethodRHF){
679 for(i=0;i<mm->nrMMatoms;i++){
680 if(NULL==fgets(buf,300,in))
682 gmx_fatal(FARGS,"Error reading Gaussian output");
685 sscanf(buf,"%lf %lf %lf\n",
690 sscanf(buf,"%f %f %f\n",
701 real read_gaussian_SH_output(rvec QMgrad[],rvec MMgrad[],int step,
702 gmx_bool swapped,t_QMrec *qm, t_MMrec *mm)
713 in=fopen("fort.7","r");
714 /* first line is the energy and in the case of CAS, the energy
715 * difference between the two states.
717 if(NULL == fgets(buf,300,in))
719 gmx_fatal(FARGS,"Error reading Gaussian output");
723 sscanf(buf,"%lf %lf\n",&QMener,&DeltaE);
725 sscanf(buf,"%f %f\n", &QMener,&DeltaE);
728 /* switch on/off the State Averaging */
730 if(DeltaE > qm->SAoff){
735 else if (DeltaE < qm->SAon || (qm->SAstep > 0)){
736 if (qm->SAstep < qm->SAsteps){
742 fprintf(stderr,"Gap = %5f,SA = %3d\n",DeltaE,(qm->SAstep>0));
743 /* next lines contain the gradients of the QM atoms */
744 for(i=0;i<qm->nrQMatoms;i++){
745 if(NULL==fgets(buf,300,in))
747 gmx_fatal(FARGS,"Error reading Gaussian output");
751 sscanf(buf,"%lf %lf %lf\n",
756 sscanf(buf,"%f %f %f\n",
762 /* the next lines, are the gradients of the MM atoms */
764 for(i=0;i<mm->nrMMatoms;i++){
765 if(NULL==fgets(buf,300,in))
767 gmx_fatal(FARGS,"Error reading Gaussian output");
770 sscanf(buf,"%lf %lf %lf\n",
775 sscanf(buf,"%f %f %f\n",
782 /* the next line contains the two CI eigenvector elements */
783 if(NULL==fgets(buf,300,in))
785 gmx_fatal(FARGS,"Error reading Gaussian output");
788 sscanf(buf,"%d",&qm->CIdim);
789 snew(qm->CIvec1,qm->CIdim);
790 snew(qm->CIvec1old,qm->CIdim);
791 snew(qm->CIvec2,qm->CIdim);
792 snew(qm->CIvec2old,qm->CIdim);
794 /* before reading in the new current CI vectors, copy the current
795 * CI vector into the old one.
797 for(i=0;i<qm->CIdim;i++){
798 qm->CIvec1old[i] = qm->CIvec1[i];
799 qm->CIvec2old[i] = qm->CIvec2[i];
803 for(i=0;i<qm->CIdim;i++){
804 if(NULL==fgets(buf,300,in))
806 gmx_fatal(FARGS,"Error reading Gaussian output");
809 sscanf(buf,"%lf\n",&qm->CIvec1[i]);
811 sscanf(buf,"%f\n", &qm->CIvec1[i]);
815 for(i=0;i<qm->CIdim;i++){
816 if(NULL==fgets(buf,300,in))
818 gmx_fatal(FARGS,"Error reading Gaussian output");
821 sscanf(buf,"%lf\n",&qm->CIvec2[i]);
823 sscanf(buf,"%f\n", &qm->CIvec2[i]);
830 real inproduct(real *a, real *b, int n)
837 /* computes the inner product between two vectors (a.b), both of
838 * which have length n.
846 int hop(int step, t_QMrec *qm)
851 d11=0.0,d12=0.0,d21=0.0,d22=0.0;
853 /* calculates the inproduct between the current Ci vector and the
854 * previous CI vector. A diabatic hop will be made if d12 and d21
855 * are much bigger than d11 and d22. In that case hop returns true,
856 * otherwise it returns false.
858 if(step){ /* only go on if more than one step has been done */
859 d11 = inproduct(qm->CIvec1,qm->CIvec1old,qm->CIdim);
860 d12 = inproduct(qm->CIvec1,qm->CIvec2old,qm->CIdim);
861 d21 = inproduct(qm->CIvec2,qm->CIvec1old,qm->CIdim);
862 d22 = inproduct(qm->CIvec2,qm->CIvec2old,qm->CIdim);
864 fprintf(stderr,"-------------------\n");
865 fprintf(stderr,"d11 = %13.8f\n",d11);
866 fprintf(stderr,"d12 = %13.8f\n",d12);
867 fprintf(stderr,"d21 = %13.8f\n",d21);
868 fprintf(stderr,"d22 = %13.8f\n",d22);
869 fprintf(stderr,"-------------------\n");
871 if((fabs(d12)>0.5)&&(fabs(d21)>0.5))
877 void do_gaussian(int step,char *exe)
882 /* make the call to the gaussian binary through system()
883 * The location of the binary will be picked up from the
884 * environment using getenv().
886 if(step) /* hack to prevent long inputfiles */
887 sprintf(buf,"%s < %s > %s",
892 sprintf(buf,"%s < %s > %s",
896 fprintf(stderr,"Calling '%s'\n",buf);
898 printf("Warning-- No calls to system(3) supported on this platform.");
899 gmx_fatal(FARGS,"Call to '%s' failed\n",buf);
901 if ( system(buf) != 0 )
902 gmx_fatal(FARGS,"Call to '%s' failed\n",buf);
906 real call_gaussian(t_commrec *cr, t_forcerec *fr,
907 t_QMrec *qm, t_MMrec *mm, rvec f[], rvec fshift[])
909 /* normal gaussian jobs */
922 sprintf(exe,"%s/%s",qm->gauss_dir,qm->gauss_exe);
923 snew(QMgrad,qm->nrQMatoms);
924 snew(MMgrad,mm->nrMMatoms);
926 write_gaussian_input(step,fr,qm,mm);
927 do_gaussian(step,exe);
928 QMener = read_gaussian_output(QMgrad,MMgrad,step,qm,mm);
929 /* put the QMMM forces in the force array and to the fshift
931 for(i=0;i<qm->nrQMatoms;i++){
933 f[i][j] = HARTREE_BOHR2MD*QMgrad[i][j];
934 fshift[i][j] = HARTREE_BOHR2MD*QMgrad[i][j];
937 for(i=0;i<mm->nrMMatoms;i++){
939 f[i+qm->nrQMatoms][j] = HARTREE_BOHR2MD*MMgrad[i][j];
940 fshift[i+qm->nrQMatoms][j] = HARTREE_BOHR2MD*MMgrad[i][j];
943 QMener = QMener*HARTREE2KJ*AVOGADRO;
948 } /* call_gaussian */
950 real call_gaussian_SH(t_commrec *cr, t_forcerec *fr, t_QMrec *qm, t_MMrec *mm,
951 rvec f[], rvec fshift[])
953 /* a gaussian call routine intended for doing diabatic surface
954 * "sliding". See the manual for the theoretical background of this
964 swapped=FALSE; /* handle for identifying the current PES */
966 swap=FALSE; /* the actual swap */
975 sprintf(exe,"%s/%s",qm->gauss_dir,qm->gauss_exe);
976 /* hack to do ground state simulations */
979 buf = getenv("STATE");
981 sscanf(buf,"%d",&state);
990 /* copy the QMMMrec pointer */
991 snew(QMgrad,qm->nrQMatoms);
992 snew(MMgrad,mm->nrMMatoms);
993 /* at step 0 there should be no SA */
996 /* temporray set to step + 1, since there is a chk start */
997 write_gaussian_SH_input(step,swapped,fr,qm,mm);
999 do_gaussian(step,exe);
1000 QMener = read_gaussian_SH_output(QMgrad,MMgrad,step,swapped,qm,mm);
1002 /* check for a surface hop. Only possible if we were already state
1007 swap = (step && hop(step,qm));
1010 else { /* already on the other surface, so check if we go back */
1011 swap = (step && hop(step,qm));
1012 swapped =!swap; /* so swapped shoud be false again */
1014 if (swap){/* change surface, so do another call */
1015 write_gaussian_SH_input(step,swapped,fr,qm,mm);
1016 do_gaussian(step,exe);
1017 QMener = read_gaussian_SH_output(QMgrad,MMgrad,step,swapped,qm,mm);
1020 /* add the QMMM forces to the gmx force array and fshift
1022 for(i=0;i<qm->nrQMatoms;i++){
1024 f[i][j] = HARTREE_BOHR2MD*QMgrad[i][j];
1025 fshift[i][j] = HARTREE_BOHR2MD*QMgrad[i][j];
1028 for(i=0;i<mm->nrMMatoms;i++){
1030 f[i+qm->nrQMatoms][j] = HARTREE_BOHR2MD*MMgrad[i][j];
1031 fshift[i+qm->nrQMatoms][j] = HARTREE_BOHR2MD*MMgrad[i][j];
1034 QMener = QMener*HARTREE2KJ*AVOGADRO;
1035 fprintf(stderr,"step %5d, SA = %5d, swap = %5d\n",
1036 step,(qm->SAstep>0),swapped);
1041 } /* call_gaussian_SH */
1043 /* end of gaussian sub routines */
1047 gmx_qmmm_gaussian_empty;