Merge release-4-6 (commit 'Ic142a690')
[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 "pbc.h"
42 #include "network.h"
43 #include "tgroup.h"
44 #include "vsite.h"
45 #include "genborn.h"
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 static const char *sepdvdlformat="  %-30s V %12.5e  dVdl %12.5e\n";
52
53 void calc_vir(FILE *fplog,int nxf,rvec x[],rvec f[],tensor vir,
54                      gmx_bool bScrewPBC,matrix box);
55 /* Calculate virial for nxf atoms, and add it to vir */
56
57 void f_calc_vir(FILE *fplog,int i0,int i1,rvec x[],rvec f[],tensor vir,
58                        t_graph *g,rvec shift_vec[]);
59 /* Calculate virial taking periodicity into account */
60
61 real RF_excl_correction(FILE *fplog,
62                                const t_forcerec *fr,t_graph *g,
63                                const t_mdatoms *mdatoms,const t_blocka *excl,
64                                rvec x[],rvec f[],rvec *fshift,const t_pbc *pbc,
65                                real lambda,real *dvdlambda);
66 /* Calculate the reaction-field energy correction for this node:
67  * epsfac q_i q_j (k_rf r_ij^2 - c_rf)
68  * and force correction for all excluded pairs, including self pairs.
69  */
70
71 void calc_rffac(FILE *fplog,int eel,real eps_r,real eps_rf,
72                        real Rc,real Temp,
73                        real zsq,matrix box,
74                        real *kappa,real *krf,real *crf);
75 /* Determine the reaction-field constants */
76
77 void init_generalized_rf(FILE *fplog,
78                                 const gmx_mtop_t *mtop,const t_inputrec *ir,
79                                 t_forcerec *fr);
80 /* Initialize the generalized reaction field parameters */
81
82
83 /* In wall.c */
84 void make_wall_tables(FILE *fplog,const output_env_t oenv,
85                              const t_inputrec *ir,const char *tabfn,
86                              const gmx_groups_t *groups,
87                              t_forcerec *fr);
88
89 real do_walls(t_inputrec *ir,t_forcerec *fr,matrix box,t_mdatoms *md,
90                      rvec x[],rvec f[],real lambda,real Vlj[],t_nrnb *nrnb);
91
92
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 void init_forcerec(FILE       *fplog,     
140                           const output_env_t oenv,
141                           t_forcerec *fr,   
142                           t_fcdata   *fcd,
143                           const t_inputrec *ir,   
144                           const gmx_mtop_t *mtop,
145                           const t_commrec  *cr,
146                           matrix     box,
147                           gmx_bool       bMolEpot,
148                           const char *tabfn,
149                           const char *tabafn,
150                           const char *tabpfn,
151                           const char *tabbfn,
152                           gmx_bool       bNoSolvOpt,
153                           real       print_force);
154 /* The Force rec struct must be created with mk_forcerec 
155  * The gmx_booleans have the following meaning:
156  * bSetQ:    Copy the charges [ only necessary when they change ]
157  * bMolEpot: Use the free energy stuff per molecule
158  * print_force >= 0: print forces for atoms with force >= print_force
159  */
160
161 void init_enerdata(int ngener,int n_flambda,gmx_enerdata_t *enerd);
162 /* Intializes the energy storage struct */
163
164 void destroy_enerdata(gmx_enerdata_t *enerd);
165 /* Free all memory associated with enerd */
166
167 void reset_enerdata(t_grpopts *opts,
168                            t_forcerec *fr,gmx_bool bNS,
169                            gmx_enerdata_t *enerd,
170                            gmx_bool bMaster);
171 /* Resets the energy data, if bNS=TRUE also zeros the long-range part */
172
173 void sum_epot(t_grpopts *opts,gmx_enerdata_t *enerd);
174 /* Locally sum the non-bonded potential energy terms */
175
176 void sum_dhdl(gmx_enerdata_t *enerd,double lambda,t_inputrec *ir);
177 /* Sum the free energy contributions */
178
179 void update_forcerec(FILE *fplog,t_forcerec *fr,matrix box);
180 /* Updates parameters in the forcerec that are time dependent */
181
182 /* Compute the average C6 and C12 params for LJ corrections */
183 void set_avcsixtwelve(FILE *fplog,t_forcerec *fr,
184                              const gmx_mtop_t *mtop);
185
186 /* The state has changed */
187 #define GMX_FORCE_STATECHANGED (1<<0)
188 /* The box might have changed */
189 #define GMX_FORCE_DYNAMICBOX   (1<<1)
190 /* Do neighbor searching */
191 #define GMX_FORCE_NS           (1<<2)
192 /* Calculate bonded energies/forces */
193 #define GMX_FORCE_DOLR         (1<<3)
194 /* Calculate long-range energies/forces */
195 #define GMX_FORCE_BONDED       (1<<4)
196 /* Store long-range forces in a separate array */
197 #define GMX_FORCE_SEPLRF       (1<<5)
198 /* Calculate non-bonded energies/forces */
199 #define GMX_FORCE_NONBONDED    (1<<6)
200 /* Calculate forces (not only energies) */
201 #define GMX_FORCE_FORCES       (1<<7)
202 /* Calculate the virial */
203 #define GMX_FORCE_VIRIAL       (1<<8)
204 /* Calculate dHdl */
205 #define GMX_FORCE_DHDL         (1<<9)
206 /* Normally one want all energy terms and forces */
207 #define GMX_FORCE_ALLFORCES    (GMX_FORCE_BONDED | GMX_FORCE_NONBONDED | GMX_FORCE_FORCES)
208
209 void do_force(FILE *log,t_commrec *cr,
210                      t_inputrec *inputrec,
211                      gmx_large_int_t step,t_nrnb *nrnb,gmx_wallcycle_t wcycle,
212                      gmx_localtop_t *top,
213                      gmx_mtop_t *mtop,
214                      gmx_groups_t *groups,
215                      matrix box,rvec x[],history_t *hist,
216                      rvec f[],
217                      tensor vir_force,
218                      t_mdatoms *mdatoms,
219                      gmx_enerdata_t *enerd,t_fcdata *fcd,
220                      real lambda,t_graph *graph,
221                      t_forcerec *fr,gmx_vsite_t *vsite,rvec mu_tot,
222                      double t,FILE *field,gmx_edsam_t ed,
223                      gmx_bool bBornRadii,
224                      int flags);
225 /* Communicate coordinates (if parallel).
226  * Do neighbor searching (if necessary).
227  * Calculate forces.
228  * Communicate forces (if parallel).
229  * Spread forces for vsites (if present).
230  *
231  * f is always required.
232  */
233
234 void ns(FILE       *fplog,
235                t_forcerec *fr,
236                rvec       x[],
237                matrix     box,
238                gmx_groups_t *groups,
239                t_grpopts  *opts,
240                gmx_localtop_t *top,
241                t_mdatoms  *md,
242                t_commrec  *cr,
243                t_nrnb     *nrnb,
244                real       lambda,
245                real       *dvdlambda,
246                gmx_grppairener_t *grppener,
247                gmx_bool       bFillGrid,
248                gmx_bool       bDoLongRange,
249                gmx_bool       bDoForces,
250                rvec       *f);
251 /* Call the neighborsearcher */
252
253 void do_force_lowlevel(FILE         *fplog,  
254                               gmx_large_int_t   step,
255                               t_forcerec   *fr,
256                               t_inputrec   *ir,
257                               t_idef       *idef,
258                               t_commrec    *cr,
259                               t_nrnb       *nrnb,
260                               gmx_wallcycle_t wcycle,
261                               t_mdatoms    *md,
262                               t_grpopts    *opts,
263                               rvec         x[],
264                               history_t    *hist,
265                               rvec         f[],    
266                               gmx_enerdata_t *enerd,
267                               t_fcdata     *fcd,
268                               gmx_mtop_t     *mtop,
269                               gmx_localtop_t *top,
270                               gmx_genborn_t *born,
271                               t_atomtypes  *atype,
272                               gmx_bool         bBornRadii,
273                               matrix       box,
274                               real         lambda,
275                               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 #ifdef __cplusplus
283 }
284 #endif
285
286 #endif  /* _force_h */