Merge branch 'master' of git.gromacs.org:gromacs
[gromacs/rigid-bodies.git] / include / force.h
blobce484a0dd45aaf7efedb9c98964b4f13b97824e2
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.
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.
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.
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.
30 * For more info, check our website at http://www.gromacs.org
32 * And Hey:
33 * Gromacs Runs On Most of All Computer Systems
36 #ifndef _force_h
37 #define _force_h
39 #ifdef HAVE_CONFIG_H
40 #include <config.h>
41 #endif
44 #include "typedefs.h"
45 #include "pbc.h"
46 #include "network.h"
47 #include "tgroup.h"
48 #include "vsite.h"
49 #include "genborn.h"
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
55 static const char *sepdvdlformat=" %-30s V %12.5e dVdl %12.5e\n";
57 extern void calc_vir(FILE *fplog,int nxf,rvec x[],rvec f[],tensor vir,
58 bool bScrewPBC,matrix box);
59 /* Calculate virial for nxf atoms, and add it to vir */
61 extern void f_calc_vir(FILE *fplog,int i0,int i1,rvec x[],rvec f[],tensor vir,
62 t_graph *g,rvec shift_vec[]);
63 /* Calculate virial taking periodicity into account */
65 extern real RF_excl_correction(FILE *fplog,
66 const t_forcerec *fr,t_graph *g,
67 const t_mdatoms *mdatoms,const t_blocka *excl,
68 rvec x[],rvec f[],rvec *fshift,const t_pbc *pbc,
69 real lambda,real *dvdlambda);
70 /* Calculate the reaction-field energy correction for this node:
71 * epsfac q_i q_j (k_rf r_ij^2 - c_rf)
72 * and force correction for all excluded pairs, including self pairs.
75 extern void calc_rffac(FILE *fplog,int eel,real eps_r,real eps_rf,
76 real Rc,real Temp,
77 real zsq,matrix box,
78 real *kappa,real *krf,real *crf);
79 /* Determine the reaction-field constants */
81 extern void init_generalized_rf(FILE *fplog,
82 const gmx_mtop_t *mtop,const t_inputrec *ir,
83 t_forcerec *fr);
84 /* Initialize the generalized reaction field parameters */
87 /* In wall.c */
88 extern void make_wall_tables(FILE *fplog,const output_env_t oenv,
89 const t_inputrec *ir,const char *tabfn,
90 const gmx_groups_t *groups,
91 t_forcerec *fr);
93 extern real do_walls(t_inputrec *ir,t_forcerec *fr,matrix box,t_mdatoms *md,
94 rvec x[],rvec f[],real lambda,real Vlj[],t_nrnb *nrnb);
98 extern t_forcerec *mk_forcerec(void);
100 #define GMX_MAKETABLES_FORCEUSER (1<<0)
101 #define GMX_MAKETABLES_14ONLY (1<<1)
103 extern t_forcetable make_tables(FILE *fp,const output_env_t oenv,
104 const t_forcerec *fr, bool bVerbose,
105 const char *fn, real rtab,int flags);
106 /* Return tables for inner loops. When bVerbose the tables are printed
107 * to .xvg files
110 extern bondedtable_t make_bonded_table(FILE *fplog,char *fn,int angle);
111 /* Return a table for bonded interactions,
112 * angle should be: bonds 0, angles 1, dihedrals 2
115 /* Return a table for GB calculations */
116 extern t_forcetable make_gb_table(FILE *out,const output_env_t oenv,
117 const t_forcerec *fr,
118 const char *fn,
119 real rtab);
121 extern void pr_forcerec(FILE *fplog,t_forcerec *fr,t_commrec *cr);
123 extern void
124 forcerec_set_ranges(t_forcerec *fr,
125 int ncg_home,int ncg_force,
126 int natoms_force,int natoms_f_novirsum);
127 /* Set the number of cg's and atoms for the force calculation */
129 extern bool can_use_allvsall(const t_inputrec *ir, const gmx_mtop_t *mtop,
130 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.
136 extern void init_forcerec(FILE *fplog,
137 const output_env_t oenv,
138 t_forcerec *fr,
139 t_fcdata *fcd,
140 const t_inputrec *ir,
141 const gmx_mtop_t *mtop,
142 const t_commrec *cr,
143 matrix box,
144 bool bMolEpot,
145 const char *tabfn,
146 const char *tabpfn,
147 const char *tabbfn,
148 bool bNoSolvOpt,
149 real print_force);
150 /* The Force rec struct must be created with mk_forcerec
151 * The booleans have the following meaning:
152 * bSetQ: Copy the charges [ only necessary when they change ]
153 * bMolEpot: Use the free energy stuff per molecule
154 * print_force >= 0: print forces for atoms with force >= print_force
157 extern void init_enerdata(int ngener,int n_flambda,gmx_enerdata_t *enerd);
158 /* Intializes the energy storage struct */
160 extern void destroy_enerdata(gmx_enerdata_t *enerd);
161 /* Free all memory associated with enerd */
163 extern void reset_enerdata(t_grpopts *opts,
164 t_forcerec *fr,bool bNS,
165 gmx_enerdata_t *enerd,
166 bool bMaster);
167 /* Resets the energy data, if bNS=TRUE also zeros the long-range part */
169 extern void sum_epot(t_grpopts *opts,gmx_enerdata_t *enerd);
170 /* Locally sum the non-bonded potential energy terms */
172 extern void sum_dhdl(gmx_enerdata_t *enerd,double lambda,t_inputrec *ir);
173 /* Sum the free energy contributions */
175 extern void update_forcerec(FILE *fplog,t_forcerec *fr,matrix box);
176 /* Updates parameters in the forcerec that are time dependent */
178 /* Compute the average C6 and C12 params for LJ corrections */
179 extern void set_avcsixtwelve(FILE *fplog,t_forcerec *fr,
180 const gmx_mtop_t *mtop);
182 /* The state has changed */
183 #define GMX_FORCE_STATECHANGED (1<<0)
184 /* The box might have changed */
185 #define GMX_FORCE_DYNAMICBOX (1<<1)
186 /* Do neighbor searching */
187 #define GMX_FORCE_NS (1<<2)
188 /* Calculate bonded energies/forces */
189 #define GMX_FORCE_DOLR (1<<3)
190 /* Calculate long-range energies/forces */
191 #define GMX_FORCE_BONDED (1<<4)
192 /* Store long-range forces in a separate array */
193 #define GMX_FORCE_SEPLRF (1<<5)
194 /* Calculate non-bonded energies/forces */
195 #define GMX_FORCE_NONBONDED (1<<6)
196 /* Calculate forces (not only energies) */
197 #define GMX_FORCE_FORCES (1<<7)
198 /* Calculate the virial */
199 #define GMX_FORCE_VIRIAL (1<<8)
200 /* Calculate dHdl */
201 #define GMX_FORCE_DHDL (1<<9)
202 /* Normally one want all energy terms and forces */
203 #define GMX_FORCE_ALLFORCES (GMX_FORCE_BONDED | GMX_FORCE_NONBONDED | GMX_FORCE_FORCES)
205 extern void do_force(FILE *log,t_commrec *cr,
206 t_inputrec *inputrec,
207 gmx_large_int_t step,t_nrnb *nrnb,gmx_wallcycle_t wcycle,
208 gmx_localtop_t *top,
209 gmx_mtop_t *mtop,
210 gmx_groups_t *groups,
211 matrix box,rvec x[],history_t *hist,
212 rvec f[],
213 tensor vir_force,
214 t_mdatoms *mdatoms,
215 gmx_enerdata_t *enerd,t_fcdata *fcd,
216 real lambda,t_graph *graph,
217 t_forcerec *fr,gmx_vsite_t *vsite,rvec mu_tot,
218 double t,FILE *field,gmx_edsam_t ed,
219 bool bBornRadii,
220 int flags);
221 /* Communicate coordinates (if parallel).
222 * Do neighbor searching (if necessary).
223 * Calculate forces.
224 * Communicate forces (if parallel).
225 * Spread forces for vsites (if present).
227 * f is always required.
230 extern void ns(FILE *fplog,
231 t_forcerec *fr,
232 rvec x[],
233 matrix box,
234 gmx_groups_t *groups,
235 t_grpopts *opts,
236 gmx_localtop_t *top,
237 t_mdatoms *md,
238 t_commrec *cr,
239 t_nrnb *nrnb,
240 real lambda,
241 real *dvdlambda,
242 gmx_grppairener_t *grppener,
243 bool bFillGrid,
244 bool bDoLongRange,
245 bool bDoForces,
246 rvec *f);
247 /* Call the neighborsearcher */
249 extern void do_force_lowlevel(FILE *fplog,
250 gmx_large_int_t step,
251 t_forcerec *fr,
252 t_inputrec *ir,
253 t_idef *idef,
254 t_commrec *cr,
255 t_nrnb *nrnb,
256 gmx_wallcycle_t wcycle,
257 t_mdatoms *md,
258 t_grpopts *opts,
259 rvec x[],
260 history_t *hist,
261 rvec f[],
262 gmx_enerdata_t *enerd,
263 t_fcdata *fcd,
264 gmx_mtop_t *mtop,
265 gmx_localtop_t *top,
266 gmx_genborn_t *born,
267 t_atomtypes *atype,
268 bool bBornRadii,
269 matrix box,
270 real lambda,
271 t_graph *graph,
272 t_blocka *excl,
273 rvec mu_tot[2],
274 int flags,
275 float *cycles_pme);
276 /* Call all the force routines */
278 #ifdef __cplusplus
280 #endif
282 #endif /* _force_h */