2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2019,2020,2021, 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 general simulator interface
38 * \author Pascal Merz <pascal.merz@me.com>
39 * \ingroup module_mdrun
41 #ifndef GMX_MDRUN_ISIMULATOR_H
42 #define GMX_MDRUN_ISIMULATOR_H
44 #include "gromacs/mdlib/stophandler.h"
46 class energyhistory_t;
47 struct gmx_ekindata_t;
48 struct gmx_enerdata_t;
52 struct gmx_multisim_t;
53 struct gmx_output_env_t;
55 struct gmx_walltime_accounting;
56 struct ObservablesHistory;
58 struct ReplicaExchangeParameters;
69 enum class StartingBehavior;
72 class MdrunScheduleWorkload;
73 class IMDOutputProvider;
74 struct MdModulesNotifier;
78 class StopHandlerBuilder;
80 class VirtualSitesHandler;
83 * \brief The Simulator interface
85 * This is the general interface for any type of simulation type
86 * run with GROMACS. This allows having a builder return different
87 * Simulator objects based on user input.
92 /*! \brief The simulation run
94 * This will be called by the owner of the simulator object. To be redefined
95 * by the child classes. This function is expected to run the simulation.
97 virtual void run() = 0;
98 //! Standard destructor
99 virtual ~ISimulator() = default;
103 * \brief The legacy simulator data
105 * This contains the data passed into the GROMACS simulators from
106 * the Mdrunner object.
108 class LegacySimulatorData
112 LegacySimulatorData(FILE* fplog,
114 const gmx_multisim_t* ms,
115 const MDLogger& mdlog,
118 const gmx_output_env_t* oenv,
119 const MdrunOptions& mdrunOptions,
120 StartingBehavior startingBehavior,
121 VirtualSitesHandler* vsite,
123 gmx_enfrot* enforcedRotation,
124 BoxDeformation* deform,
125 IMDOutputProvider* outputProvider,
126 const MdModulesNotifier& mdModulesNotifier,
127 t_inputrec* inputrec,
128 ImdSession* imdSession,
131 const gmx_mtop_t& top_global,
132 t_state* state_global,
133 ObservablesHistory* observablesHistory,
136 gmx_wallcycle* wcycle,
138 gmx_enerdata_t* enerd,
139 gmx_ekindata_t* ekind,
140 MdrunScheduleWorkload* runScheduleWork,
141 const ReplicaExchangeParameters& replExParams,
142 gmx_membed_t* membed,
143 gmx_walltime_accounting* walltime_accounting,
144 std::unique_ptr<StopHandlerBuilder> stopHandlerBuilder,
153 mdrunOptions(mdrunOptions),
154 startingBehavior(startingBehavior),
157 enforcedRotation(enforcedRotation),
159 outputProvider(outputProvider),
160 mdModulesNotifier(mdModulesNotifier),
162 imdSession(imdSession),
163 pull_work(pull_work),
165 top_global(top_global),
166 state_global(state_global),
167 observablesHistory(observablesHistory),
174 runScheduleWork(runScheduleWork),
175 replExParams(replExParams),
177 walltime_accounting(walltime_accounting),
178 stopHandlerBuilder(std::move(stopHandlerBuilder)),
185 //! Handles communication.
187 //! Coordinates multi-simulations.
188 const gmx_multisim_t* ms;
190 const MDLogger& mdlog;
191 //! Count of input file options.
193 //! Content of input file options.
195 //! Handles writing text output.
196 const gmx_output_env_t* oenv;
197 //! Contains command-line options to mdrun.
198 const MdrunOptions& mdrunOptions;
199 //! Whether the simulation will start afresh, or restart with/without appending.
200 const StartingBehavior startingBehavior;
201 //! Handles virtual sites.
202 VirtualSitesHandler* vsite;
203 //! Handles constraints.
205 //! Handles enforced rotation.
206 gmx_enfrot* enforcedRotation;
207 //! Handles box deformation.
208 BoxDeformation* deform;
209 //! Handles writing output files.
210 IMDOutputProvider* outputProvider;
211 //! Handles notifications to MdModules for checkpoint writing
212 const MdModulesNotifier& mdModulesNotifier;
213 //! Contains user input mdp options. Note: The const-ness is casted away in a few instances, see #3854.
214 const t_inputrec* inputrec;
215 //! The Interactive Molecular Dynamics session.
216 ImdSession* imdSession;
217 //! The pull work object.
219 //! The coordinate-swapping session.
221 //! Full system topology.
222 const gmx_mtop_t& top_global;
223 //! Full simulation state (only non-nullptr on master rank).
224 t_state* state_global;
225 //! History of simulation observables.
226 ObservablesHistory* observablesHistory;
227 //! Atom parameters for this domain.
229 //! Manages flop accounting.
231 //! Manages wall cycle accounting.
232 gmx_wallcycle* wcycle;
233 //! Parameters for force calculations.
235 //! Data for energy output.
236 gmx_enerdata_t* enerd;
237 //! Kinetic energy data.
238 gmx_ekindata_t* ekind;
239 //! Schedule of work for each MD step for this task.
240 MdrunScheduleWorkload* runScheduleWork;
241 //! Parameters for replica exchange algorihtms.
242 const ReplicaExchangeParameters& replExParams;
243 //! Parameters for membrane embedding.
244 gmx_membed_t* membed;
245 //! Manages wall time accounting.
246 gmx_walltime_accounting* walltime_accounting;
247 //! Registers stop conditions
248 std::unique_ptr<StopHandlerBuilder> stopHandlerBuilder;
249 //! Whether we're doing a rerun.
255 #endif // GMX_MDRUN_ISIMULATOR_H