Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / legacyheaders / force.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 #ifndef _force_h
39 #define _force_h
40
41
42 #include "gromacs/legacyheaders/genborn.h"
43 #include "gromacs/legacyheaders/network.h"
44 #include "gromacs/legacyheaders/tgroup.h"
45 #include "gromacs/legacyheaders/typedefs.h"
46 #include "gromacs/legacyheaders/vsite.h"
47 #include "gromacs/legacyheaders/types/force_flags.h"
48 #include "gromacs/timing/wallcycle.h"
49
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53
54 struct t_graph;
55 struct t_pbc;
56
57 void calc_vir(int nxf, rvec x[], rvec f[], tensor vir,
58               gmx_bool bScrewPBC, matrix box);
59 /* Calculate virial for nxf atoms, and add it to vir */
60
61 void f_calc_vir(int i0, int i1, rvec x[], rvec f[], tensor vir,
62                 struct t_graph *g, rvec shift_vec[]);
63 /* Calculate virial taking periodicity into account */
64
65 real RF_excl_correction(const t_forcerec *fr, struct t_graph *g,
66                         const t_mdatoms *mdatoms, const t_blocka *excl,
67                         rvec x[], rvec f[], rvec *fshift, const struct t_pbc *pbc,
68                         real lambda, real *dvdlambda);
69 /* Calculate the reaction-field energy correction for this node:
70  * epsfac q_i q_j (k_rf r_ij^2 - c_rf)
71  * and force correction for all excluded pairs, including self pairs.
72  */
73
74 void calc_rffac(FILE *fplog, int eel, real eps_r, real eps_rf,
75                 real Rc, real Temp,
76                 real zsq, matrix box,
77                 real *kappa, real *krf, real *crf);
78 /* Determine the reaction-field constants */
79
80 void init_generalized_rf(FILE *fplog,
81                          const gmx_mtop_t *mtop, const t_inputrec *ir,
82                          t_forcerec *fr);
83 /* Initialize the generalized reaction field parameters */
84
85
86 /* In wall.c */
87 void make_wall_tables(FILE *fplog, const output_env_t oenv,
88                       const t_inputrec *ir, const char *tabfn,
89                       const gmx_groups_t *groups,
90                       t_forcerec *fr);
91
92 real do_walls(t_inputrec *ir, t_forcerec *fr, matrix box, t_mdatoms *md,
93               rvec x[], rvec f[], real lambda, real Vlj[], t_nrnb *nrnb);
94
95 t_forcerec *mk_forcerec(void);
96
97 #define GMX_MAKETABLES_FORCEUSER  (1<<0)
98 #define GMX_MAKETABLES_14ONLY     (1<<1)
99
100 t_forcetable make_tables(FILE *fp, const output_env_t oenv,
101                          const t_forcerec *fr, gmx_bool bVerbose,
102                          const char *fn, real rtab, int flags);
103 /* Return tables for inner loops. When bVerbose the tables are printed
104  * to .xvg files
105  */
106
107 bondedtable_t make_bonded_table(FILE *fplog, char *fn, int angle);
108 /* Return a table for bonded interactions,
109  * angle should be: bonds 0, angles 1, dihedrals 2
110  */
111
112 /* Return a table for GB calculations */
113 t_forcetable make_gb_table(const output_env_t oenv,
114                            const t_forcerec  *fr);
115
116 /* Read a table for AdResS Thermo Force calculations */
117 extern t_forcetable make_atf_table(FILE *out, const output_env_t oenv,
118                                    const t_forcerec *fr,
119                                    const char *fn,
120                                    matrix box);
121
122 void pr_forcerec(FILE *fplog, t_forcerec *fr);
123
124 void
125 forcerec_set_ranges(t_forcerec *fr,
126                     int ncg_home, int ncg_force,
127                     int natoms_force,
128                     int natoms_force_constr, int natoms_f_novirsum);
129 /* Set the number of cg's and atoms for the force calculation */
130
131 gmx_bool can_use_allvsall(const t_inputrec *ir,
132                           gmx_bool bPrintNote, t_commrec *cr, FILE *fp);
133 /* Returns if we can use all-vs-all loops.
134  * If bPrintNote==TRUE, prints a note, if necessary, to stderr
135  * and fp (if !=NULL) on the master node.
136  */
137
138
139 gmx_bool nbnxn_acceleration_supported(FILE             *fplog,
140                                       const t_commrec  *cr,
141                                       const t_inputrec *ir,
142                                       gmx_bool          bGPU);
143 /* Return if GPU/CPU-SIMD acceleration is supported with the given inputrec
144  * with bGPU TRUE/FALSE.
145  * If the return value is FALSE and fplog/cr != NULL, prints a fallback
146  * message to fplog/stderr.
147  */
148
149 gmx_bool uses_simple_tables(int                        cutoff_scheme,
150                             struct nonbonded_verlet_t *nbv,
151                             int                        group);
152 /* Returns whether simple tables (i.e. not for use with GPUs) are used
153  * with the type of kernel indicated.
154  */
155
156 void init_interaction_const_tables(FILE                *fp,
157                                    interaction_const_t *ic,
158                                    gmx_bool             bSimpleTable,
159                                    real                 rtab);
160 /* Initializes the tables in the interaction constant data structure.
161  * Setting verlet_kernel_type to -1 always initializes tables for
162  * use with group kernels.
163  */
164
165 void init_forcerec(FILE              *fplog,
166                    const output_env_t oenv,
167                    t_forcerec        *fr,
168                    t_fcdata          *fcd,
169                    const t_inputrec  *ir,
170                    const gmx_mtop_t  *mtop,
171                    const t_commrec   *cr,
172                    matrix             box,
173                    const char        *tabfn,
174                    const char        *tabafn,
175                    const char        *tabpfn,
176                    const char        *tabbfn,
177                    const char        *nbpu_opt,
178                    gmx_bool           bNoSolvOpt,
179                    real               print_force);
180 /* The Force rec struct must be created with mk_forcerec
181  * The gmx_booleans have the following meaning:
182  * bSetQ:    Copy the charges [ only necessary when they change ]
183  * bMolEpot: Use the free energy stuff per molecule
184  * print_force >= 0: print forces for atoms with force >= print_force
185  */
186
187 void forcerec_set_excl_load(t_forcerec           *fr,
188                             const gmx_localtop_t *top);
189 /* Set the exclusion load for the local exclusions and possibly threads */
190
191 void init_enerdata(int ngener, int n_lambda, gmx_enerdata_t *enerd);
192 /* Intializes the energy storage struct */
193
194 void destroy_enerdata(gmx_enerdata_t *enerd);
195 /* Free all memory associated with enerd */
196
197 void reset_foreign_enerdata(gmx_enerdata_t *enerd);
198 /* Resets only the foreign energy data */
199
200 void reset_enerdata(t_forcerec *fr, gmx_bool bNS,
201                     gmx_enerdata_t *enerd,
202                     gmx_bool bMaster);
203 /* Resets the energy data, if bNS=TRUE also zeros the long-range part */
204
205 void sum_epot(gmx_grppairener_t *grpp, real *epot);
206 /* Locally sum the non-bonded potential energy terms */
207
208 void sum_dhdl(gmx_enerdata_t *enerd, real *lambda, t_lambda *fepvals);
209 /* Sum the free energy contributions */
210
211 void update_forcerec(t_forcerec *fr, matrix box);
212 /* Updates parameters in the forcerec that are time dependent */
213
214 /* Compute the average C6 and C12 params for LJ corrections */
215 void set_avcsixtwelve(FILE *fplog, t_forcerec *fr,
216                       const gmx_mtop_t *mtop);
217
218 extern void do_force(FILE *log, t_commrec *cr,
219                      t_inputrec *inputrec,
220                      gmx_int64_t step, t_nrnb *nrnb, gmx_wallcycle_t wcycle,
221                      gmx_localtop_t *top,
222                      gmx_groups_t *groups,
223                      matrix box, rvec x[], history_t *hist,
224                      rvec f[],
225                      tensor vir_force,
226                      t_mdatoms *mdatoms,
227                      gmx_enerdata_t *enerd, t_fcdata *fcd,
228                      real *lambda, struct t_graph *graph,
229                      t_forcerec *fr,
230                      gmx_vsite_t *vsite, rvec mu_tot,
231                      double t, FILE *field, gmx_edsam_t ed,
232                      gmx_bool bBornRadii,
233                      int flags);
234
235 /* Communicate coordinates (if parallel).
236  * Do neighbor searching (if necessary).
237  * Calculate forces.
238  * Communicate forces (if parallel).
239  * Spread forces for vsites (if present).
240  *
241  * f is always required.
242  */
243
244 void ns(FILE              *fplog,
245         t_forcerec        *fr,
246         matrix             box,
247         gmx_groups_t      *groups,
248         gmx_localtop_t    *top,
249         t_mdatoms         *md,
250         t_commrec         *cr,
251         t_nrnb            *nrnb,
252         gmx_bool           bFillGrid,
253         gmx_bool           bDoLongRangeNS);
254 /* Call the neighborsearcher */
255
256 extern void do_force_lowlevel(t_forcerec   *fr,
257                               t_inputrec   *ir,
258                               t_idef       *idef,
259                               t_commrec    *cr,
260                               t_nrnb       *nrnb,
261                               gmx_wallcycle_t wcycle,
262                               t_mdatoms    *md,
263                               rvec         x[],
264                               history_t    *hist,
265                               rvec         f_shortrange[],
266                               rvec         f_longrange[],
267                               gmx_enerdata_t *enerd,
268                               t_fcdata     *fcd,
269                               gmx_localtop_t *top,
270                               gmx_genborn_t *born,
271                               gmx_bool         bBornRadii,
272                               matrix       box,
273                               t_lambda     *fepvals,
274                               real         *lambda,
275                               struct t_graph      *graph,
276                               t_blocka     *excl,
277                               rvec         mu_tot[2],
278                               int          flags,
279                               float        *cycles_pme);
280 /* Call all the force routines */
281
282 void free_gpu_resources(const t_forcerec *fr,
283                         const t_commrec  *cr);
284
285 #ifdef __cplusplus
286 }
287 #endif
288
289 #endif  /* _force_h */