Valgrind suppression for OS X 10.9
[alexxy/gromacs.git] / src / gromacs / legacyheaders / types / idef.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
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.
10  *
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.
15  *
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.
20  *
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.
25  *
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.
33  *
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.
36  */
37
38
39 #ifndef _idef_h
40 #define _idef_h
41
42 #include "simple.h"
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48
49 /* check kernel/toppush.c when you change these numbers */
50 #define MAXATOMLIST 6
51 #define MAXFORCEPARAM   12
52 #define NR_RBDIHS   6
53 #define NR_CBTDIHS   6
54 #define NR_FOURDIHS     4
55
56 typedef atom_id t_iatom;
57
58 /* this MUST correspond to the
59    t_interaction_function[F_NRE] in gmxlib/ifunc.c */
60 enum {
61     F_BONDS,
62     F_G96BONDS,
63     F_MORSE,
64     F_CUBICBONDS,
65     F_CONNBONDS,
66     F_HARMONIC,
67     F_FENEBONDS,
68     F_TABBONDS,
69     F_TABBONDSNC,
70     F_RESTRBONDS,
71     F_ANGLES,
72     F_G96ANGLES,
73     F_RESTRANGLES,
74     F_LINEAR_ANGLES,
75     F_CROSS_BOND_BONDS,
76     F_CROSS_BOND_ANGLES,
77     F_UREY_BRADLEY,
78     F_QUARTIC_ANGLES,
79     F_TABANGLES,
80     F_PDIHS,
81     F_RBDIHS,
82     F_RESTRDIHS,
83     F_CBTDIHS,
84     F_FOURDIHS,
85     F_IDIHS,
86     F_PIDIHS,
87     F_TABDIHS,
88     F_CMAP,
89     F_GB12,
90     F_GB13,
91     F_GB14,
92     F_GBPOL,
93     F_NPSOLVATION,
94     F_LJ14,
95     F_COUL14,
96     F_LJC14_Q,
97     F_LJC_PAIRS_NB,
98     F_LJ,
99     F_BHAM,
100     F_LJ_LR,
101     F_BHAM_LR,
102     F_DISPCORR,
103     F_COUL_SR,
104     F_COUL_LR,
105     F_RF_EXCL,
106     F_COUL_RECIP,
107     F_LJ_RECIP,
108     F_DPD,
109     F_POLARIZATION,
110     F_WATER_POL,
111     F_THOLE_POL,
112     F_ANHARM_POL,
113     F_POSRES,
114     F_FBPOSRES,
115     F_DISRES,
116     F_DISRESVIOL,
117     F_ORIRES,
118     F_ORIRESDEV,
119     F_ANGRES,
120     F_ANGRESZ,
121     F_DIHRES,
122     F_DIHRESVIOL,
123     F_CONSTR,
124     F_CONSTRNC,
125     F_SETTLE,
126     F_VSITE2,
127     F_VSITE3,
128     F_VSITE3FD,
129     F_VSITE3FAD,
130     F_VSITE3OUT,
131     F_VSITE4FD,
132     F_VSITE4FDN,
133     F_VSITEN,
134     F_COM_PULL,
135     F_EQM,
136     F_EPOT,
137     F_EKIN,
138     F_ETOT,
139     F_ECONSERVED,
140     F_TEMP,
141     F_VTEMP_NOLONGERUSED,
142     F_PDISPCORR,
143     F_PRES,
144     F_DVDL_CONSTR,
145     F_DVDL,
146     F_DKDL,
147     F_DVDL_COUL,
148     F_DVDL_VDW,
149     F_DVDL_BONDED,
150     F_DVDL_RESTRAINT,
151     F_DVDL_TEMPERATURE, /* not calculated for now, but should just be the energy (NVT) or enthalpy (NPT), or 0 (NVE) */
152     F_NRE               /* This number is for the total number of energies      */
153 };
154
155 #define IS_RESTRAINT_TYPE(ifunc) (((ifunc == F_POSRES) || (ifunc == F_FBPOSRES) || (ifunc == F_DISRES) || (ifunc == F_RESTRBONDS) || (ifunc == F_DISRESVIOL) || (ifunc == F_ORIRES) || (ifunc == F_ORIRESDEV) || (ifunc == F_ANGRES) || (ifunc == F_ANGRESZ) || (ifunc == F_DIHRES)))
156
157 /* A macro for checking if ftype is an explicit pair-listed LJ or COULOMB
158  * interaction type:
159  * bonded LJ (usually 1-4), or special listed non-bonded for FEP.
160  */
161 #define IS_LISTED_LJ_C(ftype) ((ftype) >= F_LJ14 && (ftype) <= F_LJC_PAIRS_NB)
162
163 typedef union
164 {
165     /* Some parameters have A and B values for free energy calculations.
166      * The B values are not used for regular simulations of course.
167      * Free Energy for nonbondeds can be computed by changing the atom type.
168      * The harmonic type is used for all harmonic potentials:
169      * bonds, angles and improper dihedrals
170      */
171     struct {
172         real a, b, c;
173     } bham;
174     struct {
175         real rA, krA, rB, krB;
176     } harmonic;
177     struct {
178         real klinA, aA, klinB, aB;
179     } linangle;
180     struct {
181         real lowA, up1A, up2A, kA, lowB, up1B, up2B, kB;
182     } restraint;
183     /* No free energy supported for cubic bonds, FENE, WPOL or cross terms */
184     struct {
185         real b0, kb, kcub;
186     } cubic;
187     struct {
188         real bm, kb;
189     } fene;
190     struct {
191         real r1e, r2e, krr;
192     } cross_bb;
193     struct {
194         real r1e, r2e, r3e, krt;
195     } cross_ba;
196     struct {
197         real thetaA, kthetaA, r13A, kUBA, thetaB, kthetaB, r13B, kUBB;
198     } u_b;
199     struct {
200         real theta, c[5];
201     } qangle;
202     struct {
203         real alpha;
204     } polarize;
205     struct {
206         real alpha, drcut, khyp;
207     } anharm_polarize;
208     struct {
209         real al_x, al_y, al_z, rOH, rHH, rOD;
210     } wpol;
211     struct {
212         real a, alpha1, alpha2, rfac;
213     } thole;
214     struct {
215         real c6, c12;
216     } lj;
217     struct {
218         real c6A, c12A, c6B, c12B;
219     } lj14;
220     struct {
221         real fqq, qi, qj, c6, c12;
222     } ljc14;
223     struct {
224         real qi, qj, c6, c12;
225     } ljcnb;
226     /* Proper dihedrals can not have different multiplicity when
227      * doing free energy calculations, because the potential would not
228      * be periodic anymore.
229      */
230     struct {
231         real phiA, cpA; int mult; real phiB, cpB;
232     } pdihs;
233     struct {
234         real dA, dB;
235     } constr;
236     /* Settle can not be used for Free energy calculations of water bond geometry.
237      * Use shake (or lincs) instead if you have to change the water bonds.
238      */
239     struct {
240         real doh, dhh;
241     } settle;
242     struct {
243         real b0A, cbA, betaA, b0B, cbB, betaB;
244     } morse;
245     struct {
246         real pos0A[DIM], fcA[DIM], pos0B[DIM], fcB[DIM];
247     } posres;
248     struct {
249         real pos0[DIM], r, k; int geom;
250     } fbposres;
251     struct {
252         real rbcA[NR_RBDIHS], rbcB[NR_RBDIHS];
253     } rbdihs;
254     struct {
255         real cbtcA[NR_CBTDIHS], cbtcB[NR_CBTDIHS];
256     } cbtdihs;
257     struct {
258         real a, b, c, d, e, f;
259     } vsite;
260     struct {
261         int  n; real a;
262     } vsiten;
263     /* NOTE: npair is only set after reading the tpx file */
264     struct {
265         real low, up1, up2, kfac; int type, label, npair;
266     } disres;
267     struct {
268         real phiA, dphiA, kfacA, phiB, dphiB, kfacB;
269     } dihres;
270     struct {
271         int  ex, power, label; real c, obs, kfac;
272     } orires;
273     struct {
274         int  table; real kA; real kB;
275     } tab;
276     struct {
277         real sar, st, pi, gbr, bmlt;
278     } gb;
279     struct {
280         int cmapA, cmapB;
281     } cmap;
282     struct {
283         real buf[MAXFORCEPARAM];
284     } generic;                                               /* Conversion */
285 } t_iparams;
286
287 typedef int t_functype;
288
289 /*
290  * The nonperturbed/perturbed interactions are now separated (sorted) in the
291  * ilist, such that the first 0..(nr_nonperturbed-1) ones are exactly that, and
292  * the remaining ones from nr_nonperturbed..(nr-1) are perturbed bonded
293  * interactions.
294  */
295 typedef struct
296 {
297     int      nr;
298     int      nr_nonperturbed;
299     t_iatom *iatoms;
300     int      nalloc;
301 } t_ilist;
302
303 /*
304  * The struct t_ilist defines a list of atoms with their interactions.
305  * General field description:
306  *   int nr
307  *      the size (nr elements) of the interactions array (iatoms[]).
308  *   t_iatom *iatoms
309  *  specifies which atoms are involved in an interaction of a certain
310  *       type. The layout of this array is as follows:
311  *
312  *        +-----+---+---+---+-----+---+---+-----+---+---+---+-----+---+---+...
313  *        |type1|at1|at2|at3|type2|at1|at2|type1|at1|at2|at3|type3|at1|at2|
314  *        +-----+---+---+---+-----+---+---+-----+---+---+---+-----+---+---+...
315  *
316  *  So for interaction type type1 3 atoms are needed, and for type2 and
317  *      type3 only 2. The type identifier is used to select the function to
318  *      calculate the interaction and its actual parameters. This type
319  *      identifier is an index in a params[] and functype[] array.
320  */
321
322 typedef struct
323 {
324     real *cmap; /* Has length 4*grid_spacing*grid_spacing, */
325     /* there are 4 entries for each cmap type (V,dVdx,dVdy,d2dVdxdy) */
326 } cmapdata_t;
327
328 typedef struct
329 {
330     int         ngrid;        /* Number of allocated cmap (cmapdata_t ) grids */
331     int         grid_spacing; /* Grid spacing */
332     cmapdata_t *cmapdata;     /* Pointer to grid with actual, pre-interpolated data */
333 } gmx_cmap_t;
334
335
336 typedef struct
337 {
338     int         ntypes;
339     int         atnr;
340     t_functype *functype;
341     t_iparams  *iparams;
342     double      reppow;    /* The repulsion power for VdW: C12*r^-reppow   */
343     real        fudgeQQ;   /* The scaling factor for Coulomb 1-4: f*q1*q2  */
344     gmx_cmap_t  cmap_grid; /* The dihedral correction maps                 */
345 } gmx_ffparams_t;
346
347 enum {
348     ilsortUNKNOWN, ilsortNO_FE, ilsortFE_UNSORTED, ilsortFE_SORTED
349 };
350
351 typedef struct
352 {
353     int         ntypes;
354     int         atnr;
355     t_functype *functype;
356     t_iparams  *iparams;
357     real        fudgeQQ;
358     gmx_cmap_t  cmap_grid;
359     t_iparams  *iparams_posres, *iparams_fbposres;
360     int         iparams_posres_nalloc, iparams_fbposres_nalloc;
361
362     t_ilist     il[F_NRE];
363     int         ilsort;
364     int         nthreads;
365     int        *il_thread_division;
366     int         il_thread_division_nalloc;
367 } t_idef;
368
369 /*
370  * The struct t_idef defines all the interactions for the complete
371  * simulation. The structure is setup in such a way that the multinode
372  * version of the program  can use it as easy as the single node version.
373  * General field description:
374  *   int ntypes
375  *      defines the number of elements in functype[] and param[].
376  *   int nodeid
377  *      the node id (if parallel machines)
378  *   int atnr
379  *      the number of atomtypes
380  *   t_functype *functype
381  *      array of length ntypes, defines for every force type what type of
382  *      function to use. Every "bond" with the same function but different
383  *      force parameters is a different force type. The type identifier in the
384  *      forceatoms[] array is an index in this array.
385  *   t_iparams *iparams
386  *      array of length ntypes, defines the parameters for every interaction
387  *      type. The type identifier in the actual interaction list
388  *      (ilist[ftype].iatoms[]) is an index in this array.
389  *   gmx_cmap_t cmap_grid
390  *      the grid for the dihedral pair correction maps.
391  *   t_iparams *iparams_posres, *iparams_fbposres
392  *      defines the parameters for position restraints only.
393  *      Position restraints are the only interactions that have different
394  *      parameters (reference positions) for different molecules
395  *      of the same type. ilist[F_POSRES].iatoms[] is an index in this array.
396  *   t_ilist il[F_NRE]
397  *      The list of interactions for each type. Note that some,
398  *      such as LJ and COUL will have 0 entries.
399  *   int ilsort
400  *      The state of the sorting of il, values are provided above.
401  *   int nthreads
402  *      The number of threads used to set il_thread_division.
403  *   int *il_thread_division
404  *      The division of the normal bonded interactions of threads.
405  *      il_thread_division[ftype*(nthreads+1)+t] contains an index
406  *      into il[ftype].iatoms; thread th operates on t=th to t=th+1.
407  *   int il_thread_division_nalloc
408  *      The allocated size of il_thread_division,
409  *      should be at least F_NRE*(nthreads+1).
410  */
411
412 typedef struct {
413     int   n;      /* n+1 is the number of points */
414     real  scale;  /* distance between two points */
415     real *data;   /* the actual table data, per point there are 4 numbers */
416 } bondedtable_t;
417
418 #ifdef __cplusplus
419 }
420 #endif
421
422
423 #endif