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