927f2fdf617bcfe2e37cea1886906660f03383a2
[alexxy/gromacs.git] / src / kernel / xmdrun.h
1 /*
2  * 
3  *                This source code is part of
4  * 
5  *                 G   R   O   M   A   C   S
6  * 
7  *          GROningen MAchine for Chemical Simulations
8  * 
9  *                        VERSION 3.2.0
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-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
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.
19  * 
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.
26  * 
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.
29  * 
30  * For more info, check our website at http://www.gromacs.org
31  * 
32  * And Hey:
33  * Gallium Rubidium Oxygen Manganese Argon Carbon Silicon
34  */
35
36 #ifndef _xmdrun_h
37 #define _xmdrun_h
38
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
42
43 #include <stdio.h>
44 #include "typedefs.h"
45 #include "network.h"
46 #include "tgroup.h"
47 #include "filenm.h"
48 #include "mshift.h"
49 #include "force.h"
50 #include "time.h"
51 #include "edsam.h"
52 #include "mdebin.h"
53 #include "vcm.h"
54 #include "vsite.h"
55 #include "gmx_wallcycle.h"
56
57 /* This file contains XMDRUN datatypes and function prototypes, grouped
58  * neatly according to parts of the functionalisty
59  */
60  
61 /* GENERAL COUPLING THEORY (GCT) STUFF */
62 enum { eoPres, eoEpot, eoVir, eoDist, eoMu, eoForce, eoFx, eoFy, eoFz,
63        eoPx, eoPy, eoPz, 
64        eoPolarizability, eoDipole, eoObsNR, 
65        eoMemory=eoObsNR, eoInter, eoUseVirial,  eoCombRule, eoNR };
66 extern const char *eoNames[eoNR];
67
68 typedef struct {
69   int  at_i,at_j;       /* Atom type # for i and j                      */
70   int  eObs;            /* Observable to couple to                      */
71   bool bPrint;          /* Does this struct have to be printed          */
72   real c6,c12;          /* Actual value of params                       */
73   real xi_6,xi_12;      /* Constants for coupling C6 and C12            */
74 } t_coupl_LJ;
75
76 typedef struct {
77   int  at_i,at_j;       /* Atom type # for i and j                      */
78   int  eObs;            /* Observable to couple to                      */
79   bool bPrint;          /* Does this struct have to be printed          */
80   real a,b,c;           /* Actual value of params                       */
81   real xi_a,xi_b,xi_c;  /* Constants for coupling A, B and C            */
82 } t_coupl_BU;
83
84 typedef struct {
85   int  at_i;            /* Atom type                                    */
86   int  eObs;            /* Observable to couple to                      */
87   bool bPrint;          /* Does this struct have to be printed          */
88   real Q;               /* Actual value of charge                       */
89   real xi_Q;            /* Constant for coupling Q                      */
90 } t_coupl_Q;
91
92 typedef struct {
93   int       type;       /* Type number in the iparams struct    */
94   int       eObs;       /* Observable to couple to              */
95   t_iparams xi;         /* Parameters that need to be changed   */
96   t_iparams iprint;
97 } t_coupl_iparams;
98
99 typedef struct {
100   real       act_value[eoObsNR];
101   real       av_value [eoObsNR];
102   real       ref_value[eoObsNR];
103   bool       bObsUsed[eoObsNR];
104   int        nLJ,nBU,nQ,nIP;
105   t_coupl_LJ *tcLJ;
106   t_coupl_BU *tcBU;
107   t_coupl_Q  *tcQ;
108   t_coupl_iparams *tIP;
109   int        nmemory;
110   bool       bInter;
111   bool       bVirial;
112   int        combrule;
113 } t_coupl_rec;
114
115 extern void write_gct(const char *fn,t_coupl_rec *tcr,t_idef *idef);
116
117 extern void read_gct(const char *fn,t_coupl_rec *tcr);
118
119 extern void comm_tcr(FILE *log,t_commrec *cr,t_coupl_rec **tcr);
120
121 extern void copy_ff(t_coupl_rec *tcr,t_forcerec *fr,t_mdatoms *md,
122                     t_idef *idef);
123
124 extern t_coupl_rec *init_coupling(FILE *log,int nfile, const t_filenm fnm[],
125                                   t_commrec *cr,t_forcerec *fr,t_mdatoms *md,
126                                   t_idef *idef);
127                                   
128 extern void calc_force(int natom,rvec f[],rvec fff[]);
129
130 extern void calc_f_dev(int natoms,real charge[],rvec x[],rvec f[],
131                        t_idef *idef,real *xiH,real *xiS);
132
133 extern void do_coupling(FILE *log,const output_env_t oenv,int nfile,
134                         const t_filenm fnm[],
135                         t_coupl_rec *tcr,real t,int step,real ener[],
136                         t_forcerec *fr,t_inputrec *ir,bool bMaster,
137                         t_mdatoms *md,t_idef *idef,real mu_aver,int nmols,
138                         t_commrec *cr,matrix box,tensor virial,
139                         tensor pres,rvec mu_tot,
140                         rvec x[],rvec f[],bool bDoIt);
141
142 /* CODE TO ADD SPECIAL 2-DIMENSIONAL LENNARD-JONES CORRECTION TO FORCES AND ENERGY */
143 extern void do_glas(FILE *log,int start,int homenr,rvec x[],rvec f[],
144                     t_forcerec *fr,t_mdatoms *md,int atnr,t_inputrec *ir,
145                     real ener[]);
146
147 extern real mol_dipole(int k0,int k1,rvec x[],real q[]);
148 /* Calculate total dipole for group of atoms */
149
150 extern real calc_mu_aver(t_commrec *cr,rvec x[],real q[],rvec mu,
151                          t_block *mols,t_mdatoms *md,int gnx,atom_id grpindex[]);
152 /* Compute average dipole */
153
154 /********************************************************************/
155 /* Force field scanning stuff */
156 typedef struct {
157   real tol,f_max,npow,epot,fac_epot,fac_pres,fac_msf,pres;
158   int  molsize,nmol;
159   bool bComb,bVerbose,bLogEps;
160 } t_ffscan;
161
162
163 extern bool update_forcefield(FILE *fplog,
164                               int nfile,const t_filenm fnm[],t_forcerec *fr,
165                               int natoms,rvec x[],matrix box);
166 /* Modify the parameters. Return TRUE when the scan is finished. */
167
168 extern bool print_forcefield(FILE *fp,real ener[],int natoms,rvec f[],
169                              rvec fshake[],rvec x[],t_block *mols,real mass[],
170                              tensor pres);
171 /* Print results. Return TRUE when the scan is finished. */
172
173 extern void set_ffvars(t_ffscan *ff);
174 /* Set variables for force scanning */
175
176 #endif  /* _xmdrun_h */