Merge branch 'release-4-6' into release-5-0
[alexxy/gromacs.git] / src / gromacs / legacyheaders / mdebin.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, 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
38 #ifndef _mdebin_h
39 #define _mdebin_h
40
41 #include "typedefs.h"
42 #include "sysstuff.h"
43 #include "ebin.h"
44 #include "../fileio/enxio.h"
45 #include "types/state.h"
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 /* The functions & data structures here determine the content for outputting
52    the .edr file; the file format and actual writing is done with functions
53    defined in enxio.h */
54
55 /* forward declaration */
56 typedef struct t_mde_delta_h_coll t_mde_delta_h_coll;
57
58
59 /* This is the collection of energy averages collected during mdrun, and to
60    be written out to the .edr file. */
61 typedef struct {
62     double              delta_t;
63     t_ebin             *ebin;
64     int                 ie, iconrmsd, ib, ivol, idens, ipv, ienthalpy;
65     int                 isvir, ifvir, ipres, ivir, isurft, ipc, itemp, itc, itcb, iu, imu;
66     int                 ivcos, ivisc;
67     int                 nE, nEg, nEc, nTC, nTCP, nU, nNHC;
68     int                *igrp;
69     char              **grpnms;
70     int                 mde_n, mdeb_n;
71     real               *tmp_r;
72     rvec               *tmp_v;
73     gmx_bool            bConstr;
74     gmx_bool            bConstrVir;
75     gmx_bool            bTricl;
76     gmx_bool            bDynBox;
77     gmx_bool            bNHC_trotter;
78     gmx_bool            bPrintNHChains;
79     gmx_bool            bMTTK;
80     gmx_bool            bMu; /* true if dipole is calculated */
81     gmx_bool            bDiagPres;
82     gmx_bool            bVir;
83     gmx_bool            bPress;
84     gmx_bool            bSurft;
85     int                 f_nre;
86     int                 epc;
87     real                ref_p;
88     int                 etc;
89     int                 nCrmsd;
90     gmx_bool            bEner[F_NRE];
91     gmx_bool            bEInd[egNR];
92     char              **print_grpnms;
93
94     FILE               *fp_dhdl; /* the dhdl.xvg output file */
95     double             *dE;      /* energy components for dhdl.xvg output */
96     t_mde_delta_h_coll *dhc;     /* the delta U components (raw data + histogram) */
97     real               *temperatures;
98 } t_mdebin;
99
100
101 /* delta_h block type enum: the kinds of energies written out. */
102 enum
103 {
104     dhbtDH   = 0, /* delta H BAR energy difference*/
105     dhbtDHDL = 1, /* dH/dlambda derivative */
106     dhbtEN,       /* System energy */
107     dhbtPV,       /* pV term */
108     dhbtEXPANDED, /* expanded ensemble statistics */
109     dhbtNR
110 };
111
112
113
114 t_mdebin *init_mdebin(ener_file_t       fp_ene,
115                       const gmx_mtop_t *mtop,
116                       const t_inputrec *ir,
117                       FILE             *fp_dhdl);
118 /* Initiate MD energy bin and write header to energy file. */
119
120 FILE *open_dhdl(const char *filename, const t_inputrec *ir,
121                 const output_env_t oenv);
122 /* Open the dhdl file for output */
123
124 /* update the averaging structures. Called every time
125    the energies are evaluated. */
126 void upd_mdebin(t_mdebin       *md,
127                 gmx_bool        bDoDHDL,
128                 gmx_bool        bSum,
129                 double          time,
130                 real            tmass,
131                 gmx_enerdata_t *enerd,
132                 t_state        *state,
133                 t_lambda       *fep,
134                 t_expanded     *expand,
135                 matrix          lastbox,
136                 tensor          svir,
137                 tensor          fvir,
138                 tensor          vir,
139                 tensor          pres,
140                 gmx_ekindata_t *ekind,
141                 rvec            mu_tot,
142                 gmx_constr_t    constr);
143
144 void upd_mdebin_step(t_mdebin *md);
145 /* Updates only the step count in md */
146
147 void print_ebin_header(FILE *log, gmx_int64_t steps, double time, real lamb);
148
149 void print_ebin(ener_file_t fp_ene, gmx_bool bEne, gmx_bool bDR, gmx_bool bOR,
150                 FILE *log,
151                 gmx_int64_t step, double time,
152                 int mode, gmx_bool bCompact,
153                 t_mdebin *md, t_fcdata *fcd,
154                 gmx_groups_t *groups, t_grpopts *opts);
155
156
157
158 /* Between .edr writes, the averages are history dependent,
159    and that history needs to be retained in checkpoints.
160    These functions set/read the energyhistory_t structure
161    that is written to checkpoints in checkpoint.c */
162
163 /* Set the energyhistory_t data structure from a mdebin structure */
164 void update_energyhistory(energyhistory_t * enerhist, t_mdebin * mdebin);
165
166 /* Read the energyhistory_t data structure to a mdebin structure*/
167 void restore_energyhistory_from_state(t_mdebin        * mdebin,
168                                       energyhistory_t * enerhist);
169
170 #ifdef __cplusplus
171 }
172 #endif
173
174 #endif  /* _mdebin_h */