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