Moved mdatom.h from legacyheader/types to mdtypes.
[gromacs.git] / src / gromacs / pulling / pull.h
blob1501e804a99c1a54303018bf40bc5d509f375cd2
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, 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/fileio/filenm.h"
56 #include "gromacs/math/vectypes.h"
57 #include "gromacs/utility/real.h"
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
63 struct gmx_mtop_t;
64 struct gmx_output_env_t;
65 struct pull_params_t;
66 struct t_inputrec;
67 struct t_mdatoms;
68 struct t_pbc;
71 /*! \brief Get the value for pull coord coord_ind.
73 * \param[in,out] pull The pull struct.
74 * \param[in] coord_ind Number of the pull coordinate.
75 * \param[in] pbc Information structure about periodicity.
76 * \param[out] value The value of the pull coordinate.
78 void get_pull_coord_value(struct pull_t *pull,
79 int coord_ind,
80 const struct t_pbc *pbc,
81 double *value);
84 /*! \brief Set the reference value for a pull coord with rate!=0 to value_ref.
86 * This modifies the reference value. For potential (non-constraint) pulling,
87 * a modification of the reference value at time t will lead to a different
88 * force over t-dt/2 to t and over t to t+dt/2. To take this into account,
89 * bUpdateForce=TRUE will update the force when this function is called
90 * after calling pull_potential.
91 * Note: can not be called for a pull coord with rate!=0.
93 * \param[in,out] pull The pull struct.
94 * \param[in] coord_ind The pull coordinate index to set.
95 * \param[in] value_ref The reference value.
96 * \param[in] pbc Information structure about periodicity.
97 * \param[in] md Atom properties.
98 * \param[in] lambda The value of lambda in FEP calculations.
99 * \param[in] bUpdateForce Update the force for the new reference value.
100 * \param[in,out] f The forces.
101 * \param[in,out] vir The virial, can be NULL.
103 void set_pull_coord_reference_value(struct pull_t *pull,
104 int coord_ind, real value_ref,
105 const struct t_pbc *pbc,
106 const t_mdatoms *md,
107 real lambda,
108 gmx_bool bUpdateForce, rvec *f, tensor vir);
111 /*! \brief Set the all the pull forces to zero.
113 * \param pull The pull group.
115 void clear_pull_forces(struct pull_t *pull);
118 /*! \brief Determine the COM pull forces and add them to f, return the potential
120 * \param[in,out] pull The pull struct.
121 * \param[in] md All atoms.
122 * \param[in] pbc Information struct about periodicity.
123 * \param[in] cr Struct for communication info.
124 * \param[in] t Time.
125 * \param[in] lambda The value of lambda in FEP calculations.
126 * \param[in] x Positions.
127 * \param[in] f Forces.
128 * \param[in,out] vir The virial, which, if != NULL, gets a pull correction.
129 * \param[out] dvdlambda Pull contribution to dV/d(lambda).
131 * \returns The pull potential energy.
133 real pull_potential(struct pull_t *pull, t_mdatoms *md, struct t_pbc *pbc,
134 t_commrec *cr, double t, real lambda,
135 rvec *x, rvec *f, tensor vir, real *dvdlambda);
138 /*! \brief Constrain the coordinates xp in the directions in x
139 * and also constrain v when v != NULL.
141 * \param[in,out] pull The pull data.
142 * \param[in] md All atoms.
143 * \param[in] pbc Information struct about periodicity.
144 * \param[in] cr Struct for communication info.
145 * \param[in] dt The time step length.
146 * \param[in] t The time.
147 * \param[in] x Positions.
148 * \param[in,out] xp Updated x, can be NULL.
149 * \param[in,out] v Velocities, which may get a pull correction.
150 * \param[in,out] vir The virial, which, if != NULL, gets a pull correction.
152 void pull_constraint(struct pull_t *pull, t_mdatoms *md, struct t_pbc *pbc,
153 t_commrec *cr, double dt, double t,
154 rvec *x, rvec *xp, rvec *v, tensor vir);
157 /*! \brief Make a selection of the home atoms for all pull groups.
158 * Should be called at every domain decomposition.
160 * \param cr Structure for communication info.
161 * \param pull The pull group.
162 * \param md All atoms.
164 void dd_make_local_pull_groups(t_commrec *cr,
165 struct pull_t *pull, t_mdatoms *md);
168 /*! \brief Allocate, initialize and return a pull work struct.
170 * \param fplog General output file, normally md.log.
171 * \param pull_params The pull input parameters containing all pull settings.
172 * \param ir The inputrec.
173 * \param nfile Number of files.
174 * \param fnm Standard filename struct.
175 * \param mtop The topology of the whole system.
176 * \param cr Struct for communication info.
177 * \param oenv Output options.
178 * \param lambda FEP lambda.
179 * \param bOutFile Open output files?
180 * \param Flags Flags passed over from main, used to determine
181 * whether or not we are appending.
183 struct pull_t *init_pull(FILE *fplog,
184 const pull_params_t *pull_params,
185 const t_inputrec *ir,
186 int nfile,
187 const t_filenm fnm[],
188 gmx_mtop_t *mtop,
189 t_commrec * cr,
190 const gmx_output_env_t *oenv,
191 real lambda,
192 gmx_bool bOutFile,
193 unsigned long Flags);
196 /*! \brief Close the pull output files.
198 * \param pull The pull group.
200 void finish_pull(struct pull_t *pull);
203 /*! \brief Print the pull output (x and/or f)
205 * \param pull The pull data structure.
206 * \param step Time step number.
207 * \param time Time.
209 void pull_print_output(struct pull_t *pull, gmx_int64_t step, double time);
212 /*! \brief Calculates centers of mass all pull groups.
214 * \param[in] cr Struct for communication info.
215 * \param[in] pull The pull data structure.
216 * \param[in] md All atoms.
217 * \param[in] pbc Information struct about periodicity.
218 * \param[in] t Time, only used for cylinder ref.
219 * \param[in] x The local positions.
220 * \param[in,out] xp Updated x, can be NULL.
223 void pull_calc_coms(t_commrec *cr,
224 struct pull_t *pull,
225 t_mdatoms *md,
226 struct t_pbc *pbc,
227 double t,
228 rvec x[],
229 rvec *xp);
232 /*! \brief Returns if we have pull coordinates with potential pulling.
234 * \param[in] pull The pull data structure.
236 gmx_bool pull_have_potential(const struct pull_t *pull);
239 /*! \brief Returns if we have pull coordinates with constraint pulling.
241 * \param[in] pull The pull data structure.
243 gmx_bool pull_have_constraint(const struct pull_t *pull);
245 #ifdef __cplusplus
247 #endif
249 #endif