Redefine the default boolean type to gmx_bool.
[alexxy/gromacs.git] / src / mdlib / mdebin_bar.h
1 /*
2  * 
3  *                This source code is part of
4  * 
5  *                 G   R   O   M   A   C   S
6  * 
7  *          GROningen MAchine for Chemical Simulations
8  * 
9  *                        VERSION 3.2.0
10  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
11  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
12  * Copyright (c) 2001-2004, The GROMACS development team,
13  * check out http://www.gromacs.org for more information.
14
15  * This program is free software; you can redistribute it and/or
16  * modify it under the terms of the GNU General Public License
17  * as published by the Free Software Foundation; either version 2
18  * of the License, or (at your option) any later version.
19  * 
20  * If you want to redistribute modifications, please consider that
21  * scientific software is very special. Version control is crucial -
22  * bugs must be traceable. We will be happy to consider code for
23  * inclusion in the official distribution, but derived work must not
24  * be called official GROMACS. Details are found in the README & COPYING
25  * files - if they are missing, get the official version at www.gromacs.org.
26  * 
27  * To help us fund GROMACS development, we humbly ask that you cite
28  * the papers on the package - you can find them in the top README file.
29  * 
30  * For more info, check our website at http://www.gromacs.org
31  * 
32  * And Hey:
33  * Gromacs Runs On Most of All Computer Systems
34  */
35
36 #ifndef _mdebin_bar_h
37 #define _mdebin_bar_h
38
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42
43 /* The functions & data structures here describe writing 
44    energy differences (or their histogram )for use with g_bar */
45
46 typedef struct 
47 {
48     real *dh; /* the raw energy differences */
49     unsigned int ndh; /* number of data points */
50     unsigned int ndhmax; /* the maximum number of points */
51
52     int *hist; /* the histogram values */
53     unsigned int nbins; /* the number of bins for the histogram to create */
54     gmx_large_int_t start; /* the starting point in units of spacing of the 
55                               histogram */
56     double spacing; /* the histogram spacing in kJ/mol */
57     unsigned int maxbin; /* highest bin with data */
58
59     double lambda; /* the 'foreign' lambda value associated with this delta H */
60     gmx_bool write_hist; /* whether to write histograms or raw data */
61     gmx_bool written; /* whether this data has already been written out */
62
63     double subblock_d[4]; /* data for an mdebin subblock for I/O. */
64     gmx_large_int_t subblock_l[2]; /* data for an mdebin subblock for I/O.  */
65 } t_mde_delta_h;
66
67 /* the type definition is in mdebin.h */
68 struct t_mde_delta_h_coll
69 {
70     t_mde_delta_h *dh; /* the delta hs */
71     int ndh; /* the number of delta_h structures */
72
73     double lambda; /* the native lambda associated with the free energy 
74                       calculations (at the time of the last sample) */
75     double delta_lambda; /* the change in lambda per time step */
76     double temp; /* the temperature */
77
78     double starttime; /* start time of the current dh collection */
79     double endtime; /* end time of the current dh collection */
80     gmx_bool starttime_set; /* whether the start time has been set */
81
82     double subblock_d[4]; /* data for writing an mdebin subblock for I/O */
83 };
84
85
86
87 /* initialize a collection of delta h histograms/sets 
88     dhc = the collection
89     ir = the input record */
90 void mde_delta_h_coll_init(t_mde_delta_h_coll *dhc,
91                            const t_inputrec *ir);
92 #if 0
93                            double temp,
94                            double native_lambda,
95                            int dh_table_size,
96                            double table_spacing,
97                            unsigned int ndhmax,
98                            int n_dh,
99                            double *flambda);
100 #endif
101
102 /* add a bunch of samples to the delta_h collection
103     dhc = the collection
104     U = the array with energies: from enerd->enerpart_lambda.
105     time = the current simulation time. */
106 void mde_delta_h_coll_add_dh(t_mde_delta_h_coll *dhc, double *U, double time);
107
108 /* write the data associated with the du blocks collection as a collection
109     of mdebin blocks.
110     dhc = the collection
111     fr = the enxio frame
112     nblock = the current number of blocks */
113 void mde_delta_h_coll_handle_block(t_mde_delta_h_coll *dhc,   
114                                    t_enxframe *fr, int nblock);
115
116
117 /* reset the collection of delta_h buffers for a new round of 
118    data gathering */
119 void mde_delta_h_coll_reset(t_mde_delta_h_coll *dhc);
120
121
122 /* set the energyhistory variables to save state */
123 void mde_delta_h_coll_update_energyhistory(t_mde_delta_h_coll *dhc, 
124                                            energyhistory_t *enerhist);
125
126 /* restore the variables from an energyhistory */
127 void mde_delta_h_coll_restore_energyhistory(t_mde_delta_h_coll *dhc, 
128                                             energyhistory_t *enerhist);
129
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif  /* _mdebin_bar_h */
136