a9bd066d754b4b51fc576218d8bcea78de6c542f
[alexxy/gromacs.git] / src / gromacs / mdlib / sim_util.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_SIM_UTIL_H
38 #define GMX_MDLIB_SIM_UTIL_H
39
40 #include "gromacs/fileio/enxio.h"
41 #include "gromacs/mdlib/mdebin.h"
42 #include "gromacs/mdlib/mdoutf.h"
43 #include "gromacs/mdlib/vcm.h"
44 #include "gromacs/timing/wallcycle.h"
45 #include "gromacs/timing/walltime_accounting.h"
46 #include "gromacs/utility/arrayref.h"
47
48 struct gmx_output_env_t;
49 struct gmx_pme_t;
50 struct gmx_update_t;
51 struct MdrunOptions;
52 struct nonbonded_verlet_t;
53 struct t_forcerec;
54 struct t_mdatoms;
55 struct t_nrnb;
56
57 namespace gmx
58 {
59 class BoxDeformation;
60 class Constraints;
61 class IMDOutputProvider;
62 class MDLogger;
63 }
64
65 typedef struct gmx_global_stat *gmx_global_stat_t;
66
67 void do_pbc_first_mtop(FILE *fplog, int ePBC, const matrix box,
68                        const gmx_mtop_t *mtop, rvec x[]);
69
70 void do_pbc_mtop(FILE *fplog, int ePBC, const matrix box,
71                  const gmx_mtop_t *mtop, rvec x[]);
72
73 /*! \brief Parallellizes put_atoms_in_box()
74  *
75  * This wrapper function around put_atoms_in_box() with the ugly manual
76  * workload splitting is needed to avoid silently introducing multithreading
77  * in tools.
78  * \param[in]    ePBC   The pbc type
79  * \param[in]    box    The simulation box
80  * \param[inout] x      The coordinates of the atoms
81  */
82 void put_atoms_in_box_omp(int ePBC, const matrix box, gmx::ArrayRef<gmx::RVec> x);
83
84
85
86 /* ROUTINES from stat.c */
87 gmx_global_stat_t global_stat_init(const t_inputrec *ir);
88
89 void global_stat_destroy(gmx_global_stat_t gs);
90
91 void global_stat(const gmx_global_stat *gs,
92                  const t_commrec *cr, gmx_enerdata_t *enerd,
93                  tensor fvir, tensor svir, rvec mu_tot,
94                  const t_inputrec *inputrec,
95                  gmx_ekindata_t *ekind,
96                  const gmx::Constraints *constr, t_vcm *vcm,
97                  int nsig, real *sig,
98                  int *totalNumberOfBondedInteractions,
99                  gmx_bool bSumEkinhOld, int flags);
100 /* All-reduce energy-like quantities over cr->mpi_comm_mysim */
101
102 bool do_per_step(int64_t step, int64_t nstep);
103 /* Return TRUE if io should be done */
104
105 /* ROUTINES from sim_util.c */
106
107 void print_time(FILE *out, gmx_walltime_accounting_t walltime_accounting,
108                 int64_t step, const t_inputrec *ir, const t_commrec *cr);
109
110 /*! \brief Print date, time, MPI rank and a description of this point
111  * in time.
112  *
113  * \param[in] log       logfile, or NULL to suppress output
114  * \param[in] rank      MPI rank to include in the output
115  * \param[in] title     Description to include in the output
116  * \param[in] the_time  Seconds since the epoch, e.g. as reported by gmx_gettime
117  */
118 void print_date_and_time(FILE *log, int rank, const char *title,
119                          double the_time);
120
121 void print_start(FILE *fplog, const t_commrec *cr,
122                  gmx_walltime_accounting_t walltime_accounting,
123                  const char *name);
124
125 void finish_run(FILE *log, const gmx::MDLogger &mdlog, const t_commrec *cr,
126                 const t_inputrec *inputrec,
127                 t_nrnb nrnb[], gmx_wallcycle_t wcycle,
128                 gmx_walltime_accounting_t walltime_accounting,
129                 nonbonded_verlet_t *nbv,
130                 const gmx_pme_t *pme,
131                 gmx_bool bWriteStat);
132
133 void calc_enervirdiff(FILE *fplog, int eDispCorr, t_forcerec *fr);
134
135 void calc_dispcorr(const t_inputrec *ir, const t_forcerec *fr,
136                    const matrix box, real lambda, tensor pres, tensor virial,
137                    real *prescorr, real *enercorr, real *dvdlcorr);
138
139 void initialize_lambdas(FILE *fplog, t_inputrec *ir, int *fep_state, gmx::ArrayRef<real> lambda, double *lam0);
140
141 void do_constrain_first(FILE *log, gmx::Constraints *constr,
142                         const t_inputrec *inputrec, const t_mdatoms *md,
143                         t_state *state);
144
145 void init_md(FILE *fplog,
146              const t_commrec *cr, gmx::IMDOutputProvider *outputProvider,
147              t_inputrec *ir, const gmx_output_env_t *oenv,
148              const MdrunOptions &mdrunOptions,
149              double *t, double *t0,
150              t_state *globalState, double *lam0,
151              t_nrnb *nrnb, gmx_mtop_t *mtop,
152              gmx_update_t **upd,
153              gmx::BoxDeformation *deform,
154              int nfile, const t_filenm fnm[],
155              gmx_mdoutf_t *outf, t_mdebin **mdebin,
156              tensor force_vir, tensor shake_vir,
157              tensor total_vir, tensor pres,
158              rvec mu_tot,
159              gmx_bool *bSimAnn, t_vcm **vcm,
160              gmx_wallcycle_t wcycle);
161
162 void init_rerun(FILE *fplog,
163                 const t_commrec *cr, gmx::IMDOutputProvider *outputProvider,
164                 t_inputrec *ir, const gmx_output_env_t *oenv,
165                 const MdrunOptions &mdrunOptions,
166                 t_state *globalState, double *lam0,
167                 t_nrnb *nrnb, gmx_mtop_t *mtop,
168                 int nfile, const t_filenm fnm[],
169                 gmx_mdoutf_t *outf, t_mdebin **mdebin,
170                 gmx_wallcycle_t wcycle);
171
172 /* Routine in sim_util.c */
173
174 gmx_bool use_GPU(const nonbonded_verlet_t *nbv);
175
176 #endif