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