Clean up cmake build host detection
[gromacs.git] / src / gromacs / pulling / pull.h
blobd0c4f934e868f9ccdf32ec1ddf325595f5c57e08
1 /*
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 * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
38 /*! \libinternal \file
41 * \brief
42 * This file contains datatypes and function declarations necessary
43 for mdrun to interface with the pull code.
45 * \author Berk Hess
47 * \inlibraryapi
50 #ifndef GMX_PULLING_PULL_H
51 #define GMX_PULLING_PULL_H
53 #include <cstdio>
55 #include "gromacs/math/vectypes.h"
56 #include "gromacs/mdtypes/pull-params.h"
57 #include "gromacs/pulling/pull_internal.h"
58 #include "gromacs/utility/basedefinitions.h"
59 #include "gromacs/utility/real.h"
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
65 struct gmx_mtop_t;
66 struct gmx_output_env_t;
67 struct pull_params_t;
68 struct t_commrec;
69 struct t_filenm;
70 struct t_inputrec;
71 struct t_mdatoms;
72 struct t_pbc;
74 /*! \brief Returns the units of the pull coordinate.
76 * \param[in] pcrd The pull coordinate to query the units for.
77 * \returns a string with the units of the coordinate.
79 const char *pull_coordinate_units(const t_pull_coord *pcrd);
81 /*! \brief Returns the conversion factor from the pull coord init/rate unit to internal value unit.
83 * \param[in] pcrd The pull coordinate to get the conversion factor for.
84 * \returns the conversion factor.
86 double pull_conversion_factor_userinput2internal(const t_pull_coord *pcrd);
88 /*! \brief Returns the conversion factor from the pull coord internal value unit to the init/rate unit.
90 * \param[in] pcrd The pull coordinate to get the conversion factor for.
91 * \returns the conversion factor.
93 double pull_conversion_factor_internal2userinput(const t_pull_coord *pcrd);
95 /*! \brief Get the value for pull coord coord_ind.
97 * \param[in,out] pull The pull struct.
98 * \param[in] coord_ind Number of the pull coordinate.
99 * \param[in] pbc Information structure about periodicity.
100 * \param[out] value The value of the pull coordinate.
102 void get_pull_coord_value(struct pull_t *pull,
103 int coord_ind,
104 const struct t_pbc *pbc,
105 double *value);
108 /*! \brief Registers the provider of an external potential for a coordinate.
110 * This function is only used for checking the consistency of the pull setup.
111 * For each pull coordinate of type external-potential, selected by the user
112 * in the mdp file, there has to be a module that provides this potential.
113 * The module registers itself as the provider by calling this function.
114 * The passed \p provider string has to match the string that the user
115 * passed with the potential-provider pull coordinate mdp option.
116 * This function should be called after init_pull has been called and before
117 * pull_potential is called for the first time.
118 * This function does many consistency checks and when it returns and the
119 * first call to do_potential passes, the pull setup is guaranteed to be
120 * correct (unless the module doesn't call apply_external_pull_coord_force
121 * every step or calls it with incorrect forces). This registering function
122 * will exit with a (release) assertion failure when used incorrely or
123 * with a fatal error when the user (mdp) input in inconsistent.
125 * \param[in,out] pull The pull struct.
126 * \param[in] coord_index The pull coordinate index to register the external potential for.
127 * \param[in] provider Provider string, should match the potential-provider pull coordinate mdp option.
129 void register_external_pull_potential(struct pull_t *pull,
130 int coord_index,
131 const char *provider);
134 /*! \brief Apply forces of an external potential to a pull coordinate.
136 * This function applies the external scalar force \p coord_force to
137 * the pull coordinate, distributing it over the atoms in the groups
138 * involved in the pull coordinate. The corresponding potential energy
139 * value should be added to the pull or the module's potential energy term
140 * separately by the module itself.
141 * This function should be called after pull_potential has been called and,
142 * obviously, before the coordinates are updated uses the forces.
144 * \param[in,out] pull The pull struct.
145 * \param[in] coord_index The pull coordinate index to set the force for.
146 * \param[in] coord_force The scalar force for the pull coordinate.
147 * \param[in] mdatoms Atom properties, only masses are used.
148 * \param[in,out] force The force buffer.
149 * \param[in,out] virial The virial, can be NULL.
151 void apply_external_pull_coord_force(struct pull_t *pull,
152 int coord_index,
153 double coord_force,
154 const t_mdatoms *mdatoms,
155 rvec *force,
156 tensor virial);
159 /*! \brief Set the all the pull forces to zero.
161 * \param pull The pull group.
163 void clear_pull_forces(struct pull_t *pull);
166 /*! \brief Determine the COM pull forces and add them to f, return the potential
168 * \param[in,out] pull The pull struct.
169 * \param[in] md All atoms.
170 * \param[in] pbc Information struct about periodicity.
171 * \param[in] cr Struct for communication info.
172 * \param[in] t Time.
173 * \param[in] lambda The value of lambda in FEP calculations.
174 * \param[in] x Positions.
175 * \param[in] f Forces.
176 * \param[in,out] vir The virial, which, if != NULL, gets a pull correction.
177 * \param[out] dvdlambda Pull contribution to dV/d(lambda).
179 * \returns The pull potential energy.
181 real pull_potential(struct pull_t *pull, t_mdatoms *md, struct t_pbc *pbc,
182 t_commrec *cr, double t, real lambda,
183 rvec *x, rvec *f, tensor vir, real *dvdlambda);
186 /*! \brief Constrain the coordinates xp in the directions in x
187 * and also constrain v when v != NULL.
189 * \param[in,out] pull The pull data.
190 * \param[in] md All atoms.
191 * \param[in] pbc Information struct about periodicity.
192 * \param[in] cr Struct for communication info.
193 * \param[in] dt The time step length.
194 * \param[in] t The time.
195 * \param[in] x Positions.
196 * \param[in,out] xp Updated x, can be NULL.
197 * \param[in,out] v Velocities, which may get a pull correction.
198 * \param[in,out] vir The virial, which, if != NULL, gets a pull correction.
200 void pull_constraint(struct pull_t *pull, t_mdatoms *md, struct t_pbc *pbc,
201 t_commrec *cr, double dt, double t,
202 rvec *x, rvec *xp, rvec *v, tensor vir);
205 /*! \brief Make a selection of the home atoms for all pull groups.
206 * Should be called at every domain decomposition.
208 * \param cr Structure for communication info.
209 * \param pull The pull group.
210 * \param md All atoms.
212 void dd_make_local_pull_groups(t_commrec *cr,
213 struct pull_t *pull, t_mdatoms *md);
216 /*! \brief Allocate, initialize and return a pull work struct.
218 * \param fplog General output file, normally md.log.
219 * \param pull_params The pull input parameters containing all pull settings.
220 * \param ir The inputrec.
221 * \param nfile Number of files.
222 * \param fnm Standard filename struct.
223 * \param mtop The topology of the whole system.
224 * \param cr Struct for communication info.
225 * \param oenv Output options.
226 * \param lambda FEP lambda.
227 * \param bOutFile Open output files?
228 * \param Flags Flags passed over from main, used to determine
229 * whether or not we are appending.
231 struct pull_t *init_pull(FILE *fplog,
232 const pull_params_t *pull_params,
233 const t_inputrec *ir,
234 int nfile,
235 const t_filenm fnm[],
236 const gmx_mtop_t *mtop,
237 t_commrec * cr,
238 const gmx_output_env_t *oenv,
239 real lambda,
240 gmx_bool bOutFile,
241 unsigned long Flags);
244 /*! \brief Close the pull output files.
246 * \param pull The pull group.
248 void finish_pull(struct pull_t *pull);
251 /*! \brief Print the pull output (x and/or f)
253 * \param pull The pull data structure.
254 * \param step Time step number.
255 * \param time Time.
257 void pull_print_output(struct pull_t *pull, gmx_int64_t step, double time);
260 /*! \brief Calculates centers of mass all pull groups.
262 * \param[in] cr Struct for communication info.
263 * \param[in] pull The pull data structure.
264 * \param[in] md All atoms.
265 * \param[in] pbc Information struct about periodicity.
266 * \param[in] t Time, only used for cylinder ref.
267 * \param[in] x The local positions.
268 * \param[in,out] xp Updated x, can be NULL.
271 void pull_calc_coms(t_commrec *cr,
272 struct pull_t *pull,
273 t_mdatoms *md,
274 struct t_pbc *pbc,
275 double t,
276 rvec x[],
277 rvec *xp);
280 /*! \brief Returns if we have pull coordinates with potential pulling.
282 * \param[in] pull The pull data structure.
284 gmx_bool pull_have_potential(const struct pull_t *pull);
287 /*! \brief Returns if we have pull coordinates with constraint pulling.
289 * \param[in] pull The pull data structure.
291 gmx_bool pull_have_constraint(const struct pull_t *pull);
293 /*! \brief Returns the maxing distance for pulling
295 * For distance geometries, only dimensions with pcrd->params[dim]=1
296 * are included in the distance calculation.
297 * For directional geometries, only dimensions with pcrd->vec[dim]!=0
298 * are included in the distance calculation.
300 * \param[in] pcrd Pulling data structure
301 * \param[in] pbc Information on periodic boundary conditions
302 * \returns The maximume distance
304 real max_pull_distance2(const pull_coord_work_t *pcrd,
305 const t_pbc *pbc);
307 #ifdef __cplusplus
309 #endif
311 #endif