Bayesian Analysis of Neutron Star Mass and Radius Observations
main.h
Go to the documentation of this file.
1 /** \file main.h
2  \brief File containing user's guide documentation
3 */
4 /** \mainpage
5 
6  \section ug_section User's Guide
7 
8  This document describes the open-source MPI implementation of a
9  Bayesian analysis of mass and radius data to determine the mass
10  versus radius curve and the equation of state of dense matter.
11  This package will principally be useful for those physicists and
12  astrophysicists who are already familiar with C++ and are
13  interested in modifying this code for their own use.
14 
15  This code was originally supported by Chandra grant TM1-12003X.
16 
17  This is a beta version. Use at your own risk.
18 
19  Currently, \bm is dual-hosted as an SVN respostory at
20  http://www.sourceforge.net/projects/bamr and a git repository at
21  http://www.github.com/awsteiner/bamr . The corresponding entry at
22  the Astrophysics Source Code Library (ASCL) is
23  http://ascl.net/1408.020 and at the ADS is
24  http://adsabs.harvard.edu/abs/2014ascl.soft08020S . This HTML
25  documentation is hosted at http://bamr.sourceforge.net. While you
26  are not required to do so, please consider citing the ASCL entry
27  following the method described at
28  http://ascl.net/wordpress/?page_id=351 , and the relevant
29  references in the bibliography below.
30 
31  If you are considering using this code for your research, I
32  encourage you to contact me so that I can help you with the
33  details and so that you can let me know if and how this code is
34  useful to you. Nevertheless, you are not required to contact me
35  and I will be improving documentation and updating this code as
36  time permits.
37 
38  \hline
39  \section contents_sect Contents
40 
41  - \ref install_sect
42  - \ref dl_sect
43  - \ref usage_sect
44  - \ref infile_sect
45  - \ref outfile_sect
46  - \ref detail_sect
47  - \ref ack_sect
48  - \ref ref_sect
49  - \ref license_page
50 
51  \hline
52  \section install_sect Installation
53 
54  The \bm executable requires the installation of
55  <a href="http://www.gnu.org/software/gsl">GSL</a>
56  (versions 1.15 and later),
57  <a href="http://www.hdfgroup.org">HDF5</a>
58  (versions 1.8.4 and later),
59  \htmlonly
60  the current development version of
61  <a href="http://o2scl.sourceforge.net">O<span style='position:
62  relative; top: 0.3em; font-size: 0.8em'>2</span>scl</a> (in the
63  <tt>branches/dev</tt> folder of the
64  <a href="http://o2scl.sourceforge.net">O<span style='position:
65  relative; top: 0.3em; font-size: 0.8em'>2</span>scl</a> distribution),
66  \endhtmlonly
67  \latexonly
68  O$_2$scl
69  \endlatexonly
70  and MPI (tested with openmpi-1.4.2). After these four packages are
71  successfully installed, you will need to edit the \c makefile and
72  then compile \bm before execution.
73 
74  \hline
75  \section dl_sect Download
76 
77  The most recent release version can be obtained from either
78  of the following:
79  \verbatim
80  svn checkout svn://svn.code.sf.net/p/bamr/code/trunk bamr
81  git clone https://github.com/awsteiner/bamr.git
82  \endverbatim
83 
84  \hline
85  \section usage_sect Basic Usage
86 
87  The basic usage is something like
88  \verbatim
89  ./bamr -model twop -run default.in -mcmc run1
90  \endverbatim
91  to perform a one day run with model \c twop with the input
92  file in \c default.in.
93 
94  There are several variables which can be modified with the
95  \c set command, e.g.
96  \verbatim
97  ./bamr -model twop -set max_time 43200 -run default.in -mcmc run2
98  \endverbatim
99  which runs for 12 hours instead of the default 24 hours.
100 
101  An example of an MPI invocation is
102  \verbatim
103  mpirun -np 4 ./bamr -set model twop -run default.in -mcmc run3 &
104  \endverbatim
105  which runs with four processors on the current machine.
106 
107  Also try
108  \verbatim
109  ./bamr -help
110  \endverbatim
111  which outputs some additional information on the
112  relevant functions and parameters.
113 
114  \hline
115  \section infile_sect Data Files
116 
117  The input data files are HDF5 files (typically named with a
118  <tt>.o2</tt> extension) which contain one \ref o2scl::table3d
119  object giving the probability density of one neutron star
120  observation as a slice in that table. The command
121  <tt>add-data</tt>, which adds a neutron star data set, takes four
122  arguments (and a fifth optional argument):
123  - The ASCII name of the neutron star for the output chains
124  - The input data file name
125  - The name of the \ref o2scl::table3d slice in which the data
126  is stored
127  - The initial guess for the neutron star's mass
128  - The fifth argument is the name of the \ref o2scl::table3d object
129  in the data file
130 
131  It is assumed that the "x" grid in the data file refers to the
132  radius and the "y" grid refers to the mass. The data need not
133  be normalized. By default \c bm renormalizes the data so that
134  the maximum probability is 1. If the parameter <tt>norm_max</tt>
135  is set to false, then the data is renormalized to have a total
136  integral of 1.
137 
138  \hline
139  \section outfile_sect Output Files
140 
141  Output is stored in HDF files with a prefix given by the
142  argument to the \c mcmc command, one set of files
143  for each processor. Output includes files with the
144  following suffixes (where X is the processor index):
145  - \c _X_out: Main output file containing full Markov chain(s)
146  and most of the parameter values
147  - \c _X_scr: Running output of entire simulation
148 
149  If the executable is run directly (without <tt>mpirun</tt>)
150  then X is always zero.
151 
152  Representations of the EOS and the \f$ M-R \f$ curve are stored on
153  grids for each Monte Carlo point. The number of points in the grid
154  is specified by the parameter <tt>grid_size</tt>. The energy
155  density grid is specified by the limits <tt>e_low</tt> and
156  <tt>e_high</tt>, the baryon density grid is specified by the
157  limits <tt>nb_low</tt> and <tt>nb_high</tt>, and the mass grid is
158  specified by the limits <tt>m_low</tt> and <tt>m_high</tt>.
159  A default run stores pressure as a function of energy density
160  (in columns with prefix <tt>P_</tt>), radius as a function
161  of mass (in columns with prefix <tt>R_</tt>), central pressure
162  as a function of mass (in columns with prefix <tt>PM_</tt>),
163  pressure as a function of baryon density (in columns with
164  prefix <tt>Pnb_</tt>), and energy per baryon as a function
165  of baryon density (in columns with prefix <tt>EoA_</tt>).
166 
167  \hline
168  \section detail_sect Some Details
169 
170  The basic functionality is provided in the \ref bamr::bamr_class
171  and each Monte Carlo point is an object of type \ref bamr::entry.
172  All of the "models" (EOS parameterizations) are children of \ref
173  bamr::model class.
174 
175  If the initial guess has no probability, then the code will fail.
176  This is indicated by the line \c "Initial weight zero." in
177  the \c _scr file. The easiest fix is just to change the initial
178  guess.
179 
180  In order to make the output more efficient, the table representing
181  the full Markov chain is divided up into tables with about 10,000
182  rows each, named \c markov_chain0, \c markov_chain1, and so on.
183  The total number of tables is stored in the integer
184  <tt>n_chains</tt>.
185 
186  Different models have different optimal MC step sizes. The step
187  size for each parameter is chosen to be the difference betwen the
188  high and low limiting values divided by the value \c step_fac .
189  Increasing or decreasing this value may give better results.
190 
191  \hline
192  \section model_sect EOS Model
193 
194  Several EOS models are provided. New models (i.e. new
195  children of the \ref bamr::model class) must perform several tasks
196 
197  - The function \ref bamr::model::compute_eos() should use the
198  parameters in the \ref bamr::entry argument to compute the EOS and
199  store it in the object returned by \ref
200  o2scl::nstar_cold::get_eos_results().
201 
202  - The energy density should be stored in a column named
203  <tt>ed</tt> and the pressure in <tt>pr</tt> with the correct units
204  set for each column (currently only <tt>1/fm^4</tt> is supported).
205 
206  - If \ref bamr::bamr_class::baryon_density is true and the EOS
207  model did not already compute the baryon density in a column named
208  <tt>"nb"</tt>, then \ref bamr::model::compute_eos() should return
209  one baryon density and energy density in \ref
210  bamr::model::baryon_density_point().
211 
212  - If the model provides the symmetry energy and its density
213  derivative, it should be stored as constants named <tt>"S"</tt>
214  and <tt>"L"</tt> in the table (in \f$ 1/\mathrm{fm} \f$ ).
215 
216  - Causality is automatically checked in bamr::compute_star(), but
217  the \ref bamr::model::compute_eos() function should check that the
218  pressure is not decreasing.
219 
220  - Finally, it is recommended to set the interpolation type in the
221  \ref o2scl::table_units object to linear interpolation.
222 
223  \hline
224  \section func_stack_sect Partial Function Call Stack
225 
226  The top-level functions in the call stack are:
227  - \ref bamr::bamr_class::run()
228  - \ref bamr::bamr_class::setup_cli()
229  - Command <tt>"model"</tt>: \ref bamr::bamr_class::set_model()
230  - Command <tt>"add-data"</tt>: \ref bamr::bamr_class::add_data()
231  - Command <tt>"first-point"</tt>:
232  \ref bamr::bamr_class::set_first_point()
233  - Command <tt>"mcmc"</tt>: \ref bamr::bamr_class::mcmc()
234  - \ref bamr::bamr_class::mcmc_init()
235  - \ref bamr::bamr_class::load_mc()
236  - \ref bamr::bamr_class::init_grids_table()
237  - \ref bamr::bamr_class::table_names_units()
238  - Run initial point:
239  - \ref bamr::bamr_class::compute_weight() (see below)
240  - \ref bamr::bamr_class::add_measurement()
241  - \ref bamr::bamr_class::fill_line()
242  - \ref bamr::bamr_class::output_best()
243  - Main MCMC loop:
244  - If at least one source: \ref bamr::bamr_class::select_mass()
245  - \ref bamr::bamr_class::compute_weight() (see below)
246  - \ref bamr::bamr_class::make_step()
247  - \ref bamr::bamr_class::add_measurement()
248  - \ref bamr::bamr_class::fill_line()
249  - \ref bamr::bamr_class::output_best()
250  - \ref bamr::bamr_class::update_files()
251  - If first file update: \ref bamr::bamr_class::first_update()
252  - Done with <tt>"mcmc"</tt> command.
253 
254  The operation of \ref bamr::bamr_class::compute_weight() can
255  be summarized with:
256  - \ref bamr::bamr_class::compute_weight()
257  - \ref bamr::bamr_class::compute_star()
258  - If the model has an EOS:
259  - \ref bamr::model::compute_eos() to compute the EOS
260  - Check pressure is increasing everywhere
261  - Compute baryon density if necessary
262  - Call \ref bamr::bamr_class::prepare_eos()
263  - Compute crust if necessary
264  - \ref o2scl::tov_solve::mvsr() to compute the mass-radius curve
265  - Check maximum mass
266  - If some masses are too large: \ref bamr::bamr_class::select_mass()
267  - Otherwise if there's no EOS: \ref bamr::model::compute_mr()
268  - Test for causality
269 
270  \hline
271  \section postproc_sect Postprocessing code
272 
273  The \c process program contains some code to analyze the \c bamr
274  output files. Principally, it attempts to remove autocorrelations
275  from the data by separating the data into blocks, and using the
276  fluctuations in the mean of each block to determine the
277  uncertainty in the mean. For example,
278 
279  \code
280  ./process -set xscale 197.33 -hist L out.o2 bamr_0_out
281  \endcode
282 
283  creates a new file called \c out.o2 with an object of type \ref
284  o2scl::table which represents a probability distribution for \f$ L
285  \f$ from the \c bamr output file named \c bamr_0_out . The option
286  <tt>-set xscale 197.33</tt> ensures that the new table converts
287  from \f$ \mathrm{fm}^{-1} \f$ to \f$ \mathrm{Mev} \f$ . The five
288  columns are \c reps, \c avgs, \c errs, \c plus and \c minus, which
289  give:
290 
291  - The central bin values for \f$ L \f$ (in \f$ \mathrm{MeV} \f$)
292  - The probability of the specified value
293  - The uncertainty in the probabiliy of the specified value
294  - Column 2 plus column 3
295  - Column 2 minus column 3
296 
297  \hline
298  \section changelog_sect Recent Change Log
299 
300  April 2015: Added process.cpp and created new functions \ref
301  bamr::model::setup_params and \ref bamr::model::remove_params() .
302  Added several new models.
303 
304  \hline
305  \section ack_sect Acknowledgements
306 
307  I would like to thank Paulo Bedaque, Ed Brown, Farrukh Fattoyev,
308  Stefano Gandolfi, Jim Lattimer, and Will Newton for their
309  collaboration on these projects.
310 
311  \hline
312  \section ref_sect Bibliography
313 
314  Some of the references which contain links should direct you to
315  the work referred to using its DOI identifer.
316 
317  \anchor Bedaque15sv Bedaque15sv:
318  <a href="http://dx.doi.org/10.1103/PhysRevLett.114.031103">
319  P. Bedaque and A.W. Steiner</a>,
320  Phys. Rev. Lett. \b 114 (2015).
321 
322  \anchor Lattimer14co Lattimer14co:
323  <a href="http://dx.doi.org/10.1140/epja/i2014-14040-y">
324  J.M. Lattimer and A.W. Steiner</a>,
325  Eur. Phys. J. A \b 50 (2014) 40.
326 
327  \anchor Lattimer14ns Lattimer14ns:
328  <a href="http://dx.doi.org/10.1088/0004-637X/784/2/123">
329  J.M. Lattimer and A.W. Steiner</a>,
330  Astrophys. J. \b 784 (2014) 123.
331 
332  \anchor Steiner10te Steiner10te:
333  <a href="http://dx.doi.org/10.1088/0004-637X/722/1/33">
334  A.W. Steiner, J.M. Lattimer, E.F. Brown</a>,
335  Astrophys. J. \b 722 (2010) 33.
336 
337  \anchor Steiner12cn Steiner12cn:
338  <a href="http://dx.doi.org/10.1103/PhysRevLett.108.081102">
339  A.W. Steiner and S. Gandolfi</a>,
340  Phys. Rev. Lett. \b 108 (2012) 081102.
341 
342  \anchor Steiner13tn Steiner13tn:
343  <a href="http://dx.doi.org/10.1088/2041-8205/765/1/L5">
344  A.W. Steiner, J.M. Lattimer, E.F. Brown</a>,
345  Astrophys. J. Lett. \b 765 (2013) 5.
346 
347  \anchor Steiner15un Steiner15un:
348  <a href="http://dx.doi.org/10.1103/PhysRevC.91.015804">
349  A.W. Steiner, S. Gandolfi, F.J. Fattoyev, and W.G. Newton</a>,
350  Phys. Rev. C \b 91 (2015) 015804.
351 
352  \page license_page Licensing
353 
354  All code is licensed under version 3 of the GPL as provided in the
355  files \c COPYING and in \c doc/gpl_license.txt.
356 
357  \verbinclude gpl_license.txt
358 
359  This documentation is provided under the GNU Free Documentation
360  License, as given below and provided in \c
361  doc/fdl_license.txt.
362 
363  \verbinclude fdl_license.txt
364 */

Documentation generated with Doxygen. Bamr documentation is under the GNU Free Documentation License.