Merge branch 'release-4-6'
[alexxy/gromacs.git] / src / gromacs / legacyheaders / types / ifunc.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  * GRoups of Organic Molecules in ACtion for Science
34  */
35
36
37 #ifndef _ifunc_h
38 #define _ifunc_h
39
40 #include "idef.h"
41 #include "mdatom.h"
42 #include "fcdata.h"
43 #include "graph.h"
44 #include "pbc.h"
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50
51 typedef real t_ifunc(int nbonds,const t_iatom iatoms[],
52                      const t_iparams iparams[],
53                      const rvec x[],rvec f[],rvec fshift[],
54                      const t_pbc *pbc,const t_graph *g,
55                      real lambda,real *dvdlambda,
56                      const t_mdatoms *md,t_fcdata *fcd,
57                      int *ddgatindex);
58
59 /*
60  * The function type t_ifunc() calculates one interaction, using iatoms[] 
61  * and iparams. Within the function the number of atoms to be used is 
62  * known. Within the function only the atomid part of the iatoms[] array 
63  * is supplied, not the type field (see also t_ilist). The function 
64  * returns the potential energy. If pbc==NULL the coordinates in x are
65  * assumed to be such that no calculation of PBC is necessary,
66  * If pbc!=NULL a full PBC calculation is performed.
67  * If g!=NULL it is used for determining the shift forces.
68  * With domain decomposition ddgatindex can be used for getting global
69  * atom numbers for warnings and error messages.
70  * ddgatindex is NULL when domain decomposition is not used.
71  */
72
73 #define IF_NULL       0
74 #define IF_BOND       1
75 #define IF_VSITE      1<<1
76 #define IF_CONSTRAINT 1<<2
77 #define IF_CHEMBOND   1<<3
78 #define IF_BTYPE      1<<4
79 #define IF_ATYPE      1<<5
80 #define IF_TABULATED  1<<6
81 #define IF_LIMZERO    1<<7
82 /* These flags tell to some of the routines what can be done with this
83  * item in the list.
84  * With IF_BOND a bonded interaction will be calculated.
85  * With IF_BTYPE grompp can convert the bond to a Morse potential.
86  * With IF_BTYPE or IF_ATYPE the bond/angle can be converted to
87  * a constraint or used for vsite parameter determination by grompp.
88  * IF_LIMZERO indicates that for a bonded interaction the potential
89  * does goes to zero for large distances, thus if such an interaction
90  * it not assigned to any node by the domain decompostion, the simulation
91  * still continue, if mdrun has been told so.
92  */
93 typedef struct
94 {
95   const char *name;     /* the name of this function                    */
96   const char *longname; /* The name for printing etc.                   */
97   int     nratoms;      /* nr of atoms needed for this function         */
98   int     nrfpA,nrfpB;  /* number of parameters for this function.      */
99                         /* this corresponds to the number of params in  */
100                         /* iparams struct! (see idef.h)                 */
101   /* A and B are for normal and free energy components respectively.    */
102   unsigned long   flags;        /* Flags (see above)                            */
103   int     nrnb_ind;     /* index for nrnb (-1 if unknown)               */
104   t_ifunc *ifunc;       /* the function it self                         */
105 } t_interaction_function;
106
107 #define NRFPA(ftype) (interaction_function[(ftype)].nrfpA)
108 #define NRFPB(ftype) (interaction_function[(ftype)].nrfpB)
109 #define NRFP(ftype)  (NRFPA(ftype)+NRFPB(ftype))
110 #define NRAL(ftype) (interaction_function[(ftype)].nratoms)
111
112 #define IS_CHEMBOND(ftype) (interaction_function[(ftype)].nratoms==2 && (interaction_function[(ftype)].flags & IF_CHEMBOND))
113 /* IS_CHEMBOND tells if function type ftype represents a chemical bond */
114
115 /* IS_ANGLE tells if a function type ftype represents an angle 
116  * Per Larsson, 2007-11-06
117  */
118 #define IS_ANGLE(ftype) (interaction_function[(ftype)].nratoms==3 && (interaction_function[(ftype)].flags & IF_ATYPE))
119 #define IS_VSITE(ftype) (interaction_function[(ftype)].flags & IF_VSITE)
120
121 #define IS_TABULATED(ftype) (interaction_function[(ftype)].flags & IF_TABULATED)
122
123 extern const t_interaction_function interaction_function[F_NRE];
124 /* initialised interaction functions descriptor                         */
125
126 #ifdef __cplusplus
127 }
128 #endif
129
130
131 #endif