2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team,
6 * check out http://www.gromacs.org for more information.
7 * Copyright (c) 2012,2013, by the GROMACS development team, led by
8 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
9 * others, as listed in the AUTHORS file in the top-level source
10 * directory and at http://www.gromacs.org.
12 * GROMACS is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public License
14 * as published by the Free Software Foundation; either version 2.1
15 * of the License, or (at your option) any later version.
17 * GROMACS is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with GROMACS; if not, see
24 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
25 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * If you want to redistribute modifications to GROMACS, please
28 * consider that scientific software is very special. Version
29 * control is crucial - bugs must be traceable. We will be happy to
30 * consider code for inclusion in the official distribution, but
31 * derived work must not be called official GROMACS. Details are found
32 * in the README & COPYING files - if they are missing, get the
33 * official version at http://www.gromacs.org.
35 * To help us fund GROMACS development, we humbly ask that you cite
36 * the research papers on the package. Check out http://www.gromacs.org.
42 #include "visibility.h"
44 #include "types/force_flags.h"
56 static const char *sepdvdlformat
= " %-30s V %12.5e dVdl %12.5e\n";
58 void calc_vir(FILE *fplog
, int nxf
, rvec x
[], rvec f
[], tensor vir
,
59 gmx_bool bScrewPBC
, matrix box
);
60 /* Calculate virial for nxf atoms, and add it to vir */
62 void f_calc_vir(FILE *fplog
, int i0
, int i1
, rvec x
[], rvec f
[], tensor vir
,
63 t_graph
*g
, rvec shift_vec
[]);
64 /* Calculate virial taking periodicity into account */
66 real
RF_excl_correction(FILE *fplog
,
67 const t_forcerec
*fr
, t_graph
*g
,
68 const t_mdatoms
*mdatoms
, const t_blocka
*excl
,
69 rvec x
[], rvec f
[], rvec
*fshift
, const t_pbc
*pbc
,
70 real lambda
, real
*dvdlambda
);
71 /* Calculate the reaction-field energy correction for this node:
72 * epsfac q_i q_j (k_rf r_ij^2 - c_rf)
73 * and force correction for all excluded pairs, including self pairs.
76 void calc_rffac(FILE *fplog
, int eel
, real eps_r
, real eps_rf
,
79 real
*kappa
, real
*krf
, real
*crf
);
80 /* Determine the reaction-field constants */
82 void init_generalized_rf(FILE *fplog
,
83 const gmx_mtop_t
*mtop
, const t_inputrec
*ir
,
85 /* Initialize the generalized reaction field parameters */
89 void make_wall_tables(FILE *fplog
, const output_env_t oenv
,
90 const t_inputrec
*ir
, const char *tabfn
,
91 const gmx_groups_t
*groups
,
94 real
do_walls(t_inputrec
*ir
, t_forcerec
*fr
, matrix box
, t_mdatoms
*md
,
95 rvec x
[], rvec f
[], real lambda
, real Vlj
[], t_nrnb
*nrnb
);
98 t_forcerec
*mk_forcerec(void);
100 #define GMX_MAKETABLES_FORCEUSER (1<<0)
101 #define GMX_MAKETABLES_14ONLY (1<<1)
103 t_forcetable
make_tables(FILE *fp
, const output_env_t oenv
,
104 const t_forcerec
*fr
, gmx_bool bVerbose
,
105 const char *fn
, real rtab
, int flags
);
106 /* Return tables for inner loops. When bVerbose the tables are printed
110 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 t_forcetable
make_gb_table(FILE *out
, const output_env_t oenv
,
117 const t_forcerec
*fr
,
121 /* Read a table for AdResS Thermo Force calculations */
122 extern t_forcetable
make_atf_table(FILE *out
, const output_env_t oenv
,
123 const t_forcerec
*fr
,
128 void pr_forcerec(FILE *fplog
, t_forcerec
*fr
, t_commrec
*cr
);
131 forcerec_set_ranges(t_forcerec
*fr
,
132 int ncg_home
, int ncg_force
,
134 int natoms_force_constr
, int natoms_f_novirsum
);
135 /* Set the number of cg's and atoms for the force calculation */
138 gmx_bool
can_use_allvsall(const t_inputrec
*ir
, const gmx_mtop_t
*mtop
,
139 gmx_bool bPrintNote
, t_commrec
*cr
, FILE *fp
);
140 /* Returns if we can use all-vs-all loops.
141 * If bPrintNote==TRUE, prints a note, if necessary, to stderr
142 * and fp (if !=NULL) on the master node.
146 gmx_bool
uses_simple_tables(int cutoff_scheme
,
147 nonbonded_verlet_t
*nbv
,
149 /* Returns whether simple tables (i.e. not for use with GPUs) are used
150 * with the type of kernel indicated.
154 void init_interaction_const_tables(FILE *fp
,
155 interaction_const_t
*ic
,
156 gmx_bool bSimpleTable
,
158 /* Initializes the tables in the interaction constant data structure.
159 * Setting verlet_kernel_type to -1 always initializes tables for
160 * use with group kernels.
163 void init_interaction_const(FILE *fp
,
164 interaction_const_t
**interaction_const
,
165 const t_forcerec
*fr
,
167 /* Initializes the interaction constant data structure. Currently it
168 * uses forcerec as input.
172 void init_forcerec(FILE *fplog
,
173 const output_env_t oenv
,
176 const t_inputrec
*ir
,
177 const gmx_mtop_t
*mtop
,
185 const char *nbpu_opt
,
188 /* The Force rec struct must be created with mk_forcerec
189 * The gmx_booleans have the following meaning:
190 * bSetQ: Copy the charges [ only necessary when they change ]
191 * bMolEpot: Use the free energy stuff per molecule
192 * print_force >= 0: print forces for atoms with force >= print_force
196 void forcerec_set_excl_load(t_forcerec
*fr
,
197 const gmx_localtop_t
*top
, const t_commrec
*cr
);
198 /* Set the exclusion load for the local exclusions and possibly threads */
201 void init_enerdata(int ngener
, int n_lambda
, gmx_enerdata_t
*enerd
);
202 /* Intializes the energy storage struct */
204 void destroy_enerdata(gmx_enerdata_t
*enerd
);
205 /* Free all memory associated with enerd */
207 void reset_foreign_enerdata(gmx_enerdata_t
*enerd
);
208 /* Resets only the foreign energy data */
210 void reset_enerdata(t_grpopts
*opts
,
211 t_forcerec
*fr
, gmx_bool bNS
,
212 gmx_enerdata_t
*enerd
,
214 /* Resets the energy data, if bNS=TRUE also zeros the long-range part */
216 void sum_epot(t_grpopts
*opts
, gmx_grppairener_t
*grpp
, real
*epot
);
217 /* Locally sum the non-bonded potential energy terms */
220 void sum_dhdl(gmx_enerdata_t
*enerd
, real
*lambda
, t_lambda
*fepvals
);
221 /* Sum the free energy contributions */
223 void update_forcerec(FILE *fplog
, t_forcerec
*fr
, matrix box
);
224 /* Updates parameters in the forcerec that are time dependent */
226 /* Compute the average C6 and C12 params for LJ corrections */
227 void set_avcsixtwelve(FILE *fplog
, t_forcerec
*fr
,
228 const gmx_mtop_t
*mtop
);
231 extern void do_force(FILE *log
, t_commrec
*cr
,
232 t_inputrec
*inputrec
,
233 gmx_large_int_t step
, t_nrnb
*nrnb
, gmx_wallcycle_t wcycle
,
236 gmx_groups_t
*groups
,
237 matrix box
, rvec x
[], history_t
*hist
,
241 gmx_enerdata_t
*enerd
, t_fcdata
*fcd
,
242 real
*lambda
, t_graph
*graph
,
244 gmx_vsite_t
*vsite
, rvec mu_tot
,
245 double t
, FILE *field
, gmx_edsam_t ed
,
249 /* Communicate coordinates (if parallel).
250 * Do neighbor searching (if necessary).
252 * Communicate forces (if parallel).
253 * Spread forces for vsites (if present).
255 * f is always required.
263 gmx_groups_t
*groups
,
271 gmx_grppairener_t
*grppener
,
273 gmx_bool bDoLongRangeNS
);
274 /* Call the neighborsearcher */
276 extern void do_force_lowlevel(FILE *fplog
,
277 gmx_large_int_t step
,
283 gmx_wallcycle_t wcycle
,
290 gmx_enerdata_t
*enerd
,
305 /* Call all the force routines */
311 #endif /* _force_h */