Prepare for 2019.1
[alexxy/gromacs.git] / src / gromacs / mdlib / md_support.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, 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 #ifndef GMX_MDLIB_MD_SUPPORT_H
38 #define GMX_MDLIB_MD_SUPPORT_H
39
40 #include "gromacs/mdlib/vcm.h"
41 #include "gromacs/timing/wallcycle.h"
42
43 struct gmx_ekindata_t;
44 struct gmx_enerdata_t;
45 struct gmx_global_stat;
46 struct gmx_multisim_t;
47 struct gmx_signalling_t;
48 struct t_extmass;
49 struct t_forcerec;
50 struct t_grpopts;
51 struct t_lambda;
52 struct t_nrnb;
53 class t_state;
54 struct t_trxframe;
55
56 namespace gmx
57 {
58 class Constraints;
59 class MDLogger;
60 class SimulationSignaller;
61 }
62
63 /* Define a number of flags to better control the information
64  * passed to compute_globals in md.c and global_stat.
65  */
66
67 /* we are initializing and not yet in the actual MD loop */
68 #define CGLO_INITIALIZATION (1<<1)
69 /* we are computing the kinetic energy from average velocities */
70 #define CGLO_EKINAVEVEL     (1<<2)
71 /* we are removing the center of mass momenta */
72 #define CGLO_STOPCM         (1<<3)
73 /* bGStat is defined in do_md */
74 #define CGLO_GSTAT          (1<<4)
75 /* Sum the energy terms in global computation */
76 #define CGLO_ENERGY         (1<<6)
77 /* Sum the kinetic energy terms in global computation */
78 #define CGLO_TEMPERATURE    (1<<7)
79 /* Sum the kinetic energy terms in global computation */
80 #define CGLO_PRESSURE       (1<<8)
81 /* Sum the constraint term in global computation */
82 #define CGLO_CONSTRAINT     (1<<9)
83 /* Reading ekin from the trajectory */
84 #define CGLO_READEKIN       (1<<10)
85 /* we need to reset the ekin rescaling factor here */
86 #define CGLO_SCALEEKIN      (1<<11)
87 /* After a new DD partitioning, we need to set a flag to schedule
88  * global reduction of the total number of bonded interactions that
89  * will be computed, to check none are missing. */
90 #define CGLO_CHECK_NUMBER_OF_BONDED_INTERACTIONS (1<<12)
91
92
93 /*! \brief Return the number of steps that will take place between
94  * intra-simulation communications, given the constraints of the
95  * inputrec and the value of mdrun -gcom. */
96 int check_nstglobalcomm(const gmx::MDLogger &mdlog,
97                         int                  nstglobalcomm,
98                         t_inputrec          *ir,
99                         const t_commrec    * cr);
100
101 /*! \brief Return true if the \p value is equal across the set of multi-simulations
102  *
103  * \todo This duplicates some of check_multi_int. Consolidate. */
104 bool multisim_int_all_are_equal(const gmx_multisim_t *ms,
105                                 int64_t               value);
106
107 void rerun_parallel_comm(t_commrec *cr, t_trxframe *fr,
108                          gmx_bool *bLastStep);
109
110 /* Set the lambda values in the global state from a frame read with rerun */
111 void setCurrentLambdasRerun(int64_t step, const t_lambda *fepvals,
112                             const t_trxframe *rerun_fr, const double *lam0,
113                             t_state *globalState);
114
115 /* Set the lambda values at each step of mdrun when they change */
116 void setCurrentLambdasLocal(int64_t step, const t_lambda *fepvals,
117                             const double *lam0, t_state *state);
118
119 int multisim_min(const gmx_multisim_t *ms, int nmin, int n);
120 /* Set an appropriate value for n across the whole multi-simulation */
121
122 void compute_globals(FILE *fplog, gmx_global_stat *gstat, t_commrec *cr, t_inputrec *ir,
123                      t_forcerec *fr, gmx_ekindata_t *ekind,
124                      t_state *state, t_mdatoms *mdatoms,
125                      t_nrnb *nrnb, t_vcm *vcm, gmx_wallcycle_t wcycle,
126                      gmx_enerdata_t *enerd, tensor force_vir, tensor shake_vir, tensor total_vir,
127                      tensor pres, rvec mu_tot, gmx::Constraints *constr,
128                      gmx::SimulationSignaller *signalCoordinator,
129                      matrix box, int *totalNumberOfBondedInteractions,
130                      gmx_bool *bSumEkinhOld, int flags);
131 /* Compute global variables during integration */
132
133 #endif