c78aba17483ab22f8ac965fd262bf975f1b6fc15
[alexxy/gromacs.git] / src / gromacs / pulling / pull_rotation.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2008, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2016,2017,2018, 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.
10  *
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.
15  *
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.
20  *
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.
25  *
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.
33  *
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.
36  */
37
38 /*! \libinternal \file
39  *
40  * \brief
41  * Declares functions to enforce rotational motion upon a group of particles.
42  *
43  * \author Carsten Kutzner <ckutzne@gwdg.de>
44  *
45  * \inlibraryapi
46  */
47
48 #ifndef GMX_PULLING_PULL_ROTATION_H
49 #define GMX_PULLING_PULL_ROTATION_H
50
51 #include <stdio.h>
52
53 #include <memory>
54
55 #include "gromacs/math/vectypes.h"
56 #include "gromacs/utility/basedefinitions.h"
57 #include "gromacs/utility/classhelpers.h"
58
59 struct gmx_domdec_t;
60 struct gmx_enfrot;
61 struct gmx_mtop_t;
62 struct gmx_output_env_t;
63 struct MdrunOptions;
64 struct t_commrec;
65 struct t_filenm;
66 struct t_inputrec;
67 struct t_rot;
68 class t_state;
69
70 namespace gmx
71 {
72
73 class EnforcedRotation
74 {
75     public:
76         EnforcedRotation();
77         ~EnforcedRotation();
78
79         /*! \brief Getter for working data
80          *
81          * This is needed while the module is still under
82          * construction. */
83         gmx_enfrot *getLegacyEnfrot();
84     private:
85         class Impl;
86
87         PrivateImplPointer<Impl> impl_;
88 };
89
90 } // namespace
91
92 /*! \brief Initializes the enforced rotation groups.
93  *
94  * This routine does the memory allocation for various helper arrays, opens
95  * the output files etc.
96  *
97  * \param fplog    General output file, normally md.log.
98  * \param ir       Struct containing MD input parameters, among those
99  *                 also the enforced rotation parameters.
100  * \param nfile    Number of entries in the fnm structure.
101  * \param fnm      The filenames struct containing also the names
102  *                 of the rotation output files.
103  * \param cr       Pointer to MPI communication data.
104  * \param globalState  The global state, only used on the master rank.
105  * \param mtop     Molecular topology.
106  * \param oenv     Needed to open the rotation output xvgr file.
107  * \param mdrunOptions  Options for mdrun.
108  * \return         An enforced rotation module.
109  */
110 std::unique_ptr<gmx::EnforcedRotation>
111 init_rot(FILE *fplog, t_inputrec *ir, int nfile, const t_filenm fnm[],
112          const t_commrec *cr, const t_state *globalState, gmx_mtop_t *mtop, const gmx_output_env_t *oenv,
113          const MdrunOptions &mdrunOptions);
114
115
116 /*! \brief Make a selection of the home atoms for all enforced rotation groups.
117  *
118  * This routine is similar to \ref dd_make_local_pull_groups, but works only with
119  * domain decomposition. It should be called at every domain decomposition.
120  *
121  * \param dd      Structure containing domain decomposition data.
122  * \param er      Pointer to the enforced rotation working data.
123  */
124 void dd_make_local_rotation_groups(struct gmx_domdec_t *dd,
125                                    gmx_enfrot          *er);
126
127
128 /*! \brief Calculates the enforced rotation potential(s).
129  *
130  * This is the main enforced rotation module which is called during every time
131  * step. Here the rotation potential as well as the resulting forces are
132  * calculated.
133  *
134  * \param cr      Pointer to MPI communication data.
135  * \param er      Pointer to the enforced rotation working data.
136  * \param box     Simulation box, needed to make group whole.
137  * \param x       The positions of all the local particles.
138  * \param t       Time.
139  * \param step    The time step.
140  * \param bNS     After domain decomposition / neighbor searching several
141  *                local arrays have to be updated (masses, shifts)
142  */
143 void do_rotation(const t_commrec  *cr,
144                  gmx_enfrot       *er,
145                  matrix            box,
146                  rvec              x[],
147                  real              t,
148                  gmx_int64_t       step,
149                  gmx_bool          bNS);
150
151
152 /*! \brief Add the enforced rotation forces to the official force array.
153  *
154  * Adds the forces from enforced rotation potential to the local forces and
155  * sums up the contributions to the rotation potential from all the nodes. Since
156  * this needs communication, this routine should be called after the short range
157  * forces have been evaluated (in order not to spoil cycle counts).
158  * This routine also outputs data to the rotation output files (e.g.
159  * the potential, the angle of the group(s), and torques).
160  *
161  * \param er      Pointer to the enforced rotation working data.
162  * \param f       The local forces to which the rotational forces have
163  *                to be added.
164  * \param cr      Pointer to MPI communication data.
165  * \param step    The time step, used for output.
166  * \param t       Time, used for output.
167  * \returns       The potential energy of the rotation potentials.
168  */
169 real add_rot_forces(gmx_enfrot *er,
170                     rvec f[], const t_commrec *cr, gmx_int64_t step, real t);
171
172
173 #endif