3a79b776fab628b700aabec56b321d9c9d519b21
[alexxy/gromacs.git] / include / types / idef.h
1 /*
2  * $Id$
3  * 
4  *       This source code is part of
5  * 
6  *        G   R   O   M   A   C   S
7  * 
8  * GROningen MAchine for Chemical Simulations
9  * 
10  *               VERSION 2.0
11  * 
12  * Copyright (c) 1991-1999
13  * BIOSON Research Institute, Dept. of Biophysical Chemistry
14  * University of Groningen, The Netherlands
15  * 
16  * Please refer to:
17  * GROMACS: A message-passing parallel molecular dynamics implementation
18  * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19  * Comp. Phys. Comm. 91, 43-56 (1995)
20  * 
21  * Also check out our WWW page:
22  * http://md.chem.rug.nl/~gmx
23  * or e-mail to:
24  * gromacs@chem.rug.nl
25  * 
26  * And Hey:
27  * Green Red Orange Magenta Azure Cyan Skyblue
28  */
29
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
33
34 #ifndef _idef_h
35 #define _idef_h
36
37
38 /* check kernel/toppush.c when you change these numbers */
39 #define MAXATOMLIST     5
40 #define MAXFORCEPARAM   6
41 #define NR_RBDIHS       6
42
43 typedef atom_id t_iatom;
44
45 /* this MUST correspond to the 
46    t_interaction_function[F_NRE] in gmxlib/ifunc.c */
47 enum {
48   F_BONDS,
49   F_G96BONDS,
50   F_MORSE,
51   F_CUBICBONDS,
52   F_CONNBONDS,
53   F_HARMONIC,
54   F_ANGLES, 
55   F_G96ANGLES, 
56   F_PDIHS,
57   F_RBDIHS,
58   F_IDIHS, 
59   F_LJ14,
60   F_COUL14,
61   F_LJ,
62   F_BHAM,
63   F_LJLR,
64   F_DISPCORR,
65   F_SR,
66   F_LR,
67   F_WPOL,
68   F_POSRES,
69   F_DISRES,
70   F_ANGRES,
71   F_ANGRESZ,
72   F_SHAKE,
73   F_SHAKENC,
74   F_SETTLE,
75   F_DUMMY2,
76   F_DUMMY3,
77   F_DUMMY3FD,
78   F_DUMMY3FAD,
79   F_DUMMY3OUT,
80   F_DUMMY4FD,
81   F_EQM,
82   F_EPOT,
83   F_EKIN,
84   F_ETOT,
85   F_TEMP,
86   F_PRES,
87   F_DVDL,
88   F_DVDLKIN,
89   F_NRE         /* This number is for the total number of energies      */
90 };
91   
92 typedef union
93 {
94   /* Some parameters have A and B values for free energy calculations.
95    * The B values are not used for regular simulations of course.
96    * Free Energy for nonbondeds can be computed by changing the atom type.
97    * The harmonic type is used for all harmonic potentials:
98    * bonds, angles and improper dihedrals
99    */
100   struct {real a,b,c;                           } bham;
101   struct {real rA,krA,rB,krB;                   } harmonic; 
102   /* No free energy support for cubic bonds */
103   struct {real b0,kb,kcub;                      } cubic; 
104   /* No free energy supported for WPOL */ 
105   struct {real kx,ky,kz,rOH,rHH,rOD;            } wpol; 
106   struct {real c6,c12;                          } lj;
107   struct {real c6A,c12A,c6B,c12B;               } lj14;
108   /* Proper dihedrals can not have different multiplicity when
109    * doing free energy calculations, because the potential would not
110    * be periodic anymore.
111    */ 
112   struct {real phiA,cpA;int mult;real phiB,cpB; } pdihs;
113   struct {real dA,dB;                           } shake;
114   /* Settle can not be used for Free energy calculations.
115    * Use shake (or lincs) instead.
116    * The rest of the things cannot (yet) be used in FEP studies either.
117    */
118   struct {real doh,dhh;                         } settle;
119   struct {real b0,cb,beta;                      } morse;
120   struct {real pos0[DIM],fc[DIM];               } posres;
121   struct {real rbc[NR_RBDIHS];                  } rbdihs;
122   struct {real a,b,c,d,e,f;                     } dummy;   
123   struct {real low,up1,up2,fac;int type,index;  } disres; 
124   struct {real buf[MAXFORCEPARAM];              } generic; /* Conversion */
125 } t_iparams;
126
127 typedef int t_functype;
128
129 typedef struct
130 {
131   int nr;
132   int multinr[MAXNODES];
133   t_iatom *iatoms;
134 } t_ilist;
135
136 /*
137  * The struct t_ilist defines a list of atoms with their interactions. 
138  * General field description:
139  *   int nr
140  *      the size (nr elements) of the interactions array (iatoms[]). This 
141  *      equals multinr[MAXNODES-1].
142  *   int multinr[MAXNODES]
143  *      specifies the number of type and atom id sequences in the iatoms[] 
144  *      array. Every element specifies the index of the first interaction
145  *      for the next node. The first node starts at zero. So for 
146  *      n=0, the interactions run from 0 upto multinr[0]. The interactions
147  *      for node n (n>0) run from multinr[n-1] to index[n] (not including 
148  *      multinr[n]).
149  *   t_iatom *iatoms
150  *      specifies which atoms are involved in an interaction of a certain 
151  *       type. The layout of this array is as follows:
152  *
153  *        +-----+---+---+---+-----+---+---+-----+---+---+---+-----+---+---+...
154  *        |type1|at1|at2|at3|type2|at1|at2|type1|at1|at2|at3|type3|at1|at2|
155  *        +-----+---+---+---+-----+---+---+-----+---+---+---+-----+---+---+...
156  *
157  *      So for interaction type type1 3 atoms are needed, and for type2 and 
158  *      type3 only 2. The type identifier is used to select the function to 
159  *      calculate the interaction and its actual parameters. This type 
160  *      identifier is an index in a params[] and functype[] array.
161  * The multinr[] array will be initialised for MAXNODES in such a way that up 
162  * to the actual number of nodes (during creation time), the array is
163  * filled with the indices, the remaining nodes get empty parts by 
164  * setting the indices to the largest value. In that way it is always possible
165  * to run this system on a larger multinode ring however only the
166  * configured number of nodes will we used. Running on less nodes
167  * than configured is also possible by taking together adjacent
168  * nodes. Note that in this case the load balance might get worse.
169  * The single node version is implemented by simply using the complete
170  * configuration as one piece.
171  */
172
173 typedef struct
174 {
175   int ntypes;
176   int nodeid;
177   int atnr;
178   t_functype *functype;
179   t_iparams  *iparams;
180
181   t_ilist il[F_NRE];
182 } t_idef;
183
184 /*
185  * The struct t_idef defines all the interactions for the complete
186  * simulation. The structure is setup in such a way that the multinode
187  * version of the program  can use it as easy as the single node version.
188  * General field description:
189  *   int ntypes
190  *      defines the number of elements in functype[] and param[].
191  *   int nodeid
192  *      the node id (if parallel machines)
193  *   int atnr
194  *      the number of atomtypes
195  *   t_functype *functype
196  *      array of length ntypes, defines for every force type what type of 
197  *      function to use. Every "bond" with the same function but different 
198  *      force parameters is a different force type. The type identifier in the 
199  *      forceatoms[] array is an index in this array.
200      t_iparams *iparams;
201  *      array of length ntypes, defines the parameters for every interaction
202  *      type. The type identifier in the actual interaction list
203  *      (bondeds.iatoms[] or shakes.iatoms[]) is an index in this array.
204  *   t_ilist il[F_NRE]
205  *      The list of interactions for each type. Note that some,
206  *      such as LJ and COUL will have 0 entries.
207  */
208
209 #endif