Split lines with many copyright years
[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 by the GROMACS development team.
7  * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
8  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
9  * and including many others, as listed in the AUTHORS file in the
10  * top-level source directory and at http://www.gromacs.org.
11  *
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.
16  *
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.
21  *
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.
26  *
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.
34  *
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.
37  */
38
39 /*! \libinternal \file
40  *
41  * \brief
42  * Declares functions to enforce rotational motion upon a group of particles.
43  *
44  * \author Carsten Kutzner <ckutzne@gwdg.de>
45  *
46  * \inlibraryapi
47  */
48
49 #ifndef GMX_PULLING_PULL_ROTATION_H
50 #define GMX_PULLING_PULL_ROTATION_H
51
52 #include <stdio.h>
53
54 #include <memory>
55
56 #include "gromacs/math/vectypes.h"
57 #include "gromacs/utility/basedefinitions.h"
58 #include "gromacs/utility/classhelpers.h"
59
60 struct gmx_domdec_t;
61 struct gmx_enfrot;
62 struct gmx_mtop_t;
63 struct gmx_output_env_t;
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 enum class StartingBehavior;
73 class LocalAtomSetManager;
74 struct MdrunOptions;
75
76 class EnforcedRotation
77 {
78 public:
79     EnforcedRotation();
80     ~EnforcedRotation();
81
82     /*! \brief Getter for working data
83      *
84      * This is needed while the module is still under
85      * construction. */
86     gmx_enfrot* getLegacyEnfrot();
87
88 private:
89     class Impl;
90
91     PrivateImplPointer<Impl> impl_;
92 };
93
94 } // namespace gmx
95
96 /*! \brief Initializes the enforced rotation groups.
97  *
98  * This routine does the memory allocation for various helper arrays, opens
99  * the output files etc.
100  *
101  * \param fplog    General output file, normally md.log.
102  * \param ir       Struct containing MD input parameters, among those
103  *                 also the enforced rotation parameters.
104  * \param nfile    Number of entries in the fnm structure.
105  * \param fnm      The filenames struct containing also the names
106  *                 of the rotation output files.
107  * \param atomSets Tracks indices of atoms subject to enforced rotation for each DD rank.
108  * \param cr       Pointer to MPI communication data.
109  * \param globalState  The global state, only used on the master rank.
110  * \param mtop     Molecular topology.
111  * \param oenv     Needed to open the rotation output xvgr file.
112  * \param mdrunOptions  Options for mdrun.
113  * \param startingBehavior  Describes whether this is a restart appending to output files
114  * \return         An enforced rotation module.
115  */
116 std::unique_ptr<gmx::EnforcedRotation> init_rot(FILE*                     fplog,
117                                                 t_inputrec*               ir,
118                                                 int                       nfile,
119                                                 const t_filenm            fnm[],
120                                                 const t_commrec*          cr,
121                                                 gmx::LocalAtomSetManager* atomSets,
122                                                 const t_state*            globalState,
123                                                 gmx_mtop_t*               mtop,
124                                                 const gmx_output_env_t*   oenv,
125                                                 const gmx::MdrunOptions&  mdrunOptions,
126                                                 gmx::StartingBehavior     startingBehavior);
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, gmx_enfrot* er, const matrix box, rvec x[], real t, int64_t step, gmx_bool bNS);
144
145
146 /*! \brief Add the enforced rotation forces to the official force array.
147  *
148  * Adds the forces from enforced rotation potential to the local forces and
149  * sums up the contributions to the rotation potential from all the nodes. Since
150  * this needs communication, this routine should be called after the short range
151  * forces have been evaluated (in order not to spoil cycle counts).
152  * This routine also outputs data to the rotation output files (e.g.
153  * the potential, the angle of the group(s), and torques).
154  *
155  * \param er      Pointer to the enforced rotation working data.
156  * \param f       The local forces to which the rotational forces have
157  *                to be added.
158  * \param cr      Pointer to MPI communication data.
159  * \param step    The time step, used for output.
160  * \param t       Time, used for output.
161  * \returns       The potential energy of the rotation potentials.
162  */
163 real add_rot_forces(gmx_enfrot* er, rvec f[], const t_commrec* cr, int64_t step, real t);
164
165
166 #endif