04cf6cdcd7867edbd22df0e1b9f83f033209223f
[alexxy/gromacs.git] / src / gromacs / essentialdynamics / edsam.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-2004, The GROMACS development team.
6  * Copyright (c) 2013,2014,2015,2016,2017,2018,2019, 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 /*! \libinternal \file
38  *
39  * \brief
40  * Declares functions to calculate both essential dynamics constraints
41  * as well as flooding potentials and forces.
42  *
43  * \authors Bert de Groot <bgroot@gwdg.de>, Oliver Lange <oliver.lange@tum.de>,
44  * Carsten Kutzner <ckutzne@gwdg.de>
45  *
46  * \inlibraryapi
47  */
48 #ifndef GMX_ESSENTIALDYNAMICS_EDSAM_H
49 #define GMX_ESSENTIALDYNAMICS_EDSAM_H
50
51 #include <memory>
52
53 #include "gromacs/math/vectypes.h"
54 #include "gromacs/utility/basedefinitions.h"
55 #include "gromacs/utility/classhelpers.h"
56
57 /*! \brief Abstract type for essential dynamics
58  *
59  * The main type is defined only in edsam.cpp
60  */
61 struct gmx_edsam;
62 struct gmx_domdec_t;
63 struct gmx_mtop_t;
64 struct gmx_output_env_t;
65 struct ObservablesHistory;
66 struct t_commrec;
67 struct t_filenm;
68 struct t_inputrec;
69 class t_state;
70
71 namespace gmx
72 {
73 enum class StartingBehavior;
74 class Constraints;
75 class EssentialDynamics
76 {
77     public:
78         EssentialDynamics();
79         ~EssentialDynamics();
80
81         /*! \brief Getter for working data
82          *
83          * This is needed while the module is still under
84          * construction. */
85         gmx_edsam *getLegacyED();
86     private:
87         class Impl;
88
89         PrivateImplPointer<Impl> impl_;
90 };
91 class MDLogger;
92 } // namespace gmx
93
94 /*! \brief Applies essential dynamics constrains as defined in the .edi input file.
95  *
96  * \param ir                MD input parameter record.
97  * \param step              Number of the time step.
98  * \param cr                Data needed for MPI communication.
99  * \param xs                The local positions on this processor.
100  * \param v                 The local velocities.
101  * \param box               The simulation box.
102  * \param ed                The essential dynamics data.
103  */
104 void do_edsam(const t_inputrec *ir, int64_t step,
105               const t_commrec *cr, rvec xs[], rvec v[], matrix box, gmx_edsam *ed);
106
107
108 /*! \brief Initializes the essential dynamics and flooding module.
109  *
110  * \param mdlog             Logger.
111  * \param ediFileName       Essential dynamics input file.
112  * \param edoFileName       Output file for essential dynamics data.
113  * \param mtop              Molecular topology.
114  * \param ir                MD input parameter record.
115  * \param cr                Data needed for MPI communication.
116  * \param constr            Data structure keeping the constraint information.
117  * \param globalState       The global state, only used on the master rank.
118  * \param oh                The observables history container.
119  * \param oenv              The output environment information.
120  * \param startingBehavior  Describes whether this is a restart appending to output files
121  *
122  * \returns                 A pointer to the ED data structure.
123  */
124 std::unique_ptr<gmx::EssentialDynamics> init_edsam(
125         const gmx::MDLogger    &mdlog,
126         const char             *ediFileName,
127         const char             *edoFileName,
128         const gmx_mtop_t       *mtop,
129         const t_inputrec       *ir,
130         const t_commrec        *cr,
131         gmx::Constraints       *constr,
132         const t_state          *globalState,
133         ObservablesHistory     *oh,
134         const gmx_output_env_t *oenv,
135         gmx::StartingBehavior   startingBehavior);
136
137 /*! \brief Make a selection of the home atoms for the ED groups.
138  *
139  * Should be called at every domain decomposition.
140  *
141  * \param dd                Domain decomposition data.
142  * \param ed                Essential dynamics and flooding data.
143  */
144 void dd_make_local_ed_indices(gmx_domdec_t *dd, gmx_edsam * ed);
145
146
147 /*! \brief Evaluate the flooding potential(s) and forces as requested in the .edi input file.
148  *
149  * \param cr                Data needed for MPI communication.
150  * \param ir                MD input parameter record.
151  * \param x                 Positions on the local processor.
152  * \param force             Forcefield forces to which the flooding forces are added.
153  * \param ed                The essential dynamics data.
154  * \param box               The simulation box.
155  * \param step              Number of the time step.
156  * \param bNS               Are we in a neighbor searching step?
157  */
158 void do_flood(const t_commrec  *cr,
159               const t_inputrec *ir,
160               const rvec        x[],
161               rvec              force[],
162               gmx_edsam        *ed,
163               const matrix      box,
164               int64_t           step,
165               gmx_bool          bNS);
166
167 #endif