2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2019,2020, 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.
35 /*! \libinternal \file
36 * \brief Declares the force element for the modular simulator
38 * This element calculates the forces, with or without shells or
39 * flexible constraints.
41 * \author Pascal Merz <pascal.merz@me.com>
42 * \ingroup module_modularsimulator
45 #ifndef GMX_MODULARSIMULATOR_FORCEELEMENT_H
46 #define GMX_MODULARSIMULATOR_FORCEELEMENT_H
50 #include "gromacs/domdec/dlbtiming.h"
51 #include "gromacs/mdtypes/md_enums.h"
52 #include "gromacs/utility/real.h"
54 #include "modularsimulatorinterfaces.h"
55 #include "topologyholder.h"
67 class FreeEnergyPerturbationElement;
70 class MdrunScheduleWorkload;
71 class StatePropagatorData;
72 class VirtualSitesHandler;
75 * \ingroup module_modularsimulator
76 * \brief Force element
78 * The force element manages the call to either
79 * do_force(...) or relax_shell_flexcon(...)
81 class ForceElement final :
82 public ISimulatorElement,
83 public ITopologyHolderClient,
84 public INeighborSearchSignallerClient,
85 public IEnergySignallerClient
89 ForceElement(StatePropagatorData* statePropagatorData,
90 EnergyElement* energyElement,
91 FreeEnergyPerturbationElement* freeEnergyPerturbationElement,
96 const t_inputrec* inputrec,
97 const MDAtoms* mdAtoms,
100 gmx_wallcycle* wcycle,
101 MdrunScheduleWorkload* runScheduleWork,
102 VirtualSitesHandler* vsite,
103 ImdSession* imdSession,
106 const gmx_mtop_t* globalTopology,
107 gmx_enfrot* enforcedRotation);
109 /*! \brief Register force calculation for step / time
111 * @param step The step number
112 * @param time The time
113 * @param registerRunFunction Function allowing to register a run function
115 void scheduleTask(Step step, Time time, const RegisterRunFunctionPtr& registerRunFunction) override;
117 //! Check that we got the local topology
118 void elementSetup() override;
119 //! Print some final output
120 void elementTeardown() override;
123 //! ITopologyHolderClient implementation
124 void setTopology(const gmx_localtop_t* top) override;
125 //! INeighborSearchSignallerClient implementation
126 SignallerCallbackPtr registerNSCallback() override;
127 //! IEnergySignallerClient implementation
128 SignallerCallbackPtr registerEnergyCallback(EnergySignallerEvent event) override;
129 //! The actual do_force call
130 template<bool doShellFC>
131 void run(Step step, Time time, unsigned int flags);
133 //! The shell / FC helper struct
134 gmx_shellfc_t* shellfc_;
135 //! Whether shells or flexible constraints are present
136 const bool doShellFC_;
140 //! The next energy calculation step
141 Step nextEnergyCalculationStep_;
142 //! The next energy calculation step
143 Step nextVirialCalculationStep_;
144 //! The next free energy calculation step
145 Step nextFreeEnergyCalculationStep_;
147 //! Pointer to the micro state
148 StatePropagatorData* statePropagatorData_;
149 //! Pointer to the energy element
150 EnergyElement* energyElement_;
151 //! Pointer to the free energy perturbation element
152 FreeEnergyPerturbationElement* freeEnergyPerturbationElement_;
154 //! The local topology - updated by Topology via Client system
155 const gmx_localtop_t* localTopology_;
157 //! Whether we're having a dynamic box
158 const bool isDynamicBox_;
159 //! Whether we're being verbose
160 const bool isVerbose_;
161 //! The number of shell relaxation steps we did
162 Step nShellRelaxationSteps_;
164 //! DD / DLB helper object
165 const DDBalanceRegionHandler ddBalanceRegionHandler_;
167 /* \brief The FEP lambda vector
169 * Used if FEP is off, since do_force
170 * requires lambda to be allocated anyway
172 std::array<real, efptNR> lambda_;
174 // Access to ISimulator data
177 //! Handles communication.
178 const t_commrec* cr_;
179 //! Contains user input mdp options.
180 const t_inputrec* inputrec_;
181 //! Atom parameters for this domain.
182 const MDAtoms* mdAtoms_;
183 //! Manages flop accounting.
185 //! Manages wall cycle accounting.
186 gmx_wallcycle* wcycle_;
187 //! Parameters for force calculations.
189 //! Handles virtual sites.
190 VirtualSitesHandler* vsite_;
191 //! The Interactive Molecular Dynamics session.
192 ImdSession* imdSession_;
193 //! The pull work object.
195 //! Schedule of work for each MD step for this task.
196 MdrunScheduleWorkload* runScheduleWork_;
197 //! Handles constraints.
198 Constraints* constr_;
199 //! Handles enforced rotation.
200 gmx_enfrot* enforcedRotation_;
205 #endif // GMX_MODULARSIMULATOR_FORCEELEMENT_H