3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
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.
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.
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.
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.
30 * For more info, check our website at http://www.gromacs.org
33 * Gromacs Runs On Most of All Computer Systems
43 /* The functions & data structures here describe writing
44 energy differences (or their histogram )for use with g_bar */
46 /* Data for one foreign lambda, or derivative. */
49 real *dh; /* the raw energy differences */
50 unsigned int ndh; /* number of data points */
51 unsigned int ndhmax; /* the maximum number of points */
53 int nhist; /* the number of histograms. There can either be
55 1 (for 'foreign lambda' histograms)
56 2 (for derivative histograms: there's
57 a 'forward' and 'backward' histogram
58 containing the minimum and maximum
59 values, respectively). */
60 int *bin[2]; /* the histogram(s) */
61 double dx; /* the histogram spacing in kJ/mol. This is the
62 same for the two histograms */
63 unsigned int nbins; /* the number of bins */
64 gmx_large_int_t x0[2]; /* the starting point in units of spacing
66 unsigned int maxbin[2]; /* highest bin number with data */
68 gmx_bool derivative; /* whether this delta_h contains derivatives */
69 double lambda; /* the 'foreign' lambda value associated with this delta H */
70 gmx_bool written; /* whether this data has already been written out */
72 double subblock_d[4]; /* data for an mdebin subblock for I/O. */
73 gmx_large_int_t subblock_l[4]; /* data for an mdebin subblock for I/O. */
74 int subblock_i[4]; /* data for an mdebin subblock for I/O. */
77 /* the type definition is in mdebin.h */
78 struct t_mde_delta_h_coll
80 t_mde_delta_h *dh; /* the delta hs */
81 int ndh; /* the number of delta_h structures */
82 int ndhdl; /* number of derivative delta_hs */
84 double start_time; /* start time of the current dh collection */
85 double delta_time; /* time difference between samples */
86 gmx_bool start_time_set; /* whether the start time has been set */
88 double start_lambda; /* the native lambda associated with the free energy
89 calculations (at the time of the first sample) */
90 double delta_lambda; /* lambda difference between samples */
92 double temp; /* the temperature */
93 double subblock_d[5]; /* data for writing an mdebin subblock for I/O */
98 /* initialize a collection of delta h histograms/sets
100 ir = the input record */
101 void mde_delta_h_coll_init(t_mde_delta_h_coll *dhc,
102 const t_inputrec *ir);
104 /* add a bunch of samples to the delta_h collection
106 dhdl = the hamiltonian derivative
107 U = the array with energies: from enerd->enerpart_lambda.
108 time = the current simulation time. */
109 void mde_delta_h_coll_add_dh(t_mde_delta_h_coll *dhc,
111 double *U, double time,
112 double native_lambda);
114 /* write the data associated with the du blocks collection as a collection
118 nblock = the current number of blocks */
119 void mde_delta_h_coll_handle_block(t_mde_delta_h_coll *dhc,
120 t_enxframe *fr, int nblock);
123 /* reset the collection of delta_h buffers for a new round of
125 void mde_delta_h_coll_reset(t_mde_delta_h_coll *dhc);
128 /* set the energyhistory variables to save state */
129 void mde_delta_h_coll_update_energyhistory(t_mde_delta_h_coll *dhc,
130 energyhistory_t *enerhist);
132 /* restore the variables from an energyhistory */
133 void mde_delta_h_coll_restore_energyhistory(t_mde_delta_h_coll *dhc,
134 energyhistory_t *enerhist);
141 #endif /* _mdebin_bar_h */