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