Split simulationWork.useGpuBufferOps into separate x and f flags
[alexxy/gromacs.git] / src / gromacs / mdlib / update_vv.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 by the GROMACS development team.
7  * Copyright (c) 2018,2019,2020,2021, 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 #ifndef GMX_MDLIB_UPDATE_VV_H
39 #define GMX_MDLIB_UPDATE_VV_H
40
41 #include <cstdio>
42
43 #include <array>
44 #include <vector>
45
46 #include "gromacs/math/vectypes.h"
47 #include "gromacs/mdtypes/md_enums.h"
48 #include "gromacs/utility/enumerationhelpers.h"
49
50 class gmx_ekindata_t;
51 struct gmx_enerdata_t;
52 struct gmx_global_stat;
53 struct gmx_wallcycle;
54 struct pull_t;
55 struct t_commrec;
56 struct t_extmass;
57 struct t_fcdata;
58 struct t_forcerec;
59 struct t_inputrec;
60 struct t_mdatoms;
61 struct t_nrnb;
62 class t_state;
63 struct t_vcm;
64
65 namespace gmx
66 {
67 class Constraints;
68 class ForceBuffers;
69 class ObservablesReducer;
70 class SimulationSignaller;
71 class Update;
72 enum class StartingBehavior : int;
73 } // namespace gmx
74
75 /*! \brief Make the first step of Velocity Verlet integration
76  *
77  * \param[in]  step              Current timestep.
78  * \param[in]  bFirstStep        Is it a first step.
79  * \param[in]  bInitStep         Is it an initialization step.
80  * \param[in]  startingBehavior  Describes whether this is a restart appending to output files.
81  * \param[in]  nstglobalcomm     Will globals be computed on this step.
82  * \param[in]  ir                Input record.
83  * \param[in]  fr                Force record.
84  * \param[in]  cr                Comunication record.
85  * \param[in]  state             Simulation state.
86  * \param[in]  mdatoms           MD atoms data.
87  * \param[in]  fcdata            Force calculation data.
88  * \param[in]  MassQ             Mass/pressure data.
89  * \param[in]  vcm               Center of mass motion removal.
90  * \param[in]  enerd             Energy data.
91  * \param[in]  observablesReducer Pointer to the \c ObservablesReducer object
92  * \param[in]  ekind             Kinetic energy data.
93  * \param[in]  gstat             Storage of thermodynamic parameters data.
94  * \param[out] last_ekin         Kinetic energies of the last step.
95  * \param[in]  bCalcVir          If the virial is computed on this step.
96  * \param[in]  total_vir         Total virial tensor.
97  * \param[in]  shake_vir         Constraints virial.
98  * \param[in]  force_vir         Force virial.
99  * \param[in]  pres              Pressure tensor.
100  * \param[in]  M                 Parrinello-Rahman velocity scaling matrix.
101  * \param[in]  do_log            Do logging on this step.
102  * \param[in]  do_ene            Print energies on this step.
103  * \param[in]  bCalcEner         Compute energies on this step.
104  * \param[in]  bGStat            Collect globals this step.
105  * \param[in]  bStopCM           Stop the center of mass motion on this step.
106  * \param[in]  bTrotter          Do trotter routines this step.
107  * \param[in]  bExchanged        If this is a replica exchange step.
108  * \param[out] bSumEkinhOld      Old kinetic energies will need to be summed up.
109  * \param[out] saved_conserved_quantity  Place to store the conserved energy.
110  * \param[in]  f                 Force buffers.
111  * \param[in]  upd               Update object.
112  * \param[in]  constr            Constraints object.
113  * \param[in]  nullSignaller     Simulation signaller.
114  * \param[in]  trotter_seq       NPT variables.
115  * \param[in]  nrnb              Cycle counters.
116  * \param[in]  fplog             Another logger.
117  * \param[in]  wcycle            Wall-clock cycle counter.
118  */
119 void integrateVVFirstStep(int64_t                   step,
120                           bool                      bFirstStep,
121                           bool                      bInitStep,
122                           gmx::StartingBehavior     startingBehavior,
123                           int                       nstglobalcomm,
124                           const t_inputrec*         ir,
125                           t_forcerec*               fr,
126                           t_commrec*                cr,
127                           t_state*                  state,
128                           t_mdatoms*                mdatoms,
129                           t_fcdata*                 fcdata,
130                           t_extmass*                MassQ,
131                           t_vcm*                    vcm,
132                           gmx_enerdata_t*           enerd,
133                           gmx::ObservablesReducer*  observablesReducer,
134                           gmx_ekindata_t*           ekind,
135                           gmx_global_stat*          gstat,
136                           real*                     last_ekin,
137                           bool                      bCalcVir,
138                           tensor                    total_vir,
139                           tensor                    shake_vir,
140                           tensor                    force_vir,
141                           tensor                    pres,
142                           matrix                    M,
143                           bool                      do_log,
144                           bool                      do_ene,
145                           bool                      bCalcEner,
146                           bool                      bGStat,
147                           bool                      bStopCM,
148                           bool                      bTrotter,
149                           bool                      bExchanged,
150                           bool*                     bSumEkinhOld,
151                           real*                     saved_conserved_quantity,
152                           gmx::ForceBuffers*        f,
153                           gmx::Update*              upd,
154                           gmx::Constraints*         constr,
155                           gmx::SimulationSignaller* nullSignaller,
156                           gmx::EnumerationArray<TrotterSequence, std::vector<int>> trotter_seq,
157                           t_nrnb*                                                  nrnb,
158                           FILE*                                                    fplog,
159                           gmx_wallcycle*                                           wcycle);
160
161
162 /*! \brief Make the second step of Velocity Verlet integration
163  *
164  * \param[in]  step              Current timestep.
165  * \param[in]  ir                Input record.
166  * \param[in]  fr                Force record.
167  * \param[in]  cr                Comunication record.
168  * \param[in]  state             Simulation state.
169  * \param[in]  mdatoms           MD atoms data.
170  * \param[in]  fcdata            Force calculation data.
171  * \param[in]  MassQ             Mass/pressure data.
172  * \param[in]  vcm               Center of mass motion removal.
173  * \param[in]  pull_work         Pulling data.
174  * \param[in]  enerd             Energy data.
175  * \param[in]  observablesReducer Pointer to the \c ObservablesReducer object
176  * \param[in]  ekind             Kinetic energy data.
177  * \param[in]  gstat             Storage of thermodynamic parameters data.
178  * \param[out] dvdl_constr       FEP data for constraints.
179  * \param[in]  bCalcVir          If the virial is computed on this step.
180  * \param[in]  total_vir         Total virial tensor.
181  * \param[in]  shake_vir         Constraints virial.
182  * \param[in]  force_vir         Force virial.
183  * \param[in]  pres              Pressure tensor.
184  * \param[in]  M                 Parrinello-Rahman velocity scaling matrix.
185  * \param[in]  lastbox           Last recorded PBC box.
186  * \param[in]  do_log            Do logging on this step.
187  * \param[in]  do_ene            Print energies on this step.
188  * \param[in]  bGStat            Collect globals this step.
189  * \param[out] bSumEkinhOld      Old kinetic energies need to be summed up.
190  * \param[in]  f                 Force buffers.
191  * \param[in]  cbuf              Buffer to store intermediate coordinates
192  * \param[in]  upd               Update object.
193  * \param[in]  constr            Constraints object.
194  * \param[in]  nullSignaller     Simulation signaller.
195  * \param[in]  trotter_seq       NPT variables.
196  * \param[in]  nrnb              Cycle counters.
197  * \param[in]  wcycle            Wall-clock cycle counter.
198  */
199 void integrateVVSecondStep(int64_t                   step,
200                            const t_inputrec*         ir,
201                            t_forcerec*               fr,
202                            t_commrec*                cr,
203                            t_state*                  state,
204                            t_mdatoms*                mdatoms,
205                            t_fcdata*                 fcdata,
206                            t_extmass*                MassQ,
207                            t_vcm*                    vcm,
208                            pull_t*                   pull_work,
209                            gmx_enerdata_t*           enerd,
210                            gmx::ObservablesReducer*  observablesReducer,
211                            gmx_ekindata_t*           ekind,
212                            gmx_global_stat*          gstat,
213                            real*                     dvdl_constr,
214                            bool                      bCalcVir,
215                            tensor                    total_vir,
216                            tensor                    shake_vir,
217                            tensor                    force_vir,
218                            tensor                    pres,
219                            matrix                    M,
220                            matrix                    lastbox,
221                            bool                      do_log,
222                            bool                      do_ene,
223                            bool                      bGStat,
224                            bool*                     bSumEkinhOld,
225                            gmx::ForceBuffers*        f,
226                            std::vector<gmx::RVec>*   cbuf,
227                            gmx::Update*              upd,
228                            gmx::Constraints*         constr,
229                            gmx::SimulationSignaller* nullSignaller,
230                            gmx::EnumerationArray<TrotterSequence, std::vector<int>> trotter_seq,
231                            t_nrnb*                                                  nrnb,
232                            gmx_wallcycle*                                           wcycle);
233
234
235 #endif // GMX_MDLIB_UPDATE_VV_H