2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2015,2016,2017,2018,2019, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 * \brief Declares the integrator interface for mdrun
38 * \author David van der Spoel <david.vanderspoel@icm.uu.se>
39 * \author Mark Abraham <mark.j.abraham@gmail.com>
40 * \ingroup module_mdrun
42 #ifndef GMX_MDRUN_INTEGRATOR_H
43 #define GMX_MDRUN_INTEGRATOR_H
49 #include "gromacs/utility/basedefinitions.h"
50 #include "gromacs/utility/real.h"
52 class energyhistory_t;
53 struct gmx_enerdata_t;
57 struct gmx_multisim_t;
58 struct gmx_output_env_t;
61 struct gmx_walltime_accounting;
62 struct ObservablesHistory;
63 struct ReplicaExchangeParameters;
77 class PpForceWorkload;
78 class IMDOutputProvider;
82 class StopHandlerBuilder;
85 //! Function type for integrator code.
86 using IntegratorFunctionType = void();
89 * \brief Struct to handle setting up and running the different "integrators".
91 * This struct is a mere aggregate of parameters to pass to evaluate an
92 * energy, so that future changes to names and types of them consume
93 * less time when refactoring other code.
95 * Aggregate initialization is used, for which the chief risk is that
96 * if a member is added at the end and not all initializer lists are
97 * updated, then the member will be value initialized, which will
98 * typically mean initialization to zero.
100 * Having multiple integrators as member functions isn't a good
101 * design, and we definitely only intend one to be called, but the
102 * goal is to make it easy to change the names and types of members
103 * without having to make identical changes in several places in the
104 * code. Once many of them have become modules, we should change this
107 * Note that the presence of const reference members means that the
108 * default constructor would be implicitly deleted. But we only want
109 * to make one of these when we know how to initialize these members,
110 * so that is perfect. To ensure this remains true even if we would
111 * remove those members, we explicitly delete this constructor.
112 * Other constructors, copies and moves are OK. */
117 //! Handles communication.
119 //! Coordinates multi-simulations.
120 const gmx_multisim_t *ms;
122 const MDLogger &mdlog;
123 //! Count of input file options.
125 //! Content of input file options.
127 //! Handles writing text output.
128 const gmx_output_env_t *oenv;
129 //! Contains command-line options to mdrun.
130 const MdrunOptions &mdrunOptions;
131 //! Handles virtual sites.
133 //! Handles constraints.
135 //! Handles enforced rotation.
136 gmx_enfrot *enforcedRotation;
137 //! Handles box deformation.
138 BoxDeformation *deform;
139 //! Handles writing output files.
140 IMDOutputProvider *outputProvider;
141 //! Contains user input mdp options.
142 t_inputrec *inputrec;
143 //! The Interactive Molecular Dynamics session.
144 ImdSession *imdSession;
145 //! Full system topology.
146 gmx_mtop_t *top_global;
147 //! Helper struct for force calculations.
149 //! Full simulation state (only non-nullptr on master rank).
150 t_state *state_global;
151 //! History of simulation observables.
152 ObservablesHistory *observablesHistory;
153 //! Atom parameters for this domain.
155 //! Manages flop accounting.
157 //! Manages wall cycle accounting.
158 gmx_wallcycle *wcycle;
159 //! Parameters for force calculations.
161 //! Data for energy output.
162 gmx_enerdata_t *enerd;
163 //! Schedule of force-calculation work each step for this task.
164 PpForceWorkload *ppForceWorkload;
165 //! Parameters for replica exchange algorihtms.
166 const ReplicaExchangeParameters &replExParams;
167 //! Parameters for membrane embedding.
168 gmx_membed_t *membed;
169 //! Manages wall time accounting.
170 gmx_walltime_accounting *walltime_accounting;
171 //! Registers stop conditions
172 std::unique_ptr<StopHandlerBuilder> stopHandlerBuilder;
173 //! Implements the normal MD integrators.
174 IntegratorFunctionType do_md;
175 //! Implements the rerun functionality.
176 IntegratorFunctionType do_rerun;
177 //! Implements steepest descent EM.
178 IntegratorFunctionType do_steep;
179 //! Implements conjugate gradient energy minimization
180 IntegratorFunctionType do_cg;
181 //! Implements onjugate gradient energy minimization using the L-BFGS algorithm
182 IntegratorFunctionType do_lbfgs;
183 //! Implements normal mode analysis
184 IntegratorFunctionType do_nm;
185 //! Implements test particle insertion
186 IntegratorFunctionType do_tpi;
187 //! Implements MiMiC QM/MM workflow
188 IntegratorFunctionType do_mimic;
189 /*! \brief Function to run the correct IntegratorFunctionType,
190 * based on the .mdp integrator field. */
191 void run(unsigned int ei, bool doRerun);
192 //! We only intend to construct such objects with an initializer list.
193 Integrator() = delete;
198 #endif // GMX_MDRUN_INTEGRATOR_H