diff --git a/doc/binary_c2.html b/doc/binary_c2.html index 3c4324765622cf6da2f0751129caca33b53dcc39..bc1d7752df7f33aa7bea674f8d6f774ae7098ccd 100644 --- a/doc/binary_c2.html +++ b/doc/binary_c2.html @@ -317,10 +317,10 @@ div.float-caption { <div class='lyxtoc-3'><a href='#magicparlabel-72' class='tocentry'>2.1 Download and build <i>binary_c</i></a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-284' class='tocentry'>2.2 Running a single- or binary-star system</a> +<div class='lyxtoc-3'><a href='#magicparlabel-304' class='tocentry'>2.2 Running a single- or binary-star system</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-317' class='tocentry'>2.3 Running a grid of stars with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class='lyxtoc-3'><a href='#magicparlabel-337' class='tocentry'>2.3 Running a grid of stars with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> <mstyle mathvariant='normal'> @@ -334,298 +334,298 @@ div.float-caption { </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-472' class='tocentry'>3 Introduction</a> +<div class='lyxtoc-2'><a href='#magicparlabel-492' class='tocentry'>3 Introduction</a> -<div class='lyxtoc-3'><a href='#magicparlabel-513' class='tocentry'>3.1 Binary_c: tools for stellar evolution and population synthesis</a> +<div class='lyxtoc-3'><a href='#magicparlabel-533' class='tocentry'>3.1 Binary_c: tools for stellar evolution and population synthesis</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-523' class='tocentry'>4 Installation</a> +<div class='lyxtoc-2'><a href='#magicparlabel-543' class='tocentry'>4 Installation</a> -<div class='lyxtoc-3'><a href='#magicparlabel-526' class='tocentry'>4.1 Quick start</a> +<div class='lyxtoc-3'><a href='#magicparlabel-546' class='tocentry'>4.1 Quick start</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-544' class='tocentry'>4.2 Getting <i>binary_c</i></a> +<div class='lyxtoc-3'><a href='#magicparlabel-566' class='tocentry'>4.2 Getting <i>binary_c</i></a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-651' class='tocentry'>4.3 System Requirements</a> +<div class='lyxtoc-3'><a href='#magicparlabel-673' class='tocentry'>4.3 System Requirements</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-815' class='tocentry'>4.4 Configuring and building <i>binary_c</i></a> +<div class='lyxtoc-3'><a href='#magicparlabel-866' class='tocentry'>4.4 Configuring and building <i>binary_c</i></a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-1036' class='tocentry'>4.5 Testing <i>binary_c</i></a> +<div class='lyxtoc-3'><a href='#magicparlabel-1191' class='tocentry'>4.5 Testing <i>binary_c</i></a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-1085' class='tocentry'>4.6 Directory structure</a> +<div class='lyxtoc-3'><a href='#magicparlabel-1234' class='tocentry'>4.6 Directory structure</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-1115' class='tocentry'>4.7 Building binary_grid2: the population synthesis module</a> +<div class='lyxtoc-3'><a href='#magicparlabel-1277' class='tocentry'>4.7 Building binary_grid2: the population synthesis module</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-1602' class='tocentry'>4.8 <em><i>binary_grid2</i></em> backends</a> +<div class='lyxtoc-3'><a href='#magicparlabel-1764' class='tocentry'>4.8 <em><i>binary_grid2</i></em> backends</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-1854' class='tocentry'>5 Evolving single and binary stars</a> +<div class='lyxtoc-2'><a href='#magicparlabel-2024' class='tocentry'>5 Evolving single and binary stars</a> -<div class='lyxtoc-3'><a href='#magicparlabel-1857' class='tocentry'>5.1 Running</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2027' class='tocentry'>5.1 Running</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-2008' class='tocentry'>6 Making populations of stars with <i>binary_grid2</i></a> +<div class='lyxtoc-2'><a href='#magicparlabel-2178' class='tocentry'>6 Making populations of stars with <i>binary_grid2</i></a> -<div class='lyxtoc-3'><a href='#magicparlabel-2028' class='tocentry'>6.1 Introduction</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2198' class='tocentry'>6.1 Introduction</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2051' class='tocentry'>6.2 Aims: what the grid does and why</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2221' class='tocentry'>6.2 Aims: what the grid does and why</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2053' class='tocentry'>6.3 Grid dimensions</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2223' class='tocentry'>6.3 Grid dimensions</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2066' class='tocentry'>6.4 What to do with the grid</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2236' class='tocentry'>6.4 What to do with the grid</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2075' class='tocentry'>6.5 Grid setup (in theory)</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2245' class='tocentry'>6.5 Grid setup (in theory)</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2096' class='tocentry'>6.6 Data parsing</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2266' class='tocentry'>6.6 Data parsing</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2108' class='tocentry'>6.7 Running grids of stars</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2278' class='tocentry'>6.7 Running grids of stars</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2249' class='tocentry'>6.8 Important Subroutines in your grid script</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2419' class='tocentry'>6.8 Important Subroutines in your grid script</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2284' class='tocentry'>6.9 Your <em>grid script </em>and coupling your population synthesis to <em><i>binary_c</i>/nucsyn</em></a> +<div class='lyxtoc-3'><a href='#magicparlabel-2454' class='tocentry'>6.9 Your <em>grid script </em>and coupling your population synthesis to <em><i>binary_c</i>/nucsyn</em></a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2546' class='tocentry'>6.10 Save your data – or process on the fly?</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2716' class='tocentry'>6.10 Save your data – or process on the fly?</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2577' class='tocentry'>6.11 Flexigrid</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2747' class='tocentry'>6.11 Flexigrid</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2599' class='tocentry'>6.12 Setup in your grid script</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2769' class='tocentry'>6.12 Setup in your grid script</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2699' class='tocentry'>6.13 3D grid example</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2869' class='tocentry'>6.13 3D grid example</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2755' class='tocentry'>6.14 Viewing The (Automatically Generated) Gridcode </a> +<div class='lyxtoc-3'><a href='#magicparlabel-2925' class='tocentry'>6.14 Viewing The (Automatically Generated) Gridcode </a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2783' class='tocentry'>6.15 Error handling</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2953' class='tocentry'>6.15 Error handling</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2807' class='tocentry'>6.16 Flexigrid variable options</a> +<div class='lyxtoc-3'><a href='#magicparlabel-2977' class='tocentry'>6.16 Flexigrid variable options</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2854' class='tocentry'>6.17 Flexigrid loop structure</a> +<div class='lyxtoc-3'><a href='#magicparlabel-3024' class='tocentry'>6.17 Flexigrid loop structure</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-2914' class='tocentry'>6.18 <i>binary_grid</i> with <em>HTCondor</em></a> +<div class='lyxtoc-3'><a href='#magicparlabel-3084' class='tocentry'>6.18 <i>binary_grid</i> with <em>HTCondor</em></a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-3343' class='tocentry'>6.19 Binary_grid with <em>slurm</em></a> +<div class='lyxtoc-3'><a href='#magicparlabel-3513' class='tocentry'>6.19 Binary_grid with <em>slurm</em></a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-3472' class='tocentry'>6.20 Initial distributions (IMF etc.) </a> +<div class='lyxtoc-3'><a href='#magicparlabel-3642' class='tocentry'>6.20 Initial distributions (IMF etc.) </a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-3493' class='tocentry'>6.21 Grid spacings</a> +<div class='lyxtoc-3'><a href='#magicparlabel-3663' class='tocentry'>6.21 Grid spacings</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-3503' class='tocentry'>6.22 The <span class='math'>\binarygrid</span> +<div class='lyxtoc-3'><a href='#magicparlabel-3673' class='tocentry'>6.22 The <span class='math'>\binarygrid</span> thread model</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-3664' class='tocentry'>6.23 Debugging, benchmarking and advanced topics</a> +<div class='lyxtoc-3'><a href='#magicparlabel-3834' class='tocentry'>6.23 Debugging, benchmarking and advanced topics</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-3866' class='tocentry'>6.24 Future Plans</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4036' class='tocentry'>6.24 Future Plans</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-3870' class='tocentry'>6.25 Cookbook</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4040' class='tocentry'>6.25 Cookbook</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-4081' class='tocentry'>6.26 FAQ</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4251' class='tocentry'>6.26 FAQ</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-4185' class='tocentry'>6.27 Multi-core scaling</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4355' class='tocentry'>6.27 Multi-core scaling</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-4193' class='tocentry'>6.28 Testing Setup</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4363' class='tocentry'>6.28 Testing Setup</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-4243' class='tocentry'>6.29 Results</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4413' class='tocentry'>6.29 Results</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-4300' class='tocentry'>6.30 Conclusions</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4470' class='tocentry'>6.30 Conclusions</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-4385' class='tocentry'>7 <em><i>binary_c</i> </em>API</a> +<div class='lyxtoc-2'><a href='#magicparlabel-4555' class='tocentry'>7 <em><i>binary_c</i> </em>API</a> -<div class='lyxtoc-3'><a href='#magicparlabel-4389' class='tocentry'>7.1 Naming conventions</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4559' class='tocentry'>7.1 Naming conventions</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-4509' class='tocentry'>7.2 Using the API</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4679' class='tocentry'>7.2 Using the API</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-4742' class='tocentry'>7.3 Standard functions</a> +<div class='lyxtoc-3'><a href='#magicparlabel-4912' class='tocentry'>7.3 Standard functions</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-4989' class='tocentry'>7.4 Extension functions</a> +<div class='lyxtoc-3'><a href='#magicparlabel-5159' class='tocentry'>7.4 Extension functions</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-5039' class='tocentry'>7.5 API Examples</a> +<div class='lyxtoc-3'><a href='#magicparlabel-5209' class='tocentry'>7.5 API Examples</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-5259' class='tocentry'>8 Code description and internals</a> +<div class='lyxtoc-2'><a href='#magicparlabel-5429' class='tocentry'>8 Code description and internals</a> -<div class='lyxtoc-3'><a href='#magicparlabel-5262' class='tocentry'>8.1 History</a> +<div class='lyxtoc-3'><a href='#magicparlabel-5432' class='tocentry'>8.1 History</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-5324' class='tocentry'>8.2 How the <em><i>binary_c</i></em> code works</a> +<div class='lyxtoc-3'><a href='#magicparlabel-5494' class='tocentry'>8.2 How the <em><i>binary_c</i></em> code works</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-5332' class='tocentry'>8.3 Memory management in <span class='math'>binary_c</i></span> +<div class='lyxtoc-3'><a href='#magicparlabel-5502' class='tocentry'>8.3 Memory management in <span class='math'>binary_c</i></span> </a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-5705' class='tocentry'>8.4 Output</a> +<div class='lyxtoc-3'><a href='#magicparlabel-5875' class='tocentry'>8.4 Output</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-5785' class='tocentry'>8.5 Debugging <span class='math'>binary_c</i></span> +<div class='lyxtoc-3'><a href='#magicparlabel-5955' class='tocentry'>8.5 Debugging <span class='math'>binary_c</i></span> </a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-6078' class='tocentry'>8.6 Events</a> +<div class='lyxtoc-3'><a href='#magicparlabel-6248' class='tocentry'>8.6 Events</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-6333' class='tocentry'>8.7 Timestepping</a> +<div class='lyxtoc-3'><a href='#magicparlabel-6503' class='tocentry'>8.7 Timestepping</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-6412' class='tocentry'>8.8 Code layout, header files, flow</a> +<div class='lyxtoc-3'><a href='#magicparlabel-6582' class='tocentry'>8.8 Code layout, header files, flow</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-6814' class='tocentry'>8.9 nucsyn</a> +<div class='lyxtoc-3'><a href='#magicparlabel-6984' class='tocentry'>8.9 nucsyn</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7153' class='tocentry'>8.10 Coding style</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7323' class='tocentry'>8.10 Coding style</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7215' class='tocentry'>8.11 Control scripts</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7385' class='tocentry'>8.11 Control scripts</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-7235' class='tocentry'>9 Advanced Configuration</a> +<div class='lyxtoc-2'><a href='#magicparlabel-7405' class='tocentry'>9 Advanced Configuration</a> -<div class='lyxtoc-3'><a href='#magicparlabel-7259' class='tocentry'>9.1 configure</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7424' class='tocentry'>9.1 Meson configuation</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7286' class='tocentry'>9.2 <i>binary_c</i>-config</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7442' class='tocentry'>9.2 <i>binary_c</i>-config</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7379' class='tocentry'>9.3 Makefile -D…</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7535' class='tocentry'>9.3 Makefile -D…</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7413' class='tocentry'>9.4 binary_c_code_options.h</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7565' class='tocentry'>9.4 binary_c_code_options.h</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7452' class='tocentry'>9.5 binary_c_parameters.h</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7604' class='tocentry'>9.5 binary_c_parameters.h</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7616' class='tocentry'>9.6 nucsyn/nucsyn_parameters.h</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7768' class='tocentry'>9.6 nucsyn/nucsyn_parameters.h</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-7735' class='tocentry'>10 <em><i>binary_c</i> </em>software development cycle</a> +<div class='lyxtoc-2'><a href='#magicparlabel-7862' class='tocentry'>10 <em><i>binary_c</i> </em>software development cycle</a> -<div class='lyxtoc-3'><a href='#magicparlabel-7739' class='tocentry'>10.1 The git revolution</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7866' class='tocentry'>10.1 The git revolution</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7762' class='tocentry'>10.2 The master(trunk)–branch model</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7889' class='tocentry'>10.2 The master(trunk)–branch model</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-7847' class='tocentry'>11 Cookbook</a> +<div class='lyxtoc-2'><a href='#magicparlabel-7974' class='tocentry'>11 Cookbook</a> -<div class='lyxtoc-3'><a href='#magicparlabel-7848' class='tocentry'>11.1 How to log output</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7975' class='tocentry'>11.1 How to log output</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7862' class='tocentry'>11.2 How to find which source files contain a string</a> +<div class='lyxtoc-3'><a href='#magicparlabel-7989' class='tocentry'>11.2 How to find which source files contain a string</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7886' class='tocentry'>11.3 How to build with debugging output</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8013' class='tocentry'>11.3 How to build with debugging output</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7920' class='tocentry'>11.4 How to check for NaNs (not a numbers)</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8047' class='tocentry'>11.4 How to check for NaNs (not a numbers)</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7942' class='tocentry'>11.5 How to exit <em><i>binary_c</i></em></a> +<div class='lyxtoc-3'><a href='#magicparlabel-8069' class='tocentry'>11.5 How to exit <em><i>binary_c</i></em></a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-7965' class='tocentry'>11.6 How to debug segfaults</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8092' class='tocentry'>11.6 How to debug segfaults</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8005' class='tocentry'>11.7 How to debug memory leaks</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8133' class='tocentry'>11.7 How to debug memory leaks</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8043' class='tocentry'>11.8 How to show the arguments that <em>tbse</em> would use, but do not evolve a star</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8172' class='tocentry'>11.8 How to show the arguments that <em>tbse</em> would use, but do not evolve a star</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8049' class='tocentry'>11.9 How to run a star which has the arguments in a file</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8178' class='tocentry'>11.9 How to run a star which has the arguments in a file</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8055' class='tocentry'>11.10 How to use profile guided optimization (PGO)</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8184' class='tocentry'>11.10 How to use profile guided optimization (PGO)</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8080' class='tocentry'>11.11 How to get help</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8209' class='tocentry'>11.11 How to get help</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8095' class='tocentry'>11.12 How to add a parameter</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8224' class='tocentry'>11.12 How to add a parameter</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8114' class='tocentry'>11.13 How to build on a Mac</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8243' class='tocentry'>11.13 How to build on a Mac</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8116' class='tocentry'>11.14 How to build as a shared library</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8245' class='tocentry'>11.14 How to build as a shared library</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8122' class='tocentry'>11.15 How to calculate stellar yields or population statistics</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8251' class='tocentry'>11.15 How to calculate stellar yields or population statistics</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8168' class='tocentry'>11.16 <em>bash</em> autocompletion of <i>binary_c</i> arguments</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8297' class='tocentry'>11.16 <em>bash</em> autocompletion of <i>binary_c</i> arguments</a> </div> -<div class='lyxtoc-3'><a href='#magicparlabel-8198' class='tocentry'>11.17 How to find the <em>git</em> revision and <em>git</em> URL</a> +<div class='lyxtoc-3'><a href='#magicparlabel-8327' class='tocentry'>11.17 How to find the <em>git</em> revision and <em>git</em> URL</a> </div> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-8234' class='tocentry'>12 Changelog</a> +<div class='lyxtoc-2'><a href='#magicparlabel-8363' class='tocentry'>12 Changelog</a> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-8262' class='tocentry'>13 Acknowledgements</a> +<div class='lyxtoc-2'><a href='#magicparlabel-8391' class='tocentry'>13 Acknowledgements</a> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-8269' class='tocentry'>A Grid options (<em>grid_options</em> hash)</a> +<div class='lyxtoc-2'><a href='#magicparlabel-8398' class='tocentry'>A Grid options (<em>grid_options</em> hash)</a> </div> -<div class='lyxtoc-2'><a href='#magicparlabel-8326' class='tocentry'>B Binary_c/nucsyn options (<em>bse_options</em> hash)</a> +<div class='lyxtoc-2'><a href='#magicparlabel-8455' class='tocentry'>B Binary_c/nucsyn options (<em>bse_options</em> hash)</a> </div> </div> </div> @@ -688,14 +688,16 @@ $y++;</pre><br /> <h2 class="section" id='magicparlabel-70'><span class="section_label">2</span> Quick start guide</h2> <div class="standard" id='magicparlabel-71'>This section is a quick guide to getting <i>binary_c</i> and <i>binary_grid</i> to work. Please start reading at Section <a href="#sec_Introduction">3</a> if you want the full manual with complete installation instructions in Section <a href="#subsec_Getting_binary_c">4.2</a>.</div> <h3 class="subsection" id='magicparlabel-72'><span class="subsection_label">2.1</span> Download and build <i>binary_c</i></h3> -<div class="standard" id='magicparlabel-73'>In the following, I assume you have internet access. I also assume you are building for a generic 64-bit CPU on Linux, and have software like <span class="flex_software">gcc</span>, <span class="flex_software">make</span>, <span class="flex_software">Perl</span>, <span class="flex_software">wget</span> and other standard build tools installed. I assume your temporary directory is <span class="flex_file">/tmp</span> and you use a shell like <span class="flex_software">bash</span>. Installed libraries will be put in <span class="flex_file">$HOME/lib</span> (with associated files in <span class="flex_file">$HOME/include</span> etc.) so they are private to the user, rather than in system locations. <i>binary_c</i> will be installed in <span class="flex_file">$HOME/progs/stars/<i>binary_c</i></span> and other software will be downloaded and built in <span class="flex_file">$HOME/git</span>.</div> +<div class="standard" id='magicparlabel-73'>In the following, I assume you have internet access. I also assume you are building for a generic 64-bit CPU on Linux, and have software like <span class="flex_software">gcc</span>, <span class="flex_software">Perl5</span>, <span class="flex_software">Python3</span>, <span class="flex_software">wget</span> and other standard build tools installed. I assume your temporary directory is <span class="flex_file">/tmp</span> and you use a shell like <span class="flex_software">bash</span>. Installed libraries will be put in <span class="flex_file">$HOME/lib</span> (with associated files in <span class="flex_file">$HOME/include</span> etc.) so they are private to the user, rather than in system locations. <i>binary_c</i> will be installed in <span class="flex_file">$HOME/progs/stars/<i>binary_c</i></span> and other software will be downloaded and built in <span class="flex_file">$HOME/git</span>.</div> <ul class="itemize" id='magicparlabel-114'><li class="itemize_item">First, you need access to the git server. Please try to log in with a <em>gmail</em> account at gitlab.eps.surrey.ac.uk and when it blocks you, email Rob (<a href="r.izzard@surrey.ac.uk">r.izzard@surrey.ac.uk</a>) to ask for access. You will then be granted access.</li> <li class="itemize_item">(Do this once) Add to your <span class="flex_file">.bashrc</span> or equivalent shell profile<br /> <pre class ='listings'>export BINARY_C=$HOME/progs/stars/<i>binary_c</i></pre><br /> and<em> <b>restart your shell</b> </em>so that the environment variable <span class="flex_envvar">BINARY_C</span> is defined.</li> -<li class="itemize_item">(Do this once) Set up LD_LIBRARY_PATH in <span class="flex_file">.bashrc</span> unless it already points to <span class="flex_file">$HOME/lib</span>. Add the following to <span class="flex_file">.bashrc</span><br /> -<pre class ='listings'>export LD_LIBRARY_PATH=$HOME/lib</pre><br /> +<li class="itemize_item">(Do this once) Set up <span class="flex_envvar">LIBRARY_PATH</span> and <span class="flex_envvar">LD_LIBRARY_PATH</span> in <span class="flex_file">.bashrc</span> unless it already points to <span class="flex_file">$HOME/lib</span>. Add the following to <span class="flex_file">.bashrc</span><br /> +<pre class ='listings'>export LD_LIBRARY_PATH=$HOME/lib +export LIBRARY_PATH=$HOME/lib +</pre><br /> and <em><b>restart your shell</b></em>.</li> <li class="itemize_item">If you can, install <span class="flex_software">libbsd</span> – this is a system package so requires root access. You will require the <em>development</em> version which contains the various header files, this is usually called <span class="flex_software">libbsd-dev</span> (or similar). <span class="flex_software">libbsd</span> is not required for <i>binary_c</i> but is useful and speeds up the code.</li> <li class="itemize_item">If you can, install RGI's custom <em>GSL</em> which has a few small fixes to make it behave better. At present, the latest release is 2.5. <br /> @@ -734,18 +736,22 @@ mkdir -p $HOME/progs/stars/ cd $HOME/progs/stars git clone gitlab@gitlab.eps.surrey.ac.uk:ri0005/<i>binary_c</i>.git</pre><br /> </li> -<li class="itemize_item">Change to the <i>binary_c</i> directory, configure and build both <i>binary_c</i> and its shared library.<br /> +<li class="itemize_item">Change to the <i>binary_c</i> directory, configure and build both <i>binary_c</i> and its shared library. Note: if builddir already exists, you need to add <br /> +<pre class\s*='listings bash'>$ --reconfigure</pre><br /> + to the <span class="flex_software">Meson</span> command. <br /> <pre class ='listings'>cd $BINARY_C -./configure generic -make cleanall -make -make <i>libbinary_c.so</i></pre><br /> +meson builddir --buildtype release +cd builddir +ninja +ninja <i>libbinary_c.so</i> +ninja libbinary_c_symlink +cd ..</pre><br /> </li> <li class="itemize_item">Install <span class="flex_software">perlbrew</span> which is your own, custom <span class="flex_software">Perl</span>. <br /> <pre class ='listings'>export NTHREADS=`cat /proc/cpuinfo |grep cpu\ famil|wc -l` export LATEST_PERL=`perlbrew available | grep “^[[:space:]]\+perl” | head -1` wget --no-check-certificate -O - http://install.perlbrew.pl | bash -perlbrew -v install perl-5.31.3 --thread --multi --64bitall --notest -Dusethreads -Duselargefiles -Dcccdlflags=-fPIC -Dpager=/usr/bin/sensible-pager -Doptimize="-O3 mtune=generic" -Duseshrplib -j $NTHREADS</pre><br /> +perlbrew -v install perl-5.31.5 --thread --multi --64bitall --notest -Dusethreads -Duselargefiles -Dcccdlflags=-fPIC -Dpager=/usr/bin/sensible-pager -Doptimize="-O3 mtune=generic" -Duseshrplib -j $NTHREADS</pre><br /> If you have problems with <span class="flex_software">wget</span>, try removing the <span class="flex_args">–no-check-certificate</span>. <br /> @@ -770,10 +776,10 @@ cd src/perl ./install_modules.pl</pre><br /> you may well need to run the <span class="flex_software">install_modules.pl</span> script repeatedly to satisfy dependencies, or if there is a failure check the error message and install the module manually using the <span class="flex_software">cpanm</span> command.</li> </ul> -<h3 class="subsection" id='magicparlabel-284'><span class="subsection_label">2.2</span> Running a single- or binary-star system</h3> -<div class="standard" id='magicparlabel-285'>Go to the <span class="flex_envvar">$BINARY_C</span> directory and open the file <span class="flex_file">tbse</span> (where <em>tbse</em> means “test binary-star evolution”). </div> +<h3 class="subsection" id='magicparlabel-304'><span class="subsection_label">2.2</span> Running a single- or binary-star system</h3> +<div class="standard" id='magicparlabel-305'>Go to the <span class="flex_envvar">$BINARY_C</span> directory and open the file <span class="flex_file">tbse</span> (where <em>tbse</em> means “test binary-star evolution”). </div> -<ul class="itemize" id='magicparlabel-294'><li class="itemize_item">In this file you can set every physical parameter of <i>binary_c</i>, for example the masses and orbital parameters<br /> +<ul class="itemize" id='magicparlabel-314'><li class="itemize_item">In this file you can set every physical parameter of <i>binary_c</i>, for example the masses and orbital parameters<br /> <pre class ='listings'># stellar masses (solar units) M1=6 M2=0.9 @@ -805,7 +811,7 @@ ECCENTRICITY=0.0</pre><br /> </mrow> </mrow></mstyle></math></li> </ul> -<h3 class="subsection" id='magicparlabel-317'><span class="subsection_label">2.3</span> Running a grid of stars with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<h3 class="subsection" id='magicparlabel-337'><span class="subsection_label">2.3</span> Running a grid of stars with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> <mstyle mathvariant='normal'> @@ -817,7 +823,7 @@ ECCENTRICITY=0.0</pre><br /> </mrow> </mrow></mstyle></math></h3> -<ul class="itemize" id='magicparlabel-318'><li class="itemize_item">Open the file $BINARY_C/src/perl/scripts2/template.pl</li> +<ul class="itemize" id='magicparlabel-338'><li class="itemize_item">Open the file $BINARY_C/src/perl/scripts2/template.pl</li> <li class="itemize_item">This is an example of how to run <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> @@ -972,22 +978,22 @@ $population->evolve();</pre><br /> </pre><br /> </li> </ul> -<h2 class="section" id='magicparlabel-472'><span class="section_label">3</span> Introduction</h2> -<div class="standard" id='magicparlabel-473'><div id="sec_Introduction"></div> +<h2 class="section" id='magicparlabel-492'><span class="section_label">3</span> Introduction</h2> +<div class="standard" id='magicparlabel-493'><div id="sec_Introduction"></div> From <a href='#LyXCite-Izzard_et_al_2003c_Monash'><span class="bib-abbrvciteauthor">Izzard and Tout</span></a> (<span class="bib-year">2003</span>):</div> -<blockquote class="quotation" id='magicparlabel-474'><div class="quotation_item">For many years the study of stellar yields and galactic chemical evolution (GCE) has gone on assuming, mainly for simplicity, that stars are isolated objects (one exception being <a href='#LyXCite-2002NewA____7___55D'><span class="bib-abbrvciteauthor">De Donder and Vanbeveren</span>, <span class="bib-year">2002</span></a>). Reality bites deeply into this picture with the observation that most stars are in multiple systems and that many of these systems are interacting. The state of the art in binary star nucleosynthesis is focused on explosive events such as type Ia supernovae and classical novae but other binary star processes contribute to pollution of the interstellar medium. Mass-transfer by Roche-lobe overflow (RLOF) occurs particularly when the stellar radius is growing rapidly and so commonly when one star is on the asymptotic giant branch (AGB).</div> +<blockquote class="quotation" id='magicparlabel-494'><div class="quotation_item">For many years the study of stellar yields and galactic chemical evolution (GCE) has gone on assuming, mainly for simplicity, that stars are isolated objects (one exception being <a href='#LyXCite-2002NewA____7___55D'><span class="bib-abbrvciteauthor">De Donder and Vanbeveren</span>, <span class="bib-year">2002</span></a>). Reality bites deeply into this picture with the observation that most stars are in multiple systems and that many of these systems are interacting. The state of the art in binary star nucleosynthesis is focused on explosive events such as type Ia supernovae and classical novae but other binary star processes contribute to pollution of the interstellar medium. Mass-transfer by Roche-lobe overflow (RLOF) occurs particularly when the stellar radius is growing rapidly and so commonly when one star is on the asymptotic giant branch (AGB).</div> </blockquote> -<div class="standard" id='magicparlabel-475'>A recent review of binary stars can be found in <a href='#LyXCite-2017PASA___34____1D'><span class="bib-abbrvciteauthor">De Marco and Izzard</span></a> (<span class="bib-year">2017</span>).</div> +<div class="standard" id='magicparlabel-495'>A recent review of binary stars can be found in <a href='#LyXCite-2017PASA___34____1D'><span class="bib-abbrvciteauthor">De Marco and Izzard</span></a> (<span class="bib-year">2017</span>).</div> -<div class="standard" id='magicparlabel-476'>To investigate the effect of a companion on stellar nucleosynthesis the <em><i>binary_c</i></em> code was developed. The <em><i>binary_c</i></em> code currently uses the <em>SSE/BSE</em> package at its core to provide most of the stellar evolution modeling, with nucleosynthesis in parallel based on various algorithms, to explore the large parameter spaces associated with binary stars in reasonable periods of time. Binaries are important for nucleosynthesis because of two main effects:</div> +<div class="standard" id='magicparlabel-496'>To investigate the effect of a companion on stellar nucleosynthesis the <em><i>binary_c</i></em> code was developed. The <em><i>binary_c</i></em> code currently uses the <em>SSE/BSE</em> package at its core to provide most of the stellar evolution modeling, with nucleosynthesis in parallel based on various algorithms, to explore the large parameter spaces associated with binary stars in reasonable periods of time. Binaries are important for nucleosynthesis because of two main effects:</div> -<ul class="itemize" id='magicparlabel-477'><li class="itemize_item">The presence of a companion affects evolution by mass loss and gain. Good examples are Roche-lobe overflow caused by interaction between a giant branch or asymptotic giant branch (GB/AGB) star and a main-sequence (MS) star. Truncation of the GB/AGB phase may prevent dredge-up events and hence reduce the amount of nuclear processing material undergoes prior to expulsion to the ISM. Common envelopes generally result and while the detailed physics is unclear it is likely that mass is ejected to the ISM from some of these stars.</li> +<ul class="itemize" id='magicparlabel-497'><li class="itemize_item">The presence of a companion affects evolution by mass loss and gain. Good examples are Roche-lobe overflow caused by interaction between a giant branch or asymptotic giant branch (GB/AGB) star and a main-sequence (MS) star. Truncation of the GB/AGB phase may prevent dredge-up events and hence reduce the amount of nuclear processing material undergoes prior to expulsion to the ISM. Common envelopes generally result and while the detailed physics is unclear it is likely that mass is ejected to the ISM from some of these stars.</li> <li class="itemize_item">Novae, type Ia supernoave, X-ray bursts, stellar mergers (including neutron-star/black-hole mergers), etc. occur in binaries, as do many tidal disruption events. These may eject material or lead to extra nuclear burning.</li> </ul> -<div class="standard" id='magicparlabel-479'>The physics of binary evolution is not all that well understood and, at the same time, suffers all the uncertainties of single-star evolution. Some effects which must be considered are:</div> +<div class="standard" id='magicparlabel-499'>The physics of binary evolution is not all that well understood and, at the same time, suffers all the uncertainties of single-star evolution. Some effects which must be considered are:</div> -<ul class="itemize" id='magicparlabel-480'><li class="itemize_item">Duplicity: is the star single or binary or perhaps even triple or quadruple?</li> +<ul class="itemize" id='magicparlabel-500'><li class="itemize_item">Duplicity: is the star single or binary or perhaps even triple or quadruple?</li> <li class="itemize_item">Metallicity and, less importantly, initial abundance mix. The initial abundance mix depends on the galactic evolution history and even the solar mixture is somewhat uncertain.</li> <li class="itemize_item">Initial distributions: What is the IMF? What is the initial distribution for primary mass, secondary mass, separation/period and eccentricity in binary stars?</li> <li class="itemize_item">Abundance changes at dredge-ups. These changes can depend on the input physics, especially in the case of third dredge-up. Calibration to observations is necessary in this case and leads to the introduction of free parameters to increase the amount of dredge-up. There is also great uncertainty with regard to the s-process isotopes, in particular the size of the C13 pocket during third dredge-up. </li> @@ -1039,9 +1045,9 @@ From <a href='#LyXCite-Izzard_et_al_2003c_Monash'><span class="bib-abbrvciteauth </mrow></mstyle></math>) TPAGB stars in binaries overflow their Roche lobes prior to HBB so C12 cannot be converted into N14.</li> <li class="itemize_item">Numerical resolution - requires careful consideration!</li> </ul> -<div class="standard" id='magicparlabel-493'><i>binary_c</i> is the trade name for the <i>C</i>-version of the <em>B</em>inary <em>S</em>tar <em>E</em>volution (<em>BSE</em>) code of <a href='#LyXCite-2002MNRAS_329_897H'><span class="bib-abbrvciteauthor">Hurley et al.</span></a> (<span class="bib-year">2002</span>) with added <em>nucleo</em>synthesis. The nucleosynthesis algorithm runs (mostly) in parallel to the nucleosynthesis code and includes the following (see <a href='#LyXCite-2006A_A___460__565I'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2006</span><span class="bib-modifier">b</span></a>; <a href='#LyXCite-2009A_A___508_1359I'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2009</span></a>; <a href='#LyXCite-2018MNRAS_473_2984I'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2018</span></a> and many subsequent papers):</div> +<div class="standard" id='magicparlabel-513'><i>binary_c</i> is the trade name for the <i>C</i>-version of the <em>B</em>inary <em>S</em>tar <em>E</em>volution (<em>BSE</em>) code of <a href='#LyXCite-2002MNRAS_329_897H'><span class="bib-abbrvciteauthor">Hurley et al.</span></a> (<span class="bib-year">2002</span>) with added <em>nucleo</em>synthesis. The nucleosynthesis algorithm runs (mostly) in parallel to the nucleosynthesis code and includes the following (see <a href='#LyXCite-2006A_A___460__565I'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2006</span><span class="bib-modifier">b</span></a>; <a href='#LyXCite-2009A_A___508_1359I'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2009</span></a>; <a href='#LyXCite-2018MNRAS_473_2984I'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2018</span></a> and many subsequent papers):</div> -<ul class="itemize" id='magicparlabel-494'><li class="itemize_item">First and second dredge-up fitted to the detailed nucleosynthesis models of <a href='#LyXCite-Parameterising_3DUP_Karakas_Lattanzio_Pols'><span class="bib-abbrvciteauthor">Karakas et al.</span></a> (<span class="bib-year">2002</span>). </li> +<ul class="itemize" id='magicparlabel-514'><li class="itemize_item">First and second dredge-up fitted to the detailed nucleosynthesis models of <a href='#LyXCite-Parameterising_3DUP_Karakas_Lattanzio_Pols'><span class="bib-abbrvciteauthor">Karakas et al.</span></a> (<span class="bib-year">2002</span>). </li> <li class="itemize_item">A new synthetic model of TPAGB stars (<a href='#LyXCite-Izzard_et_al_2003b_AGBs'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2004</span></a>) in collaboration with Amanda Karakas, Chris Tout and Onno Pols based on the Karakas et al. models. The effects of third dredge-up, the <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>s</mi> </mrow></mstyle></math>-process, hot-bottom burning (CNO, NeNa and MgAl) and mass loss are included.</li> @@ -1058,52 +1064,54 @@ From <a href='#LyXCite-Izzard_et_al_2003c_Monash'><span class="bib-abbrvciteauth <li class="itemize_item">Mergers.</li> <li class="itemize_item">SN stripping of companions.</li> </ul> -<div class="standard" id='magicparlabel-506'>What does the <i>binary_c</i> code not do?</div> +<div class="standard" id='magicparlabel-526'>What does the <i>binary_c</i> code not do?</div> -<ul class="itemize" id='magicparlabel-507'><li class="itemize_item">Diffusion - nobody plans to work on this! </li> +<ul class="itemize" id='magicparlabel-527'><li class="itemize_item">Diffusion - nobody plans to work on this! </li> <li class="itemize_item">"Extra mixing" - dubious although might be the cause of J-stars. </li> <li class="itemize_item">Common envelope nucleosynthesis - thought not to be important, but you never know. </li> <li class="itemize_item">(Pre-)MS burning of the interior of the star - this means that if a MS star is stripped the increase in C13/N14 due to CNO cycling is not taken into account. However, if the star makes it to 1st dredge up then this is taken into account. Note there is <em>experimental</em> code which can deal with this.</li> <li class="itemize_item">WD surface layers - these are very complicated!</li> <li class="itemize_item">Probably some other things too.</li> </ul> -<h3 class="subsection" id='magicparlabel-513'><span class="subsection_label">3.1</span> Binary_c: tools for stellar evolution and population synthesis</h3> -<div class="standard" id='magicparlabel-514'>The <i>binary_c</i> software framework consists of a number of tools, in particular:</div> +<h3 class="subsection" id='magicparlabel-533'><span class="subsection_label">3.1</span> Binary_c: tools for stellar evolution and population synthesis</h3> +<div class="standard" id='magicparlabel-534'>The <i>binary_c</i> software framework consists of a number of tools, in particular:</div> -<dl class='description' id='magicparlabel-515'><dt class="description_label"><i>binary_c</i></dt> +<dl class='description' id='magicparlabel-535'><dt class="description_label"><i>binary_c</i></dt> <dd class="description_item"> The <i>binary_c</i> code itself. This is the core code, written in <em>C</em>, which contains the stellar evolution and nucleosynthesis algorithms.</dd> <dt class="description_label"><i>libbinary_c</i></dt> <dd class="description_item"> The shared library based on <i>binary_c</i> which should be accessed through the <i>binary_c</i> API functions. This works with other languages such as <em>Python</em> and <em>FORTRAN</em>.</dd> <dt class="description_label"><i>binary_grid</i></dt> <dd class="description_item"> A suite of software to run many stars in a stellar population. This is written in <span class="flex_scriptinglanguage">Perl</span> because when I started there was no <em>Python</em>. Sorry! But before you say “oh but Perl is not <i><a href="https://www.python.org/">Python</a></i>” – true, but it's a damned powerful language. You only need it to run the populations: after that, you can process the resulting data however you like (even in Excel if you want – but please don't!).</dd> </dl> -<div class="standard" id='magicparlabel-522'><br /> +<div class="standard" id='magicparlabel-542'><br /> </div> -<h2 class="section" id='magicparlabel-523'><span class="section_label">4</span> Installation</h2> -<div class="standard" id='magicparlabel-524'>The following is an installation guide for installing <i>binary_c</i> and some of its support tools. If you know how to run code, and want to run <i>binary_c</i> as quickly as possible, just go for the quick start guide. If you want to get <i>binary_c</i>, either as source code, a virtual machine or Docker image, see section <a href="#subsec_Getting_binary_c">4.2</a>. Technical system requirements are discussed in section <a href="#subsec_system_requirements">4.3</a>. Building <i>binary_c</i> is describe in section <a href="#subsec_Building">4.4</a>.</div> +<h2 class="section" id='magicparlabel-543'><span class="section_label">4</span> Installation</h2> +<div class="standard" id='magicparlabel-544'>The following is an installation guide for installing <i>binary_c</i> and some of its support tools. If you know how to run code, and want to run <i>binary_c</i> as quickly as possible, just go for the quick start guide. If you want to get <i>binary_c</i>, either as source code, a virtual machine or Docker image, see section <a href="#subsec_Getting_binary_c">4.2</a>. Technical system requirements are discussed in section <a href="#subsec_system_requirements">4.3</a>. Building <i>binary_c</i> is describe in section <a href="#subsec_Building">4.4</a>.</div> -<div class="standard" id='magicparlabel-525'>The <i>binary_grid</i> software is described in section <a href="#subsec_installing_binary_grid">4.7.3</a>.</div> -<h3 class="subsection" id='magicparlabel-526'><span class="subsection_label">4.1</span> Quick start</h3> +<div class="standard" id='magicparlabel-545'>The <i>binary_grid</i> software is described in section <a href="#subsec_installing_binary_grid">4.7.3</a>.</div> +<h3 class="subsection" id='magicparlabel-546'><span class="subsection_label">4.1</span> Quick start</h3> -<ul class="itemize" id='magicparlabel-527'><li class="itemize_item">From the git repository check out <i>binary_c</i> and change to its directory</li> +<ul class="itemize" id='magicparlabel-547'><li class="itemize_item">From the git repository check out <i>binary_c</i> and change to its directory</li> <li class="itemize_item">Run one binary system with the <span class="flex_bashscript">tbse</span> (test binary star evolution) script:<br /> -<pre class\s*='listings bash'>$ ./configure -$ make +<pre class\s*='listings bash'>$ meson builddir --buildtype release +$ cd builddir +$ ninja +$ cd .. $ tbse</pre><br /> </li> <li class="itemize_item">Change <span class="flex_bashscript">tbse</span> to suit.</li> </ul> -<h3 class="subsection" id='magicparlabel-544'><span class="subsection_label">4.2</span> Getting <i>binary_c</i><div id="subsec_Getting_binary_c"></div> +<h3 class="subsection" id='magicparlabel-566'><span class="subsection_label">4.2</span> Getting <i>binary_c</i><div id="subsec_Getting_binary_c"></div> </h3> -<div class="standard" id='magicparlabel-545'>You can either get the <i>binary_c</i> source code, and build it yourself, or use the prebuilt <span class="flex_software">Docker</span><em> </em>image.</div> +<div class="standard" id='magicparlabel-567'>You can either get the <i>binary_c</i> source code, and build it yourself, or use the prebuilt <span class="flex_software">Docker</span><em> </em>image.</div> -<h4 class="subsubsection" id='magicparlabel-552'><span class="subsubsection_label">4.2.1</span> Getting the source code</h4> -<div class="standard" id='magicparlabel-553'>At present, <em>the <span class='math'>binary_c</i></span> +<h4 class="subsubsection" id='magicparlabel-574'><span class="subsubsection_label">4.2.1</span> Getting the source code</h4> +<div class="standard" id='magicparlabel-575'>At present, <em>the <span class='math'>binary_c</i></span> </em> source code is accessed through the Faculty of Engineering and Physics (FEPS) of the University of Surrey's <em>git </em>server at <a href="https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i>">https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i></a>. Access requires permission which is done on a user-by-user basis and currently only works easily if you have a Gmail account. If you don't, we can probably arrange something. </div> -<div class="standard" id='magicparlabel-554'>In order to obtain an account, you need to do the following, in order</div> +<div class="standard" id='magicparlabel-576'>In order to obtain an account, you need to do the following, in order</div> -<ol class="enumerate" id='magicparlabel-555'><li class="enumerate_item">Try to log in at <a href="https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i>">https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i></a> using your Gmail account by clicking on the <img style='width:1.2em;' src='images/1.png' alt='image: 7_tmp_binary_c_lyx_images_8.png' /> +<ol class="enumerate" id='magicparlabel-577'><li class="enumerate_item">Try to log in at <a href="https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i>">https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i></a> using your Gmail account by clicking on the <img style='width:1.2em;' src='images/1.png' alt='image: 7_tmp_binary_c_lyx_images_8.png' /> . You will be told <em>your account is locked!</em> This poorly-worded message means you have to…</li> <li class="enumerate_item">Email me at r.izzard@surrey.ac.uk and tell me your account is “locked”. I will then email IT support, who will unlock your account.</li> <li class="enumerate_item">IT support should then tell me your account is unlocked so I should then be able to tell you. However, IT support have been known to unlock accounts and <em>not </em>let me know, so please keep trying. If you find you <em>can </em>access the gitlab server (i.e. you can log in) but get a “404 The page could not be found or you don't have permission to view it” error when trying to view <a href="https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i>">https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i></a>, then I can probably fix the problem. But you have to tell me, so keep trying to log in :)</li> @@ -1111,7 +1119,7 @@ $ tbse</pre><br /> <li class="enumerate_item">Once you have confirmation from me (or before, if you are impatient) go back to the website, please click on the <img style='width:1.2em;' src='images/2.png' alt='image: 8_tmp_binary_c_lyx_images_9.png' /> to sign in, and grab the code. If everything works, great! If not, I may have to talk with IT support, yet again.</li> </ol> -<div class="standard" style='text-align: center;' id='magicparlabel-560'><div class='Boxed' style='width: 75%; '><div class="plain_layout" id='magicparlabel-564'>If you do not know me, it would really help me – and those who fund <em><span class='math'>binary_c</i></span> +<div class="standard" style='text-align: center;' id='magicparlabel-582'><div class='Boxed' style='width: 75%; '><div class="plain_layout" id='magicparlabel-586'>If you do not know me, it would really help me – and those who fund <em><span class='math'>binary_c</i></span> </em> – if you could include in your email to me a little about you and why you want to download and use <span class='math'>binary_c</i></span> . <br /> @@ -1122,12 +1130,12 @@ $ tbse</pre><br /> Please also let me know if you publish a paper which uses results derived from <em><span class='math'>binary_c</i></span> </em>.</div> </div></div> -<h4 class="subsubsection" id='magicparlabel-565'><span class="subsubsection_label">4.2.2</span> Getting the Docker image</h4> -<div class="standard" id='magicparlabel-566'>You can access <em><span class='math'>binary_c</i></span> -</em> through <em>docker</em><div class="foot"><span class="foot_label">1</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-570'><a href="https://www.docker.com/">https://www.docker.com/</a></div> +<h4 class="subsubsection" id='magicparlabel-587'><span class="subsubsection_label">4.2.2</span> Getting the Docker image</h4> +<div class="standard" id='magicparlabel-588'>You can access <em><span class='math'>binary_c</i></span> +</em> through <em>docker</em><div class="foot"><span class="foot_label">1</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-592'><a href="https://www.docker.com/">https://www.docker.com/</a></div> </div></div>.</div> -<ol class="enumerate" id='magicparlabel-571'><li class="enumerate_item">I assume you have installed and signed in to <em>docker</em>. I cannot provide support for <em>Docker</em>!</li> +<ol class="enumerate" id='magicparlabel-593'><li class="enumerate_item">I assume you have installed and signed in to <em>docker</em>. I cannot provide support for <em>Docker</em>!</li> <li class="enumerate_item">The newest <em><span class='math'>binary_c</i></span> </em> container is <b><span style='font-family:monospace;font-size: 18px;'>robizzard/<i>binary_c</i>:master2.0pre32 <br /> @@ -1205,134 +1213,170 @@ rm $XAUTH </li> </ol> -<h3 class="subsection" id='magicparlabel-651'><span class="subsection_label">4.3</span> System Requirements</h3> -<div class="standard" id='magicparlabel-652'><div id="subsec_system_requirements"></div> +<h3 class="subsection" id='magicparlabel-673'><span class="subsection_label">4.3</span> System Requirements</h3> +<div class="standard" id='magicparlabel-674'><div id="subsec_system_requirements"></div> In the following I assume you are using a <span class="flex_os">Linux</span>-type system (e.g running an distribution like <span class="flex_os">Ubuntu</span>). If you are not, I highly recommend using a virtual machine (e.g. <span class="flex_software">Virtualbox</span>) to run <span class="flex_os">Linux</span> on your system. <span class="flex_os">MacOS</span> and <span class="flex_os">Windows</span> have a quite different build structure compared to <span class="flex_os">Linux</span>, and while the code itself should work I have no Mac on which to test it. You can also run the <em><span class="flex_software">Docker</span></em> directly on <span class="flex_os">MacOS</span>.</div> -<div class="standard" id='magicparlabel-689'>To build <i>binary_c</i> from source, the following software is required on your system:</div> +<div class="standard" id='magicparlabel-711'>To build <i>binary_c</i> from source, the following software is required on your system:</div> -<ul class="itemize" id='magicparlabel-690'><li class="itemize_item">A <em><span class="flex_programminglanguage"><em>C</em></span></em> compiler e.g. one of, +<ul class="itemize" id='magicparlabel-712'><li class="itemize_item">A <em><span class="flex_programminglanguage"><em>C</em></span></em> compiler e.g. one of, <br /> -<ul class="itemize" id='magicparlabel-695'><li class="itemize_item"><span class="flex_software">gcc</span> (the <em>GNU</em> compiler <a href="http://gcc.gnu.org/">http://gcc.gnu.org/</a>) this comes as standard on most <span class="flex_os">Linux</span> and <span class="flex_os">MacOS</span> systems and is easily installed on others,</li> -<li class="itemize_item"><span class="flex_software">icc</span> (Intel compiler <a href="http://software.intel.com/en-us/articles/intel-compilers/">http://software.intel.com/en-us/articles/intel-compilers/</a>) this costs money but it is probably faster than <span class="flex_software">gcc</span>,</li> +<ul class="itemize" id='magicparlabel-717'><li class="itemize_item"><span class="flex_software">gcc</span> (the <em>GNU</em> compiler <a href="http://gcc.gnu.org/">http://gcc.gnu.org/</a>) this comes as standard on most <span class="flex_os">Linux</span> and <span class="flex_os">MacOS</span> systems and is easily installed on others, and is free software.</li> <li class="itemize_item"><span class="flex_software">clang</span> (<em>C</em> compiler for <span class="flex_software">LLVM</span> <a href="http://clang.llvm.org/">http://clang.llvm.org/</a>) is also free, and may be faster than <span class="flex_software">gcc</span><em>.</em></li> +<li class="itemize_item"><span class="flex_software">icc</span> (Intel compiler <a href="http://software.intel.com/en-us/articles/intel-compilers/">http://software.intel.com/en-us/articles/intel-compilers/</a>) this costs money but it is probably faster than <span class="flex_software">gcc</span>.</li> </ul> -<div class="standard" id='magicparlabel-730'>Your system should include such a compiler unless you're using <span class="flex_os">Windows</span>. <em>Binary_c</em> has been tested on <span class="flex_os">Linux</span> and various <span class="flex_os">Solaris</span> machines. Note that (for an unknown reason!) it does not run (but does compile) on older versions of <span class="flex_os">MacOS</span>. If you can fix this problem please let me know! Also, there has been trouble with <span class="flex_software">gcc</span><em> </em>on Xeon machines. This is not my fault, please use <span class="flex_software">icc</span> or perhaps a newer <em><span class="flex_software">gcc</span></em>.<div class="foot"><span class="foot_label">2</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-762'>This information may be out of date! Please test the build and let me know.</div> +<div class="standard" id='magicparlabel-752'>Your system should include such a compiler unless you're using <span class="flex_os">Windows</span>. <em>Binary_c</em> has been tested on <span class="flex_os">Linux</span> and various <span class="flex_os">Solaris</span> machines. Note that (for an unknown reason!) it does not run (but does compile) on older versions of <span class="flex_os">MacOS</span>. If you can fix this problem please let me know! Also, there has been trouble with <span class="flex_software">gcc</span><em> </em>on Xeon machines. This is not my fault, please use <span class="flex_software">icc</span> or perhaps a newer <em><span class="flex_software">gcc</span></em>.<div class="foot"><span class="foot_label">2</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-784'>This information may be out of date! Please test the build and let me know.</div> </div></div></div> -</li><li class="itemize_item"><span class="flex_scriptinglanguage">Perl</span> - this is required for the configuration script and, should you wish to evolve stellar populations, the <em><i>binary_grid</i></em> software. <span class="flex_scriptinglanguage">Perl</span> is usually installed on your system, and for configuration of <em><i>binary_c</i></em> this should be sufficient. You can download <span class="flex_scriptinglanguage">Perl</span> at <a href="www.perl.com">www.perl.com</a>, or use your system <span class="flex_scriptinglanguage">Perl</span>, but I recommend <em>Perlbrew</em> instead. Please try to use a version of <span class="flex_scriptinglanguage">Perl</span> that is 5.16 or later: 5.29.8 is currently the latest version and works just fine. +</li><li class="itemize_item"><span class="flex_scriptinglanguage">Python</span>, <span class="flex_software">meson</span> and <span class="flex_software">ninja</span>. You can install these tools on your system. You should make sure you have <span class="flex_software">meson</span> V0.52.0 or later. If you have <span class="flex_scriptinglanguage">Python3</span> installed, you can update <span class="flex_software">meson</span> with <br /> +<pre class ='listings'>pip3 install meson</pre><br /> +which should get you the latest version.</li> +<li class="itemize_item"><span class="flex_scriptinglanguage">Perl</span> - this is required for the <em><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> + <mrow> + <mrow> + <mstyle mathvariant='normal'> + <mstyle mathvariant='italic'> + <mrow><mi>b</mi><mi>i</mi><mi>n</mi><mi>a</mi><mi>r</mi><mi>y</mi>_<mi>g</mi><mi>r</mi><mi>i</mi><mi>d</mi> + </mrow> + </mstyle> + </mstyle><mn>2</mn> + </mrow> + </mrow></mstyle></math></em> software. <span class="flex_scriptinglanguage">Perl</span> is usually installed on your system, or you can download <span class="flex_scriptinglanguage">Perl</span> at <a href="www.perl.com">www.perl.com</a>, but I recommend <span class="flex_software">Perlbrew</span> instead. Please try to use a version of <span class="flex_scriptinglanguage">Perl</span> that is 5.16 or later: 5.31.5 is currently the latest version and works just fine. <em><br /> -NOTE: </em><span class="flex_software">Perlbrew</span> and <span class="flex_software">cpanm</span> are <em>essential </em>if you want to use <i>binary_grid</i>. These are standard tools. I recommend downloading them, but they could also be installed on your system as packages.</li> -<li class="itemize_item">You will want to use <em>git</em> to get<em> <i>binary_c</i></em>, see the document </li> +NOTE: </em><span class="flex_software">Perlbrew</span> and <span class="flex_software">cpanm</span> are <em>essential </em>if you want to use <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> + <mrow> + <mrow> + <mstyle mathvariant='normal'> + <mstyle mathvariant='italic'> + <mrow><mi>b</mi><mi>i</mi><mi>n</mi><mi>a</mi><mi>r</mi><mi>y</mi>_<mi>g</mi><mi>r</mi><mi>i</mi><mi>d</mi> + </mrow> + </mstyle> + </mstyle><mn>2</mn> + </mrow> + </mrow></mstyle></math>.</li> +<li class="itemize_item">You will want to use <em>git</em> to get<em> <i>binary_c</i></em>, see the document <em>getting_binary_c </em>.</li> <li class="itemize_item">If you plan to modify <em><i>binary_c</i> </em>you probably want a debugger of some sort. <span class="flex_software">Valgrind</span> is the tool of choice although you can also use <span class="flex_software">gdb</span>.</li> </ul> -<div class="standard" id='magicparlabel-802'>By using <em><i>binary_c</i></em> and <em><i>binary_grid</i></em> you are part of a community. You are therefore jointly responsible for helping with the never-ending process of improvement and bug fixing.<em> Binary_c</em> (and its <span class="flex_scriptinglanguage">Perl</span> modules, such as <em><i>binary_grid</i></em>) is stored on a<em> </em><span class="flex_software">git</span> server. Please read the <span class="flex_file">LICENCE</span> file before use.</div> -<h3 class="subsection" id='magicparlabel-815'><span class="subsection_label">4.4</span> Configuring and building <i>binary_c</i></h3> -<div class="standard" id='magicparlabel-816'><div id="subsec_Building"></div> -</div> -<h4 class="subsubsection" id='magicparlabel-817'><span class="subsubsection_label">4.4.1</span> From <em>git</em></h4> -<div class="standard" id='magicparlabel-818'>Assuming you have checked out your branch, a release or the trunk, from the <em>git</em> repository (see Sec. <a href="#subsec_Getting_binary_c">4.2</a>), go to that directory (which will be called the <span class="flex_file"><i>binary_c</i></span> directory below) and skip to <a href="#subsec_Configuration">4.4.3</a>.</div> -<h4 class="subsubsection" id='magicparlabel-823'><span class="subsubsection_label">4.4.2</span> From a <em>zip</em> file or tarball</h4> -<div class="standard" id='magicparlabel-824'>If have been given a file <span class="flex_software">zip</span> file <span class="flex_file"><i>binary_c</i>.zip</span><span style='font-family:monospace;font-size: 18px;'>,</span> or a tarball e.g. <span class="flex_file"><i>binary_c</i>.tar.gz</span> or <span class="flex_file"><i>binary_c</i>.tar.bz2</span>, you should copy it to a directory (hereafter <span class="flex_file"><i>binary_c</i></span>, usually I put everything in <span class="flex_file"><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-853'>By using <em><i>binary_c</i></em> and <em><i>binary_grid</i></em> you are part of a community. You are therefore jointly responsible for helping with the never-ending process of improvement and bug fixing.<em> Binary_c</em> (and its <span class="flex_scriptinglanguage">Perl</span> modules, such as <em><i>binary_grid</i></em>) is stored on a<em> </em><span class="flex_software">git</span> server. Please read the <span class="flex_file">LICENCE</span> file before use.</div> +<h3 class="subsection" id='magicparlabel-866'><span class="subsection_label">4.4</span> Configuring and building <i>binary_c</i></h3> +<div class="standard" id='magicparlabel-867'><div id="subsec_Building"></div> +</div> +<h4 class="subsubsection" id='magicparlabel-868'><span class="subsubsection_label">4.4.1</span> From <em>git</em></h4> +<div class="standard" id='magicparlabel-869'>Assuming you have checked out your branch, a release or the trunk, from the <em>git</em> repository (see Sec. <a href="#subsec_Getting_binary_c">4.2</a>), go to that directory (which will be called the <span class="flex_file"><i>binary_c</i></span> directory below) and skip to <a href="#subsec_Configuration">4.4.3</a>.</div> +<h4 class="subsubsection" id='magicparlabel-874'><span class="subsubsection_label">4.4.2</span> From a <em>zip</em> file or tarball</h4> +<div class="standard" id='magicparlabel-875'>If have been given a file <span class="flex_software">zip</span> file <span class="flex_file"><i>binary_c</i>.zip</span><span style='font-family:monospace;font-size: 18px;'>,</span> or a tarball e.g. <span class="flex_file"><i>binary_c</i>.tar.gz</span> or <span class="flex_file"><i>binary_c</i>.tar.bz2</span>, you should copy it to a directory (hereafter <span class="flex_file"><i>binary_c</i></span>, usually I put everything in <span class="flex_file"><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mo> ∼ </mo> </mrow></mstyle></math>/progs/stars/<i>binary_c</i></span> where <span class="flex_file"><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mo> ∼ </mo> </mrow></mstyle></math></span> is your home directory – if you put it there then all the scripts will work) and <span class="flex_software">unzip</span> it with one of the following commands (depending on the type of file you were given):</div> -<div class="standard" id='magicparlabel-857'><b><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-908'><b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ unzip <i>binary_c</i>.zip $ tar -xvf <i>binary_c</i>.tar.gz $ tar -xvf <i>binary_c</i>.tar.bz2</pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-864'>which will <span class="flex_software">unzip</span> the files in the appropriate places.</div> -<h4 class="subsubsection" id='magicparlabel-869'><span class="subsubsection_label">4.4.3</span> Configuration<div id="subsec_Configuration"></div> +<div class="standard" id='magicparlabel-915'>which will <span class="flex_software">unzip</span> the files in the appropriate places.</div> +<h4 class="subsubsection" id='magicparlabel-920'><span class="subsubsection_label">4.4.3</span> Building with Meson<div id="subsec_Configuration"></div> </h4> -<div class="standard" id='magicparlabel-870'>Now, from the <span class="flex_file"><i>binary_c</i></span> directory, you need to run the configuration script with</div> +<div class="standard" id='magicparlabel-921'>Now, from the <span class="flex_file"><i>binary_c</i></span> directory, you need to use <span class="flex_software">Meson</span> to make<div class="foot"><span class="foot_label">3</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-933'>Consider installing also <span class="flex_software">ccache</span> and bash auto-completion for <span class="flex_software">Meson</span> <a href="https://github.com/ninja-build/ninja/blob/master/misc/bash-completion">https://github.com/ninja-build/ninja/blob/master/misc/bash-completion</a></div> +</div></div> a build directory, e.g.,<b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ meson builddir --buildtype release</pre><br /> +</span></b>and now you should go to that directory to build the code using <span class="flex_software">ninja,</span></div> -<div class="standard" id='magicparlabel-875'><b><span style='font-family:monospace;font-size: 18px;'><br /> -<pre class\s*='listings bash'>$ ./configure</pre><br /> -</span></b></div> - -<div class="standard" id='magicparlabel-880'>which creates some object files and the <span class="flex_file">Makefile</span>. Now type</div> - -<div class="standard" id='magicparlabel-885'><b><span style='font-family:monospace;font-size: 18px;'><br /> -<pre class\s*='listings bash'>$ ./make</pre><br /> -</span></b></div> +<div class="standard" id='magicparlabel-954'><b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ cd builddir +$ ninja</pre><br /> +</span></b>The code will now build, assuming everything worked ok. If it does <em>not</em> work then please try to fix it (using, e.g. <em>Google</em>) before running to me with complaints. It works fine on <span class="flex_os">Linux</span> and will revert to <span class="flex_software">gcc</span> as the default compiler if something goes wrong. </div> -<div class="standard" id='magicparlabel-890'>to build the code. The make script is a wrapper around <span class="flex_software">GNU make</span> that executes the build on as many CPUs as you have, and pretties up the output so that it is more readable. Note that you may need to use</div> +<div class="standard" id='magicparlabel-968'>You can change the <span class="flex_args">buildtype</span> to debug if you want to build for testing (this is the default if you do not include any <span class="flex_args">buildtype</span>) – see <a href="https://mesonbuild.com/Running-Meson.html">https://mesonbuild.com/Running-Meson.html</a> for details.</div> -<div class="standard" id='magicparlabel-895'><b><span style='font-family:monospace;font-size: 18px;'><br /> -<pre class\s*='listings bash'>$ gmake</pre><br /> +<div class="standard" id='magicparlabel-981'>The executable is called <span class="flex_file"><i>binary_c</i></span>. To run a star go back to the main <i>binary_c</i> directory and run tbse, e.g.,<b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ cd .. +$ tbse</pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-900'>from the <span class="flex_file">src</span> directory if <span class="flex_software">GNU make</span> is not your default (e.g. on <span class="flex_os">Solaris</span>). -<br /> - -The code will now build, assuming <span style='font-family:monospace;font-size: 18px;'>configure</span> worked ok. If configure does <em>not</em> work then please try to fix it before running to me with complaints. It works fine on <span class="flex_os">Linux</span> and will revert to <span class="flex_software">gcc</span> as the default compiler if something goes wrong. The executable is called <span class="flex_file"><i>binary_c</i></span><span style='font-family:monospace;font-size: 18px;'>.</span></div> - -<div class="standard" id='magicparlabel-925'>Note: <span class="flex_file"><i>binary_c</i></span> is built as a single, possibly <em>large</em> (many MB) executable. The reason for this is the ease of use when transferring the executable from one machine to another (e.g. for use with distributed computing). It is possible to build a shared library instead (see below) and future <i>binary_c</i> versions will probably use environment variables to point to data directories.</div> -<h4 class="subsubsection" id='magicparlabel-930'><span class="subsubsection_label">4.4.4</span> Building the shared library <i>libbinary_c</i></h4> -<div class="standard" id='magicparlabel-931'>To build the shared library, run</div> - -<div class="standard" id='magicparlabel-932'><br /> -<pre class\s*='listings bash'>$ ./configure -$ make <i>libbinary_c.so</i></pre><br /> -</div> - -<div class="standard" id='magicparlabel-938'>This makes the <span class="flex_file"><i>libbinary_c.so</i></span> shared library which can be used, for example, by the <span class="flex_programminglanguage">C</span> backend to <i>binary_grid</i><em>2</em>, or to access <i>binary_c</i> through its <em>API</em> functions.</div> -<h4 class="subsubsection" id='magicparlabel-947'><span class="subsubsection_label">4.4.5</span> Alternative compiler</h4> -<div class="standard" id='magicparlabel-948'>You can build with another compiler, e.g.<em> <span class="flex_software">clang</span></em>, with</div> - -<div class="standard" id='magicparlabel-953'><br /> +<div class="standard" id='magicparlabel-991'>Note: <span class="flex_file"><i>binary_c</i></span> is built as a single, possibly <em>large</em> (many MB) executable. The reason for this is the ease of use when transferring the executable from one machine to another (e.g. for use with distributed computing). It is possible to build a shared library instead (see below) and future <i>binary_c</i> versions will probably use environment variables to point to data directories.</div> +<h4 class="subsubsection" id='magicparlabel-996'><span class="subsubsection_label">4.4.4</span> Cleaning the build tree</h4> +<div class="standard" id='magicparlabel-997'>You can clean the build directory with<b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ cd builddir +$ ninja clean</pre><br /> +</span></b>This does not clean the data objects, which are built only once. If you want to clean these as well (equivalent to a <br /> +<pre class\s*='listings bash'>$ make cleanall</pre><br /> + of old) you should run,<b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ ./meson/clean_data_objects.sh</pre><br /> +</span></b>from within the <i>binary_c</i> main directory.</div> +<h4 class="subsubsection" id='magicparlabel-1011'><span class="subsubsection_label">4.4.5</span> Building the shared library <i>libbinary_c</i></h4> +<div class="standard" id='magicparlabel-1012'>To build the shared library, go back into the builddir and run,</div> + +<div class="standard" id='magicparlabel-1013'><br /> +<pre class\s*='listings bash'>$ cd builddir +$ ninja <i>libbinary_c.so</i> +$ ninja libbinary_c_symlink</pre><br /> +</div> + +<div class="standard" id='magicparlabel-1020'>This makes the <span class="flex_file"><i>libbinary_c.so</i></span> shared library which can be used, for example, by the <span class="flex_programminglanguage">C</span> backend to <i>binary_grid</i><em>2</em>, or to access <i>binary_c</i> through its <em>API</em> functions. The <span class="flex_args">libbinary_c_symlink</span> build sets up a symbolic link in the <i>binary_c</i> <span class="flex_file">src</span> directory which allows <i>binary_grid</i><em>2 </em>to function.</div> +<h4 class="subsubsection" id='magicparlabel-1037'><span class="subsubsection_label">4.4.6</span> Alternative compiler</h4> +<div class="standard" id='magicparlabel-1038'>You can build with another compiler, e.g.<em> <span class="flex_software">clang</span></em>, by setting the <span class="flex_envvar">CC</span> environment variable. If you have not yet made a builddir, do the following.</div> + +<div class="standard" id='magicparlabel-1047'><br /> <pre class\s*='listings bash'>$ export CC=clang -$ ./configure -$ ./make</pre><br /> +$ meson builddir --buildtype release +$ cd builddir +$ ninja</pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-960'><span class="subsubsection_label">4.4.6</span> Debugging build</h4> -<div class="standard" id='magicparlabel-961'>To enable full debugging, run</div> - -<div class="standard" id='magicparlabel-962'><br /> -<pre class\s*='listings bash'>$ ./configure debug -$ ./make</pre><br /> - -<b><span style='font-family:monospace;font-size: 18px;'><br /> +<h4 class="subsubsection" id='magicparlabel-1055'><span class="subsubsection_label">4.4.7</span> Existing builddir</h4> +<div class="standard" id='magicparlabel-1056'>If you already have a <span class="flex_file">builddir</span>, instead of deleting it, do the following,<br /> +<pre class\s*='listings bash'>$ export CC=clang +$ cd builddir +$ meson --reconfigure --buildtype release +$ ninja</pre><br /> +</div> +<h4 class="subsubsection" id='magicparlabel-1068'><span class="subsubsection_label">4.4.8</span> Debugging build</h4> +<div class="standard" id='magicparlabel-1069'>To enable full debugging, run, from within <span class="flex_file">builddir</span>,<b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ meson builddir --buildtype debug +$ ninja</pre><br /> +</span></b>or just <b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ meson builddir +$ cd builddir +$ ninja</pre><br /> +</span></b>because <span class="flex_args">debug</span> is the default <span class="flex_args">buildtype</span>. You require debugging to use <span class="flex_software">gdb</span>, <span class="flex_software">valgrind</span>, etc. as well as <span class="flex_software">libbacktrace</span>.</div> +<h4 class="subsubsection" id='magicparlabel-1105'><span class="subsubsection_label">4.4.9</span> Accurate floating point build</h4> +<div class="standard" id='magicparlabel-1106'>Binary_c generally does not require perfect floating-point accuracy and uses <span class="flex_cflags">-ffast-math</span> for extra speed, but you can turn on <span class="flex_software">gcc</span>'s various flags to improve accuracy with <b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ meson builddir -Daccurate=true</pre><br /> +</span></b></div> +<h4 class="subsubsection" id='magicparlabel-1119'><span class="subsubsection_label">4.4.10</span> Generic build, e.g. for <em>HTCondor</em></h4> +<div class="standard" id='magicparlabel-1120'>You may wish to build a generic version of <i>binary_c</i> which is not tied to the CPU architecture or operating system on which you are building, e.g. if your <i>binary_c</i> is required for use on the many machines of an <span class="flex_software">HTCondor</span><em> </em>or <span class="flex_software">Slurm</span> grid. Try <b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ meson builddir -Dgeneric=true</pre><br /> +</span></b></div> +<h4 class="subsubsection" id='magicparlabel-1133'><span class="subsubsection_label">4.4.11</span> Libraries for <i>binary_c</i></h4> +<div class="standard" id='magicparlabel-1134'><i>binary_c</i> uses <a href="https://gitlab.eps.surrey.ac.uk/ri0005/libmemoize">libmemoize</a> and <a href="https://gitlab.eps.surrey.ac.uk/ri0005/librinterpolate">librinterpolate</a>, written by RGI, and RGI's customized <i>GNU</i> Scientific Library (at <a href="https://gitlab.eps.surrey.ac.uk/ri0005/GSL-RGI">this link</a>). These should really just be installed locally, but there are internal versions inside <i>binary_c</i> just in case you cannot install them, and a standard system <span class="flex_software">GSL</span> should work.</div> -</span></b>You require debugging to use <span class="flex_software">gdb</span>, <span class="flex_software">valgrind</span>, etc. as well as <span class="flex_software">libbacktrace</span>.</div> -<h4 class="subsubsection" id='magicparlabel-980'><span class="subsubsection_label">4.4.7</span> Accurate floating point build</h4> -<div class="standard" id='magicparlabel-981'>Binary_c generally does not require perfect floating-point accuracy and uses <span class="flex_cflags">-ffast-math</span> for extra speed, but you can turn on <span class="flex_software">gcc</span>'s various flags to improve accuracy with <br /> -<pre class\s*='listings bash'>$ ./configure accurate</pre><br /> -</div> -<h4 class="subsubsection" id='magicparlabel-994'><span class="subsubsection_label">4.4.8</span> Generic build, e.g. for <em>HTCondor</em></h4> -<div class="standard" id='magicparlabel-995'>You may wish to build a generic version of <i>binary_c</i> which is not tied to the CPU architecture or operating system on which you are building, e.g. if your <i>binary_c</i> is required for use on the many machines of an <span class="flex_software">HTCondor</span><em> </em>or <span class="flex_software">Slurm</span> grid. Try <b><span style='font-family:monospace;font-size: 18px;'><br /> -<pre class\s*='listings bash'>$ ./configure generic</pre><br /> +<div class="standard" id='magicparlabel-1139'>You should make sure <span class="flex_software">Meson</span> knows about the locations of your libraries. Usually it is sufficient to set their locations (i.e. the directories in which they reside) in the environment variables <span class="flex_envvar">LIBRARY_PATH</span> (for compilation) and <span class="flex_envvar">LD_LIBRARY_PATH</span> (at runtime). For example, to point to the directories <span class="flex_file">$HOME/lib</span> and <span class="flex_file">$HOME/otherlibs</span>, using <span class="flex_software">bash</span>, <b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ export LIBRARY_PATH=$HOME/lib:$HOME/otherlibs +$ export LD_LIBRARY_PATH=$HOME/lib:$HOME/otherlibs</pre><br /> </span></b></div> -<h4 class="subsubsection" id='magicparlabel-1008'><span class="subsubsection_label">4.4.9</span> Libraries for <i>binary_c</i></h4> -<div class="standard" id='magicparlabel-1009'><i>binary_c</i> uses <a href="https://gitlab.eps.surrey.ac.uk/ri0005/libmemoize">libmemoize</a> and <a href="https://gitlab.eps.surrey.ac.uk/ri0005/librinterpolate">librinterpolate</a>, written by RGI, and RGI's customized <i>GNU</i> Scientific Library (at <a href="https://gitlab.eps.surrey.ac.uk/ri0005/GSL-RGI">this link</a>). These should really just be installed locally, but there are internal versions inside <i>binary_c</i> just in case you cannot install them, and a standard system <span class="flex_software">GSL</span> should work.</div> -<h4 class="subsubsection" id='magicparlabel-1014'><span class="subsubsection_label">4.4.10</span> Extra libraries</h4> -<div class="standard" id='magicparlabel-1015'>A number of external libraries can be used, particularly during debugging. These include <span class="flex_software">libiberty</span>, <span class="flex_software">libbfd</span> (part of <span class="flex_software">gcc</span>) and <em><span class="flex_software">libbacktrace</span></em>. The latter is particularly useful, and I recommend installing it if you want to do any serious debugging. You can download <span class="flex_software">libbacktrace</span> from <a href="https://github.com/ianlancetaylor/libbacktrace">https://github.com/ianlancetaylor/libbacktrace</a>.</div> -<h3 class="subsection" id='magicparlabel-1036'><span class="subsection_label">4.5</span> Testing <i>binary_c</i></h3> -<div class="standard" id='magicparlabel-1037'>Run the <span class="flex_scriptinglanguage">bash</span> script to “test binary star evolution” called,</div> - -<div class="standard" id='magicparlabel-1042'><br /> +<h4 class="subsubsection" id='magicparlabel-1169'><span class="subsubsection_label">4.4.12</span> Extra libraries</h4> +<div class="standard" id='magicparlabel-1170'>A number of external libraries can be used, particularly during debugging. These include <span class="flex_software">libiberty</span>, <span class="flex_software">libbfd</span> (part of <span class="flex_software">gcc</span>) and <em><span class="flex_software">libbacktrace</span></em>. The latter is particularly useful, and I recommend installing it if you want to do any serious debugging. You can download <span class="flex_software">libbacktrace</span> from <a href="https://github.com/ianlancetaylor/libbacktrace">https://github.com/ianlancetaylor/libbacktrace</a>.</div> +<h3 class="subsection" id='magicparlabel-1191'><span class="subsection_label">4.5</span> Testing <i>binary_c</i></h3> +<div class="standard" id='magicparlabel-1192'>Run the <span class="flex_scriptinglanguage">bash</span> script to “test binary star evolution” which is located in the main <i>binary_c</i> directory, called,</div> + +<div class="standard" id='magicparlabel-1197'><br /> <pre class\s*='listings bash'>$ tbse</pre><br /> You should see some output. <br /> -You may have to symbolically link the executable at <span class="flex_file">src/<i>binary_c</i> to <i>binary_c</i></span> in the root <i>binary_c</i> directory to make this work, e.g.,</div> - -<div class="standard" id='magicparlabel-1051'><br /> -<pre class\s*='listings bash'>$ cd <binary_c_directory> -$ ln -s src/<i>binary_c</i></pre><br /> -</div> -<h4 class="subsubsection" id='magicparlabel-1057'><span class="subsubsection_label">4.5.1</span> tbse commands<div id="subsec_tbse_commands"></div> +Note: You may have to symbolically link the executable to make this work. You can do this manually by going into the builddir and running<b><span style='font-family:monospace;font-size: 18px;'><br /> +<pre class\s*='listings bash'>$ ninja binary_c_symlink</pre><br /> +</span></b></div> +<h4 class="subsubsection" id='magicparlabel-1206'><span class="subsubsection_label">4.5.1</span> tbse commands<div id="subsec_tbse_commands"></div> </h4> -<div class="standard" id='magicparlabel-1058'><span class="flex_bashscript">tbse</span><em> </em>can take extra arguments, which are often passed to <em><i>binary_c</i></em> directly or are directives to perform special tasks.</div> +<div class="standard" id='magicparlabel-1207'><span class="flex_bashscript">tbse</span><em> </em>can take extra arguments, which are often passed to <em><i>binary_c</i></em> directly or are directives to perform special tasks.</div> -<dl class='description' id='magicparlabel-1063'><dt class="description_label">tbse echo</dt> +<dl class='description' id='magicparlabel-1212'><dt class="description_label">tbse echo</dt> <dd class="description_item"> This outputs (to <em>stdout</em>) the arguments that would have been sent to <em><i>binary_c</i></em>.</dd> <dt class="description_label">tbse_echolines</dt> <dd class="description_item"> As <em>tbse echo</em> but in a single line of output. Newlines are converted to <span style='font-family:monospace;font-size: 18px;'>\n</span>.</dd> @@ -1377,39 +1421,40 @@ $ ln -s src/<i>binary_c</i></pre><br /> <dt class="description_label">tbse clip</dt> <dd class="description_item"> Runs <i>binary_c</i> and saves the output to the clipboard (requires <em>xclip</em>).</dd> </dl> -<h3 class="subsection" id='magicparlabel-1085'><span class="subsection_label">4.6</span> Directory structure</h3> +<h3 class="subsection" id='magicparlabel-1234'><span class="subsection_label">4.6</span> Directory structure</h3> -<ul class="itemize" id='magicparlabel-1086'><li class="itemize_item">The <span class="flex_file">src</span> directory, which holds all the <span style='font-family:monospace;font-size: 18px;'>.c</span> files</li> +<ul class="itemize" id='magicparlabel-1235'><li class="itemize_item">The <span class="flex_file">src</span> directory, which holds all the <span style='font-family:monospace;font-size: 18px;'>.c</span> files</li> <li class="itemize_item"><span class="flex_file">src/doc</span> contains documentation</li> <li class="itemize_item"><span class="flex_file">src/perl</span> contains the <span class="flex_scriptinglanguage">Perl</span> scripts e.g.<span style='font-family:monospace;font-size: 18px;'> </span><span class="flex_file">grid.pl</span><span style='font-family:monospace;font-size: 18px;'> </span>as well as latest <em><i>binary_grid</i></em> and helper modules, as well as some useful scripts. Please see the installation guide for help on installing these components.</li> -<li class="itemize_item"><span class="flex_file">unit_tests</span> contains some test components</li> +<li class="itemize_item"><span class="flex_file">unit_tests</span> contains some test components (likely to be updated in later versions)</li> +<li class="itemize_item"><span class="flex_file">builddir</span> contains the <span class="flex_software">Meson</span>/<span class="flex_software">Ninja</span> build information. You can delete this at any time, but you will have to rebuild everything from scratch.</li> </ul> -<div class="standard" id='magicparlabel-1114'><br /> +<div class="standard" id='magicparlabel-1276'><br /> </div> -<h3 class="subsection" id='magicparlabel-1115'><span class="subsection_label">4.7</span> Building binary_grid2: the population synthesis module</h3> -<div class="standard" id='magicparlabel-1116'>This section describes in some detail the installation of <em><i>binary_grid2</i></em>. Note that sometimes you will require the latest version of pieces of software, in particular <span class="flex_scriptinglanguage">Perl</span> which should be at least version 5.16. I show you how to do this <em>without</em> requiring root permissions on your machine. Should you require packages to be installed that require root permission, you can always set up <em><i>binary_c</i></em> and <em><i>binary_grid</i></em> on a <em>virtual machine</em> which runs as a guest on your operating system, I do this with <span class="flex_software">Virtualbox</span> (<a href="https://www.virtualbox.org/">https://www.virtualbox.org/</a>). This would be my advice if you are running on a non-standard operating system, e.g.<em> </em><span class="flex_os">Windows</span>. You will have the root password for your virtual machine, so there are never permissions problems.</div> +<h3 class="subsection" id='magicparlabel-1277'><span class="subsection_label">4.7</span> Building binary_grid2: the population synthesis module</h3> +<div class="standard" id='magicparlabel-1278'>This section describes in some detail the installation of <em><i>binary_grid2</i></em>. Note that sometimes you will require the latest version of pieces of software, in particular <span class="flex_scriptinglanguage">Perl</span> which should be at least version 5.16. I show you how to do this <em>without</em> requiring root permissions on your machine. Should you require packages to be installed that require root permission, you can always set up <em><i>binary_c</i></em> and <em><i>binary_grid</i></em> on a <em>virtual machine</em> which runs as a guest on your operating system, I do this with <span class="flex_software">Virtualbox</span> (<a href="https://www.virtualbox.org/">https://www.virtualbox.org/</a>). This would be my advice if you are running on a non-standard operating system, e.g.<em> </em><span class="flex_os">Windows</span>. You will have the root password for your virtual machine, so there are never permissions problems.</div> -<div class="standard" id='magicparlabel-1129'>You will need some basic tools installed to make everything work: <span class="flex_scriptinglanguage">bash</span>, <span class="flex_software">subversion</span>, <span class="flex_scriptinglanguage">Perl</span>, <span class="flex_software">gmake</span>, <span class="flex_software">wget</span>, <span class="flex_software">gcc</span>. These are available on all good operating systems, and come by default – or after a simple install – with most flavours of <span class="flex_os">Linux</span>/<span class="flex_os">Unix</span> and <span class="flex_os">MacOS</span>.</div> +<div class="standard" id='magicparlabel-1291'>You will need some basic tools installed to make everything work: <span class="flex_scriptinglanguage">bash</span>, <span class="flex_software">subversion</span>, <span class="flex_scriptinglanguage">Perl</span>, <span class="flex_software">gmake</span>, <span class="flex_software">wget</span>, <span class="flex_software">gcc</span>. These are available on all good operating systems, and come by default – or after a simple install – with most flavours of <span class="flex_os">Linux</span>/<span class="flex_os">Unix</span> and <span class="flex_os">MacOS</span>.</div> -<div class="standard" id='magicparlabel-1166'>Some <span class="flex_scriptinglanguage">Perl</span><em> </em>modules also require some other system libraries and development files. It is difficult to know exactly what these would be for every operating system. You may have to use a web search to find out, but that's fine because you are smart!</div> -<h4 class="subsubsection" id='magicparlabel-1171'><span class="subsubsection_label">4.7.1</span> Get the latest <span class="flex_scriptinglanguage">Perl</span> with<em> perlbrew</em></h4> -<div class="standard" id='magicparlabel-1176'>I highly recommend that you install the latest version of <span class="flex_scriptinglanguage">Perl</span><em> </em>using <span class="flex_software">perlbrew</span> and install modules using <span class="flex_software">cpanm</span><em>.</em> I describe how to do this below, but also please see <a href="http://perlbrew.pl/">http://perlbrew.pl/</a> and <a href="http://perlbrew.pl/Perlbrew-and-Friends.html ">http://perlbrew.pl/Perlbrew-and-Friends.html </a>for further instructions and documentation.</div> -<h4 class="subsubsection" id='magicparlabel-1189'><span class="subsubsection_label">4.7.2</span> Installing <em><i>binary_c</i></em></h4> -<div class="standard" id='magicparlabel-1190'>Please see Sec. <a href="#subsec_Building">4.4</a> above for details about how to install <i>binary_c</i>. </div> -<h4 class="subsubsection" id='magicparlabel-1191'><span class="subsubsection_label">4.7.3</span> Installing <em><i>binary_grid2</i></em></h4> -<div class="standard" id='magicparlabel-1192'><div id="subsec_installing_binary_grid"></div> +<div class="standard" id='magicparlabel-1328'>Some <span class="flex_scriptinglanguage">Perl</span><em> </em>modules also require some other system libraries and development files. It is difficult to know exactly what these would be for every operating system. You may have to use a web search to find out, but that's fine because you are smart!</div> +<h4 class="subsubsection" id='magicparlabel-1333'><span class="subsubsection_label">4.7.1</span> Get the latest <span class="flex_scriptinglanguage">Perl</span> with<em> perlbrew</em></h4> +<div class="standard" id='magicparlabel-1338'>I highly recommend that you install the latest version of <span class="flex_scriptinglanguage">Perl</span><em> </em>using <span class="flex_software">perlbrew</span> and install modules using <span class="flex_software">cpanm</span><em>.</em> I describe how to do this below, but also please see <a href="http://perlbrew.pl/">http://perlbrew.pl/</a> and <a href="http://perlbrew.pl/Perlbrew-and-Friends.html ">http://perlbrew.pl/Perlbrew-and-Friends.html </a>for further instructions and documentation.</div> +<h4 class="subsubsection" id='magicparlabel-1351'><span class="subsubsection_label">4.7.2</span> Installing <em><i>binary_c</i></em></h4> +<div class="standard" id='magicparlabel-1352'>Please see Sec. <a href="#subsec_Building">4.4</a> above for details about how to install <i>binary_c</i>. </div> +<h4 class="subsubsection" id='magicparlabel-1353'><span class="subsubsection_label">4.7.3</span> Installing <em><i>binary_grid2</i></em></h4> +<div class="standard" id='magicparlabel-1354'><div id="subsec_installing_binary_grid"></div> </div> -<div class="standard" id='magicparlabel-1193'><em><i>binary_grid2</i></em> is written in <span class="flex_scriptinglanguage"><span class="flex_scriptinglanguage">Perl</span> </span> (<a href="http://www.perl.org/">http://www.perl.org/</a>) which is available on almost every modern operating system, although to my knowledge <em><i>binary_grid2</i></em> has never been tested on anything other than <span class="flex_os">Linux</span> (<a href="http://www.linux.org/">http://www.linux.org/</a>), <span class="flex_os">Solaris</span> and <span class="flex_os">MacOS</span>.</div> +<div class="standard" id='magicparlabel-1355'><em><i>binary_grid2</i></em> is written in <span class="flex_scriptinglanguage"><span class="flex_scriptinglanguage">Perl</span> </span> (<a href="http://www.perl.org/">http://www.perl.org/</a>) which is available on almost every modern operating system, although to my knowledge <em><i>binary_grid2</i></em> has never been tested on anything other than <span class="flex_os">Linux</span> (<a href="http://www.linux.org/">http://www.linux.org/</a>), <span class="flex_os">Solaris</span> and <span class="flex_os">MacOS</span>.</div> -<div class="standard" id='magicparlabel-1214'>The newest <em><i>binary_grid2</i></em> uses features from the latest <span class="flex_scriptinglanguage">Perl</span> (5.16 or above, currently testing on 5.29.8) so you'll need a recent <span class="flex_scriptinglanguage">Perl</span> to be installed. Unfortunately most versions of <span class="flex_os">Linux</span> run an older <span class="flex_scriptinglanguage">Perl</span> without support for many of the required features. You will also need to have the latest versions of a number of <span class="flex_scriptinglanguage">Perl</span> modules which come from either from the online resource <em>CPAN</em><div class="foot"><span class="foot_label">3</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-1238'><em>Comprehensive Perl Archive Network</em></div> +<div class="standard" id='magicparlabel-1376'>The newest <em><i>binary_grid2</i></em> uses features from the latest <span class="flex_scriptinglanguage">Perl</span> (5.16 or above, currently testing on 5.29.8) so you'll need a recent <span class="flex_scriptinglanguage">Perl</span> to be installed. Unfortunately most versions of <span class="flex_os">Linux</span> run an older <span class="flex_scriptinglanguage">Perl</span> without support for many of the required features. You will also need to have the latest versions of a number of <span class="flex_scriptinglanguage">Perl</span> modules which come from either from the online resource <em>CPAN</em><div class="foot"><span class="foot_label">4</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-1400'><em>Comprehensive Perl Archive Network</em></div> </div></div> (<a href="http://www.cpan.org/">http://www.cpan.org/</a>) or as part of the <em><i>binary_c</i></em> package.</div> -<div class="standard" id='magicparlabel-1239'>My recommendation is to use <em><b>perlbrew</b> </em>to make your own <span class="flex_scriptinglanguage">Perl</span> and <span class="flex_software">cpanminus</span> (the command is <span class="flex_software">cpanm</span>) to install the modules.</div> +<div class="standard" id='magicparlabel-1401'>My recommendation is to use <em><b>perlbrew</b> </em>to make your own <span class="flex_scriptinglanguage">Perl</span> and <span class="flex_software">cpanminus</span> (the command is <span class="flex_software">cpanm</span>) to install the modules.</div> -<div class="standard" id='magicparlabel-1252'>You can find <span class="flex_software">perlbrew</span> at <a href="http://perlbrew.pl/">http://perlbrew.pl/</a> : please follow the instructions on that page to install the latest <span class="flex_scriptinglanguage">Perl</span> on your system if you do not trust my instructions below. Typically do the following, but remember you <em>must</em> install <span class="flex_software">perlbrew</span> with <span class="flex_cflags">-Dusethreads</span> otherwise <span class="flex_scriptinglanguage">Perl</span> will not use threads and you will lose the multi-CPU features of <em><i>binary_grid</i></em>2. Please note that I assume you are using the <span class="flex_software">bash</span> shell.</div> +<div class="standard" id='magicparlabel-1414'>You can find <span class="flex_software">perlbrew</span> at <a href="http://perlbrew.pl/">http://perlbrew.pl/</a> : please follow the instructions on that page to install the latest <span class="flex_scriptinglanguage">Perl</span> on your system if you do not trust my instructions below. Typically do the following, but remember you <em>must</em> install <span class="flex_software">perlbrew</span> with <span class="flex_cflags">-Dusethreads</span> otherwise <span class="flex_scriptinglanguage">Perl</span> will not use threads and you will lose the multi-CPU features of <em><i>binary_grid</i></em>2. Please note that I assume you are using the <span class="flex_software">bash</span> shell.</div> -<ol class="enumerate" id='magicparlabel-1277'><li class="enumerate_item"><br /> +<ol class="enumerate" id='magicparlabel-1439'><li class="enumerate_item"><br /> <pre class\s*='listings bash'>$ wget --no-check-certificate -O - http://install.perlbrew.pl | bash</pre><br /> or <br /> <pre class\s*='listings bash'>$ curl -kL http://install.perlbrew.pl | bash</pre><br /> @@ -1419,7 +1464,7 @@ If you have problems with <span class="flex_software">wget</span>, try removing You can use <span class="flex_cflags">-march=native -mtune=native</span> if you are quite sure you will not use this version of <span class="flex_scriptinglanguage">Perl</span> , or its modules, on a machine with a different architecture. If you are building for use with an <span class="flex_software">HTCondor</span> grid or on a shared (e.g. <em><span class="flex_software">NFS</span></em>) filesystem which is used on many different machines, I highly recommend using the <span class="flex_args">generic</span> option. <br /> -Note that the final <em>8</em> should be replaced by the number of CPUs you wish to use for the build (it is an option passed to <em>make</em>). Note also that <span class="flex_cflags">-Duseshrplib</span> may no longer be required. I have recently added <span class="flex_cflags">–thread-multi –64bitall</span> so if you have trouble, please remove these and try again. <div class="foot"><span class="foot_label">4</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-1342'>In <span class="flex_scriptinglanguage">Perl</span> 5.27.5 there is a (known) bug in the test routines which may (or may not) stop your installation. For this reason the <span class="flex_cflags">--notest</span> flag if set. Remove this if you want testing back (also, it is slow).</div> +Note that the final <em>8</em> should be replaced by the number of CPUs you wish to use for the build (it is an option passed to <em>make</em>). Note also that <span class="flex_cflags">-Duseshrplib</span> may no longer be required. I have recently added <span class="flex_cflags">–thread-multi –64bitall</span> so if you have trouble, please remove these and try again. <div class="foot"><span class="foot_label">5</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-1504'>In <span class="flex_scriptinglanguage">Perl</span> 5.27.5 there is a (known) bug in the test routines which may (or may not) stop your installation. For this reason the <span class="flex_cflags">--notest</span> flag if set. Remove this if you want testing back (also, it is slow).</div> </div></div>The installation process can take a long time, go and have lunch… then:</li> <li class="enumerate_item">Do what <span class="flex_software">perlbrew</span> suggests with your <span class="flex_file">.bashrc</span> (or whatever shell initialization script you use) to fix the <span class="flex_envvar">PERLBREW_PATH</span>.</li> <li class="enumerate_item">Restart your shell (e.g. close your terminal and open a new one, or just run <span class="flex_scriptinglanguage">bash</span> again) to update your environment and <span class="flex_envvar">$PATH</span>.</li> @@ -1450,9 +1495,9 @@ If you have a previous version of <span class="flex_scriptinglanguage">Perl</spa <pre class\s*='listings bash'>$ perlbrew install-cpanm </pre><br /> </li> </ol> -<div class="standard" id='magicparlabel-1428'>Now you have the latest <span class="flex_scriptinglanguage">Perl</span> and <span class="flex_software">cpanm</span> installed, you can start to install the modules needed for <em><i>binary_grid</i></em>2. (Un?)fortunately, there are many of them, so I have made a script to do it for you</div> +<div class="standard" id='magicparlabel-1590'>Now you have the latest <span class="flex_scriptinglanguage">Perl</span> and <span class="flex_software">cpanm</span> installed, you can start to install the modules needed for <em><i>binary_grid</i></em>2. (Un?)fortunately, there are many of them, so I have made a script to do it for you</div> -<ol class="enumerate" id='magicparlabel-1437'><li class="enumerate_item">From the <span class="flex_file"><i>binary_c</i></span> directory, go to <span class="flex_file">src/perl</span> with <br /> +<ol class="enumerate" id='magicparlabel-1599'><li class="enumerate_item">From the <span class="flex_file"><i>binary_c</i></span> directory, go to <span class="flex_file">src/perl</span> with <br /> <pre class\s*='listings bash'>$ cd src/perl</pre><br /> </li> <li class="enumerate_item">Run the install script which uses <span class="flex_software">cpanminus</span> to install the modules @@ -1485,10 +1530,10 @@ If you <em>do</em> have trouble, try <br /> <pre class\s*='listings bash'>$ export PERL5LIB=$HOME/perl5/perlbrew/perls/5.29.8/lib/site_perl/5.29.8</pre><br /> (or similar).</li> </ol> -<div class="standard" id='magicparlabel-1512'>Now you should have everything installed and be able to run a <em><i>binary_grid</i></em> script.</div> -<h4 class="subsubsection" id='magicparlabel-1513'><span class="subsubsection_label">4.7.4</span> Troubleshooting <em><span class="flex_scriptinglanguage"><em>Perl</em></span></em></h4> +<div class="standard" id='magicparlabel-1674'>Now you should have everything installed and be able to run a <em><i>binary_grid</i></em> script.</div> +<h4 class="subsubsection" id='magicparlabel-1675'><span class="subsubsection_label">4.7.4</span> Troubleshooting <em><span class="flex_scriptinglanguage"><em>Perl</em></span></em></h4> -<dl class='description' id='magicparlabel-1518'><dt class="description_label">Module not found</dt> +<dl class='description' id='magicparlabel-1680'><dt class="description_label">Module not found</dt> <dd class="description_item"> Check the <span class="flex_envvar">PERL5LIB</span> environment variable. When it is empty, <span class="flex_software">cpanm</span>/<span class="flex_software">perlbrew</span> should find your modules automatically, <em>if</em> they are installed correctly by <span class="flex_software">cpanm</span> (in the <span class="flex_file">site_perl</span> directory, see above). You can try installing modules again with <br /> <pre class\s*='listings bash'>$ cpanm --force --reinstall</pre><br /> to force a reinstallation, and with <span class="flex_args">-v</span> for extra logging.</dd> @@ -1515,22 +1560,22 @@ I also recommend <span class="flex_cflags">-Dcccdlflags=-fPIC</span><span style= <pre class\s*='listings bash'>$ perlbrew list-modules | perlbrew exec --with 5.xx.yy cpanm</pre><br /> </dd> </dl> -<h3 class="subsection" id='magicparlabel-1602'><span class="subsection_label">4.8</span> <em><i>binary_grid2</i></em> backends<div id="subsec_binary_grid2_backends"></div> +<h3 class="subsection" id='magicparlabel-1764'><span class="subsection_label">4.8</span> <em><i>binary_grid2</i></em> backends<div id="subsec_binary_grid2_backends"></div> </h3> -<div class="standard" id='magicparlabel-1603'>The “backend” of <em><i>binary_c</i></em> is a set of interface code between <em><i>binary_c</i></em> and <i>binary_grid</i><em>2</em>. To understand what a backend is, please see <a href="https://en.wikipedia.org/wiki/Front_and_back_ends">https://en.wikipedia.org/wiki/Front_and_back_ends</a>. There are two backends – <span class="flex_scriptinglanguage">Perl</span> and <span class="flex_programminglanguage">C</span> – corresponding to the two different ways <em><i>binary_c</i></em> can talk to <i>binary_grid</i>. You should always use the <span class="flex_programminglanguage">C</span> backend if at all possible: it is faster and has more features, and the <span class="flex_scriptinglanguage">Perl</span> backend will be deprecated at some point.</div> -<h4 class="subsubsection" id='magicparlabel-1620'><span class="subsubsection_label">4.8.1</span> <span class="flex_programminglanguage">C</span> backend</h4> -<div class="standard" id='magicparlabel-1625'>New to <em><i>binary_grid2</i></em> is the<em> </em><span class="flex_programminglanguage">C</span> backend. This features simpler code and uses <em><i>binary_c</i></em>'s <em>API</em> to access data directly, hence it is a lot faster than the <span class="flex_scriptinglanguage">Perl</span> backend, and scales better on multi-core architectures. The down side is that installation is more difficult, especially if you have multiple projects.</div> +<div class="standard" id='magicparlabel-1765'>The “backend” of <em><i>binary_c</i></em> is a set of interface code between <em><i>binary_c</i></em> and <i>binary_grid</i><em>2</em>. To understand what a backend is, please see <a href="https://en.wikipedia.org/wiki/Front_and_back_ends">https://en.wikipedia.org/wiki/Front_and_back_ends</a>. There are two backends – <span class="flex_scriptinglanguage">Perl</span> and <span class="flex_programminglanguage">C</span> – corresponding to the two different ways <em><i>binary_c</i></em> can talk to <i>binary_grid</i>. You should always use the <span class="flex_programminglanguage">C</span> backend if at all possible: it is faster and has more features, and the <span class="flex_scriptinglanguage">Perl</span> backend will be deprecated at some point.</div> +<h4 class="subsubsection" id='magicparlabel-1782'><span class="subsubsection_label">4.8.1</span> <span class="flex_programminglanguage">C</span> backend</h4> +<div class="standard" id='magicparlabel-1787'>New to <em><i>binary_grid2</i></em> is the<em> </em><span class="flex_programminglanguage">C</span> backend. This features simpler code and uses <em><i>binary_c</i></em>'s <em>API</em> to access data directly, hence it is a lot faster than the <span class="flex_scriptinglanguage">Perl</span> backend, and scales better on multi-core architectures. The down side is that installation is more difficult, especially if you have multiple projects.</div> -<div class="standard" id='magicparlabel-1634'>If you see errors like:</div> +<div class="standard" id='magicparlabel-1796'>If you see errors like:</div> -<div class="standard" id='magicparlabel-1635'><b><br /> +<div class="standard" id='magicparlabel-1797'><b><br /> <pre class ='listings'>perl: symbol lookup error: /.../perl5/perlbrew/perls/perl-5.29.8/lib/site_perl/5.29.8/x86_64-linux-thread-multi/auto/<i>binary_grid</i>/C/C.so: undefined symbol: new_system</pre><br /> </b>then you have failed to build the shared library as is required when using the <span class="flex_programminglanguage">C</span> backend. <br /> To make the <span class="flex_programminglanguage">C</span> backend work, you have to <em>first</em> build <span class="flex_file"><i>libbinary_c.so</i></span> and <em>then</em> install <em><i>binary_grid2</i></em>. In summary:</div> -<ol class="enumerate" id='magicparlabel-1652'><li class="enumerate_item">Build <em><i>binary_c</i></em> as normal <br /> +<ol class="enumerate" id='magicparlabel-1814'><li class="enumerate_item">Build <em><i>binary_c</i></em> as normal <br /> <pre class\s*='listings bash'>$ make</pre><br /> </li> <li class="enumerate_item">Make the shared library, <em><i>libbinary_c.so</i></em> <br /> @@ -1540,25 +1585,29 @@ To make the <span class="flex_programminglanguage">C</span> backend work, you ha <pre class\s*='listings bash'>$ ./install_modules.pl Histogram <i>binary_grid</i></pre><br /> </li> </ol> -<div class="standard" id='magicparlabel-1667'>Because this module is written partly in <span class="flex_programminglanguage">C</span> and partly in <span class="flex_scriptinglanguage">Perl</span> , everything has to work perfectly or it will crash (usually with a segmentation fault). The shared library file <span class="flex_file"><i>libbinary_c.so</i></span><em> </em>must match with <em><i>binary_grid2</i></em> <b>at compile time</b>, and if you change anything in <em><i>binary_c</i></em> you probably have to follow the above instructions to reinstall the <span class="flex_programminglanguage">C</span> backend. </div> +<div class="standard" id='magicparlabel-1829'>Because this module is written partly in <span class="flex_programminglanguage">C</span> and partly in <span class="flex_scriptinglanguage">Perl</span> , everything has to work perfectly or it will crash (usually with a segmentation fault). The shared library file <span class="flex_file"><i>libbinary_c.so</i></span><em> </em>must match with <em><i>binary_grid2</i></em> <b>at compile time</b>, and if you change anything in <em><i>binary_c</i></em> you probably have to follow the above instructions to reinstall the <span class="flex_programminglanguage">C</span> backend. </div> -<div class="standard" id='magicparlabel-1684'>You can change the name of the shared library by setting the environment variable <span style='font-family:monospace;font-size: 18px;'>BINARY_GRID2_LIB</span> to the name of the library, and pointing <span class="flex_envvar">BINARY_C</span> to your <em><i>binary_c</i></em> tree. Then rebuild, e.g.,</div> +<div class="standard" id='magicparlabel-1846'>You can change the name of the shared library by setting the environment variable <span style='font-family:monospace;font-size: 18px;'>BINARY_GRID2_LIB</span> to the name of the library, and pointing <span class="flex_envvar">BINARY_C</span> to your <em><i>binary_c</i></em> tree. Then rebuild, e.g., assuming you already have a <span class="flex_file">builddir</span>,</div> -<div class="standard" id='magicparlabel-1689'><br /> +<div class="standard" id='magicparlabel-1855'><br /> <pre class\s*='listings bash'>$ export BINARY_GRID2_LIB=binary_c_custom $ export BINARY_C=$HOME/<i>binary_c</i> -$ ./configure -$ make libbinary_c_custom.so +$ cd builddir +$ meson --reconfigure -Dlibname=binary_c_custom +$ ninja libbinary_c_custom.so +$ +$ # ... change directory to where you have <i>binary_grid2</i>.tar.gz ... +$ $ cpanm <i>binary_grid2</i>.tar.gz</pre><br /> </div> -<div class="standard" id='magicparlabel-1698'>The <em><i>binary_grid2</i></em> module respects the <span class="flex_envvar">BINARY_GRID2_LIB</span> environment variable. </div> +<div class="standard" id='magicparlabel-1868'>The <em><i>binary_grid2</i></em> module respects the <span class="flex_envvar">BINARY_GRID2_LIB</span> environment variable. </div> -<div class="standard" id='magicparlabel-1703'>I do not yet know how to have custom <span class="flex_programminglanguage">C</span> backend modules with different shared libraries. It is quite possible that you could use the <span class="flex_envvar">PERL_INLINE_DIRECTORY</span> environment variable to have multiple builds, and point to the appropriate one. Please read <a href="http://search.cpan.org/~ingy/Inline-0.44/Inline.pod">http://search.cpan.org/~ingy/Inline-0.44/Inline.pod</a> especially the section <em>The Inline DIRECTORY</em> for instructions on how it is best to set up production code for multiple projects. Let RGI know if it works, so better instructions can be put in here.</div> +<div class="standard" id='magicparlabel-1873'>I do not yet know how to have custom <span class="flex_programminglanguage">C</span> backend modules with different shared libraries. It is quite possible that you could use the <span class="flex_envvar">PERL_INLINE_DIRECTORY</span> environment variable to have multiple builds, and point to the appropriate one. Please read <a href="http://search.cpan.org/~ingy/Inline-0.44/Inline.pod">http://search.cpan.org/~ingy/Inline-0.44/Inline.pod</a> especially the section <em>The Inline DIRECTORY</em> for instructions on how it is best to set up production code for multiple projects. Let RGI know if it works, so better instructions can be put in here.</div> -<div class="standard" id='magicparlabel-1712'>There are a number of environment variables which can be set when installing <em><i>binary_grid2</i></em>'s <em>C</em> backend:</div> +<div class="standard" id='magicparlabel-1882'>There are a number of environment variables which can be set when installing <em><i>binary_grid2</i></em>'s <em>C</em> backend:</div> -<dl class='description' id='magicparlabel-1713'><dt class="description_label">BINARY_C</dt> +<dl class='description' id='magicparlabel-1883'><dt class="description_label">BINARY_C</dt> <dd class="description_item"> The directory in which your <i>binary_c</i> source tree lives. From this, the <span class="flex_file">src</span> directory is at <span class="flex_file"><span class="flex_envvar">$BINARY_C</span>/src</span></dd> <dt class="description_label">BINARY_GRID2_LIB</dt> <dd class="description_item"> The name of the shared library. Usually this is <em>'<i>binary_c</i></em>'.</dd> @@ -1581,14 +1630,14 @@ $ cpanm <i>binary_grid2</i>.tar.gz</pre><br /> <dt class="description_label">BINARY_GRID2_DEBUG</dt> <dd class="description_item"> If non-zero, is used at the debugging flag when building the <span class="flex_perlmodule">binary_grid::C</span> backend.</dd> </dl> -<h4 class="subsubsection" id='magicparlabel-1768'><span class="subsubsection_label">4.8.2</span> The <i>C</i> backend with multiple versions of <em><i>binary_c</i></em></h4> -<div class="standard" id='magicparlabel-1769'>You may well have several branches, each of which uses a different <em><i>binary_c</i></em> setup (e.g. one with <span class="flex_cmacro">NUCSYN</span>, one without). However, using <span class="flex_software">cpanm</span> the <span class="flex_perlmodule">binary_grid::C</span> module is installed only <em>once</em> and cannot possibly thus work with all your branches. (The reason is that in each branch the various structures used by <em><i>binary_c</i></em> will be of different sizes in memory, so trying to access them from an incompatible version will likely give you a segmentation fault.)</div> +<h4 class="subsubsection" id='magicparlabel-1938'><span class="subsubsection_label">4.8.2</span> The <i>C</i> backend with multiple versions of <em><i>binary_c</i></em></h4> +<div class="standard" id='magicparlabel-1939'>You may well have several branches, each of which uses a different <em><i>binary_c</i></em> setup (e.g. one with <span class="flex_cmacro">NUCSYN</span>, one without). However, using <span class="flex_software">cpanm</span> the <span class="flex_perlmodule">binary_grid::C</span> module is installed only <em>once</em> and cannot possibly thus work with all your branches. (The reason is that in each branch the various structures used by <em><i>binary_c</i></em> will be of different sizes in memory, so trying to access them from an incompatible version will likely give you a segmentation fault.)</div> -<div class="standard" id='magicparlabel-1782'>There is a solution. Make two directories containing your <em><i>binary_c</i></em> trees. You can either check out new copies of your git branches, or use “git archive” to copy a tree. In each tree, build a local copy of the <em><i>binary_grid</i></em> modules using <span class="flex_scriptinglanguage">Perl</span>'s <span class="flex_perlmodule">local::lib</span> and use this when calling your <span class="flex_scriptinglanguage">Perl</span> grid script.</div> +<div class="standard" id='magicparlabel-1952'>There is a solution. Make two directories containing your <em><i>binary_c</i></em> trees. You can either check out new copies of your git branches, or use “git archive” to copy a tree. In each tree, build a local copy of the <em><i>binary_grid</i></em> modules using <span class="flex_scriptinglanguage">Perl</span>'s <span class="flex_perlmodule">local::lib</span> and use this when calling your <span class="flex_scriptinglanguage">Perl</span> grid script.</div> -<div class="standard" id='magicparlabel-1795'>Note: it is important to set <span class="flex_envvar">BINARY_C</span> prior to the rebuild, this points to your <i>binary_c</i> directory (as checked out using <em>git</em>), because the <i>binary_grid</i> module looks in these locations for source code (which is different from tree to tree). So, from within the tree directory, run the following:</div> +<div class="standard" id='magicparlabel-1965'>Note: it is important to set <span class="flex_envvar">BINARY_C</span> prior to the rebuild, this points to your <i>binary_c</i> directory (as checked out using <em>git</em>), because the <i>binary_grid</i> module looks in these locations for source code (which is different from tree to tree). So, from within the tree directory, run the following:</div> -<div class="standard" id='magicparlabel-1800'><br /> +<div class="standard" id='magicparlabel-1970'><br /> <pre class\s*='listings bash'>$ export BINARY_C=”path_to_tree” # you have to set this to the git checkout directory $ PERL_LIBDIR=”path_to_binary_grid_perl_module” # you have to set this $ @@ -1607,34 +1656,34 @@ $ # run your grid $ perl -Mlocal::lib=$PER_MODDIR your_grid_script.pl ... $ </pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-1821'><span class="subsubsection_label">4.8.3</span> Perl backend</h4> -<div class="standard" id='magicparlabel-1822'><b>Warning: the <span class="flex_scriptinglanguage">Perl</span> backend will soon be deprecated.</b></div> +<h4 class="subsubsection" id='magicparlabel-1991'><span class="subsubsection_label">4.8.3</span> Perl backend</h4> +<div class="standard" id='magicparlabel-1992'><b>Warning: the <span class="flex_scriptinglanguage">Perl</span> backend will soon be deprecated.</b></div> -<div class="standard" id='magicparlabel-1827'>In <em><i>binary_grid</i> </em>version 1, the only backend available was the <span class="flex_scriptinglanguage">Perl</span> backend which communicates with <em><i>binary_c</i></em> via a set of <span class="flex_os">Unix</span> pipes. This is portable and flexible, and hence for many years was the default. It does not, however, scale very well in multi-CPU architectures (mostly because of the bandwidth required for the pipes). In <em><i>binary_grid2</i></em> a pure <span class="flex_scriptinglanguage">Perl</span> module is also provided, both for backwards compatibility and because the code is well tested and stable. The <span class="flex_scriptinglanguage">Perl</span> backend is installed by default with <em><i>binary_grid2</i> </em>although the <span class="flex_programminglanguage">C</span><em> </em>backend will replace it eventually.</div> +<div class="standard" id='magicparlabel-1997'>In <em><i>binary_grid</i> </em>version 1, the only backend available was the <span class="flex_scriptinglanguage">Perl</span> backend which communicates with <em><i>binary_c</i></em> via a set of <span class="flex_os">Unix</span> pipes. This is portable and flexible, and hence for many years was the default. It does not, however, scale very well in multi-CPU architectures (mostly because of the bandwidth required for the pipes). In <em><i>binary_grid2</i></em> a pure <span class="flex_scriptinglanguage">Perl</span> module is also provided, both for backwards compatibility and because the code is well tested and stable. The <span class="flex_scriptinglanguage">Perl</span> backend is installed by default with <em><i>binary_grid2</i> </em>although the <span class="flex_programminglanguage">C</span><em> </em>backend will replace it eventually.</div> -<div class="standard" id='magicparlabel-1848'>It is a simple matter of changing the <span class="flex_perlcode">prog</span> grid variable if you want to use a different version of <em><i>binary_c</i></em> with each grid script.</div> +<div class="standard" id='magicparlabel-2018'>It is a simple matter of changing the <span class="flex_perlcode">prog</span> grid variable if you want to use a different version of <em><i>binary_c</i></em> with each grid script.</div> -<div class="standard" id='magicparlabel-1853'><br /> +<div class="standard" id='magicparlabel-2023'><br /> </div> -<h2 class="section" id='magicparlabel-1854'><span class="section_label">5</span> Evolving single and binary stars</h2> -<div class="standard" id='magicparlabel-1855'><div id="sec_Simple_Use"></div> +<h2 class="section" id='magicparlabel-2024'><span class="section_label">5</span> Evolving single and binary stars</h2> +<div class="standard" id='magicparlabel-2025'><div id="sec_Simple_Use"></div> This section describes how to run <em><i>binary_c</i></em> on one stellar system, be it single or binary. The web home of <i>binary_c</i> is <a href="http://personal.ph.surrey.ac.uk/~ri0005/<i>binary_c</i>.html">http://personal.ph.surrey.ac.uk/~ri0005/<i>binary_c</i>.html</a>. The online binary-star simulator is at <a href="http://personal.ph.surrey.ac.uk/~ri0005/cgi-bin/binary5.cgi">http://personal.ph.surrey.ac.uk/~ri0005/cgi-bin/binary5.cgi</a>. If these should move, you can use your favourite web-search engine to locate the code.</div> -<div class="standard" id='magicparlabel-1856'>You should consider joining the mailing lists (see Sec. <a href="#subsec_mailing_lists">1.3</a>).</div> -<h3 class="subsection" id='magicparlabel-1857'><span class="subsection_label">5.1</span> Running</h3> -<div class="standard" id='magicparlabel-1858'><div id="subsec_Running"></div> +<div class="standard" id='magicparlabel-2026'>You should consider joining the mailing lists (see Sec. <a href="#subsec_mailing_lists">1.3</a>).</div> +<h3 class="subsection" id='magicparlabel-2027'><span class="subsection_label">5.1</span> Running</h3> +<div class="standard" id='magicparlabel-2028'><div id="subsec_Running"></div> </div> -<div class="standard" id='magicparlabel-1859'>A <span class="flex_scriptinglanguage">bash</span> script called <span class="flex_file">tbse</span> is provided to run one single or binary star system. Run it with +<div class="standard" id='magicparlabel-2029'>A <span class="flex_scriptinglanguage">bash</span> script called <span class="flex_file">tbse</span> is provided to run one single or binary star system. Run it with <br /> <br /> <pre class\s*='listings bash'>$ ./tbse</pre><br /> </div> -<div class="standard" id='magicparlabel-1872'>from the <em><i>binary_c</i></em> directory (you can omit the <span class="flex_file">.</span> if it is in your <span class="flex_envvar">PATH</span>). The script sets a number of <span class="flex_scriptinglanguage">bash</span> variables (in capital letters) which are then passed to <i>binary_c</i>. In general, the capitalized <span class="flex_scriptinglanguage">bash</span><em> </em>variable corresponds to the same variable in <i>binary_c</i> in lower case. For example,</div> +<div class="standard" id='magicparlabel-2042'>from the <em><i>binary_c</i></em> directory (you can omit the <span class="flex_file">.</span> if it is in your <span class="flex_envvar">PATH</span>). The script sets a number of <span class="flex_scriptinglanguage">bash</span> variables (in capital letters) which are then passed to <i>binary_c</i>. In general, the capitalized <span class="flex_scriptinglanguage">bash</span><em> </em>variable corresponds to the same variable in <i>binary_c</i> in lower case. For example,</div> -<div class="standard" id='magicparlabel-1889'><br /> +<div class="standard" id='magicparlabel-2059'><br /> <pre class ='listings'># Initial primary mass M1=6 # Initial secondary mass @@ -1649,7 +1698,7 @@ METALLICITY=0.02 MAX_EVOLUTION_TIME=16000</pre><br /> </div> -<div class="standard" id='magicparlabel-1905'>Many parameters are not just simple numbers, they are choices of algorithms. You can replace the numerical algorithm number, as usually defined by a macro in a header file, with the macro itself. For example, the following two are equivalent because the macro <span class="flex_cmacro">MAGNETIC_BRAKING_ALGORITHM_HURLEY_2002</span> is defined to be <span class="flex_cvar">0</span>,<br /> +<div class="standard" id='magicparlabel-2075'>Many parameters are not just simple numbers, they are choices of algorithms. You can replace the numerical algorithm number, as usually defined by a macro in a header file, with the macro itself. For example, the following two are equivalent because the macro <span class="flex_cmacro">MAGNETIC_BRAKING_ALGORITHM_HURLEY_2002</span> is defined to be <span class="flex_cvar">0</span>,<br /> <pre class ='listings'>MAGNETIC_BRAKING_ALGORITHM=0 MAGNETIC_BRAKING_ALGORITHM=MAGNETIC_BRAKING_ALGORITHM_HURLEY_2002</pre><br /> similarly, you can use <span class="flex_cmacro">True</span> and <span class="flex_cmacro">False</span> (or <span class="flex_cmacro">t</span>, <span class="flex_cmacro">T</span>, <span class="flex_cmacro">true</span>, etc.) to represent <span class="flex_cvar">1</span> and <span class="flex_cvar">0</span> respectively,<br /> @@ -1657,13 +1706,13 @@ similarly, you can use <span class="flex_cmacro">True</span> and <span class="fl PRE_MAIN_SEQUENCE_FIT_LOBES=False</pre><br /> </div> -<div class="standard" id='magicparlabel-1952'>A simple output log is sent to the file defined in <span class="flex_cmacro">LOG_FILENAME</span> which is <span class="flex_file">/tmp/c_log2.dat</span> by default. What gets output to the screen depends on what options you select (see section <a href="#subsec_Advanced_Configuration">9</a>).</div> +<div class="standard" id='magicparlabel-2122'>A simple output log is sent to the file defined in <span class="flex_cmacro">LOG_FILENAME</span> which is <span class="flex_file">/tmp/c_log2.dat</span> by default. What gets output to the screen depends on what options you select (see section <a href="#subsec_Advanced_Configuration">9</a>).</div> -<div class="standard" id='magicparlabel-1961'>Run <br /> +<div class="standard" id='magicparlabel-2131'>Run <br /> <pre class\s*='listings bash'>$ tbse help</pre><br /> to obtain general help for <span class="flex_file">tbse</span> or read Section <a href="#subsec_tbse_commands">4.5.1</a> to see more options.</div> -<div class="standard" id='magicparlabel-1970'>Use<br /> +<div class="standard" id='magicparlabel-2140'>Use<br /> <pre class\s*='listings bash'>$ ./<i>binary_c</i> help </pre><br /> for general <i>binary_c</i> help, or <br /> <pre class\s*='listings bash'>$ ./<i>binary_c</i> help <string></pre><br /> @@ -1682,12 +1731,12 @@ MAGNETIC_BRAKING_ALGORITHM_RAPPAPORT_1983 = 3 </pre><br /> </div> -<div class="standard" id='magicparlabel-1998'>Do <em>not</em> use <span class="flex_file">tbse</span> to run many stars in a stellar population! This is amazingly inefficient: you'll waste a huge amount of time just loading <span class="flex_scriptinglanguage">bash</span> and saving your data.</div> +<div class="standard" id='magicparlabel-2168'>Do <em>not</em> use <span class="flex_file">tbse</span> to run many stars in a stellar population! This is amazingly inefficient: you'll waste a huge amount of time just loading <span class="flex_scriptinglanguage">bash</span> and saving your data.</div> -<div class="standard" id='magicparlabel-2007'><br /> +<div class="standard" id='magicparlabel-2177'><br /> </div> -<h2 class="section" id='magicparlabel-2008'><span class="section_label">6</span> Making populations of stars with <i>binary_grid2</i></h2> -<div class="standard" id='magicparlabel-2009'><div id="subsec_Running_a_grid"></div> +<h2 class="section" id='magicparlabel-2178'><span class="section_label">6</span> Making populations of stars with <i>binary_grid2</i></h2> +<div class="standard" id='magicparlabel-2179'><div id="subsec_Running_a_grid"></div> You <em>could</em> run many stars by directly calling <em><i>binary_c</i></em> with the appropriate arguments or making many <span class="flex_file">tbse</span><em> </em>scripts. This is <em><b>very</b></em> <em><b>inefficient</b></em>. Instead, <em><i>binary_c</i></em> can be controlled by a <span class="flex_scriptinglanguage">Perl</span> script, e.g. <span class="flex_file">grid.pl</span>, which uses a library of functions in the <em><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> @@ -1700,8 +1749,8 @@ You <em>could</em> run many stars by directly calling <em><i>binary_c</i></em> w </mrow> </mrow></mstyle></math></em> <span class="flex_scriptinglanguage">Perl</span> module to run the stars on a grid for you.</div> -<h3 class="subsection" id='magicparlabel-2028'><span class="subsection_label">6.1</span> Introduction</h3> -<div class="standard" id='magicparlabel-2029'>The <em><span class='math'>\binarygrid</span> +<h3 class="subsection" id='magicparlabel-2198'><span class="subsection_label">6.1</span> Introduction</h3> +<div class="standard" id='magicparlabel-2199'>The <em><span class='math'>\binarygrid</span> </em> software has been developed over the last ten years or so by Robert Izzard with help from many people around the world. It is designed to work with the <em><span class='math'>binary_c</i></span> </em> stellar evolution code, based on <em>BSE</em> of <a href='#LyXCite-2002MNRAS_329_897H'><span class="bib-abbrvciteauthor">Hurley et al.</span></a> (<span class="bib-year">2002</span>), but should work with any suitably prepared stellar evolution code. In 2011 and 2012, the old <em><span class='math'>\binarygrid</span> </em> code was replaced with the <em>flexigrid</em> – this document is the guide to the <em>flexigrid</em> version of software. In 2016 a new <em><span class='math'>\binarygrid</span> @@ -1709,14 +1758,14 @@ You <em>could</em> run many stars by directly calling <em><i>binary_c</i></em> w code. In the future, only the (faster, simpler) <span class="flex_programminglanguage">C</span> backend will be supported. In the following, <em><span class='math'>\binarygrid</span> </em>implies <em><span class='math'>\binarygrid</span> 2</em>, although there may be parts of the documentation which require an update to the newer version (please let RGI know if you find an example).</div> -<h3 class="subsection" id='magicparlabel-2051'><span class="subsection_label">6.2</span> Aims: what the grid does and why</h3> -<div class="standard" id='magicparlabel-2052'><div id="sec_aims"></div> +<h3 class="subsection" id='magicparlabel-2221'><span class="subsection_label">6.2</span> Aims: what the grid does and why</h3> +<div class="standard" id='magicparlabel-2222'><div id="sec_aims"></div> Binary population synthesis is a glorified form of accountancy, without the huge pay but with of course much more fun! It involves modelling perhaps millions of binary stars in a population to pick out those few that contribute to the population of scientific interest. The rate of formation, or number of these stars, or some other property of them can then be examined in a <em>quantitative</em> and <em>statistical</em> manner. This manual explains how the <em><span class='math'>\binarygrid</span> </em>module – part of the <em><span class='math'>binary_c</i></span> </em> code package – can be used to model populations of single and binary stars. This guide is <em>only</em> concerned with the details of running grids of models, not about the details of the models themselves.</div> -<h3 class="subsection" id='magicparlabel-2053'><span class="subsection_label">6.3</span> Grid dimensions<div id="subsec_Grid_dimensions"></div> +<h3 class="subsection" id='magicparlabel-2223'><span class="subsection_label">6.3</span> Grid dimensions<div id="subsec_Grid_dimensions"></div> </h3> -<div class="standard" id='magicparlabel-2054'>There are many parameters which can be set before running a stellar model. The most important, for single stars, are the stellar mass <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2224'>There are many parameters which can be set before running a stellar model. The most important, for single stars, are the stellar mass <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>M</mi> </mrow></mstyle></math> and metallicity <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>Z</mi> @@ -1728,7 +1777,7 @@ Binary population synthesis is a glorified form of accountancy, without the huge <mrow><mi>Z</mi> </mrow></mstyle></math>. </div> -<div class="standard" id='magicparlabel-2055'>The situation is more complicated in binaries because instead of just <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2225'>The situation is more complicated in binaries because instead of just <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>M</mi> </mrow></mstyle></math> there are two stellar masses <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -1754,7 +1803,7 @@ Binary population synthesis is a glorified form of accountancy, without the huge <mrow><mi>e</mi> </mrow></mstyle></math>. To run a population of binary stars then requires a grid of models in four dimensions. Often the eccentricity is ignored because close binaries – which are the ones in which you may be interested – tend to circularise rapidly. This reduces the problem to three dimensions.</div> -<div class="standard" id='magicparlabel-2056'>The number of stars on each side of the grid, i.e. the <em>resolution</em> <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2226'>The number of stars on each side of the grid, i.e. the <em>resolution</em> <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>n</mi> </mrow></mstyle></math>, roughly determines the total runtime of your simulation. In single stars this is just <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -1817,11 +1866,11 @@ Binary population synthesis is a glorified form of accountancy, without the huge </mstyle> </mrow> </mrow></mstyle></math>. </div> -<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-2060'><img style='width:45%;' src='images/3.png' alt='image: 9_tmp_binary_c_lyx_images_1.png' /> +<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-2230'><img style='width:45%;' src='images/3.png' alt='image: 9_tmp_binary_c_lyx_images_1.png' /> <img style='width:45%;' src='images/4.png' alt='image: 10_tmp_binary_c_lyx_images_2.png' /> </div> -<div class="plain_layout" id='magicparlabel-2061'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 1: <div id="fig_grid_size"></div> +<div class="plain_layout" id='magicparlabel-2231'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 1: <div id="fig_grid_size"></div> The relative size of the single- and binary-star grids. In single stars only one mass is required, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> @@ -1889,17 +1938,17 @@ The relative size of the single- and binary-star grids. In single stars only one </mrow></mstyle></math> PC.</span></div> </div> -<h3 class="subsection" id='magicparlabel-2066'><span class="subsection_label">6.4</span> What to do with the grid<div id="subsec_What_to_do"></div> +<h3 class="subsection" id='magicparlabel-2236'><span class="subsection_label">6.4</span> What to do with the grid<div id="subsec_What_to_do"></div> </h3> -<div class="standard" id='magicparlabel-2067'>What do we do once the grid of stars is set up? In most cases this involves adding up some statistics related to each star on the grid. There are two approaches which are commonly used, constant star formation and a starburst. The one that suits you depends on what you are trying to calculate and to which observations you hope to compare.</div> -<h4 class="subsubsection" id='magicparlabel-2068'><span class="subsubsection_label">6.4.1</span> Constant star formation rate</h4> -<div class="standard" id='magicparlabel-2069'>In this case the formation rate or (perhaps <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2237'>What do we do once the grid of stars is set up? In most cases this involves adding up some statistics related to each star on the grid. There are two approaches which are commonly used, constant star formation and a starburst. The one that suits you depends on what you are trying to calculate and to which observations you hope to compare.</div> +<h4 class="subsubsection" id='magicparlabel-2238'><span class="subsubsection_label">6.4.1</span> Constant star formation rate</h4> +<div class="standard" id='magicparlabel-2239'>In this case the formation rate or (perhaps <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi> </mrow> </mrow></mstyle></math>-weighted) probabilities for each star corresponding to those in which you are interested are simply added up. This is why I say it is like accountancy! Because the rate of star formation is assumed to be <em>constant</em> the evolution time of the stellar evolution is irrelevant. A hybrid scheme can also be used, you might only consider stars older than a given age (e.g. for halo stars).</div> -<h4 class="subsubsection" id='magicparlabel-2070'><span class="subsubsection_label">6.4.2</span> Starburst</h4> -<div class="standard" id='magicparlabel-2071'>All stars form at time zero and you add up the (probably <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<h4 class="subsubsection" id='magicparlabel-2240'><span class="subsubsection_label">6.4.2</span> Starburst</h4> +<div class="standard" id='magicparlabel-2241'>All stars form at time zero and you add up the (probably <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi> </mrow> @@ -1908,16 +1957,16 @@ The relative size of the single- and binary-star grids. In single stars only one </div> -<div class="standard" id='magicparlabel-2072'>The statistic you wish to add up is usually output from <em><span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-2242'>The statistic you wish to add up is usually output from <em><span class='math'>binary_c</i></span> . </em>Your “grid script” runs each star in your population, takes the output of <em><span class='math'>binary_c</i></span> </em> and adds up the statistic. You can generate single numbers, histograms or arbitrarily complicated statistical constructs for comparison with observations. You can choose whether to do the calculations on the fly or save the progenitor information for later data processing.</div> -<div class="standard" id='magicparlabel-2073'>The grid script can be used on multi-CPU machines and handles the administrative issues regarding parallel processing.</div> +<div class="standard" id='magicparlabel-2243'>The grid script can be used on multi-CPU machines and handles the administrative issues regarding parallel processing.</div> -<div class="standard" id='magicparlabel-2074'><br /> +<div class="standard" id='magicparlabel-2244'><br /> </div> -<h3 class="subsection" id='magicparlabel-2075'><span class="subsection_label">6.5</span> Grid setup (in theory)</h3> -<div class="standard" id='magicparlabel-2076'><div id="sec_grid_setup_theory"></div> +<h3 class="subsection" id='magicparlabel-2245'><span class="subsection_label">6.5</span> Grid setup (in theory)</h3> +<div class="standard" id='magicparlabel-2246'><div id="sec_grid_setup_theory"></div> This section presents the <em>theory</em> behind the setup of a grid in <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>M</mi> </mrow></mstyle></math>, for single stars, or <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -1964,7 +2013,7 @@ This section presents the <em>theory</em> behind the setup of a grid in <math xm </mrow> </mrow></mstyle></math>. This is rather subjective but you can chose the bounds of your grid to reflect the stars in which your interest lies.</div> -<div class="standard" id='magicparlabel-2077'>Each star in the grid represents a <em>phase volume</em>. This means that a star of mass <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2247'>Each star in the grid represents a <em>phase volume</em>. This means that a star of mass <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>M</mi> </mrow></mstyle></math> represents stars which, in reality, have masses <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -1988,7 +2037,7 @@ This section presents the <em>theory</em> behind the setup of a grid in <math xm </mrow> </mrow></mstyle></math> decreased) until your “answer” converges.</div> -<div class="standard" id='magicparlabel-2078'>One concept which must be grasped is that the bounds of the <em>grid</em> are not necessarily the bounds of the <em>initial distributions</em> you will be using (e.g. the initial mass function, IMF). This is a critical point which can lead to confusion, it is best explained with an example. Say you wish to calculate the ratio of type II to type Ib/c supernovae. You would do this by adding up the number of stars that explode as type IIs and divide by the number of stars that explode as type Ib/cs. You <em>could</em> do this with a grid from <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2248'>One concept which must be grasped is that the bounds of the <em>grid</em> are not necessarily the bounds of the <em>initial distributions</em> you will be using (e.g. the initial mass function, IMF). This is a critical point which can lead to confusion, it is best explained with an example. Say you wish to calculate the ratio of type II to type Ib/c supernovae. You would do this by adding up the number of stars that explode as type IIs and divide by the number of stars that explode as type Ib/cs. You <em>could</em> do this with a grid from <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mn>0.1</mn> </mrow></mstyle></math> to <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -2130,11 +2179,11 @@ This section presents the <em>theory</em> behind the setup of a grid in <math xm </mrow> </mrow></mstyle></math>. Note that the <em>grid</em> has changed, but the result has not. This is because the initial distributions have fixed bounds independent of the grid bounds. See Section <a href="#sec_initial_dists">6.20</a> for more details on initial distributions. </div> -<div class="standard" id='magicparlabel-2079'>This process requires some knowledge in advance, which you may not have. In that case, run a low resolution grid, find suitable grid bounds and then repeat at higher resolution until you are happy. The downside to the process is that you may well miss small parts of the parameter space which contain interesting systems. In practice this is often a compromise worth making and, if in doubt, test your model runs at low resolution but then crank the resolution to the maximum you think is possible for the final model run.</div> +<div class="standard" id='magicparlabel-2249'>This process requires some knowledge in advance, which you may not have. In that case, run a low resolution grid, find suitable grid bounds and then repeat at higher resolution until you are happy. The downside to the process is that you may well miss small parts of the parameter space which contain interesting systems. In practice this is often a compromise worth making and, if in doubt, test your model runs at low resolution but then crank the resolution to the maximum you think is possible for the final model run.</div> -<div class="standard" id='magicparlabel-2080'>Another advantage of choosing the grid bounds is that sub-grids can be run on different computers or CPU cores and the results combined. This is discussed further in Section <a href="#sec_The_Thread_Model">6.22</a>.</div> -<h4 class="subsubsection" id='magicparlabel-2081'><span class="subsubsection_label">6.5.1</span> Phase Volume</h4> -<div class="standard" id='magicparlabel-2082'><div id="subsec_phase_volume"></div> +<div class="standard" id='magicparlabel-2250'>Another advantage of choosing the grid bounds is that sub-grids can be run on different computers or CPU cores and the results combined. This is discussed further in Section <a href="#sec_The_Thread_Model">6.22</a>.</div> +<h4 class="subsubsection" id='magicparlabel-2251'><span class="subsubsection_label">6.5.1</span> Phase Volume</h4> +<div class="standard" id='magicparlabel-2252'><div id="subsec_phase_volume"></div> Given a chosen set of these distributions a logarithmic grid is set up in one-dimensional <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>M</mi> </mrow></mstyle></math> space for single stars or in 3D <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -2163,7 +2212,7 @@ Given a chosen set of these distributions a logarithmic grid is set up in one-di </mrow> </mrow></mstyle></math> where </div> -<div class="standard" id='magicparlabel-2083'><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2253'><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mtable> <mtr> <mtd> @@ -2313,11 +2362,11 @@ Given a chosen set of these distributions a logarithmic grid is set up in one-di </mrow> </mrow></mstyle></math> for binary stars.</div> -<div class="standard" id='magicparlabel-2084'>The probability of existence of star <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2254'>The probability of existence of star <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>i</mi> </mrow></mstyle></math> is given by</div> -<div class="standard" id='magicparlabel-2085'><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2255'><math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mtable> <mtr> <mtd> @@ -2347,7 +2396,7 @@ Given a chosen set of these distributions a logarithmic grid is set up in one-di <mrow><mo> Ψ </mo> </mrow></mstyle></math> is discussed in Section <a href="#sec_initial_dists">6.20</a>. </div> -<div class="standard" id='magicparlabel-2086'>The probability, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2256'>The probability, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi> <msub subscriptshift="0.2ex"> @@ -2384,8 +2433,8 @@ Given a chosen set of these distributions a logarithmic grid is set up in one-di </msub> </mrow> </mrow></mstyle></math>. You have to be careful to calculate the appropriate statistics for comparison with the observations.</div> -<h4 class="subsubsection" id='magicparlabel-2087'><span class="subsubsection_label">6.5.2</span> Grid loops</h4> -<div class="standard" id='magicparlabel-2088'><div id="subsec_grid_loops"></div> +<h4 class="subsubsection" id='magicparlabel-2257'><span class="subsubsection_label">6.5.2</span> Grid loops</h4> +<div class="standard" id='magicparlabel-2258'><div id="subsec_grid_loops"></div> In binary systems, the secondary mass <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> @@ -2408,7 +2457,7 @@ In binary systems, the secondary mass <math xmlns="http://www.w3.org/1998/Math/M <mrow><mi>P</mi> </mrow></mstyle></math>, may depend on both. This means that usually the grid must be constructed in a series of nested loops:</div> -<div class="standard" id='magicparlabel-2089'><div id="eq_grid_loops"></div> +<div class="standard" id='magicparlabel-2259'><div id="eq_grid_loops"></div> <math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mtable> <mtr> @@ -2613,8 +2662,8 @@ In binary systems, the secondary mass <math xmlns="http://www.w3.org/1998/Math/M </mrow> </msub> </mrow></mstyle></math>.</div> -<h4 class="subsubsection" id='magicparlabel-2090'><span class="subsubsection_label">6.5.3</span> Resolution</h4> -<div class="standard" id='magicparlabel-2091'><div id="subsec_resolution"></div> +<h4 class="subsubsection" id='magicparlabel-2260'><span class="subsubsection_label">6.5.3</span> Resolution</h4> +<div class="standard" id='magicparlabel-2261'><div id="subsec_resolution"></div> The choice of grid resolution depends very much on the problem you wish to address and what you are trying to calculate. As a general rule, assuming you are modelling stars from <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> @@ -2673,9 +2722,9 @@ The choice of grid resolution depends very much on the problem you wish to addre </msub> </mrow></mstyle></math>) dimension. </div> -<div class="standard" id='magicparlabel-2092'>However, before rushing off to run millions of stars, run some low-resolution test models and gradually increase the number of stars. The best way to determine the required resolution is simply the brute force method: keep increasing the resolution until your answers converge.</div> +<div class="standard" id='magicparlabel-2262'>However, before rushing off to run millions of stars, run some low-resolution test models and gradually increase the number of stars. The best way to determine the required resolution is simply the brute force method: keep increasing the resolution until your answers converge.</div> -<div class="standard" id='magicparlabel-2093'>You can roughly estimate the <em>statistical </em>error by counting the number of stars that satisfy your criterion (say <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2263'>You can roughly estimate the <em>statistical </em>error by counting the number of stars that satisfy your criterion (say <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>k</mi> </mrow></mstyle></math> stars) and then use Poisson statistics (i.e. the error on a value <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>x</mi> @@ -2687,20 +2736,20 @@ The choice of grid resolution depends very much on the problem you wish to addre </mrow> </mrow></mstyle></math>). <b>Be warned that this is <em>not</em> the error due to the use of a grid.</b> If your data calculation binning is <em>over</em>-resolved you may see problems with artefacts and aliasing. These may or may not affect your results. If in doubt, increase the resolution until the problem goes away (if it goes away!). In some cases this may not be possible because your computer is not fast enough. You could always buy a time machine… but then you wouldn't be doing astrophysics!</div> -<div class="standard" id='magicparlabel-2094'>Overall resolution is often not your only concern: perhaps you want more stars in a certain region of the parameter space. Well, with the flexigrid and its spacing_functions module you can define your own grid spacing function which as flexible as you like (see Sections <a href="#sec_flexigrid">6.11</a> and <a href="#sec_The_spacing_functions_module">6.21</a>). </div> +<div class="standard" id='magicparlabel-2264'>Overall resolution is often not your only concern: perhaps you want more stars in a certain region of the parameter space. Well, with the flexigrid and its spacing_functions module you can define your own grid spacing function which as flexible as you like (see Sections <a href="#sec_flexigrid">6.11</a> and <a href="#sec_The_spacing_functions_module">6.21</a>). </div> -<div class="standard" id='magicparlabel-2095'><br /> +<div class="standard" id='magicparlabel-2265'><br /> </div> -<h3 class="subsection" id='magicparlabel-2096'><span class="subsection_label">6.6</span> Data parsing</h3> -<div class="standard" id='magicparlabel-2097'><div id="sec_data_parsing"></div> +<h3 class="subsection" id='magicparlabel-2266'><span class="subsection_label">6.6</span> Data parsing</h3> +<div class="standard" id='magicparlabel-2267'><div id="sec_data_parsing"></div> Before you actually run your own population synthesis grid you have to think about what you want to discover from your stellar models. A few standard cases are outlined here. It is vital to decide what you want in advance, because often data analysis takes up a large chunk of CPU time when evolving a population. While <em><span class='math'>\binarygrid</span> 2</em> is a great advance over earlier versions of <span class='math'>\binarygrid</span> in this regard, it is still good to be <em>efficient</em>.</div> -<div class="standard" id='magicparlabel-2098'>This section describes the theory, the practical aspects of combining<em> <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-2268'>This section describes the theory, the practical aspects of combining<em> <span class='math'>binary_c</i></span> </em>with your grid script are described in the following, e.g. Section <a href="#sec_grid_pl">6.9</a>.</div> -<h4 class="subsubsection" id='magicparlabel-2099'><span class="subsubsection_label">6.6.1</span> Rates of things</h4> -<div class="standard" id='magicparlabel-2100'><div id="subsec_rates_of_things"></div> +<h4 class="subsubsection" id='magicparlabel-2269'><span class="subsubsection_label">6.6.1</span> Rates of things</h4> +<div class="standard" id='magicparlabel-2270'><div id="subsec_rates_of_things"></div> The simplest thing to calculate is the rate of formation of some type of star, or alternatively the rate of stellar death (e.g. the supernova rate), merger rate, etc. These are <em>events </em>which have no duration so the important thing to log is the <em>time at which the event happened</em>,<em> <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> @@ -2719,7 +2768,7 @@ The simplest thing to calculate is the rate of formation of some type of star, o </msub> </mrow></mstyle></math>.</div> -<div class="standard" id='magicparlabel-2101'>You will probably want to count the number of systems that explode in a given time bin, i.e. between time <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2271'>You will probably want to count the number of systems that explode in a given time bin, i.e. between time <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>t</mi> </mrow></mstyle></math> and <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -2754,7 +2803,7 @@ The simplest thing to calculate is the rate of formation of some type of star, o <mrow><mi>S</mi> </mrow></mstyle></math> (and its associated uncertainty) cancels out.</div> -<div class="standard" id='magicparlabel-2102'>This is all correct for a starburst at time <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2272'>This is all correct for a starburst at time <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi>t</mi><mo>=</mo><mn>0</mn> </mrow> @@ -2762,11 +2811,11 @@ The simplest thing to calculate is the rate of formation of some type of star, o <mrow><mi>t</mi> </mrow></mstyle></math>) or use a pre-existing code such as RGI's Galactic Chemical Evolution (<em>GCE</em>) code. The latter has the advantage that it already exists and is well tested. You will, however, have to ask RGI about it because it is not (yet) a part of the standard<em> <span class='math'>binary_c</i></span> </em>distribution. </div> -<h4 class="subsubsection" id='magicparlabel-2103'><span class="subsubsection_label">6.6.2</span> Numbers of things</h4> -<div class="standard" id='magicparlabel-2104'><div id="subsec_numbers_of_things"></div> +<h4 class="subsubsection" id='magicparlabel-2273'><span class="subsubsection_label">6.6.2</span> Numbers of things</h4> +<div class="standard" id='magicparlabel-2274'><div id="subsec_numbers_of_things"></div> </div> -<div class="standard" id='magicparlabel-2105'>Alternatively, perhaps you wish to calculate the number of stars of a certain type e.g. the number of carbon stars or the number of K-type stars. In this case you have to count both the probability of the existence of the star <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2275'>Alternatively, perhaps you wish to calculate the number of stars of a certain type e.g. the number of carbon stars or the number of K-type stars. In this case you have to count both the probability of the existence of the star <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>p</mi> @@ -2802,7 +2851,7 @@ The simplest thing to calculate is the rate of formation of some type of star, o </mrow> </mrow></mstyle></math> if the star is interesting to you, but zero otherwise.</div> -<div class="standard" id='magicparlabel-2106'>As in the previous example, if <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2276'>As in the previous example, if <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>S</mi> </mrow></mstyle></math> is not simply a constant things get tricky. But usually a constant star formation rate is “good enough” for e.g. Galactic stellar population studies of anything but the youngest stars. In other cases a starburst is more appropriate and you will have to factor in a check on the time <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>t</mi> @@ -2814,36 +2863,36 @@ The simplest thing to calculate is the rate of formation of some type of star, o </mover> </mrow></mstyle></math> to match the present-day age of the population. </div> -<div class="standard" id='magicparlabel-2107'><br /> +<div class="standard" id='magicparlabel-2277'><br /> </div> -<h3 class="subsection" id='magicparlabel-2108'><span class="subsection_label">6.7</span> Running grids of stars</h3> -<div class="standard" id='magicparlabel-2109'><div id="sec_grid_setup_practice"></div> +<h3 class="subsection" id='magicparlabel-2278'><span class="subsection_label">6.7</span> Running grids of stars</h3> +<div class="standard" id='magicparlabel-2279'><div id="sec_grid_setup_practice"></div> You run a grid of stars using a combination of the <em><i>binary_grid2</i></em> module and a chosen backend (see Section <a href="#subsec_binary_grid2_backends">4.8</a>).</div> -<dl class='description' id='magicparlabel-2110'><dt class="description_label"><i>binary_grid2</i></dt> +<dl class='description' id='magicparlabel-2280'><dt class="description_label"><i>binary_grid2</i></dt> <dd class="description_item"> is the code which sets out the parameter space, and defines the (object oriented) interface to your stellar population. </dd> <dt class="description_label">the backend</dt> <dd class="description_item"> is the code that connects your <span class='math'>\binarygrid</span> 2 stellar population to the stellar evolution code (usually<em> <span class='math'>binary_c</i></span> </em>). As of V2.00 there is a <span class="flex_programminglanguage">C</span> and a <span class="flex_scriptinglanguage">Perl</span> backend. Please use the <span class="flex_programminglanguage">C</span> backend, the <span class="flex_scriptinglanguage">Perl</span> backend is for backwards compatibility reasons and testing only, and the <span class="flex_programminglanguage">C</span> version is <em>much</em> more efficient.</dd> </dl> -<div class="standard" id='magicparlabel-2132'>For details on how the grid is set up, and how it is multithreaded, please see Section <a href="#sec_flexigrid">6.11</a>.</div> -<h4 class="subsubsection" id='magicparlabel-2133'><span class="subsubsection_label">6.7.1</span> Your <em>grid script</em></h4> -<div class="standard" id='magicparlabel-2134'>You load the<em> <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-2302'>For details on how the grid is set up, and how it is multithreaded, please see Section <a href="#sec_flexigrid">6.11</a>.</div> +<h4 class="subsubsection" id='magicparlabel-2303'><span class="subsubsection_label">6.7.1</span> Your <em>grid script</em></h4> +<div class="standard" id='magicparlabel-2304'>You load the<em> <span class='math'>\binarygrid</span> 2 </em>module from your <em>grid</em> <em>script</em> (see Sec. <a href="#sec_grid_pl">6.9</a> for full details). This is a<em> </em><span class="flex_scriptinglanguage">Perl</span> script which contains the definition of both your population synthesis grid and your input physics. Do not make this yourself: instead, use the template script in the <span class="flex_file">src/perl/scripts2</span> directory of the<em> <span class='math'>binary_c</i></span> </em>tree and modify appropriately (Sec. <a href="#sec_grid_pl">6.9</a>). The most appropriate starting place is the script <span class="flex_file">src/perl/scripts2/template.pl</span> which is a basic grid that can be adapted.</div> -<h4 class="subsubsection" id='magicparlabel-2147'><span class="subsubsection_label">6.7.2</span> The <em><i>binary_grid2</i></em> Module</h4> -<div class="standard" id='magicparlabel-2148'><div id="subsec_the_binary_grid_perl_module"></div> +<h4 class="subsubsection" id='magicparlabel-2317'><span class="subsubsection_label">6.7.2</span> The <em><i>binary_grid2</i></em> Module</h4> +<div class="standard" id='magicparlabel-2318'><div id="subsec_the_binary_grid_perl_module"></div> </div> -<div class="standard" id='magicparlabel-2149'>The <em><span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-2319'>The <em><span class='math'>\binarygrid</span> 2</em> module contains all the code to set up, manage and run your stellar grid(s). The internal workings should be (almost) transparent to you, the user, and the process is as automated as possible. You still have to do something, of course, and – most importantly – decide on input physics.</div> -<h4 class="subsubsection" id='magicparlabel-2150'><span class="subsubsection_label">6.7.3</span> <span class='math'>\binarygrid</span> +<h4 class="subsubsection" id='magicparlabel-2320'><span class="subsubsection_label">6.7.3</span> <span class='math'>\binarygrid</span> 2 objects</h4> -<div class="standard" id='magicparlabel-2151'>You should make <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-2321'>You should make <span class='math'>\binarygrid</span> 2 objects, each of which is one of your stellar populations. You can have multiple populations in the same grid (they are independent) but usually you just want one. Make a new one with code like the following:</div> -<div class="standard" id='magicparlabel-2152'><br /> +<div class="standard" id='magicparlabel-2322'><br /> <pre class ='listings Perl'># number of computational threads to launch my $nthreads = rob_misc::ncpus(); @@ -2856,12 +2905,12 @@ my $population = <i>binary_grid2</i>->new( </pre><br /> </div> -<div class="standard" id='magicparlabel-2166'>You can now access the object, <span class="flex_perlcode">$population</span>, through the various methods of the <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-2336'>You can now access the object, <span class="flex_perlcode">$population</span>, through the various methods of the <span class='math'>\binarygrid</span> 2 module.</div> -<h4 class="subsubsection" id='magicparlabel-2171'><span class="subsubsection_label">6.7.4</span> Variables</h4> -<div class="standard" id='magicparlabel-2172'>You can set variables:</div> +<h4 class="subsubsection" id='magicparlabel-2341'><span class="subsubsection_label">6.7.4</span> Variables</h4> +<div class="standard" id='magicparlabel-2342'>You can set variables:</div> -<ul class="itemize" id='magicparlabel-2173'><li class="itemize_item">When defining the object, as shown above.</li> +<ul class="itemize" id='magicparlabel-2343'><li class="itemize_item">When defining the object, as shown above.</li> <li class="itemize_item">With calls the <span style='font-family:monospace;font-size: 18px;'>set</span> method, e.g.,<br /> <pre class ='listings Perl'>$population->set( vb=>1, # turn on verbose logging (can be 0,1,2...) @@ -2874,12 +2923,12 @@ $population->{_bse_options}->{metallicity} = 0.004;</pre><br /> This method is <b>not recommended unless you know exactly what you are doing.</b></li> <li class="itemize_item">Calls to object methods which are <em>undefined</em> are passed to the <span class="flex_perlcode">AUTOLOAD</span> method which issues a warning. This usually indicates a typo or mistake on your part.</li> </ul> -<h4 class="subsubsection" id='magicparlabel-2193'><span class="subsubsection_label">6.7.5</span> Important Subroutines in <em><i>binary_grid</i></em></h4> -<div class="standard" id='magicparlabel-2194'><div id="subsec_subs_in_binary_grid"></div> +<h4 class="subsubsection" id='magicparlabel-2363'><span class="subsubsection_label">6.7.5</span> Important Subroutines in <em><i>binary_grid</i></em></h4> +<div class="standard" id='magicparlabel-2364'><div id="subsec_subs_in_binary_grid"></div> A few <span class='math'>\binarygrid</span> 2 methods are used often</div> -<dl class='description' id='magicparlabel-2195'><dt class="description_label">parse args</dt> +<dl class='description' id='magicparlabel-2365'><dt class="description_label">parse args</dt> <dd class="description_item"> This scans the command line arguments to your script and sets any variables thus defined as <span class="flex_perlcode"><variable>=<value></span> pairs.</dd> <dt class="description_label">set</dt> <dd class="description_item"> Sets a list of variables in <span class="flex_perlcode"><variable> => <value></span> pairs.</dd> @@ -2898,11 +2947,11 @@ If the grid variable <span class="flex_perlcode">return_array_refs</span><em> </ <dt class="description_label">results</dt> <dd class="description_item"> Returns (a reference to) the hash containing the results of the evolution. At the end of the evolution of your population you can acquire statistics through this hash reference.</dd> </dl> -<h3 class="subsection" id='magicparlabel-2249'><span class="subsection_label">6.8</span> Important Subroutines in your grid script</h3> -<div class="standard" id='magicparlabel-2250'><div id="subsec_subs_in_your_script"></div> +<h3 class="subsection" id='magicparlabel-2419'><span class="subsection_label">6.8</span> Important Subroutines in your grid script</h3> +<div class="standard" id='magicparlabel-2420'><div id="subsec_subs_in_your_script"></div> </div> -<h4 class="subsubsection" id='magicparlabel-2251'><span class="subsubsection_label">6.8.1</span> <em>parse_data </em>(required)</h4> -<div class="standard" id='magicparlabel-2252'>You have to write a function to parse the data which comes from your <span class='math'>\binarygrid</span> +<h4 class="subsubsection" id='magicparlabel-2421'><span class="subsubsection_label">6.8.1</span> <em>parse_data </em>(required)</h4> +<div class="standard" id='magicparlabel-2422'>You have to write a function to parse the data which comes from your <span class='math'>\binarygrid</span> 2 object and return when there is no more data. <br /> @@ -2940,10 +2989,10 @@ An example function is the following. </pre><br /> </div> -<div class="standard" id='magicparlabel-2283'><br /> +<div class="standard" id='magicparlabel-2453'><br /> </div> -<h3 class="subsection" id='magicparlabel-2284'><span class="subsection_label">6.9</span> Your <em>grid script </em>and coupling your population synthesis to <em><i>binary_c</i>/nucsyn</em></h3> -<div class="standard" id='magicparlabel-2285'><div id="sec_grid_pl"></div> +<h3 class="subsection" id='magicparlabel-2454'><span class="subsection_label">6.9</span> Your <em>grid script </em>and coupling your population synthesis to <em><i>binary_c</i>/nucsyn</em></h3> +<div class="standard" id='magicparlabel-2455'><div id="sec_grid_pl"></div> This describes what you should do in your grid script in order to make the <em>flexigrid </em>work. Learn about the <em>flexigrid</em> in Section <a href="#sec_flexigrid">6.11</a>. <br /> @@ -2957,19 +3006,19 @@ Before you start: you should copy the <span class="flex_perlscript">grid-flexigr <br /> </div> -<h4 class="subsubsection" id='magicparlabel-2302'><span class="subsubsection_label">6.9.1</span> Logging in <em><i>binary_c</i></em></h4> -<div class="standard" id='magicparlabel-2303'><div id="subsec_logging_in_binary_c"></div> +<h4 class="subsubsection" id='magicparlabel-2472'><span class="subsubsection_label">6.9.1</span> Logging in <em><i>binary_c</i></em></h4> +<div class="standard" id='magicparlabel-2473'><div id="subsec_logging_in_binary_c"></div> </div> -<div class="standard" id='magicparlabel-2304'>When <em><span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-2474'>When <em><span class='math'>binary_c</i></span> </em> is run for one star with the <span class="flex_bashscript">tbse</span> script the output is dumped to the screen (known in <span class="flex_os">UNIX</span> as <span class="flex_cvar">stdout</span>). A standard build of <em><span class='math'>binary_c</i></span> </em> outputs very little information because it does not know what you wish to know (this is a <em>known unknown</em>). Every line that is output is expensive in terms of CPU time, and CPU time is critical when running millions of stars. This means you have to think carefully about what you will output from <em><span class='math'>binary_c</i></span> </em> and when. Too much information slows things down, too little is useless – you have to decide.</div> -<div class="standard" id='magicparlabel-2317'>You may want to choose whether to output one line of information every <em><span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-2487'>You may want to choose whether to output one line of information every <em><span class='math'>binary_c</i></span> </em> timestep. This should be done either in your grid script by setting <span class="flex_perlscript">C_auto_logging</span> or <span class="flex_perlcode">C_logging_code</span> or manually in the <span class="flex_sourcefile">src/logging/log_every_timestep.c</span> subroutine which is called every timestep.</div> -<ul class="itemize" id='magicparlabel-2330'><li class="itemize_item"><em><b>C_auto_logging</b></em> This is the recommended route to logging when coupling <span class='math'>binary_c</i></span> +<ul class="itemize" id='magicparlabel-2500'><li class="itemize_item"><em><b>C_auto_logging</b></em> This is the recommended route to logging when coupling <span class='math'>binary_c</i></span> to <span class='math'>\binarygrid</span> but only works for simple variables that are inside stardata. In your grid script, do something like the following to set <span class="flex_perlscript">C_auto_logging</span>. This is a hash of headers (in this case MY_STELLAR_DATA) which correspond to lines of output from <span class='math'>binary_c</i></span> which are then prefixed with the header. Following this is a set of numerical data items, in the case below time, mass of star 0 (the primary star), the system probability and the timestep. All the items are assumed to be floating point variables, and are processed with the <span class="flex_cvar">%g</span> format statement so that (small) integers are output as integers.<br /> @@ -3006,12 +3055,12 @@ Before you start: you should copy the <span class="flex_perlscript">grid-flexigr </pre><br /> </li> </ul> -<div class="standard" id='magicparlabel-2392'>The string <span class="flex_cmacro">MY_STELLAR_DATA</span> is critical: this is the <em>header</em> that is recognised by your <span class="flex_perlscript">parse_data</span> function as <span class="flex_perlcode">$header</span> and on the basis of which your <span class="flex_perlcode">parse_data</span> function decides how to act and save data for later statistical analysis, output, plotting, etc.</div> +<div class="standard" id='magicparlabel-2562'>The string <span class="flex_cmacro">MY_STELLAR_DATA</span> is critical: this is the <em>header</em> that is recognised by your <span class="flex_perlscript">parse_data</span> function as <span class="flex_perlcode">$header</span> and on the basis of which your <span class="flex_perlcode">parse_data</span> function decides how to act and save data for later statistical analysis, output, plotting, etc.</div> -<div class="standard" id='magicparlabel-2409'>You should have a think (and consult Section <a href="#sec_data_parsing">6.6</a>) to determine whether you want to output either the probability (<span class="flex_cvar">stardata->model.probability</span>) or both the probability and timestep<div class="foot"><span class="foot_label">5</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-2417'>Do not use stardata->model.dt or stardata->model.dtm: use the local variable dt.</div> +<div class="standard" id='magicparlabel-2579'>You should have a think (and consult Section <a href="#sec_data_parsing">6.6</a>) to determine whether you want to output either the probability (<span class="flex_cvar">stardata->model.probability</span>) or both the probability and timestep<div class="foot"><span class="foot_label">6</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-2587'>Do not use stardata->model.dt or stardata->model.dtm: use the local variable dt.</div> </div></div> (<span class="flex_cvar">dt</span> in years, or <span class="flex_cvar">dtm</span> in megayears). Often it is the number of stars in a particular phase that you want to count, in which case you want to add up the product: <span class="flex_cvar">stardata-> model.probability*dt</span>, which is set up for you as the local variable <span class="flex_cvar">dtp</span>. If you are counting the rate of an event, e.g. supernovae, then the probability alone is more likely to be what you want.</div> -<h4 class="subsubsection" id='magicparlabel-2434'><span class="subsubsection_label">6.9.2</span> Adding things up</h4> -<div class="standard" id='magicparlabel-2435'><div id="subsec_adding_things_up"></div> +<h4 class="subsubsection" id='magicparlabel-2604'><span class="subsubsection_label">6.9.2</span> Adding things up</h4> +<div class="standard" id='magicparlabel-2605'><div id="subsec_adding_things_up"></div> The <span class="flex_perlcode">$h</span> hash pointer in <span class="flex_perlscript">parse_data</span> is where you should put data which you later want to analyse. You should scan for the appropriate header, e.g.<span style='font-family:monospace;font-size: 18px;'> </span><span class="flex_cvar">MY_STELLAR_DATA</span>, and then act on the rest of the data. An example <span style='font-family:monospace;font-size: 18px;'>parse_data</span> function corresponding to the above <span style='font-family:monospace;font-size: 18px;'>Printf</span> statement is (assuming <span class="flex_perlcode">return_array_refs</span> is set to <span class="flex_perlcode">1</span>)<br /> <pre class ='listings Perl'>sub parse_data { @@ -3049,8 +3098,8 @@ The <span class="flex_perlcode">$h</span> hash pointer in <span class="flex_perl } }</pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-2494'><span class="subsubsection_label">6.9.3</span> Joining the results</h4> -<div class="standard" id='magicparlabel-2495'>The <span class="flex_perlcode">$results</span> hash pointer in <span class="flex_perlcode">parse_data</span> is unique to its thread: it does not contain your final result, just the part of it corresponding to the population of stars which ran on that thread. You have to add up the results by joining the various threads at the end of the run. In practice this is done automatically by <span class='math'>\binarygrid</span> +<h4 class="subsubsection" id='magicparlabel-2664'><span class="subsubsection_label">6.9.3</span> Joining the results</h4> +<div class="standard" id='magicparlabel-2665'>The <span class="flex_perlcode">$results</span> hash pointer in <span class="flex_perlcode">parse_data</span> is unique to its thread: it does not contain your final result, just the part of it corresponding to the population of stars which ran on that thread. You have to add up the results by joining the various threads at the end of the run. In practice this is done automatically by <span class='math'>\binarygrid</span> 2 in combination with some <span class="flex_scriptinglanguage">Perl</span> wizardry. You can, however, override this yourself by writing your own join function, which should be set in the following manner: <br /> @@ -3058,7 +3107,7 @@ The <span class="flex_perlcode">$h</span> hash pointer in <span class="flex_perl <pre class ='listings Perl'>$binary_grid::grid_options{'threads_join_function_pointer'}=\&join_thread;</pre><br /> </div> -<div class="standard" id='magicparlabel-2512'><b>Beware that joining large hashes may require a lot of RAM. </b>If you are running <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2682'><b>Beware that joining large hashes may require a lot of RAM. </b>If you are running <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>N</mi> </mrow></mstyle></math> threads which each uses <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>M</mi> @@ -3072,10 +3121,10 @@ The <span class="flex_perlcode">$h</span> hash pointer in <span class="flex_perl <mi>M</mi> </mrow> </mrow></mstyle></math> MB to join the data (probably a bit more). If you have trouble, say on a cluster, you might consider saving the results hash from each thread to a file, then joining the results on another machine. When running on <span class="flex_software">condor</span> or <span class="flex_software">slurm</span>, this is done automatically if you postpone the join.</div> -<h4 class="subsubsection" id='magicparlabel-2521'><span class="subsubsection_label">6.9.4</span> Outputting the results</h4> -<div class="standard" id='magicparlabel-2522'>At the end of the grid script you should output the results, usually by writing an <em>output</em> subroutine and calling it. An example is the following which outputs to <span class="flex_cvar">stdout</span>, but you could of course open files and save your output to them.</div> +<h4 class="subsubsection" id='magicparlabel-2691'><span class="subsubsection_label">6.9.4</span> Outputting the results</h4> +<div class="standard" id='magicparlabel-2692'>At the end of the grid script you should output the results, usually by writing an <em>output</em> subroutine and calling it. An example is the following which outputs to <span class="flex_cvar">stdout</span>, but you could of course open files and save your output to them.</div> -<div class="standard" id='magicparlabel-2527'><br /> +<div class="standard" id='magicparlabel-2697'><br /> <pre class ='listings Perl'>sub output { my $population = shift; @@ -3092,10 +3141,10 @@ The <span class="flex_perlcode">$h</span> hash pointer in <span class="flex_perl } </pre><br /> </div> -<h3 class="subsection" id='magicparlabel-2546'><span class="subsection_label">6.10</span> Save your data – or process on the fly?</h3> -<div class="standard" id='magicparlabel-2547'>Before running a grid you have to make the big decision: do you save your data or process it all on the fly? Above I have shown you the latter, and there is good reason to teach this first and use this method preferably. That said, there are advantages and disadvantages to both, as described below.</div> -<h4 class="subsubsection" id='magicparlabel-2548'><span class="subsubsection_label">6.10.1</span> Saving data </h4> -<div class="standard" id='magicparlabel-2549'><div id="subsec_saving_data"></div> +<h3 class="subsection" id='magicparlabel-2716'><span class="subsection_label">6.10</span> Save your data – or process on the fly?</h3> +<div class="standard" id='magicparlabel-2717'>Before running a grid you have to make the big decision: do you save your data or process it all on the fly? Above I have shown you the latter, and there is good reason to teach this first and use this method preferably. That said, there are advantages and disadvantages to both, as described below.</div> +<h4 class="subsubsection" id='magicparlabel-2718'><span class="subsubsection_label">6.10.1</span> Saving data </h4> +<div class="standard" id='magicparlabel-2719'><div id="subsec_saving_data"></div> In this case you run a grid and tag the initial parameters of each system of interest (i.e. the <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> @@ -3133,7 +3182,7 @@ In this case you run a grid and tag the initial parameters of each system of int </mrow></mstyle></math>). <em>You save these initial parameters into a large datafile </em>(possibly in a binary format)<em>.</em> The big advantage of this technique is that you can rerun the saved grid <em>from the datafile, </em>possibly<em> </em>without running <em><span class='math'>binary_c</i></span> </em> again, and with a different initial distribution function (e.g. initial mass function) or very slightly different physics (on the assumption that changing the physics will not change the systems which were saved). </div> -<div class="standard" id='magicparlabel-2550'>You could save, as well as the initial parameters of the systems, the time spent in the phase of interest, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2720'>You could save, as well as the initial parameters of the systems, the time spent in the phase of interest, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mo> Δ </mo><mi>t</mi> </mrow> @@ -3157,7 +3206,7 @@ In this case you run a grid and tag the initial parameters of each system of int </mrow> </mrow></mstyle></math> which is your required “number of stars”. You can either </div> -<ol class="enumerate" id='magicparlabel-2551'><li class="enumerate_item">Change <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<ol class="enumerate" id='magicparlabel-2721'><li class="enumerate_item">Change <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>p</mi> @@ -3178,14 +3227,14 @@ In this case you run a grid and tag the initial parameters of each system of int </mrow></mstyle></math> and some physics, which requires rerunning of <span class='math'>binary_c</i></span> . This is slower, but still faster than running the full grid.</li> </ol> -<div class="standard" id='magicparlabel-2553'>Saving the progenitor data set is a very useful way of saving time after an initial high-resolution grid run.</div> +<div class="standard" id='magicparlabel-2723'>Saving the progenitor data set is a very useful way of saving time after an initial high-resolution grid run.</div> -<div class="standard" id='magicparlabel-2554'>You may want to consider converting your saved data from <span class="flex_software">ASCII</span> to binary format, particularly if you will be processing it repeatedly. This can save a lot of time, but it renders your data very difficult to read, and it is hard to make such code truly backwards compatible. If someone comes to look at your results in ten years' time, will you remember exactly what is going on? Sacrificing clarity for speed is not necessarily a good thing.</div> -<h4 class="subsubsection" id='magicparlabel-2559'><span class="subsubsection_label">6.10.2</span> On the fly data processing</h4> -<div class="standard" id='magicparlabel-2560'><div id="subsec_on_the_fly"></div> +<div class="standard" id='magicparlabel-2724'>You may want to consider converting your saved data from <span class="flex_software">ASCII</span> to binary format, particularly if you will be processing it repeatedly. This can save a lot of time, but it renders your data very difficult to read, and it is hard to make such code truly backwards compatible. If someone comes to look at your results in ten years' time, will you remember exactly what is going on? Sacrificing clarity for speed is not necessarily a good thing.</div> +<h4 class="subsubsection" id='magicparlabel-2729'><span class="subsubsection_label">6.10.2</span> On the fly data processing</h4> +<div class="standard" id='magicparlabel-2730'><div id="subsec_on_the_fly"></div> </div> -<div class="standard" id='magicparlabel-2561'>If you do not want to recalculate your answer with different initial functions, you might be better off calculating the results you require “on the fly”. This means you do your data processing <em>in your grid script</em>. The main advantages to this are speed and data storage. For example, if you have <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2731'>If you do not want to recalculate your answer with different initial functions, you might be better off calculating the results you require “on the fly”. This means you do your data processing <em>in your grid script</em>. The main advantages to this are speed and data storage. For example, if you have <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mn>1</mn> <msup> @@ -3207,7 +3256,7 @@ In this case you run a grid and tag the initial parameters of each system of int </mrow> </mrow></mstyle></math> lines of data – this might be a lot of data.</div> -<div class="standard" id='magicparlabel-2562'>In some cases you <em>must</em> do this. If you are looking at data which is time dependent then you will have <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2732'>In some cases you <em>must</em> do this. If you are looking at data which is time dependent then you will have <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mn>1</mn> <msup> @@ -3280,15 +3329,15 @@ In this case you run a grid and tag the initial parameters of each system of int </mrow></mstyle></math>. The time it takes to process all this data may be longer than the time to <em>rerun</em> <em><span class='math'>binary_c</i></span> </em>for each system, especially if your data storage is non-local (e.g. on an <em>NFS</em> (network) partition). </div> -<div class="standard" id='magicparlabel-2563'>You can save some space by outputting data every, say, Myr, but this may not be the time resolution you require to catch systems of interest.</div> +<div class="standard" id='magicparlabel-2733'>You can save some space by outputting data every, say, Myr, but this may not be the time resolution you require to catch systems of interest.</div> -<div class="standard" id='magicparlabel-2564'>You can increase the speed of your run by using the <span class="flex_programminglanguage">C</span> backend and setting <span class="flex_perlcode">return_array_refs</span> to <span class="flex_perlcode">1</span>.<br /> +<div class="standard" id='magicparlabel-2734'>You can increase the speed of your run by using the <span class="flex_programminglanguage">C</span> backend and setting <span class="flex_perlcode">return_array_refs</span> to <span class="flex_perlcode">1</span>.<br /> </div> -<h3 class="subsection" id='magicparlabel-2577'><span class="subsection_label">6.11</span> Flexigrid</h3> -<div class="standard" id='magicparlabel-2578'><div id="sec_flexigrid"></div> +<h3 class="subsection" id='magicparlabel-2747'><span class="subsection_label">6.11</span> Flexigrid</h3> +<div class="standard" id='magicparlabel-2748'><div id="sec_flexigrid"></div> As of summer 2011, the “flexi<em>grid</em>” was developed. This is an attempt to replace much of the old, rigid grid framework with a new, dynamic and flexible API. The key concepts are the following:</div> -<ul class="itemize" id='magicparlabel-2579'><li class="itemize_item">When a <em>flexigrid</em> is run, it sets up <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<ul class="itemize" id='magicparlabel-2749'><li class="itemize_item">When a <em>flexigrid</em> is run, it sets up <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>n</mi> </mrow></mstyle></math> concurrently running <em>threads</em>. Each of these is fed with stars until the population is complete. Because of this, <em>flexigrid</em> is designed specifically to work on the latest multi-core CPUs on shared-memory machines (which are the typical PCs of the early 21st century). It scales quite well if you use the <span class="flex_programminglanguage">C</span> backend, less well with the <em>Perl</em> backend on more than a few CPUs.</li> <li class="itemize_item"><em>Flexigrid</em> sets up its <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -3314,13 +3363,13 @@ As of summer 2011, the “flexi<em>grid</em>” was developed. This is a <li class="itemize_item">Probabilities are calculated more efficiently and flexibly by the <span class="flex_perlmodule">distribution_functions</span> module.</li> <li class="itemize_item">Grid spacings are calculated with the <span class="flex_perlmodule">spacing_functions</span> module.</li> </ul> -<h3 class="subsection" id='magicparlabel-2599'><span class="subsection_label">6.12</span> Setup in your grid script</h3> -<div class="standard" id='magicparlabel-2600'><div id="subsec_setup_grid_script"></div> +<h3 class="subsection" id='magicparlabel-2769'><span class="subsection_label">6.12</span> Setup in your grid script</h3> +<div class="standard" id='magicparlabel-2770'><div id="subsec_setup_grid_script"></div> </div> -<div class="standard" id='magicparlabel-2601'>You need to do a few things to define the variables which describe your grid. </div> -<h4 class="subsubsection" id='magicparlabel-2602'><span class="subsubsection_label">6.12.1</span> Grid variables: 1D example</h4> -<div class="standard" id='magicparlabel-2603'>Setting up which variables you use is best defined by example. Let's start with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2771'>You need to do a few things to define the variables which describe your grid. </div> +<h4 class="subsubsection" id='magicparlabel-2772'><span class="subsubsection_label">6.12.1</span> Grid variables: 1D example</h4> +<div class="standard" id='magicparlabel-2773'>Setting up which variables you use is best defined by example. Let's start with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>M</mi> @@ -3345,7 +3394,7 @@ Next, use your <em><span class='math'>\binarygrid</span> </div> -<div class="standard" id='magicparlabel-2616'><br /> +<div class="standard" id='magicparlabel-2786'><br /> <pre class ='listings Perl'> # Mass 1 my $mmin=0.1; my $mmax=80.0; @@ -3364,9 +3413,9 @@ Next, use your <em><span class='math'>\binarygrid</span> );</pre><br /> </div> -<div class="standard" id='magicparlabel-2636'>What does this mean?</div> +<div class="standard" id='magicparlabel-2806'>What does this mean?</div> -<ol class='lyxlist' id='magicparlabel-2637'><li class="labeling_item"><span class='lyxlist'>name string</span> +<ol class='lyxlist' id='magicparlabel-2807'><li class="labeling_item"><span class='lyxlist'>name string</span> This is the variable name. It should be parsable in <span class="flex_scriptinglanguage">Perl</span>, e.g. in the above case it is expanded to <span class="flex_perlcode">$lnm1</span> in the gridcode.</li> <li class="labeling_item"><span class='lyxlist'>longname string</span> This is a long (human-readable) name used in logging. It should contain no spaces (use underscores).</li> @@ -3419,11 +3468,11 @@ Next, use your <em><span class='math'>\binarygrid</span> <li class="labeling_item"><span class='lyxlist'>dphasevol expression</span> <em> </em>This defines the contribution to the phase volume of each stellar system from this variable. In general this is just <span class="flex_perlcode">$dlnm1</span> (i.e. should be <span class="flex_perlcode">$dname</span>) but you can set it to whatever you like. </li> </ol> -<h3 class="subsection" id='magicparlabel-2699'><span class="subsection_label">6.13</span> 3D grid example</h3> -<div class="standard" id='magicparlabel-2700'><div id="subsec_3d_grid_example"></div> +<h3 class="subsection" id='magicparlabel-2869'><span class="subsection_label">6.13</span> 3D grid example</h3> +<div class="standard" id='magicparlabel-2870'><div id="subsec_3d_grid_example"></div> </div> -<div class="standard" id='magicparlabel-2701'>The next step is to set up the further grid variables. Usually these are <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-2871'>The next step is to set up the further grid variables. Usually these are <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>M</mi> @@ -3435,7 +3484,7 @@ Next, use your <em><span class='math'>\binarygrid</span> <mrow><mi>a</mi> </mrow></mstyle></math>, as defined in the code below.</div> -<div class="standard" id='magicparlabel-2702'><br /> +<div class="standard" id='magicparlabel-2872'><br /> <pre class ='listings Perl'> my $resolution = { m1 => 10, q => 10, @@ -3486,34 +3535,34 @@ my \$eccentricity = 0.0; 'dphasevol'=>'$dln10per' );</pre><br /> </div> -<h3 class="subsection" id='magicparlabel-2755'><span class="subsection_label">6.14</span> Viewing The (Automatically Generated) Gridcode </h3> -<div class="standard" id='magicparlabel-2756'><div id="subsec_viewing_the_gridcode"></div> +<h3 class="subsection" id='magicparlabel-2925'><span class="subsection_label">6.14</span> Viewing The (Automatically Generated) Gridcode </h3> +<div class="standard" id='magicparlabel-2926'><div id="subsec_viewing_the_gridcode"></div> </div> -<div class="standard" id='magicparlabel-2757'>When you evolve your <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-2927'>When you evolve your <span class='math'>\binarygrid</span> 2 object, the<span style='font-family:monospace;font-size: 18px;'> </span><span class="flex_perlcode">flexigrid</span> is run. First the grid code is generated, then this processed by <span class="flex_scriptinglanguage">Perl</span>'s <span class="flex_perlcode">eval()</span>.</div> -<div class="standard" id='magicparlabel-2770'>You can find the grid code in the file <span class="flex_file">/tmp/gridcode</span> where <span class="flex_file">/tmp</span> can be changed, e.g. with,<br /> +<div class="standard" id='magicparlabel-2940'>You can find the grid code in the file <span class="flex_file">/tmp/gridcode</span> where <span class="flex_file">/tmp</span> can be changed, e.g. with,<br /> <pre class ='listings Perl'>$population->set(tmp=>”/directory/of/your/choice”);</pre><br /> </div> -<h3 class="subsection" id='magicparlabel-2783'><span class="subsection_label">6.15</span> Error handling</h3> -<div class="standard" id='magicparlabel-2784'><div id="subsec_flexigrid_error_handling"></div> +<h3 class="subsection" id='magicparlabel-2953'><span class="subsection_label">6.15</span> Error handling</h3> +<div class="standard" id='magicparlabel-2954'><div id="subsec_flexigrid_error_handling"></div> </div> -<div class="standard" id='magicparlabel-2785'>Things do go wrong. Usually when this happens, the threads will be shut down and your grid script will exit, telling you as much as it can about the error. </div> +<div class="standard" id='magicparlabel-2955'>Things do go wrong. Usually when this happens, the threads will be shut down and your grid script will exit, telling you as much as it can about the error. </div> -<div class="standard" id='magicparlabel-2786'>When running with the <span class="flex_programminglanguage">C</span> backend, the grid will crash. If you have built <span class="flex_file"><i>libbinary_c.so</i></span> with debugging (e.g. <span class="flex_command">configure debug</span>) you should see a stack trace so that you can debug the crash. With the <span class="flex_scriptinglanguage">Perl</span> backend this is more difficult, but you should see an error message. Beware that if the <span class="flex_scriptinglanguage">Perl</span> backend crashes at the wrong place, there may be zombie processes hanging around, or worse: processes that eat your CPU time. Please check for these when testing your code! </div> -<h3 class="subsection" id='magicparlabel-2807'><span class="subsection_label">6.16</span> Flexigrid variable options</h3> -<div class="standard" id='magicparlabel-2808'><div id="subsec_flexigrid_variable_options"></div> +<div class="standard" id='magicparlabel-2956'>When running with the <span class="flex_programminglanguage">C</span> backend, the grid will crash. If you have built <span class="flex_file"><i>libbinary_c.so</i></span> with debugging (e.g. <span class="flex_command">configure debug</span>) you should see a stack trace so that you can debug the crash. With the <span class="flex_scriptinglanguage">Perl</span> backend this is more difficult, but you should see an error message. Beware that if the <span class="flex_scriptinglanguage">Perl</span> backend crashes at the wrong place, there may be zombie processes hanging around, or worse: processes that eat your CPU time. Please check for these when testing your code! </div> +<h3 class="subsection" id='magicparlabel-2977'><span class="subsection_label">6.16</span> Flexigrid variable options</h3> +<div class="standard" id='magicparlabel-2978'><div id="subsec_flexigrid_variable_options"></div> </div> -<div class="standard" id='magicparlabel-2809'><b>FIXME! This is out of date.</b></div> +<div class="standard" id='magicparlabel-2979'><b>FIXME! This is out of date.</b></div> -<div class="standard" id='magicparlabel-2810'>Note that any <em>code</em> is executed in the context of the flexigrid <span class="flex_perlcode">eval</span> call, so you should prepend calls to subroutines with <span class="flex_perlmodule">main::</span> or <span class="flex_perlmodule">module_name::</span> or, if they are part of <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-2980'>Note that any <em>code</em> is executed in the context of the flexigrid <span class="flex_perlcode">eval</span> call, so you should prepend calls to subroutines with <span class="flex_perlmodule">main::</span> or <span class="flex_perlmodule">module_name::</span> or, if they are part of <span class='math'>\binarygrid</span> 2, <span class="flex_perlcode">$self</span> to access them through the <span class='math'>\binarygrid</span> 2 object.</div> -<ol class='lyxlist' id='magicparlabel-2827'><li class="labeling_item"><span class='lyxlist'>condition code</span> +<ol class='lyxlist' id='magicparlabel-2997'><li class="labeling_item"><span class='lyxlist'>condition code</span> The loop is executed only if <em>condition</em> is true. </li> <li class="labeling_item"><span class='lyxlist'>dphasevol expression</span> <em> </em>This defines the contribution to the phase volume from this variable.</li> @@ -3544,15 +3593,15 @@ my \$eccentricity = 0.0; <li class="labeling_item"><span class='lyxlist'>spacingfunc func</span> <em> </em>This defines the spacing function which should be in the <span class="flex_perlmodule">spacing_functions</span> Perl module. </li> </ol> -<div class="standard" id='magicparlabel-2853'><br /> +<div class="standard" id='magicparlabel-3023'><br /> </div> -<h3 class="subsection" id='magicparlabel-2854'><span class="subsection_label">6.17</span> Flexigrid loop structure</h3> -<div class="standard" id='magicparlabel-2855'><div id="subsec_flexigrid_loop_structure"></div> +<h3 class="subsection" id='magicparlabel-3024'><span class="subsection_label">6.17</span> Flexigrid loop structure</h3> +<div class="standard" id='magicparlabel-3025'><div id="subsec_flexigrid_loop_structure"></div> </div> -<div class="standard" id='magicparlabel-2856'>Each loop is logically structured as follows:</div> +<div class="standard" id='magicparlabel-3026'>Each loop is logically structured as follows:</div> -<ul class="itemize" id='magicparlabel-2857'><li class="itemize_item">setup <span class="flex_perlcode">%fvar</span> (min, max, initial grid spacing <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<ul class="itemize" id='magicparlabel-3027'><li class="itemize_item">setup <span class="flex_perlcode">%fvar</span> (min, max, initial grid spacing <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi> δ </mi> </mrow></mstyle></math> from the <em>spacing_functions, </em>type=<em>grid</em> or <em>edge</em>)</li> <li class="itemize_item">calculate the resolution (with an <span class="flex_perlcode">eval</span><em> </em>call)</li> @@ -3582,28 +3631,28 @@ my \$eccentricity = 0.0; <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>}</span> (close the loop)</li> <li class="itemize_item">execute <span class="flex_perlcode">postloopcode</span></li> </ul> -<div class="standard" id='magicparlabel-2912'>Only the innermost loop contains the calls to push commands onto the thread queue.</div> +<div class="standard" id='magicparlabel-3082'>Only the innermost loop contains the calls to push commands onto the thread queue.</div> -<div class="standard" id='magicparlabel-2913'><br /> +<div class="standard" id='magicparlabel-3083'><br /> </div> -<h3 class="subsection" id='magicparlabel-2914'><span class="subsection_label">6.18</span> <i>binary_grid</i> with <em>HTCondor<div id="sec_Working_with_HTCondor"></div> +<h3 class="subsection" id='magicparlabel-3084'><span class="subsection_label">6.18</span> <i>binary_grid</i> with <em>HTCondor<div id="sec_Working_with_HTCondor"></div> </em></h3> -<div class="standard" id='magicparlabel-2915'>The <span class="flex_software">HTCondor</span> system allows you to distribute your computing of stellar populations over many PCs and hence greatly increase your available computing power. In the following we define the following terms:</div> +<div class="standard" id='magicparlabel-3085'>The <span class="flex_software">HTCondor</span> system allows you to distribute your computing of stellar populations over many PCs and hence greatly increase your available computing power. In the following we define the following terms:</div> -<dl class='description' id='magicparlabel-2920'><dt class="description_label">Launching</dt> +<dl class='description' id='magicparlabel-3090'><dt class="description_label">Launching</dt> <dd class="description_item"> jobs means sending a grid of stars to be run on a remote PC by submitting an <span class="flex_software">HTCondor</span> script.</dd> <dt class="description_label">Joining</dt> <dd class="description_item"> jobs means taking all the data that you have generated on remote PCs and making your final dataset. By default, <em><span class='math'>\binarygrid</span> </em> tries to join the data when all the jobs have finished. However, this places a considerable load on the machine in question (often far greater, especially in terms of memory, than running a single job). You may want to load a local machine, or one which has faster access to the data store (e.g. if it is an <em>NFS </em>mountpoint). Use the <span class="flex_perlcode">condor_postpone_join</span><span style='font-family:monospace;font-size: 18px;'> </span>variable to postpone the join in this manner (see below).</dd> </dl> -<ul class="itemize" id='magicparlabel-2930'><li class="itemize_item">You need to decide how many condor jobs to run (<span class="flex_perlcode">condor_njobs</span>). This is a tradeoff between how many <em>HTCondor</em> slots you have available (probably this is the number of cores you have available on your PCs), how much disk space you want to take up, and how long you would like to wait in the joining process (which scales linearly with the number of jobs). In general, joining is fast compared to running large stellar populations, so the joining is irrelevant. Thus, you want to set this to the number of slots available, unless there is some limit set by your administrator, or you are short of disk space (the amount of disk space you require is linear in the number of slots you use).</li> +<ul class="itemize" id='magicparlabel-3100'><li class="itemize_item">You need to decide how many condor jobs to run (<span class="flex_perlcode">condor_njobs</span>). This is a tradeoff between how many <em>HTCondor</em> slots you have available (probably this is the number of cores you have available on your PCs), how much disk space you want to take up, and how long you would like to wait in the joining process (which scales linearly with the number of jobs). In general, joining is fast compared to running large stellar populations, so the joining is irrelevant. Thus, you want to set this to the number of slots available, unless there is some limit set by your administrator, or you are short of disk space (the amount of disk space you require is linear in the number of slots you use).</li> <li class="itemize_item">You will need to set a <span class="flex_perlcode">condor_dir</span> directory which stores the <span class="flex_software">HTCondor</span> scripts, logs, <span class="flex_cvar">stdout</span>, <span class="flex_cvar">stderr</span>, status and the data which is to be joined. This directory must be accessible to <em>all the compute nodes </em>(e.g. mounted as an <em>NFS</em> partition).</li> <li class="itemize_item">The data that is to be joined is stored in your <span class="flex_perlcode">condor_dir</span> directory. There are <span class="flex_perlcode">condor_njobs</span> of these files, one for each job. Together they contain your raw population data (prior to <span style='font-family:monospace;font-size: 18px;'>output()</span> being called).</li> <li class="itemize_item">The generated scripts are actually called from wrapper scripts (appended with <span class="flex_file">.wrap</span>) which catch errors. See below for more details.</li> </ul> -<dl class='description' id='magicparlabel-2966'><dt class="description_label">Binary_c</dt> +<dl class='description' id='magicparlabel-3136'><dt class="description_label">Binary_c</dt> <dd class="description_item"> You should configure <span class='math'>binary_c</i></span> to use generic flags by running,<br /> <pre class\s*='listings bash'>$ ./configure generic</pre><br /> @@ -3617,9 +3666,9 @@ You will need to completely rebuild <span class='math'>binary_c</i></span> .so on the <span class="flex_software">HTCondor</span> submission machine after setting <span class="flex_envvar">ARCHFLAGS</span> and (perhaps) each time you change <span class='math'>binary_c</i></span> . If you do not, you will suffer from (seemingly random) segmentation faults.</dd> </dl> -<div class="standard" id='magicparlabel-2987'>Other parameters include:</div> +<div class="standard" id='magicparlabel-3157'>Other parameters include:</div> -<dl class='description' id='magicparlabel-2988'><dt class="description_label">condor_memory</dt> +<dl class='description' id='magicparlabel-3158'><dt class="description_label">condor_memory</dt> <dd class="description_item"> The amount of RAM allocated to your run. Since each job uses only one CPU at a time, this is generally small (less than 1GB) however there may be occasions where you require more.</dd> <dt class="description_label">condor_universe</dt> <dd class="description_item"> This must be <span class="flex_args">vanilla</span>. I have not tried to compile all the required tools using <span class="flex_software">HTCondor</span>'s compiler.</dd> @@ -3643,17 +3692,17 @@ Other, less common, options are <span class="flex_perlcode">join_datafiles</span <dt class="description_label">condor_resubmit_finished</dt> <dd class="description_item"> Please see section <a href="#subsec_Rerunning_your_jobs">6.18.4</a>.</dd> </dl> -<h4 class="subsubsection" id='magicparlabel-3054'><span class="subsubsection_label">6.18.1</span> Modifying your grid script for HTCondor<div id="subsec_Modifying_your_grid"></div> +<h4 class="subsubsection" id='magicparlabel-3224'><span class="subsubsection_label">6.18.1</span> Modifying your grid script for HTCondor<div id="subsec_Modifying_your_grid"></div> </h4> -<div class="standard" id='magicparlabel-3055'>You need to:</div> +<div class="standard" id='magicparlabel-3225'>You need to:</div> -<ol class="enumerate" id='magicparlabel-3056'><li class="enumerate_item">load in the <span class="flex_perlmodule">binary_grid::condor</span> module</li> +<ol class="enumerate" id='magicparlabel-3226'><li class="enumerate_item">load in the <span class="flex_perlmodule">binary_grid::condor</span> module</li> <li class="enumerate_item">set some parameters and </li> <li class="enumerate_item">modify the call to your <span style='font-family:monospace;font-size: 18px;'>output</span> function. </li> </ol> -<div class="standard" id='magicparlabel-3063'>The following is a basic example.</div> +<div class="standard" id='magicparlabel-3233'>The following is a basic example.</div> -<div class="standard" id='magicparlabel-3064'><br /> +<div class="standard" id='magicparlabel-3234'><br /> <pre class ='listings Perl'>#!/usr/bin/env perl use strict; # recommended use 5.16.0; # recommended @@ -3696,29 +3745,29 @@ output($population) if($population->output_allowed()); # the rest of the script remains unchanged </pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-3109'><span class="subsubsection_label">6.18.2</span> Launching your jobs<div id="subsec_Launching_your_jobs"></div> +<h4 class="subsubsection" id='magicparlabel-3279'><span class="subsubsection_label">6.18.2</span> Launching your jobs<div id="subsec_Launching_your_jobs"></div> </h4> -<div class="standard" id='magicparlabel-3110'>Once your grid script is modified, you just have to run it on a PC which is allowed to submit jobs using <span class="flex_perlcode">condor_submit</span>. </div> +<div class="standard" id='magicparlabel-3280'>Once your grid script is modified, you just have to run it on a PC which is allowed to submit jobs using <span class="flex_perlcode">condor_submit</span>. </div> -<div class="standard" id='magicparlabel-3115'>If you want the script to sometimes run condor (e.g. if you are on the condor submit machine), and sometimes not (e.g. you are on your personal PC or laptop), set <span class="flex_args">condor=>0</span> in the above example, and run with <span class="flex_args">condor=1</span> as an argument <em>only </em>on the condor submit machine.</div> +<div class="standard" id='magicparlabel-3285'>If you want the script to sometimes run condor (e.g. if you are on the condor submit machine), and sometimes not (e.g. you are on your personal PC or laptop), set <span class="flex_args">condor=>0</span> in the above example, and run with <span class="flex_args">condor=1</span> as an argument <em>only </em>on the condor submit machine.</div> -<div class="standard" id='magicparlabel-3124'><br /> +<div class="standard" id='magicparlabel-3294'><br /> <pre class\s*='listings bash'>$ mygridscript.pl condor=1</pre><br /> </div> -<h4 class="subsubsection_" id='magicparlabel-3129'>Job IDs<div id="subsec_Job_IDs"></div> +<h4 class="subsubsection_" id='magicparlabel-3299'>Job IDs<div id="subsec_Job_IDs"></div> </h4> -<div class="standard" id='magicparlabel-3130'>Each job is given an ID string, <span style='font-family:monospace;font-size: 18px;'>x.y</span>, where <span style='font-family:monospace;font-size: 18px;'>x</span> is a counter which ranges from <span style='font-family:monospace;font-size: 18px;'>0</span> to <span style='font-family:monospace;font-size: 18px;'>y-1</span>, where <span style='font-family:monospace;font-size: 18px;'>y</span> is the number of jobs to be launched (<span class="flex_args">condor_njobs</span>). The files in the various subdirectories that control your jobs are named <span style='font-family:monospace;font-size: 18px;'>x.y</span>. </div> +<div class="standard" id='magicparlabel-3300'>Each job is given an ID string, <span style='font-family:monospace;font-size: 18px;'>x.y</span>, where <span style='font-family:monospace;font-size: 18px;'>x</span> is a counter which ranges from <span style='font-family:monospace;font-size: 18px;'>0</span> to <span style='font-family:monospace;font-size: 18px;'>y-1</span>, where <span style='font-family:monospace;font-size: 18px;'>y</span> is the number of jobs to be launched (<span class="flex_args">condor_njobs</span>). The files in the various subdirectories that control your jobs are named <span style='font-family:monospace;font-size: 18px;'>x.y</span>. </div> -<div class="standard" id='magicparlabel-3135'>Please note: <b>if you change </b><span class="flex_perlcode">condor_njobs</span><b> or </b><span class="flex_perlcode">condor_dir</span><b> then you are also changing your job IDs. If you make changes to these variables and then try to join your data after postponing the join, things will break.</b> Please see Section <a href="#subsec_Joining_your_jobs">6.18.5</a>.</div> -<h4 class="subsubsection" id='magicparlabel-3144'><span class="subsubsection_label">6.18.3</span> Status of your jobs<div id="subsec_Status_of_your_jobs"></div> +<div class="standard" id='magicparlabel-3305'>Please note: <b>if you change </b><span class="flex_perlcode">condor_njobs</span><b> or </b><span class="flex_perlcode">condor_dir</span><b> then you are also changing your job IDs. If you make changes to these variables and then try to join your data after postponing the join, things will break.</b> Please see Section <a href="#subsec_Joining_your_jobs">6.18.5</a>.</div> +<h4 class="subsubsection" id='magicparlabel-3314'><span class="subsubsection_label">6.18.3</span> Status of your jobs<div id="subsec_Status_of_your_jobs"></div> </h4> -<ul class="itemize" id='magicparlabel-3145'><li class="itemize_item">You can use the <span class="flex_command">condor_q</span> command and its various options to enquire about the status of your jobs.</li> +<ul class="itemize" id='magicparlabel-3315'><li class="itemize_item">You can use the <span class="flex_command">condor_q</span> command and its various options to enquire about the status of your jobs.</li> <li class="itemize_item">You can also use the <span class="flex_file">condor_dir/status</span> files which are used by <span class='math'>\binarygrid</span> to monitor the status of your jobs. These have the values:</li> </ul> -<dl class='description' id='magicparlabel-3155'><dt class="description_label">submitted</dt> +<dl class='description' id='magicparlabel-3325'><dt class="description_label">submitted</dt> <dd class="description_item"> The job is submitted and will (hopefully) soon be run.</dd> <dt class="description_label">running</dt> <dd class="description_item"> The job is currently running (and a crash has not been detected).</dd> @@ -3727,11 +3776,11 @@ output($population) if($population->output_allowed()); <dt class="description_label">crash n</dt> <dd class="description_item"> The job crashed with exit code <em>n.</em></dd> </dl> -<h4 class="subsubsection" id='magicparlabel-3159'><span class="subsubsection_label">6.18.4</span> Rerunning your jobs<div id="subsec_Rerunning_your_jobs"></div> +<h4 class="subsubsection" id='magicparlabel-3329'><span class="subsubsection_label">6.18.4</span> Rerunning your jobs<div id="subsec_Rerunning_your_jobs"></div> </h4> -<div class="standard" id='magicparlabel-3160'>Sometimes you would like to rerun your jobs, especially if some of them fail to run and you later fix the bug. Four variables allow you to restart a job, depending on its current status.</div> +<div class="standard" id='magicparlabel-3330'>Sometimes you would like to rerun your jobs, especially if some of them fail to run and you later fix the bug. Four variables allow you to restart a job, depending on its current status.</div> -<dl class='description' id='magicparlabel-3161'><dt class="description_label">condor_resubmit_submitted</dt> +<dl class='description' id='magicparlabel-3331'><dt class="description_label">condor_resubmit_submitted</dt> <dd class="description_item"> If this is <span style='font-family:monospace;font-size: 18px;'>1</span> and a job status is <span style='font-family:monospace;font-size: 18px;'>submitted</span>, it is resubmitted. </dd> <dt class="description_label">condor_resubmit_running</dt> <dd class="description_item"> If this is <span style='font-family:monospace;font-size: 18px;'>1</span> and a job status is <span style='font-family:monospace;font-size: 18px;'>running</span>, it is resubmitted.</dd> @@ -3740,27 +3789,27 @@ output($population) if($population->output_allowed()); <dt class="description_label">condor_resubmit_finished</dt> <dd class="description_item"> If this is <span style='font-family:monospace;font-size: 18px;'>1</span> and a job status is <span style='font-family:monospace;font-size: 18px;'>finished</span>, it is resubmitted.</dd> </dl> -<div class="standard" id='magicparlabel-3165'>By default, all the <span class="flex_perlcode">condor_resubmit_*</span> variables are <span style='font-family:monospace;font-size: 18px;'>0</span>, so jobs that have already been started are not resubmitted.</div> -<h4 class="subsubsection" id='magicparlabel-3170'><span class="subsubsection_label">6.18.5</span> Joining your jobs<div id="subsec_Joining_your_jobs"></div> +<div class="standard" id='magicparlabel-3335'>By default, all the <span class="flex_perlcode">condor_resubmit_*</span> variables are <span style='font-family:monospace;font-size: 18px;'>0</span>, so jobs that have already been started are not resubmitted.</div> +<h4 class="subsubsection" id='magicparlabel-3340'><span class="subsubsection_label">6.18.5</span> Joining your jobs<div id="subsec_Joining_your_jobs"></div> </h4> -<div class="standard" id='magicparlabel-3171'>If you postponed the join of your jobs with <span class="flex_perlcode">condor_postpone_join</span> set to <span class="flex_perlcode">1</span>, you have to join them in order to finish your population calculations. You can either:</div> +<div class="standard" id='magicparlabel-3341'>If you postponed the join of your jobs with <span class="flex_perlcode">condor_postpone_join</span> set to <span class="flex_perlcode">1</span>, you have to join them in order to finish your population calculations. You can either:</div> -<ul class="itemize" id='magicparlabel-3180'><li class="itemize_item">Rerun your script with <span class="flex_args">condor_command=join</span> appended to the command line. This automatically locates the list of files require, joins them and calls <span class="flex_perlcode">output()</span>. This is the simplest, and recommended, way to do it.</li> +<ul class="itemize" id='magicparlabel-3350'><li class="itemize_item">Rerun your script with <span class="flex_args">condor_command=join</span> appended to the command line. This automatically locates the list of files require, joins them and calls <span class="flex_perlcode">output()</span>. This is the simplest, and recommended, way to do it.</li> <li class="itemize_item">Locate the <span class="flex_file">condor_dir/scripts/joincmd</span> file and run the command in it to join the data and call <span class="flex_perlcode">output()</span>.</li> </ul> -<div class="standard" id='magicparlabel-3198'>You <b>must not change</b> <span class="flex_perlcode">condor_njobs</span><b> or <span style='font-family:monospace;font-size: 18px;'>condor_dir </span>prior to joining your jobs</b>. This is because these variables are used to construct job IDs. See section <a href="#subsec_Job_IDs">6.18.2</a> for more details.</div> -<h4 class="subsubsection" id='magicparlabel-3203'><span class="subsubsection_label">6.18.6</span> Debugging <em>HTCondor</em> jobs<div id="subsec_Debugging_HTCondor_jobs"></div> +<div class="standard" id='magicparlabel-3368'>You <b>must not change</b> <span class="flex_perlcode">condor_njobs</span><b> or <span style='font-family:monospace;font-size: 18px;'>condor_dir </span>prior to joining your jobs</b>. This is because these variables are used to construct job IDs. See section <a href="#subsec_Job_IDs">6.18.2</a> for more details.</div> +<h4 class="subsubsection" id='magicparlabel-3373'><span class="subsubsection_label">6.18.6</span> Debugging <em>HTCondor</em> jobs<div id="subsec_Debugging_HTCondor_jobs"></div> </h4> -<div class="standard" id='magicparlabel-3204'>All the <span class="flex_software">HTCondor</span> logs, <span class="flex_cvar">stdout</span> and <span class="flex_cvar">stderr</span> from your jobs are stored in the <span class="flex_file">condor_dir</span>. I cannot guide you on how <span class="flex_software">HTCondor</span> works or what its error codes mean, I suggest you look at their website for these instructions. However, you can check the log files to see whether a job that has stopped has crashed (as opposed to having been <em>evicted</em>). </div> +<div class="standard" id='magicparlabel-3374'>All the <span class="flex_software">HTCondor</span> logs, <span class="flex_cvar">stdout</span> and <span class="flex_cvar">stderr</span> from your jobs are stored in the <span class="flex_file">condor_dir</span>. I cannot guide you on how <span class="flex_software">HTCondor</span> works or what its error codes mean, I suggest you look at their website for these instructions. However, you can check the log files to see whether a job that has stopped has crashed (as opposed to having been <em>evicted</em>). </div> -<div class="standard" id='magicparlabel-3225'>When a job crashes and the crash has been caught by<em> </em><span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-3395'>When a job crashes and the crash has been caught by<em> </em><span class='math'>\binarygrid</span> 's wrapper script (this is usually the case), its status file contains crashed <em>n</em> where <em>n</em> is the crashed exit code from <span class='math'>binary_c</i></span> .</div> -<h4 class="subsubsection" id='magicparlabel-3226'><span class="subsubsection_label">6.18.7</span> “Random” segmentation faults (segfaults)</h4> -<div class="standard" id='magicparlabel-3227'>Sometimes you may find that the grid does not start. This looks like a random segmentation fault (such faults are almost never random). The most common cause is that your <span class='math'>\binarygrid</span> +<h4 class="subsubsection" id='magicparlabel-3396'><span class="subsubsection_label">6.18.7</span> “Random” segmentation faults (segfaults)</h4> +<div class="standard" id='magicparlabel-3397'>Sometimes you may find that the grid does not start. This looks like a random segmentation fault (such faults are almost never random). The most common cause is that your <span class='math'>\binarygrid</span> <span class="flex_scriptinglanguage">Perl</span> module must be reinstalled after you recompile <span class="flex_file"><i>libbinary_c.so</i></span>.</div> -<ul class="itemize" id='magicparlabel-3236'><li class="itemize_item">Recompile <span style='font-family:monospace;font-size: 18px;'><span class='math'>libbinary_c</i></span> +<ul class="itemize" id='magicparlabel-3406'><li class="itemize_item">Recompile <span style='font-family:monospace;font-size: 18px;'><span class='math'>libbinary_c</i></span> : <br /> @@ -3775,11 +3824,11 @@ output($population) if($population->output_allowed()); <pre class\s*='listings bash'>$ cpanm <i>binary_grid</i> --force -v</pre><br /> </li> </ul> -<h4 class="subsubsection" id='magicparlabel-3246'><span class="subsubsection_label">6.18.8</span> <span style='font-family:monospace;font-size: 18px;'>SIGILL</span> – Error code 4</h4> -<div class="standard" id='magicparlabel-3247'>If you find “Error code 4”, a <span class="flex_cvar">SIGILL</span>, is occurring, then you have a problem because it turns out that your build of either <span class='math'>libbinary_c</i></span>, <em><span class='math'>binary_c</i></span> +<h4 class="subsubsection" id='magicparlabel-3416'><span class="subsubsection_label">6.18.8</span> <span style='font-family:monospace;font-size: 18px;'>SIGILL</span> – Error code 4</h4> +<div class="standard" id='magicparlabel-3417'>If you find “Error code 4”, a <span class="flex_cvar">SIGILL</span>, is occurring, then you have a problem because it turns out that your build of either <span class='math'>libbinary_c</i></span>, <em><span class='math'>binary_c</i></span> </em> or <span class="flex_scriptinglanguage">Perl</span> (and its modules) is incompatible with the architecture on one of your slots. This problem can overcome by:</div> -<ul class="itemize" id='magicparlabel-3256'><li class="itemize_item">Setting the <span class="flex_envvar">ARCHFLAGS</span> environment variable, e.g. +<ul class="itemize" id='magicparlabel-3426'><li class="itemize_item">Setting the <span class="flex_envvar">ARCHFLAGS</span> environment variable, e.g. <br /> <br /> @@ -3790,34 +3839,34 @@ then run <br /> .</li> <li class="itemize_item">Replacing the <span class="flex_args">mtune</span> and <span class="flex_args">march</span> flags in your <span class="flex_software">Perlbrew</span> build with the above “generic” flags. To do this: -<ul class="itemize" id='magicparlabel-3282'><li class="itemize_item">Move (or remove) your <span class="flex_file">perlbrew</span><em> </em>and <span class="flex_file">perl5</span><em> </em>directories. </li> +<ul class="itemize" id='magicparlabel-3452'><li class="itemize_item">Move (or remove) your <span class="flex_file">perlbrew</span><em> </em>and <span class="flex_file">perl5</span><em> </em>directories. </li> <li class="itemize_item">Reinstall <span class="flex_scriptinglanguage">Perl</span> and <em><b>all</b></em> its modules. </li> <li class="itemize_item">If in doubt, check that the <span class="flex_perlmodule">binary_grid::C</span> module has the generic flags set rather than anything else. (If you are reading this documentation, then your version is fixed.)</li> </ul> </li></ul> -<div class="standard" id='magicparlabel-3301'>Note that using the above flags slows <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-3471'>Note that using the above flags slows <span class='math'>binary_c</i></span> but hopefully not by too much.</div> -<h4 class="subsubsection" id='magicparlabel-3302'><span class="subsubsection_label">6.18.9</span> Timeouts</h4> -<div class="standard" id='magicparlabel-3303'><em><span class='math'>binary_c</i></span> +<h4 class="subsubsection" id='magicparlabel-3472'><span class="subsubsection_label">6.18.9</span> Timeouts</h4> +<div class="standard" id='magicparlabel-3473'><em><span class='math'>binary_c</i></span> </em>automatically stops if <span class="flex_cmacro">TIMEOUT_SECONDS</span> (defined in <em><span class="flex_file">code_options.h</span></em>) have passed without a call to the <span class="flex_cfunction">reset_timeout()</span> function. This may happen if the host machine locks up for some reason, or if the network fails to write a file. There is not much I can do about this, but you could always set <span class="flex_cmacro">TIMEOUT_SECONDS</span> to <span class="flex_cmacro">0</span>, or comment out <span class="flex_cvar">CATCH_SIGVTALRM</span>. You will have to rebuild <span class='math'>libbinary_c</i></span> /<span class='math'>binary_c</i></span> if you do this.</div> -<h4 class="subsubsection_" id='magicparlabel-3328'>Checkpointing<div id="subsec_Checkpointing"></div> +<h4 class="subsubsection_" id='magicparlabel-3498'>Checkpointing<div id="subsec_Checkpointing"></div> </h4> -<div class="standard" id='magicparlabel-3329'>At one point there was an option to stop and start <span class='math'>\binarygrid</span>, however this has not been used in a long time. Because your jobs are running in the <em>vanilla</em> universe, they cannot be checkpointed by <span class="flex_software">HTCondor</span>. This might be considered a disadvantage, and annoying because checkpointing is one of the big features of <span class="flex_software">HTCondor</span>. However, I would disagree with this assessment. Your jobs will, if split onto enough PCs, not (each) take long to run. This means that should the <span class="flex_software">HTCondor</span> grid go down (e.g. there is a power cut) you can simply restart when it is up and your runtime will be delayed only by as long as one script takes to run (typically an hour or two if you have not too many stars in your population and you have plenty of compute machines). This is probably less time than your power cut. It is simply not worth my while programming in more features to deal with such a situation when the solution is so cheap.</div> +<div class="standard" id='magicparlabel-3499'>At one point there was an option to stop and start <span class='math'>\binarygrid</span>, however this has not been used in a long time. Because your jobs are running in the <em>vanilla</em> universe, they cannot be checkpointed by <span class="flex_software">HTCondor</span>. This might be considered a disadvantage, and annoying because checkpointing is one of the big features of <span class="flex_software">HTCondor</span>. However, I would disagree with this assessment. Your jobs will, if split onto enough PCs, not (each) take long to run. This means that should the <span class="flex_software">HTCondor</span> grid go down (e.g. there is a power cut) you can simply restart when it is up and your runtime will be delayed only by as long as one script takes to run (typically an hour or two if you have not too many stars in your population and you have plenty of compute machines). This is probably less time than your power cut. It is simply not worth my while programming in more features to deal with such a situation when the solution is so cheap.</div> -<div class="standard" id='magicparlabel-3342'><br /> +<div class="standard" id='magicparlabel-3512'><br /> </div> -<h3 class="subsection" id='magicparlabel-3343'><span class="subsection_label">6.19</span> Binary_grid with <em>slurm<div id="sec_Working_with_slurm"></div> +<h3 class="subsection" id='magicparlabel-3513'><span class="subsection_label">6.19</span> Binary_grid with <em>slurm<div id="sec_Working_with_slurm"></div> </em></h3> -<div class="standard" id='magicparlabel-3344'><span class="flex_software">Slurm</span> is a distributed computing system similar to <span class="flex_software">HTCondor</span>. <em><span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-3514'><span class="flex_software">Slurm</span> is a distributed computing system similar to <span class="flex_software">HTCondor</span>. <em><span class='math'>\binarygrid</span> </em>2 has a dedicated <span class="flex_software">slurm</span> module which you can load simply with:<br /> <pre class ='listings Perl'>use binary_grid2; use binary_grid::C; use binary_grid::slurm;</pre><br /> </div> -<div class="standard" id='magicparlabel-3363'>After setting up your population as usual, just insert some <em><span class="flex_software">slurm</span></em>-specific parameters<br /> +<div class="standard" id='magicparlabel-3533'>After setting up your population as usual, just insert some <em><span class="flex_software">slurm</span></em>-specific parameters<br /> <pre class ='listings Perl'># set up slurm $population->set( slurm=>1, # use slurm if 1 @@ -3833,21 +3882,21 @@ $population->set( );</pre><br /> </div> -<div class="standard" id='magicparlabel-3384'>Hopefully the options are obvious, but you will need to set them all.</div> +<div class="standard" id='magicparlabel-3554'>Hopefully the options are obvious, but you will need to set them all.</div> -<ul class="itemize" id='magicparlabel-3385'><li class="itemize_item">The <span class="flex_perlcode">slurm_dir</span> is a space that needs to be writable by all the nodes of your <span class="flex_software">slurm</span> setup. The <em>partition</em> is a queue name which you will have to find out from your local <span class="flex_software">slurm</span> setup (e.g. with <span class="flex_command">sinfo</span> or <em><span class="flex_command">squeue</span></em>). The <em>jobname</em> should be set to something sensible so you can identify your jobs.</li> +<ul class="itemize" id='magicparlabel-3555'><li class="itemize_item">The <span class="flex_perlcode">slurm_dir</span> is a space that needs to be writable by all the nodes of your <span class="flex_software">slurm</span> setup. The <em>partition</em> is a queue name which you will have to find out from your local <span class="flex_software">slurm</span> setup (e.g. with <span class="flex_command">sinfo</span> or <em><span class="flex_command">squeue</span></em>). The <em>jobname</em> should be set to something sensible so you can identify your jobs.</li> <li class="itemize_item"><span class="flex_perlcode">slurm_time</span> is the maximum time your job has to run (<span class="flex_perlcode">0</span> means infinite).</li> <li class="itemize_item"><span class="flex_perlcode">slurm_use_all_node_CPUs</span> should be set to <span class="flex_perlcode">1</span> if you are running the default setup where each <span class="flex_software">slurm</span> job gets a single node and all its CPUs.</li> <li class="itemize_item"><span class="flex_perlcode">slurm_control_CPUs</span> is the number of CPUs belonging to the control script, i.e. if you set this to <span class="flex_perlcode">1</span> then one of the CPUs is <em>not</em> given to calculations but rather to the <span class="flex_scriptinglanguage">Perl</span> grid. It is safe to leave this at zero.</li> </ul> -<div class="standard" id='magicparlabel-3441'>One big advantage of <span class="flex_software">slurm</span> compared to <span class="flex_software">HTCondor</span> is that <span class="flex_software">slurm</span> has array jobs which make it easy to set up a grid of models (the details are handled internally by the <span class="flex_software">slurm</span> module and all CPUs are used by default). </div> +<div class="standard" id='magicparlabel-3611'>One big advantage of <span class="flex_software">slurm</span> compared to <span class="flex_software">HTCondor</span> is that <span class="flex_software">slurm</span> has array jobs which make it easy to set up a grid of models (the details are handled internally by the <span class="flex_software">slurm</span> module and all CPUs are used by default). </div> -<div class="standard" id='magicparlabel-3458'>Please note that the <span class="flex_software">slurm</span> module has only been tested with <span class="flex_perlmodule"><i>binary_grid2</i></span> and <span class="flex_perlmodule">binary_grid::C</span>.</div> +<div class="standard" id='magicparlabel-3628'>Please note that the <span class="flex_software">slurm</span> module has only been tested with <span class="flex_perlmodule"><i>binary_grid2</i></span> and <span class="flex_perlmodule">binary_grid::C</span>.</div> -<div class="standard" id='magicparlabel-3471'><br /> +<div class="standard" id='magicparlabel-3641'><br /> </div> -<h3 class="subsection" id='magicparlabel-3472'><span class="subsection_label">6.20</span> Initial distributions (IMF etc.) </h3> -<div class="standard" id='magicparlabel-3473'><div id="sec_initial_dists"></div> +<h3 class="subsection" id='magicparlabel-3642'><span class="subsection_label">6.20</span> Initial distributions (IMF etc.) </h3> +<div class="standard" id='magicparlabel-3643'><div id="sec_initial_dists"></div> The initial distributions of stellar masses, mass ratios, separations and periods are handled by the <span class="flex_perlmodule">distribution_functions</span> <span class="flex_scriptinglanguage">Perl</span> module. The general idea is that given a set of stellar parameters <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> @@ -3900,7 +3949,7 @@ The initial distributions of stellar masses, mass ratios, separations and period <mrow><mi>i</mi> </mrow></mstyle></math> is calculated from </div> -<div class="standard" id='magicparlabel-3482'><div id="eq_prob_eq"></div> +<div class="standard" id='magicparlabel-3652'><div id="eq_prob_eq"></div> <math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mtable> <mtr> @@ -4111,12 +4160,12 @@ The initial distributions of stellar masses, mass ratios, separations and period </mrow> </mrow></mstyle></math>.</div> -<div class="standard" id='magicparlabel-3483'>There are many forms for each initial distributions and they depend on which authors you believe and/or which stars you are looking at (e.g. low- or high-mass stars). There is no one true answer – yet!</div> -<h4 class="subsubsection" id='magicparlabel-3484'><span class="subsubsection_label">6.20.1</span> Predefined functions in the distribution_functions module</h4> -<div class="standard" id='magicparlabel-3485'><div id="subsec_distribution_functions_predefined_functions"></div> +<div class="standard" id='magicparlabel-3653'>There are many forms for each initial distributions and they depend on which authors you believe and/or which stars you are looking at (e.g. low- or high-mass stars). There is no one true answer – yet!</div> +<h4 class="subsubsection" id='magicparlabel-3654'><span class="subsubsection_label">6.20.1</span> Predefined functions in the distribution_functions module</h4> +<div class="standard" id='magicparlabel-3655'><div id="subsec_distribution_functions_predefined_functions"></div> </div> -<dl class='description' id='magicparlabel-3486'><dt class="description_label">const(<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<dl class='description' id='magicparlabel-3656'><dt class="description_label">const(<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>a</mi> </mrow></mstyle></math>,<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>b</mi> @@ -4358,13 +4407,13 @@ The initial distributions of stellar masses, mass ratios, separations and period <mrow><mi>x</mi> </mrow></mstyle></math>.</dd> </dl> -<div class="standard" id='magicparlabel-3492'><br /> +<div class="standard" id='magicparlabel-3662'><br /> </div> -<h3 class="subsection" id='magicparlabel-3493'><span class="subsection_label">6.21</span> Grid spacings</h3> -<div class="standard" id='magicparlabel-3494'><div id="sec_The_spacing_functions_module"></div> +<h3 class="subsection" id='magicparlabel-3663'><span class="subsection_label">6.21</span> Grid spacings</h3> +<div class="standard" id='magicparlabel-3664'><div id="sec_The_spacing_functions_module"></div> The <span class="flex_perlmodule">spacing_functions</span><em> </em>module is used to set up the grid spacings. At the moment there are only a few functions, but you can add your own of course.</div> -<dl class='description' id='magicparlabel-3499'><dt class="description_label">const(<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<dl class='description' id='magicparlabel-3669'><dt class="description_label">const(<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>x</mi> @@ -4497,22 +4546,22 @@ The <span class="flex_perlmodule">spacing_functions</span><em> </em>module is us <mrow><mi>t</mi> </mrow></mstyle></math>. See Sec. <a href="#Recipe_time_resolved_mass_grid">6.25.3</a> for an example of its use.</dd> </dl> -<div class="standard" id='magicparlabel-3502'><br /> +<div class="standard" id='magicparlabel-3672'><br /> </div> -<h3 class="subsection" id='magicparlabel-3503'><span class="subsection_label">6.22</span> The <span class='math'>\binarygrid</span> +<h3 class="subsection" id='magicparlabel-3673'><span class="subsection_label">6.22</span> The <span class='math'>\binarygrid</span> thread model</h3> -<div class="standard" id='magicparlabel-3504'><div id="sec_The_Thread_Model"></div> +<div class="standard" id='magicparlabel-3674'><div id="sec_The_Thread_Model"></div> CPUs used to be simple devices that did one job at a time. No more: every CPU these days has multiple <em>cores</em> which can run simultaneously while sharing system resources (e.g. RAM, disk). <span class='math'>\binarygrid</span> takes advantage of this by splitting the workload of running stars over a parameter space into multiple <em>threads</em> which run concurrently, thus speeding up execution of the grid.</div> -<div class="standard" id='magicparlabel-3505'>Note: you should <em>not</em> call <span class="flex_perlcode">flexigrid</span> directly with <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-3675'>Note: you should <em>not</em> call <span class="flex_perlcode">flexigrid</span> directly with <span class='math'>\binarygrid</span> 2: instead call <br /> <pre class ='listings'>$population->evolve();</pre><br /> </div> -<div class="standard" id='magicparlabel-3514'>When you call <span class="flex_perlcode">$population->evolve()</span> it sends a single argument to <span class="flex_perlcode">flexigrid()</span>: the number of child threads. Let's say you launch <span class="flex_perlcode">flexigrid(4);</span><em> </em>then the parent thread launches four children which are managed in a thread queue (using <span class="flex_scriptinglanguage">Perl</span>'s <span class="flex_perlmodule">Thread::Queue</span> module). Each star you want to run is placed in the queue and the threads pull them off one by one until the parameter space is complete.</div> -<h4 class="subsubsection" id='magicparlabel-3535'><span class="subsubsection_label">6.22.1</span> Thread resources</h4> -<div class="standard" id='magicparlabel-3536'><div id="subsec_thread_resources"></div> +<div class="standard" id='magicparlabel-3684'>When you call <span class="flex_perlcode">$population->evolve()</span> it sends a single argument to <span class="flex_perlcode">flexigrid()</span>: the number of child threads. Let's say you launch <span class="flex_perlcode">flexigrid(4);</span><em> </em>then the parent thread launches four children which are managed in a thread queue (using <span class="flex_scriptinglanguage">Perl</span>'s <span class="flex_perlmodule">Thread::Queue</span> module). Each star you want to run is placed in the queue and the threads pull them off one by one until the parameter space is complete.</div> +<h4 class="subsubsection" id='magicparlabel-3705'><span class="subsubsection_label">6.22.1</span> Thread resources</h4> +<div class="standard" id='magicparlabel-3706'><div id="subsec_thread_resources"></div> Each thread stores its results in a <em>hash table </em>(marked by <span class="flex_perlcode">%</span> in <em>Perl</em>, see <br /> @@ -4521,7 +4570,7 @@ Each thread stores its results in a <em>hash table </em>(marked by <span class=" <a href="http://www.perltutorial.org/perl-hash.aspx">http://www.perltutorial.org/perl-hash.aspx</a>, if you know about <span class="flex_scriptinglanguage">Python</span><em> </em>dictionaries, these are pretty much the same). This is like an array, which is probably familiar to you from other programming languages e.g. <em>C</em>, <em>C++</em> and <em>FORTRAN</em>, but instead of using numbers (e.g. 0, 1, 2…) as indices, it uses <em>keys</em> instead which can be any scalar, i.e. strings or numbers. Hashes can be nested, e.g. as hashes of hashes or hashes of arrays or arrays of hashes etc. This concept is very powerful because it allows you to store the results of your population synthesis in a <em>single hash table.</em> Because hashes can be nested, a single table can store <em>everything</em> you can throw at it. </div> -<div class="standard" id='magicparlabel-3545'>Each thread has its own hash, usually accessed (e.g. in <em><span class="flex_perlcode">parse_bse</span></em>) through the variable +<div class="standard" id='magicparlabel-3715'>Each thread has its own hash, usually accessed (e.g. in <em><span class="flex_perlcode">parse_bse</span></em>) through the variable <br /> <span class="flex_perlcode">$population->results</span> where <span class="flex_perlcode">$population</span> is your <em><span class='math'>\binarygrid</span> @@ -4529,14 +4578,14 @@ Each thread stores its results in a <em>hash table </em>(marked by <span class=" <pre class ='listings Perl'>$h=$population->results();</pre><br /> into which you put your data in <span style='font-family:monospace;font-size: 18px;'>$h</span> and it is propagated where it is required.</div> -<div class="standard" id='magicparlabel-3570'>When the threads finish they are <em>joined</em> together – in this process, the thread's<em> </em>results hash is added to a global hash which ends up in your <span class="flex_perlcode">$population</span> object. The mechanism to do this is automatically included in <span class='math'>\binarygrid</span>, you do not usually have to do anything yourself. At the end of the grid, the<em> </em><span class="flex_perlcode">$population->results</span> hash contains the sum of the population synthesis over all the stars you have run.</div> +<div class="standard" id='magicparlabel-3740'>When the threads finish they are <em>joined</em> together – in this process, the thread's<em> </em>results hash is added to a global hash which ends up in your <span class="flex_perlcode">$population</span> object. The mechanism to do this is automatically included in <span class='math'>\binarygrid</span>, you do not usually have to do anything yourself. At the end of the grid, the<em> </em><span class="flex_perlcode">$population->results</span> hash contains the sum of the population synthesis over all the stars you have run.</div> -<div class="standard" id='magicparlabel-3579'>Beware that the default hash join function <em>only </em>knows how to add up scalars, arrays and hashes. It cannot know how to add a hash to an array. I cannot think of a case where this would be a problem unless you make your results hash structure depend on thread number. I cannot think of a reason why you would do this.</div> -<h4 class="subsubsection" id='magicparlabel-3580'><span class="subsubsection_label">6.22.2</span> CPU load and thread number</h4> -<div class="standard" id='magicparlabel-3581'><div id="subsec_CPU_load"></div> +<div class="standard" id='magicparlabel-3749'>Beware that the default hash join function <em>only </em>knows how to add up scalars, arrays and hashes. It cannot know how to add a hash to an array. I cannot think of a case where this would be a problem unless you make your results hash structure depend on thread number. I cannot think of a reason why you would do this.</div> +<h4 class="subsubsection" id='magicparlabel-3750'><span class="subsubsection_label">6.22.2</span> CPU load and thread number</h4> +<div class="standard" id='magicparlabel-3751'><div id="subsec_CPU_load"></div> </div> -<dl class='description' id='magicparlabel-3582'><dt class="description_label">C backend</dt> +<dl class='description' id='magicparlabel-3752'><dt class="description_label">C backend</dt> <dd class="description_item"> Using the <em>C</em> backend, the number of threads scales well with CPU usage and runtime, tested up to 8 threads (or 16 with hyperthreading, which obviously isn't really a valid test given how dodgy hyperthreading is). <b>It is highly recommended to use the <i>C</i> backend for greatly increased performance.</b></dd> <dt class="description_label">Perl backend</dt> <dd class="description_item"> It is not obviously clear how many threads you should launch even if you know the number of CPUs in your system. If your <span class='math'>binary_c</i></span> @@ -4554,12 +4603,12 @@ will not have much processing to do and you may as well launch as many threads a </mrow> </mrow></mstyle></math> threads for the fastest possible grid.</dd> </dl> -<div class="standard" id='magicparlabel-3584'>The best option is to experiment with a limited (low-resolution) parameter space and gradually increase the number of stars while changing the number of threads. This is, in any case, good practice for debugging your newly programmed code. When debugging, use <em>only one thread.</em></div> -<h4 class="subsubsection" id='magicparlabel-3585'><span class="subsubsection_label">6.22.3</span> Memory usage</h4> -<div class="standard" id='magicparlabel-3586'><div id="subsec_memory_usage"></div> +<div class="standard" id='magicparlabel-3754'>The best option is to experiment with a limited (low-resolution) parameter space and gradually increase the number of stars while changing the number of threads. This is, in any case, good practice for debugging your newly programmed code. When debugging, use <em>only one thread.</em></div> +<h4 class="subsubsection" id='magicparlabel-3755'><span class="subsubsection_label">6.22.3</span> Memory usage</h4> +<div class="standard" id='magicparlabel-3756'><div id="subsec_memory_usage"></div> Each thread stores its data in its own hash, so the more threads you have the more memory you will use. If you are not saving much data, this will not bother you, but obviously if you save a lot of high-resolution data you may start to use a lot of RAM. </div> -<div class="standard" id='magicparlabel-3587'>You should bin your hash keys to save RAM: consider this example. If you save the luminosity at each timestep, you will end up with hashes with keys (e.g.) 1.0, 1.0001, 1.0002, 1.0003 etc. Very quickly – in seconds! – you will have more data than you or your RAM can handle. Instead, bin your data and use logarithms when you can. Binary_grid has a bin_data function for this, e.g. <br /> +<div class="standard" id='magicparlabel-3757'>You should bin your hash keys to save RAM: consider this example. If you save the luminosity at each timestep, you will end up with hashes with keys (e.g.) 1.0, 1.0001, 1.0002, 1.0003 etc. Very quickly – in seconds! – you will have more data than you or your RAM can handle. Instead, bin your data and use logarithms when you can. Binary_grid has a bin_data function for this, e.g. <br /> <pre class ='listings Perl'>$logL=bin_data(log10($L),0.1);</pre><br /> bins the logarithm of <span style='font-family:monospace;font-size: 18px;'>$L</span> (e.g. the luminosity) to the nearest <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -4571,7 +4620,7 @@ Each thread stores its data in its own hash, so the more threads you have the mo </mrow> </mrow></mstyle></math>. </div> -<div class="standard" id='magicparlabel-3592'>Remember that if each thread uses <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-3762'>Remember that if each thread uses <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>N</mi> </mrow></mstyle></math> megabytes of RAM and you have <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>n</mi> @@ -4585,12 +4634,12 @@ Each thread stores its data in its own hash, so the more threads you have the mo <mrow><mo><</mo><mn>2</mn><mi>n</mi><mi>N</mi> </mrow> </mrow></mstyle></math>, your grid may fail at the thread join step if there is not sufficient RAM. In the case of an <span class="flex_software">HTCondor</span> or <span class="flex_software">slurm</span> grid, your data files are preserved and you can simply rerun the final grid join step on a machine with more memory.</div> -<h4 class="subsubsection" id='magicparlabel-3601'><span class="subsubsection_label">6.22.4</span> <span style='font-family:monospace;font-size: 18px;'>threadinfo</span> variables</h4> -<div class="standard" id='magicparlabel-3602'><div id="subsec_thread_variables"></div> +<h4 class="subsubsection" id='magicparlabel-3771'><span class="subsubsection_label">6.22.4</span> <span style='font-family:monospace;font-size: 18px;'>threadinfo</span> variables</h4> +<div class="standard" id='magicparlabel-3772'><div id="subsec_thread_variables"></div> Each thread sets its own copy of the<span style='font-family:monospace;font-size: 18px;'> </span><span class="flex_perlcode">_threadinfo</span> hash inside the<em> <span class='math'>\binarygrid2</span> </em>object, containing information relevant only to the thread. Most of this is used internally but you have access to it (do not change it unless you know what you are doing!).</div> -<ol class='lyxlist' id='magicparlabel-3607'><li class="labeling_item"><span class='lyxlist'>evcode_pid</span> +<ol class='lyxlist' id='magicparlabel-3777'><li class="labeling_item"><span class='lyxlist'>evcode_pid</span> <span class='math'>binary_c</i></span> process id associated with this thread (only for <span class="flex_scriptinglanguage">Perl</span><em> </em>backend)</li> <li class="labeling_item"><span class='lyxlist'>cmd</span> @@ -4625,17 +4674,17 @@ Each thread sets its own copy of the<span style='font-family:monospace;font-size <li class="labeling_item"><span class='lyxlist'>thread_prev_complaint</span> Thread timer (from <span class="flex_perlcode">time()</span>): this is the time the thread last registered a complaint about taking too long</li> </ol> -<div class="standard" id='magicparlabel-3663'><br /> +<div class="standard" id='magicparlabel-3833'><br /> </div> -<h3 class="subsection" id='magicparlabel-3664'><span class="subsection_label">6.23</span> Debugging, benchmarking and advanced topics</h3> -<div class="standard" id='magicparlabel-3665'><div id="sec_debugging"></div> +<h3 class="subsection" id='magicparlabel-3834'><span class="subsection_label">6.23</span> Debugging, benchmarking and advanced topics</h3> +<div class="standard" id='magicparlabel-3835'><div id="sec_debugging"></div> This section provides a summary of debugging options and suggestions for ways to fix your code (or<em> <span class='math'>\binarygrid</span> </em>!). </div> -<h4 class="subsubsection" id='magicparlabel-3666'><span class="subsubsection_label">6.23.1</span> Debugging options</h4> -<div class="standard" id='magicparlabel-3667'>The following <span class='math'>\binarygrid</span> +<h4 class="subsubsection" id='magicparlabel-3836'><span class="subsubsection_label">6.23.1</span> Debugging options</h4> +<div class="standard" id='magicparlabel-3837'>The following <span class='math'>\binarygrid</span> 2 object variables affect debugging:</div> -<ul class="itemize" id='magicparlabel-3668'><li class="itemize_item"><span class="flex_perlcode">vb</span> +<ul class="itemize" id='magicparlabel-3838'><li class="itemize_item"><span class="flex_perlcode">vb</span> <br /> See Section <a href="#subsec_Verbosity">6.23.2</a> below.</li> @@ -4745,9 +4794,9 @@ See Section <a href="#subsec_Verbosity">6.23.2</a> below.</li> </mrow></mstyle></math>, and the values contain the appropriate data. Again, this is accessible from <span class="flex_perlcode">parse_bse</span>. </li> <li class="itemize_item">Use the <span class="flex_perlcode">timeout</span> feature if your code is freezing. This is <em>not</em> the same as fixing your problem, but you may be able to stop the code from using all your CPU when it freezes! (Note that this uses <span class="flex_os">Unix</span> signals to test for timeouts: it may not work e.g. with the <span class="flex_software">HTCondor</span>/<span class="flex_software">slurm</span> queueing system).</li> </ul> -<h4 class="subsubsection" id='magicparlabel-3747'><span class="subsubsection_label">6.23.2</span> Verbosity<div id="subsec_Verbosity"></div> +<h4 class="subsubsection" id='magicparlabel-3917'><span class="subsubsection_label">6.23.2</span> Verbosity<div id="subsec_Verbosity"></div> </h4> -<div class="standard" id='magicparlabel-3748'><span style='font-family:monospace;font-size: 18px;'>vb</span> controls the amount of grid output to the screen, usually lines showing the number of stars evolved, the total number in the grid, the current time, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-3918'><span style='font-family:monospace;font-size: 18px;'>vb</span> controls the amount of grid output to the screen, usually lines showing the number of stars evolved, the total number in the grid, the current time, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>M</mi> @@ -4773,13 +4822,13 @@ See Section <a href="#subsec_Verbosity">6.23.2</a> below.</li> <mrow>% </mrow></mstyle></math> grid completion, estimated time until arrival (finish) i.e. <em>ETA</em>, <em>tpr</em> (time per run), <em>ETF</em> (estimated time at which it will finish) and memory usage. If set to 1 it shows output every second or every <span style='font-family:monospace;font-size: 18px;'>nmod</span> models. </div> -<div class="standard" id='magicparlabel-3749'>If <span style='font-family:monospace;font-size: 18px;'>vb</span> is set to <span style='font-family:monospace;font-size: 18px;'>2</span> then more output, showing the arguments sent to <span class='math'>binary_c</i></span>, will be dumped onto the screen for each model. This is only useful for small grids, for large grids it will overwhelm you. It is possible to set <span style='font-family:monospace;font-size: 18px;'>vb=3</span> for even more output. +<div class="standard" id='magicparlabel-3919'>If <span style='font-family:monospace;font-size: 18px;'>vb</span> is set to <span style='font-family:monospace;font-size: 18px;'>2</span> then more output, showing the arguments sent to <span class='math'>binary_c</i></span>, will be dumped onto the screen for each model. This is only useful for small grids, for large grids it will overwhelm you. It is possible to set <span style='font-family:monospace;font-size: 18px;'>vb=3</span> for even more output. <br /> Note that as of <em><span class='math'>\binarygrid</span> </em> 0.18 it is impossible to set <span style='font-family:monospace;font-size: 18px;'>vb</span> from inside your script if you are using the two-stage bootstrapping (which you really should, see Section <a href="#subsec_Two_stage_bootstrapping">6.23.4</a> below): it <em>must</em> be sent on the command line that runs your script.</div> -<div class="standard" id='magicparlabel-3750'>Inside <span class="flex_perlmodule"><i>binary_grid2</i>.pm</span> are many <span class="flex_perlcode">vbout(<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-3920'>Inside <span class="flex_perlmodule"><i>binary_grid2</i>.pm</span> are many <span class="flex_perlcode">vbout(<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>n</mi> </mrow></mstyle></math>,…);</span> statements. These control the verbose output from<em> <span class='math'>\binarygrid</span> 2</em>, such that the statement is output to the screen <em>only if </em><span style='font-family:monospace;font-size: 18px;'>vb</span><em><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -4787,52 +4836,52 @@ Note that as of <em><span class='math'>\binarygrid</span> <mrow><mo> ≥ </mo><mi>n</mi> </mrow> </mrow></mstyle></math></em>. If you want to insert new verbose statements, please use this format!</div> -<h4 class="subsubsection" id='magicparlabel-3759'><span class="subsubsection_label">6.23.3</span> Benchmarking with subroutine timers<div id="subsec_Subroutine_timers"></div> +<h4 class="subsubsection" id='magicparlabel-3929'><span class="subsubsection_label">6.23.3</span> Benchmarking with subroutine timers<div id="subsec_Subroutine_timers"></div> </h4> -<div class="standard" id='magicparlabel-3760'><b>Warning:timers have not been tested with <i>binary_grid2</i></b></div> +<div class="standard" id='magicparlabel-3930'><b>Warning:timers have not been tested with <i>binary_grid2</i></b></div> -<div class="standard" id='magicparlabel-3761'>If your grid is running slowly, you can use subroutine timers by first setting:</div> +<div class="standard" id='magicparlabel-3931'>If your grid is running slowly, you can use subroutine timers by first setting:</div> -<div class="standard" id='magicparlabel-3762'><br /> +<div class="standard" id='magicparlabel-3932'><br /> <pre class ='listings Perl'>$population->timers=1;</pre><br /> <span style='font-family:monospace;font-size: 18px;'> </span>and then make a list of subroutines you would like to time:</div> -<div class="standard" id='magicparlabel-3767'><br /> +<div class="standard" id='magicparlabel-3937'><br /> <pre class ='listings Perl'>$population->timer_subroutines=['main::parse_bse','binary_out','print_binary_in'];</pre><br /> Note that a default subroutine list is used (see <span class="flex_file"><i>binary_grid2</i>.pm</span>) which includes most of the subroutines in <span class='math'>\binarygrid</span> . To see the results of the subroutine timing, put a call to</div> -<div class="standard" id='magicparlabel-3776'><br /> +<div class="standard" id='magicparlabel-3946'><br /> <pre class ='listings Perl'>output_binary_grid_timers();</pre><br /> in your script before it exits.</div> -<div class="standard" id='magicparlabel-3781'>There is considerable overhead in activating subroutine timers, so your grid will run possibly up to twice as slow as normal. Timers should <em>not</em> be used for production code, but are very useful if you want to know what is slowing you down.</div> +<div class="standard" id='magicparlabel-3951'>There is considerable overhead in activating subroutine timers, so your grid will run possibly up to twice as slow as normal. Timers should <em>not</em> be used for production code, but are very useful if you want to know what is slowing you down.</div> -<div class="standard" id='magicparlabel-3782'>Note that some subroutines are designed to sit and wait for something to happen (e.g. <em>binary_out</em>) and these will therefore use up a lot of time. This is normal: I have gone to great length to make these functions as fast as possible (while keeping debugging and code-crash checking) – if you can make them faster, great, but this will be difficult if you want stability and error-checking.</div> -<h4 class="subsubsection" id='magicparlabel-3783'><span class="subsubsection_label">6.23.4</span> Two-stage bootstrapping<div id="subsec_Two_stage_bootstrapping"></div> +<div class="standard" id='magicparlabel-3952'>Note that some subroutines are designed to sit and wait for something to happen (e.g. <em>binary_out</em>) and these will therefore use up a lot of time. This is normal: I have gone to great length to make these functions as fast as possible (while keeping debugging and code-crash checking) – if you can make them faster, great, but this will be difficult if you want stability and error-checking.</div> +<h4 class="subsubsection" id='magicparlabel-3953'><span class="subsubsection_label">6.23.4</span> Two-stage bootstrapping<div id="subsec_Two_stage_bootstrapping"></div> </h4> -<div class="standard" id='magicparlabel-3784'><b>Warning: bootstrapping is no longer of much concern in <em><i>binary_grid2</i></em>, even though it still works for some of the module code. The backend modules are <em>not </em>bootstrapped because it is simply impossible to do so.</b></div> +<div class="standard" id='magicparlabel-3954'><b>Warning: bootstrapping is no longer of much concern in <em><i>binary_grid2</i></em>, even though it still works for some of the module code. The backend modules are <em>not </em>bootstrapped because it is simply impossible to do so.</b></div> -<div class="standard" id='magicparlabel-3785'>As of version 0.18 of <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-3955'>As of version 0.18 of <span class='math'>\binarygrid</span> and hence inherited in <span class='math'>\binarygrid</span> 2, the <span class='math'>\binarygrid</span> 2 module is loaded using a two-stage bootstrap technique. The aim of this is to reduce the overhead of using verbose debugging statements (and the like) in the <em><span class='math'>\binarygrid</span> </em>code by removing unnecessary code at runtime <em>prior to compilation</em>. Perl is a superb language for doing this by means of its <span class="flex_perlcode">eval</span> command. Roughly, when you load <span class="flex_file"><i>binary_grid2</i>.pm</span> the following happens:</div> -<ol class="enumerate" id='magicparlabel-3794'><li class="enumerate_item">The module loads a few basic subroutines, including <span class="flex_perlcode">parse_args</span> to check the command line arguments, especially to look for a <span class="flex_args">vb=n</span> switch that controls verbosity.</li> +<ol class="enumerate" id='magicparlabel-3964'><li class="enumerate_item">The module loads a few basic subroutines, including <span class="flex_perlcode">parse_args</span> to check the command line arguments, especially to look for a <span class="flex_args">vb=n</span> switch that controls verbosity.</li> <li class="enumerate_item">The variable <span class="flex_perlcode">$binary_grid_code</span> is set up: this contains most of the module code. This is then filtered to remove <span class="flex_perlcode">vbout()</span> and <span class="flex_perlcode">verbose_output()</span> statements that would never output anything, based on your choice of the <span class="flex_perlcode">vb</span> <span class="flex_perlcode">grid_option</span> (as given in the arguments to your script). Note that the useless code is <em>completely removed</em> rather than left to always do nothing.</li> <li class="enumerate_item">The <span class="flex_perlcode">$binary_grid_code</span> is <span class="flex_perlcode">eval</span>d, i.e. compiled at runtime.</li> </ol> -<div class="standard" id='magicparlabel-3833'>This <em>bootstrapping</em> eliminates the overhead of calls to the vbout subroutine, and its check of the <span style='font-family:monospace;font-size: 18px;'>vb</span> variable. You may think this overhead is small, but it really is not. The reason is that the arguments to a <span class="flex_software">Perl</span> subroutine are evaluated <em>prior </em>to the call. This often makes sense, but if the arguments are (say) long lists that need joining, this takes valuable CPU time – and for nothing!</div> +<div class="standard" id='magicparlabel-4003'>This <em>bootstrapping</em> eliminates the overhead of calls to the vbout subroutine, and its check of the <span style='font-family:monospace;font-size: 18px;'>vb</span> variable. You may think this overhead is small, but it really is not. The reason is that the arguments to a <span class="flex_software">Perl</span> subroutine are evaluated <em>prior </em>to the call. This often makes sense, but if the arguments are (say) long lists that need joining, this takes valuable CPU time – and for nothing!</div> -<div class="standard" id='magicparlabel-3838'>Benchmarking tests with subroutine timers (see Section <a href="#subsec_Subroutine_timers">6.23.3</a>) show a considerable saving by using this technique, sometimes up to a factor of two in runtime. Bootstrapping is set to be on by default, but can be disabled by setting +<div class="standard" id='magicparlabel-4008'>Benchmarking tests with subroutine timers (see Section <a href="#subsec_Subroutine_timers">6.23.3</a>) show a considerable saving by using this technique, sometimes up to a factor of two in runtime. Bootstrapping is set to be on by default, but can be disabled by setting <br /> <br /> <pre class ='listings Perl'>$binary_grid::grid_options{binary_grid_code_filtering}=0;</pre><br /> </div> -<div class="standard" id='magicparlabel-3843'>If you have problems, e.g. the <span class="flex_perlcode">eval()</span><em> </em>step fails, you should be able to spot this at module installation time (e.g.<em> </em><span class="flex_software">cpanm</span> will fail). Alternatively, you can set +<div class="standard" id='magicparlabel-4013'>If you have problems, e.g. the <span class="flex_perlcode">eval()</span><em> </em>step fails, you should be able to spot this at module installation time (e.g.<em> </em><span class="flex_software">cpanm</span> will fail). Alternatively, you can set <br /> <span class="flex_perlcode">$binary_grid::grid_options{pre_filter_file}</span> and @@ -4840,27 +4889,27 @@ in your script before it exits.</div> <span class="flex_perlcode">$binary_grid::grid_options{post_filter_file}</span> to dump the contents of <span class="flex_perlcode">$binary_grid_code</span> to files, which you can then diff to determine what went wrong. </div> -<div class="standard" id='magicparlabel-3864'>Note that, if you use the bootstrapping – which you really should! – you <em>must</em> set <span style='font-family:monospace;font-size: 18px;'>vb</span> in the arguments to your script. Any later settings (e.g. setting the variable manually inside your script) will be ignored.</div> +<div class="standard" id='magicparlabel-4034'>Note that, if you use the bootstrapping – which you really should! – you <em>must</em> set <span style='font-family:monospace;font-size: 18px;'>vb</span> in the arguments to your script. Any later settings (e.g. setting the variable manually inside your script) will be ignored.</div> -<div class="standard" id='magicparlabel-3865'><br /> +<div class="standard" id='magicparlabel-4035'><br /> </div> -<h3 class="subsection" id='magicparlabel-3866'><span class="subsection_label">6.24</span> Future Plans</h3> -<div class="standard" id='magicparlabel-3867'><div id="sec_future_plans"></div> +<h3 class="subsection" id='magicparlabel-4036'><span class="subsection_label">6.24</span> Future Plans</h3> +<div class="standard" id='magicparlabel-4037'><div id="sec_future_plans"></div> </div> -<ul class="itemize" id='magicparlabel-3868'><li class="itemize_item">A graphical frontend would be good! Please write one for me.</li> +<ul class="itemize" id='magicparlabel-4038'><li class="itemize_item">A graphical frontend would be good! Please write one for me.</li> </ul> -<div class="standard" id='magicparlabel-3869'><br /> +<div class="standard" id='magicparlabel-4039'><br /> </div> -<h3 class="subsection" id='magicparlabel-3870'><span class="subsection_label">6.25</span> Cookbook</h3> -<div class="standard" id='magicparlabel-3871'><div id="sec_Cookbook"></div> +<h3 class="subsection" id='magicparlabel-4040'><span class="subsection_label">6.25</span> Cookbook</h3> +<div class="standard" id='magicparlabel-4041'><div id="sec_Cookbook"></div> This section contains some examples of how to use <i>binary_grid</i>, so refers to old code (which I have updated where I can). I will fill this in for<b> <span class='math'>\binarygrid2</span> </b>at some point.</div> -<h4 class="subsubsection" id='magicparlabel-3872'><span class="subsubsection_label">6.25.1</span> Star Formation History</h4> -<div class="standard" id='magicparlabel-3873'><div id="Recipe_SFR"></div> +<h4 class="subsubsection" id='magicparlabel-4042'><span class="subsubsection_label">6.25.1</span> Star Formation History</h4> +<div class="standard" id='magicparlabel-4043'><div id="Recipe_SFR"></div> You may not want to use a constant star formation rate (SFR). If you can live with all your models having the same input physics (i.e. metallicity, etc.) you can easily fold in a star formation history (SFH).</div> -<ol class="enumerate" id='magicparlabel-3874'><li class="enumerate_item">Make sure you know the <em>time</em> at each output of <span class='math'>binary_c</i></span>, let's call this <span style='font-family:monospace;font-size: 18px;'>$t</span>.</li> +<ol class="enumerate" id='magicparlabel-4044'><li class="enumerate_item">Make sure you know the <em>time</em> at each output of <span class='math'>binary_c</i></span>, let's call this <span style='font-family:monospace;font-size: 18px;'>$t</span>.</li> <li class="enumerate_item">You also need <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi>d</mi><mi>t</mi><mo> × </mo><mi>p</mi> @@ -4870,9 +4919,9 @@ You may not want to use a constant star formation rate (SFR). If you can live wi <pre class ='listings Perl'>$dtp *= SFR($binary_grid::bse_options{'max_evolution_time'}-$t);</pre><br /> </span></li> </ol> -<div class="standard" id='magicparlabel-3889'>You have to write the SFR function yourself, e.g.,</div> +<div class="standard" id='magicparlabel-4059'>You have to write the SFR function yourself, e.g.,</div> -<div class="standard" id='magicparlabel-3890'><br /> +<div class="standard" id='magicparlabel-4060'><br /> <pre class ='listings Perl'>sub SFR { # SFR as a function of Galactic age in Myr @@ -4883,7 +4932,7 @@ You may not want to use a constant star formation rate (SFR). If you can live wi }</pre><br /> </div> -<div class="standard" id='magicparlabel-3902'>How does this work? What you're passing into the SFR function is <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4072'>How does this work? What you're passing into the SFR function is <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> <msub subscriptshift="0.2ex"> @@ -4911,26 +4960,26 @@ You may not want to use a constant star formation rate (SFR). If you can live wi </msub> </mrow></mstyle></math> ago.</div> -<div class="standard" id='magicparlabel-3903'>This does not describe the overall normalization, e.g. if you want <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4073'>This does not describe the overall normalization, e.g. if you want <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>N</mi> </mrow></mstyle></math> stars in total. You have to add up the statistic appropriate to <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>N</mi> </mrow></mstyle></math> (i.e. the number of stars seen <em>now</em>) and apply this to your results.</div> -<h4 class="subsubsection" id='magicparlabel-3904'><span class="subsubsection_label">6.25.2</span> Aliasing</h4> -<div class="standard" id='magicparlabel-3905'><div id="Recipe_aliasing"></div> +<h4 class="subsubsection" id='magicparlabel-4074'><span class="subsubsection_label">6.25.2</span> Aliasing</h4> +<div class="standard" id='magicparlabel-4075'><div id="Recipe_aliasing"></div> You output your histogram but it's all spiky and noisy! What's wrong? The simple answer is that you don't have enough stars on your grid for the bin width of your histogram. (See e.g. <br /> <a href="http://en.wikipedia.org/wiki/Nyquist-Shannon_sampling_theorem">http://en.wikipedia.org/wiki/Nyquist-Shannon_sampling_theorem</a>) Solutions are:</div> -<ol class="enumerate" id='magicparlabel-3906'><li class="enumerate_item">More stars</li> +<ol class="enumerate" id='magicparlabel-4076'><li class="enumerate_item">More stars</li> <li class="enumerate_item">Wider bins</li> </ol> -<div class="standard" id='magicparlabel-3908'>Now, I hear you cry that your old Monte Carlo code gives a lovely smooth histogram. Yes, for the same number of stars, it might. But it might also give you worse spikes. With a MC code you can never guarantee resolution, and in the limit of a large number of stars the result is the same. At least with a grid-based solution you can <em>see</em> the spikes so you <em>know </em>the limit of your resolution. With an MC code you're just playing dice (see the FAQ <a href="#FAQ_why_not_MC_">6.26.1</a>).</div> +<div class="standard" id='magicparlabel-4078'>Now, I hear you cry that your old Monte Carlo code gives a lovely smooth histogram. Yes, for the same number of stars, it might. But it might also give you worse spikes. With a MC code you can never guarantee resolution, and in the limit of a large number of stars the result is the same. At least with a grid-based solution you can <em>see</em> the spikes so you <em>know </em>the limit of your resolution. With an MC code you're just playing dice (see the FAQ <a href="#FAQ_why_not_MC_">6.26.1</a>).</div> -<div class="standard" id='magicparlabel-3909'>Usually I just run with more stars. See also Recipe <a href="#Recipe_SFR">6.25.1</a> above.</div> -<h4 class="subsubsection" id='magicparlabel-3910'><span class="subsubsection_label">6.25.3</span> Time-resolved mass grid</h4> -<div class="standard" id='magicparlabel-3911'><div id="Recipe_time_resolved_mass_grid"></div> +<div class="standard" id='magicparlabel-4079'>Usually I just run with more stars. See also Recipe <a href="#Recipe_SFR">6.25.1</a> above.</div> +<h4 class="subsubsection" id='magicparlabel-4080'><span class="subsubsection_label">6.25.3</span> Time-resolved mass grid</h4> +<div class="standard" id='magicparlabel-4081'><div id="Recipe_time_resolved_mass_grid"></div> Some problems require a more carefully spaced grid than the simple <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mo> ln </mo><mi>M</mi> @@ -4986,7 +5035,7 @@ Some problems require a more carefully spaced grid than the simple <math xmlns=" <mrow><mi>t</mi> </mrow></mstyle></math> is large. </div> -<div class="standard" id='magicparlabel-3912'>We could just set a normal log-mass grid and have a very large resolution. A smarter alternative is to set up the grid to <em>enforce </em><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4082'>We could just set a normal log-mass grid and have a very large resolution. A smarter alternative is to set up the grid to <em>enforce </em><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>M</mi><mo>=</mo><mi>f</mi><mo> × </mo><mi> δ </mi><mi>t</mi><mo>/</mo><mo form='prefix' fence='true' stretchy='true' symmetric='true'>(</mo> @@ -5011,9 +5060,9 @@ Some problems require a more carefully spaced grid than the simple <math xmlns=" </mrow> </mrow></mstyle></math> grid, are available in <em><i>binary_grid</i></em> via the <em>spacing_functions </em>module.</div> -<div class="standard" id='magicparlabel-3913'>In the HRD project with Peter Anders, I use the following:</div> +<div class="standard" id='magicparlabel-4083'>In the HRD project with Peter Anders, I use the following:</div> -<div class="standard" id='magicparlabel-3914'><br /> +<div class="standard" id='magicparlabel-4084'><br /> <pre class ='listings Perl'># Mass 1 $binary_grid::grid_options{'flexigrid'}{'grid variable '.$nvar++}= { @@ -5050,7 +5099,7 @@ $binary_grid::grid_options{'flexigrid'}{'grid variable '.$nvar++}= };</pre><br /> </div> -<div class="standard" id='magicparlabel-3952'>The key line is <span class="flex_perlcode">time_adaptive_mass_grid_log10_step=>0.05</span> which specifies that I want (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4122'>The key line is <span class="flex_perlcode">time_adaptive_mass_grid_log10_step=>0.05</span> which specifies that I want (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mo> log </mo> @@ -5067,8 +5116,8 @@ $binary_grid::grid_options{'flexigrid'}{'grid variable '.$nvar++}= </mstyle> </mrow> </mrow></mstyle></math>. Note how I set up the <span class="flex_perlcode">$const_dt_opts</span> anonymous hash of options and then send it via the spacing function with the option '<span class="flex_perlcode">reset</span>'. This sets up a list of masses which are just returned for each call to <span class="flex_perlcode">const_dt()</span> with the '<span class="flex_perlcode">next</span>' parameter. Calling <span class="flex_perlcode">const_dt()</span> with the '<span class="flex_perlcode">resolution</span>' parameter just returns the number of masses in the list, which is trivially the resolution.</div> -<h4 class="subsubsection" id='magicparlabel-3981'><span class="subsubsection_label">6.25.4</span> Single and binary stars combined</h4> -<div class="standard" id='magicparlabel-3982'><div id="Recipe_Single_and_binary_stars"></div> +<h4 class="subsubsection" id='magicparlabel-4151'><span class="subsubsection_label">6.25.4</span> Single and binary stars combined</h4> +<div class="standard" id='magicparlabel-4152'><div id="Recipe_Single_and_binary_stars"></div> You can set up a grid containing both single and binary stars quite easily. The following code defines a grid variable “<em>duplicity</em>” which is either <span class="flex_perlcode">0</span> or <span class="flex_perlcode">1</span>, and sets the <span class="flex_perlcode">grid_option</span> “binary” appropriately. Deeper nested grid variables can then depend on the duplicity and choose, through the <em>condition </em>variable, whether to execute grids over <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> @@ -5079,7 +5128,7 @@ You can set up a grid containing both single and binary stars quite easily. The </msub> </mrow></mstyle></math> and beyond.</div> -<div class="standard" id='magicparlabel-3995'><br /> +<div class="standard" id='magicparlabel-4165'><br /> <pre class ='listings Perl'># duplicity $binary_grid::grid_options{'flexigrid'}{'grid variable '.$nvar++}= { @@ -5093,45 +5142,45 @@ $binary_grid::grid_options{'flexigrid'}{'grid variable '.$nvar++}= 'noprobdist'=>1, };</pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-4011'><span class="subsubsection_label">6.25.5</span> Snapshots: I want to stop a grid and restart later</h4> -<div class="standard" id='magicparlabel-4012'><div id="subsec_snapshotting"></div> +<h4 class="subsubsection" id='magicparlabel-4181'><span class="subsubsection_label">6.25.5</span> Snapshots: I want to stop a grid and restart later</h4> +<div class="standard" id='magicparlabel-4182'><div id="subsec_snapshotting"></div> The ability to stop and restart the grid is called <em>snapshotting</em>. Note that while this currently works, it assumes that you:</div> -<ol class="enumerate" id='magicparlabel-4013'><li class="enumerate_item">Use the identical grid script to restart</li> +<ol class="enumerate" id='magicparlabel-4183'><li class="enumerate_item">Use the identical grid script to restart</li> <li class="enumerate_item">Do not change any of your installation (<span class='math'>binary_c</i></span>, <span class='math'>\binarygrid</span> etc.) between stopping and restarting, </li> </ol> -<div class="standard" id='magicparlabel-4015'>thus snapshotting is quite limited in its functionality but it might save your data when your computer is about to die.</div> -<h4 class="subsubsection" id='magicparlabel-4016'><span class="subsubsection_label">6.25.6</span> Suspending the grid</h4> -<div class="standard" id='magicparlabel-4017'><em><span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-4185'>thus snapshotting is quite limited in its functionality but it might save your data when your computer is about to die.</div> +<h4 class="subsubsection" id='magicparlabel-4186'><span class="subsubsection_label">6.25.6</span> Suspending the grid</h4> +<div class="standard" id='magicparlabel-4187'><em><span class='math'>\binarygrid</span> </em> looks in files, defined in <span class="flex_perlcode">$binary_grid::grid_options{'suspend_files'}=[…]</span>, and if one exists, it executes its snapshot code. To make one exist, use the <span class="flex_scriptinglanguage">Unix</span> command <span class="flex_command">touch</span><em> </em>e.g. </div> -<div class="standard" id='magicparlabel-4030'><br /> +<div class="standard" id='magicparlabel-4200'><br /> <pre class ='listings'>touch /tmp/force_binary_c_suspend</pre><br /> </div> -<div class="standard" id='magicparlabel-4035'>This joins all the current threads and saves their data in one file so you can restart it later. It may take some time to join all the threads, so please be patient. By default, <i>binary_grid</i> looks at the files <span class="flex_file">/tmp/force_binary_c_suspend</span> and <span class="flex_perlcode">./force_binary_c_suspend</span> (although you can add your own with <span class="flex_perlcode">push(@$binary_grid::grid_options{'suspend_files'}, “new filename”);)</span></div> +<div class="standard" id='magicparlabel-4205'>This joins all the current threads and saves their data in one file so you can restart it later. It may take some time to join all the threads, so please be patient. By default, <i>binary_grid</i> looks at the files <span class="flex_file">/tmp/force_binary_c_suspend</span> and <span class="flex_perlcode">./force_binary_c_suspend</span> (although you can add your own with <span class="flex_perlcode">push(@$binary_grid::grid_options{'suspend_files'}, “new filename”);)</span></div> -<div class="standard" id='magicparlabel-4048'>The saved file name is defined in <span class="flex_perlcode">$binary_grid::grid_options{'snapshot_file'}</span> (default <span style='font-family:monospace;font-size: 18px;'>'</span><span class="flex_file">/tmp/<i>binary_c</i>-snapshot</span><span style='font-family:monospace;font-size: 18px;'>'</span>).</div> +<div class="standard" id='magicparlabel-4218'>The saved file name is defined in <span class="flex_perlcode">$binary_grid::grid_options{'snapshot_file'}</span> (default <span style='font-family:monospace;font-size: 18px;'>'</span><span class="flex_file">/tmp/<i>binary_c</i>-snapshot</span><span style='font-family:monospace;font-size: 18px;'>'</span>).</div> -<div class="standard" id='magicparlabel-4057'>All the above <span class="flex_file">/tmp/</span> are actually <span class="flex_perlcode">$binary_grid::grid_options{tmp}</span> so you can define your own location for all the files (which is probably more secure, because then you can prevent anyone from touching the file and stopping your grid).</div> -<h4 class="subsubsection" id='magicparlabel-4066'><span class="subsubsection_label">6.25.7</span> Restarting the grid</h4> -<div class="standard" id='magicparlabel-4067'>If <span class="flex_perlcode">$binary_grid::grid_options{starting_snapshot_file}</span> is defined, it is used to load in a previously saved snapshot and the grid is restarted. You can usually just load this on the command line, e.g. by running your grid script as</div> +<div class="standard" id='magicparlabel-4227'>All the above <span class="flex_file">/tmp/</span> are actually <span class="flex_perlcode">$binary_grid::grid_options{tmp}</span> so you can define your own location for all the files (which is probably more secure, because then you can prevent anyone from touching the file and stopping your grid).</div> +<h4 class="subsubsection" id='magicparlabel-4236'><span class="subsubsection_label">6.25.7</span> Restarting the grid</h4> +<div class="standard" id='magicparlabel-4237'>If <span class="flex_perlcode">$binary_grid::grid_options{starting_snapshot_file}</span> is defined, it is used to load in a previously saved snapshot and the grid is restarted. You can usually just load this on the command line, e.g. by running your grid script as</div> -<div class="standard" id='magicparlabel-4072'><span class="flex_perlcode">./src/perl/scripts/my_grid_script.pl starting_snapshot_file=my_snapshot_file</span></div> -<h4 class="subsubsection" id='magicparlabel-4077'><span class="subsubsection_label">6.25.8</span> World Domination</h4> -<div class="standard" id='magicparlabel-4078'><div id="subsec_World_Domination"></div> +<div class="standard" id='magicparlabel-4242'><span class="flex_perlcode">./src/perl/scripts/my_grid_script.pl starting_snapshot_file=my_snapshot_file</span></div> +<h4 class="subsubsection" id='magicparlabel-4247'><span class="subsubsection_label">6.25.8</span> World Domination</h4> +<div class="standard" id='magicparlabel-4248'><div id="subsec_World_Domination"></div> </div> -<div class="standard" id='magicparlabel-4079'>I'm working on it. I have started to brew my own beer, does that count?</div> +<div class="standard" id='magicparlabel-4249'>I'm working on it. I have started to brew my own beer, does that count?</div> -<div class="standard" id='magicparlabel-4080'><br /> +<div class="standard" id='magicparlabel-4250'><br /> </div> -<h3 class="subsection" id='magicparlabel-4081'><span class="subsection_label">6.26</span> FAQ</h3> -<div class="standard" id='magicparlabel-4082'><div id="sec_FAQ"></div> +<h3 class="subsection" id='magicparlabel-4251'><span class="subsection_label">6.26</span> FAQ</h3> +<div class="standard" id='magicparlabel-4252'><div id="sec_FAQ"></div> Frequently asked questions. </div> -<h4 class="subsubsection" id='magicparlabel-4083'><span class="subsubsection_label">6.26.1</span> Why not Monte Carlo?</h4> -<div class="standard" id='magicparlabel-4084'><div id="FAQ_why_not_MC_"></div> +<h4 class="subsubsection" id='magicparlabel-4253'><span class="subsubsection_label">6.26.1</span> Why not Monte Carlo?</h4> +<div class="standard" id='magicparlabel-4254'><div id="FAQ_why_not_MC_"></div> The alternative to running a grid is a Monte Carlo method, where you throw systems in according to some initial distribution and a random number generator. In the high number limit this should give the <em>same</em> <em>result </em>as a grid. However, in the low-number limit, the results are probably going to be different, and this is when you test your code. The big advantage of a grid is that you have a good handle on <em>errors</em> due to the finite resolution of your sampling of the initial distribution(s) without the smearing out of a Monte Carlo approach. Furthermore, MC may accidentally miss part of the initial parameter space (it is, after all, random) which you know is covered by a grid approach (at least to within a known error e.g. <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mo> ln </mo> @@ -5152,9 +5201,9 @@ The alternative to running a grid is a Monte Carlo method, where you throw syste </msub> </mrow></mstyle></math>, but on the other hand these might be the systems of particular interest to you!</div> -<div class="standard" id='magicparlabel-4085'><b>Update: there is a monte carlo option to the flexigrid. It is not well tested, but could work for you if you really need it.</b></div> -<h4 class="subsubsection" id='magicparlabel-4086'><span class="subsubsection_label">6.26.2</span> Why MC SN kicks?</h4> -<div class="standard" id='magicparlabel-4087'><div id="FAQ_WhyMCSNkicks_"></div> +<div class="standard" id='magicparlabel-4255'><b>Update: there is a monte carlo option to the flexigrid. It is not well tested, but could work for you if you really need it.</b></div> +<h4 class="subsubsection" id='magicparlabel-4256'><span class="subsubsection_label">6.26.2</span> Why MC SN kicks?</h4> +<div class="standard" id='magicparlabel-4257'><div id="FAQ_WhyMCSNkicks_"></div> Traditionally supernova (and white dwarf) kicks have had their velocity chosen in a Monte-Carlo way, rather than on a grid. This was left as-is because there are four dimensions for each kick, which – given a coarse grid of <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mn>10</mn><mo> × </mo><mn>10</mn><mo> × </mo><mn>10</mn><mo> × </mo><mn>10</mn> @@ -5182,37 +5231,37 @@ Traditionally supernova (and white dwarf) kicks have had their velocity chosen i </mrow></mstyle></math>, but probably not <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>a</mi> </mrow></mstyle></math>.</div> -<h4 class="subsubsection" id='magicparlabel-4088'><span class="subsubsection_label">6.26.3</span> Zombie <i>binary_c</i> processes </h4> -<div class="standard" id='magicparlabel-4089'><div id="FAQ_Zombie_binary_c"></div> +<h4 class="subsubsection" id='magicparlabel-4258'><span class="subsubsection_label">6.26.3</span> Zombie <i>binary_c</i> processes </h4> +<div class="standard" id='magicparlabel-4259'><div id="FAQ_Zombie_binary_c"></div> </div> -<div class="standard" id='magicparlabel-4090'><b>This section is only relevant if you use the <em>Perl </em>backend.</b></div> +<div class="standard" id='magicparlabel-4260'><b>This section is only relevant if you use the <em>Perl </em>backend.</b></div> -<div class="standard" id='magicparlabel-4091'>When the grid exits abnormally, or is killed, a <em><span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-4261'>When the grid exits abnormally, or is killed, a <em><span class='math'>binary_c</i></span> </em>process may be left behind in an infinite loop state and as such will take up your precious CPU time. You will have to kill it manually <em>if you are sure it is not doing anything with another grid process! </em>(Be careful and do <em>not</em> do “killall <i>binary_c</i>” as root…)</div> -<h4 class="subsubsection" id='magicparlabel-4092'><span class="subsubsection_label">6.26.4</span> Zombie Perl processes </h4> -<div class="standard" id='magicparlabel-4093'><b>This section is only relevant if you use the <em>Perl </em>backend.</b></div> +<h4 class="subsubsection" id='magicparlabel-4262'><span class="subsubsection_label">6.26.4</span> Zombie Perl processes </h4> +<div class="standard" id='magicparlabel-4263'><b>This section is only relevant if you use the <em>Perl </em>backend.</b></div> -<div class="standard" id='magicparlabel-4094'><div id="FAQ_Zombie_perl"></div> +<div class="standard" id='magicparlabel-4264'><div id="FAQ_Zombie_perl"></div> These should die naturally when the grid finishes and the Perl script exits. They are harmless and have never been seen to consume CPU time.</div> -<h4 class="subsubsection" id='magicparlabel-4095'><span class="subsubsection_label">6.26.5</span> Setting functions and/or function pointers </h4> -<div class="standard" id='magicparlabel-4096'><div id="FAQ_functions_and_pointers"></div> +<h4 class="subsubsection" id='magicparlabel-4265'><span class="subsubsection_label">6.26.5</span> Setting functions and/or function pointers </h4> +<div class="standard" id='magicparlabel-4266'><div id="FAQ_functions_and_pointers"></div> </div> -<div class="standard" id='magicparlabel-4097'><b>Please set function pointers, not function names, especially with the <i>C</i> backend. I may remove this functionality in future, however convenient it once was. Function names will definitely not work with the <i>C</i> backend.</b></div> +<div class="standard" id='magicparlabel-4267'><b>Please set function pointers, not function names, especially with the <i>C</i> backend. I may remove this functionality in future, however convenient it once was. Function names will definitely not work with the <i>C</i> backend.</b></div> -<div class="standard" id='magicparlabel-4098'>In the good old days you had to set up function pointers, e.g. <span class="flex_perlcode">\&parse_bse</span>, manually when setting up your grid. However, in the latest version of <em><span class="flex_perlcode">flexigrid()</span></em>, this is set automatically (from <span class="flex_perlcode">\&main::parse_bse</span>). However, you can override the settings. </div> +<div class="standard" id='magicparlabel-4268'>In the good old days you had to set up function pointers, e.g. <span class="flex_perlcode">\&parse_bse</span>, manually when setting up your grid. However, in the latest version of <em><span class="flex_perlcode">flexigrid()</span></em>, this is set automatically (from <span class="flex_perlcode">\&main::parse_bse</span>). However, you can override the settings. </div> -<div class="standard" id='magicparlabel-4111'>As an example, if you want to set the <span class="flex_perlcode">parse_bse_function_pointer</span>, just set<span style='font-family:monospace;font-size: 18px;'> <br /> +<div class="standard" id='magicparlabel-4281'>As an example, if you want to set the <span class="flex_perlcode">parse_bse_function_pointer</span>, just set<span style='font-family:monospace;font-size: 18px;'> <br /> <pre class ='listings Perl'>$binary_grid::grid_options{parse_bse_function}='my_parse_bse';</pre><br /> </span>where <span class="flex_perlcode">my_parse_bse</span> is your new function name. <br /> This will automatically be converted into <span class="flex_perlcode">\&main::my_parse_bse</span> at runtime.</div> -<div class="standard" id='magicparlabel-4128'>This process is applied to any <span class="flex_perlcode">grid_option</span> whose key ends in <span class="flex_perlcode">_function</span>. These include </div> +<div class="standard" id='magicparlabel-4298'>This process is applied to any <span class="flex_perlcode">grid_option</span> whose key ends in <span class="flex_perlcode">_function</span>. These include </div> -<ul class="itemize" id='magicparlabel-4137'><li class="itemize_item"><span class="flex_perlcode">thread_precreate_function</span></li> +<ul class="itemize" id='magicparlabel-4307'><li class="itemize_item"><span class="flex_perlcode">thread_precreate_function</span></li> <li class="itemize_item"><span class="flex_perlcode">threads_entry_function</span></li> <li class="itemize_item"><span class="flex_perlcode">threads_flush_function</span></li> <li class="itemize_item"><span class="flex_perlcode">thread_postrun_function</span></li> @@ -5220,25 +5269,25 @@ This will automatically be converted into <span class="flex_perlcode">\&main <li class="itemize_item"><span class="flex_perlcode">threads_join_function</span></li> <li class="itemize_item"><span class="flex_perlcode">thread_postjoin_function</span></li> </ul> -<div class="standard" id='magicparlabel-4172'>These are all <span class="flex_perlcode">undef</span> by default, so are ignored (unless you override them with function names), except +<div class="standard" id='magicparlabel-4342'>These are all <span class="flex_perlcode">undef</span> by default, so are ignored (unless you override them with function names), except <br /> <span class="flex_perlcode">threads_join_function</span> which is set to <span class="flex_perlcode">binary_grid::join_flexigrid_thread</span> as usual.</div> -<h3 class="subsection" id='magicparlabel-4185'><span class="subsection_label">6.27</span> Multi-core scaling</h3> -<div class="standard" id='magicparlabel-4188'>The <i>binary_grid</i> software is used to run <i>binary_c</i>, and other stellar evolution codes, on either a single CPU or a grid of machines, e.g. with its <span class="flex_software">HTCondor</span> extension module. It is important to know whether <span class='math'>\binarygrid</span> +<h3 class="subsection" id='magicparlabel-4355'><span class="subsection_label">6.27</span> Multi-core scaling</h3> +<div class="standard" id='magicparlabel-4358'>The <i>binary_grid</i> software is used to run <i>binary_c</i>, and other stellar evolution codes, on either a single CPU or a grid of machines, e.g. with its <span class="flex_software">HTCondor</span> extension module. It is important to know whether <span class='math'>\binarygrid</span> scales appropriately to running on <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>N</mi> </mrow></mstyle></math> CPUs. This document answers this question by looking at <em>CPU-bound </em>and <em>IO-bound</em> jobs. In conclusion: it scales very well.<em> </em></div> -<h3 class="subsection" id='magicparlabel-4193'><span class="subsection_label">6.28</span> Testing Setup</h3> -<div class="standard" id='magicparlabel-4194'>It is not ideal to use <span class='math'>binary_c</i></span> +<h3 class="subsection" id='magicparlabel-4363'><span class="subsection_label">6.28</span> Testing Setup</h3> +<div class="standard" id='magicparlabel-4364'>It is not ideal to use <span class='math'>binary_c</i></span> as an evolution code. Instead, a <span class="flex_scriptinglanguage">Perl</span> script called <br /> -<span class="flex_file">./src/perl/scripts-flexigrid/<i>binary_c</i>-dummy.pl</span> was developed<div class="foot"><span class="foot_label">6</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-4206'>All files are relative to my<em> <span class='math'>binary_c</i></span> +<span class="flex_file">./src/perl/scripts-flexigrid/<i>binary_c</i>-dummy.pl</span> was developed<div class="foot"><span class="foot_label">7</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-4376'>All files are relative to my<em> <span class='math'>binary_c</i></span> </em>branch – or maybe the trunk if I have time to merge it!</div> </div></div>. This has the following features:</div> -<ol class="enumerate" id='magicparlabel-4207'><li class="enumerate_item">It can output <em><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<ol class="enumerate" id='magicparlabel-4377'><li class="enumerate_item">It can output <em><math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>n</mi> @@ -5263,18 +5312,18 @@ This will automatically be converted into <span class="flex_perlcode">\&main </mrow> </msub> </mrow></mstyle></math> stars, both are free parameters. This simulates I/O limited runs.</li> -<li class="enumerate_item">It simulates CPU burn (“spin” mode<div class="foot"><span class="foot_label">7</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-4212'>A <span class="flex_perlcode">while{}</span> loop until a specified time has lapsed.</div> -</div></div>) or can simply “sleep” (with no CPU activity<div class="foot"><span class="foot_label">8</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-4220'>A call to the <span class="flex_perlmodule">Time::HiRes</span> <span style='font-family:monospace;font-size: 18px;'>sleep</span> function.</div> +<li class="enumerate_item">It simulates CPU burn (“spin” mode<div class="foot"><span class="foot_label">8</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-4382'>A <span class="flex_perlcode">while{}</span> loop until a specified time has lapsed.</div> +</div></div>) or can simply “sleep” (with no CPU activity<div class="foot"><span class="foot_label">9</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-4390'>A call to the <span class="flex_perlmodule">Time::HiRes</span> <span style='font-family:monospace;font-size: 18px;'>sleep</span> function.</div> </div></div>) for a specified time <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi> </mrow> </mrow></mstyle></math>.</li> </ol> -<div class="standard" id='magicparlabel-4225'>By using this dummy script instead of <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-4395'>By using this dummy script instead of <span class='math'>binary_c</i></span> we control the CPU and I/O usage precisely without relying on a complicated, and difficult to predict, piece of code to do it for us.</div> -<h4 class="subsubsection" id='magicparlabel-4226'><span class="subsubsection_label">6.28.1</span> Multithread overhead</h4> -<div class="standard" id='magicparlabel-4227'>The <em><span class='math'>\binarygrid</span> +<h4 class="subsubsection" id='magicparlabel-4396'><span class="subsubsection_label">6.28.1</span> Multithread overhead</h4> +<div class="standard" id='magicparlabel-4397'>The <em><span class='math'>\binarygrid</span> </em> software is designed to speed up running a full parameter space by splitting the work into <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>N</mi> </mrow></mstyle></math> threads (or <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -5317,7 +5366,7 @@ This will automatically be converted into <span class="flex_perlcode">\&main </mrow> </mrow></mstyle></math>. The runtime of this grid is then subtracted from the runtime of the true grid to accurately calculate the runtime of the grid while it is doing useful work.</div> -<div class="standard" id='magicparlabel-4236'>When the grid resolution is large, e.g. <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4406'>When the grid resolution is large, e.g. <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> <msub subscriptshift="0.2ex"> @@ -5332,16 +5381,16 @@ This will automatically be converted into <span class="flex_perlcode">\&main </msub><mo> ≳ </mo><mn>1000</mn> </mrow> </mrow></mstyle></math>, the overhead cost is negligible. It is really only useful to subtract it to obtain more precise results and work with fewer stars.</div> -<h4 class="subsubsection" id='magicparlabel-4237'><span class="subsubsection_label">6.28.2</span> PC setup</h4> -<div class="standard" id='magicparlabel-4238'>The tests were run on the <em>klaipeda2 </em>machine at the Argelander Institute for Astronomy (AIfA). This is a 16-core (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<h4 class="subsubsection" id='magicparlabel-4407'><span class="subsubsection_label">6.28.2</span> PC setup</h4> +<div class="standard" id='magicparlabel-4408'>The tests were run on the <em>klaipeda2 </em>machine at the Argelander Institute for Astronomy (AIfA). This is a 16-core (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mn>4</mn><mo> × </mo> </mrow> </mrow></mstyle></math> quad-core AMD Opteron 8378) machine with CPU speeds of 2.4GHz (4800 bogomips), 512KB cache and 64GB (shared) RAM. Mostly the cores were empty, occasionally only 15 were available. This has a negligible effect on the results.</div> -<div class="standard" id='magicparlabel-4239'>A few smaller scale tests were carried out on <em>aibn36</em> at the AIfA. This is a 4-core AMD Phenom II X4 945 running at 3GHz (6027 bogomips) with 8GB RAM. This machine was often multitasking with (background) jobs and a full KDE desktop running in the foreground. </div> -<h4 class="subsubsection" id='magicparlabel-4240'><span class="subsubsection_label">6.28.3</span> Score</h4> -<div class="standard" id='magicparlabel-4241'>Each test run has an associated <em>score </em>which is defined as, <math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4409'>A few smaller scale tests were carried out on <em>aibn36</em> at the AIfA. This is a 4-core AMD Phenom II X4 945 running at 3GHz (6027 bogomips) with 8GB RAM. This machine was often multitasking with (background) jobs and a full KDE desktop running in the foreground. </div> +<h4 class="subsubsection" id='magicparlabel-4410'><span class="subsubsection_label">6.28.3</span> Score</h4> +<div class="standard" id='magicparlabel-4411'>Each test run has an associated <em>score </em>which is defined as, <math display="block" xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mtable> <mtr> <mtd> @@ -5418,19 +5467,19 @@ This will automatically be converted into <span class="flex_perlcode">\&main </msub> </mrow></mstyle></math> is the number of threads used.</div> -<div class="standard" id='magicparlabel-4242'>A score of <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4412'>A score of <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mn>1.0</mn> </mrow></mstyle></math> is considered <em>perfect scaling.</em> Higher scores are <em>bad scaling</em> and occasionally scores slightly less than <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mn>1.0</mn> </mrow></mstyle></math> are seen. If <span class='math'>\binarygrid</span> does its job properly, the score should be around 1.0.</div> -<h3 class="subsection" id='magicparlabel-4243'><span class="subsection_label">6.29</span> Results</h3> -<h4 class="subsubsection" id='magicparlabel-4244'><span class="subsubsection_label">6.29.1</span> No CPU (sleep mode <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<h3 class="subsection" id='magicparlabel-4413'><span class="subsection_label">6.29</span> Results</h3> +<h4 class="subsubsection" id='magicparlabel-4414'><span class="subsubsection_label">6.29.1</span> No CPU (sleep mode <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>0</mn> </mrow> </mrow></mstyle></math>)</h4> -<div class="standard" id='magicparlabel-4245'>When measuring runtimes in “sleep” mode it is trivial to test the pure grid and I/O overheads, as the sleep time can be set to zero (i.e. no “runtime” at all for <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-4415'>When measuring runtimes in “sleep” mode it is trivial to test the pure grid and I/O overheads, as the sleep time can be set to zero (i.e. no “runtime” at all for <span class='math'>binary_c</i></span> ). <em>By definition</em> these runs are I/O limited because there is no CPU use associated with “stellar evolution”. Figure <a href="#fig_Timing_tests_klaipeda_dt0">2</a> shows the results. The scaling is <em>not good </em>with scores above 1.0 for all but the runs with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> @@ -5447,9 +5496,9 @@ This will automatically be converted into <span class="flex_perlcode">\&main </mrow> </mrow></mstyle></math>. The tests on aibn36 show similar results (Fig. <a href="#fig_Timing_tests_aibn36_dt0">3</a>). </div> -<div class="standard" id='magicparlabel-4246'>The poor results suggest that I/O limited runs do not perfect well when large numbers of threads are employed. Using two threads is still a <em>lot</em> faster than using just one, but after that there is no improvement. </div> +<div class="standard" id='magicparlabel-4416'>The poor results suggest that I/O limited runs do not perfect well when large numbers of threads are employed. Using two threads is still a <em>lot</em> faster than using just one, but after that there is no improvement. </div> -<div class="standard" id='magicparlabel-4247'>The results can be understood if we consider that our I/O limited jobs <em>run at the maximum possible bandwidth of the CPU</em>. If the <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-4417'>The results can be understood if we consider that our I/O limited jobs <em>run at the maximum possible bandwidth of the CPU</em>. If the <span class='math'>\binarygrid</span> software <em>already maximises</em> its use of the I/O resources of the machine when running two threads, then running three or more will <em>never </em>result in reduced runtime. This describes the behaviour we see perfectly and is a limitation of the PC rather than <em><span class='math'>\binarygrid</span> </em>. The runtime then depends linearly on the product <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -5478,10 +5527,10 @@ This will automatically be converted into <span class="flex_perlcode">\&main </mrow></mstyle></math>, as clearly shown in Figs. <a href="#fig_Timing_tests_klaipeda_dt0">2</a> and <a href="#fig_Timing_tests_aibn36_dt0">3</a>.</div> -<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4252'><img style='width:85%;' src='images/5.png' alt='image: 11_tmp_binary_c_lyx_images_3.png' /> +<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4422'><img style='width:85%;' src='images/5.png' alt='image: 11_tmp_binary_c_lyx_images_3.png' /> </div> -<div class="plain_layout" id='magicparlabel-4253'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 2: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="plain_layout" id='magicparlabel-4423'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 2: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>0</mn> </mrow> @@ -5490,10 +5539,10 @@ This will automatically be converted into <span class="flex_perlcode">\&main </div> -<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4262'><img style='width:85%;' src='images/6.png' alt='image: 12_tmp_binary_c_lyx_images_4.png' /> +<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4432'><img style='width:85%;' src='images/6.png' alt='image: 12_tmp_binary_c_lyx_images_4.png' /> </div> -<div class="plain_layout" id='magicparlabel-4263'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 3: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="plain_layout" id='magicparlabel-4433'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 3: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>0</mn> </mrow> @@ -5501,12 +5550,12 @@ This will automatically be converted into <span class="flex_perlcode">\&main </span></div> </div> -<h4 class="subsubsection" id='magicparlabel-4268'><span class="subsubsection_label">6.29.2</span> 1.0s runs (sleep mode <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<h4 class="subsubsection" id='magicparlabel-4438'><span class="subsubsection_label">6.29.2</span> 1.0s runs (sleep mode <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>1.0</mn> </mrow> </mrow></mstyle></math>)</h4> -<div class="standard" id='magicparlabel-4269'>Next up are sleep mode runs with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4439'>Next up are sleep mode runs with <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>1.0</mn> <mstyle mathvariant='normal'><mi>s</mi> @@ -5517,10 +5566,10 @@ This will automatically be converted into <span class="flex_perlcode">\&main <mrow><mn>1.0</mn> </mrow></mstyle></math> are <em>always</em> achieved, showing the <span class='math'>\binarygrid</span> does an excellent job in this case.</div> -<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4273'><img style='width:85%;' src='images/7.png' alt='image: 13_tmp_binary_c_lyx_images_5.png' /> +<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4443'><img style='width:85%;' src='images/7.png' alt='image: 13_tmp_binary_c_lyx_images_5.png' /> </div> -<div class="plain_layout" id='magicparlabel-4274'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 4: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="plain_layout" id='magicparlabel-4444'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 4: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>1</mn> </mrow> @@ -5528,12 +5577,12 @@ This will automatically be converted into <span class="flex_perlcode">\&main </span></div> </div> -<h4 class="subsubsection" id='magicparlabel-4279'><span class="subsubsection_label">6.29.3</span> 1.0s runs (spin mode <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<h4 class="subsubsection" id='magicparlabel-4449'><span class="subsubsection_label">6.29.3</span> 1.0s runs (spin mode <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>1.0</mn> </mrow> </mrow></mstyle></math>)</h4> -<div class="standard" id='magicparlabel-4280'>With no I/O (Fig. <a href="#fig_Timing_tests_klaipeda_spin_dt1_Nlines0">5</a>), i.e. <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4450'>With no I/O (Fig. <a href="#fig_Timing_tests_klaipeda_spin_dt1_Nlines0">5</a>), i.e. <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> <msub subscriptshift="0.2ex"> @@ -5553,10 +5602,10 @@ This will automatically be converted into <span class="flex_perlcode">\&main <mrow><mo> ≳ </mo><mn>100</mn> </mrow> </mrow></mstyle></math>). With 10 stars and 32 threads, the tests are pretty much meaningless in any case because 22 threads do no work at all! </div> -<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4284'><img style='width:85%;' src='images/8.png' alt='image: 14_tmp_binary_c_lyx_images_6.png' /> +<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4454'><img style='width:85%;' src='images/8.png' alt='image: 14_tmp_binary_c_lyx_images_6.png' /> </div> -<div class="plain_layout" id='magicparlabel-4285'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 5: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="plain_layout" id='magicparlabel-4455'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 5: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>1</mn> </mrow> @@ -5565,7 +5614,7 @@ This will automatically be converted into <span class="flex_perlcode">\&main </div> -<div class="standard" id='magicparlabel-4290'>With large amounts of I/O (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-4460'>With large amounts of I/O (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> <msub subscriptshift="0.2ex"> @@ -5595,10 +5644,10 @@ This will automatically be converted into <span class="flex_perlcode">\&main </mrow> </mrow></mstyle></math><em>.</em> Again <span class='math'>\binarygrid</span> does a great job.</div> -<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4294'><img style='width:95%;' src='images/9.png' alt='image: 15_tmp_binary_c_lyx_images_7.png' /> +<div class='float-figure'><div class="plain_layout" style='text-align: center;' id='magicparlabel-4464'><img style='width:95%;' src='images/9.png' alt='image: 15_tmp_binary_c_lyx_images_7.png' /> </div> -<div class="plain_layout" id='magicparlabel-4295'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 6: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="plain_layout" id='magicparlabel-4465'><span class='float-caption-Standard float-caption float-caption-standard'>Figure 6: Timing tests for <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>t</mi><mo>=</mo><mn>1</mn> </mrow> @@ -5620,44 +5669,44 @@ This will automatically be converted into <span class="flex_perlcode">\&main </span></div> </div> -<h3 class="subsection" id='magicparlabel-4300'><span class="subsection_label">6.30</span> Conclusions</h3> -<div class="standard" id='magicparlabel-4301'><em><span class='math'>\binarygrid</span> +<h3 class="subsection" id='magicparlabel-4470'><span class="subsection_label">6.30</span> Conclusions</h3> +<div class="standard" id='magicparlabel-4471'><em><span class='math'>\binarygrid</span> </em>does an excellent job of scaling to the number of CPUs available on multi-core architectures. The only exception is when a) the runtime is very short and b) the amount of data I/O is very large.</div> -<div class="standard" id='magicparlabel-4302'>How can we improve this situation? Naturally, the first choice is the limit the amount of output from <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-4472'>How can we improve this situation? Naturally, the first choice is the limit the amount of output from <span class='math'>binary_c</i></span> whenever possible. A first step is to for the user to choose what output is <em>truly necessary </em>for their project and only output this. However, this is not always a trivial question to answer. At some level, the CPU and I/O bus of the machine has limited bandwidth, and if it is this that is the bottleneck there is little that can be done <em>except </em>buy better machines or just wait.</div> -<div class="standard" id='magicparlabel-4303'>To investigate whether Perl is the problem, I wrote a new function <span class="flex_perlcode">tbse_lines</span> which, instead of returning data line by line (as traditional calls to <span class="flex_perlcode">tbse_line</span> do) takes the data for each star, bundles it in an array and then sends this back instead (as an array reference). In my tests this actually <em>costs more time</em> than simply sending data line by line, probably because there is overhead involved in setting up an array and returning it. I will leave this in <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-4473'>To investigate whether Perl is the problem, I wrote a new function <span class="flex_perlcode">tbse_lines</span> which, instead of returning data line by line (as traditional calls to <span class="flex_perlcode">tbse_line</span> do) takes the data for each star, bundles it in an array and then sends this back instead (as an array reference). In my tests this actually <em>costs more time</em> than simply sending data line by line, probably because there is overhead involved in setting up an array and returning it. I will leave this in <span class='math'>\binarygrid</span> (as of version 0.24) for you to try.</div> -<div class="standard" id='magicparlabel-4312'>Other updates to <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-4482'>Other updates to <span class='math'>\binarygrid</span> version 0.24 include the complete removal of support for separate <span class="flex_cvar">stdout</span> and <span class="flex_cvar">stderr</span> streams from the evolution code. I used to handle these streams separately, but if either stream buffer should fill then there would be deadlock. This could happen, for example, if there were a lot of errors so the <span class="flex_cvar">stderr</span> buffer fills before <span class="flex_cvar">stdout</span> is checked again. See also <a href="http://perl.plover.com/FAQs/Buffering.html">http://perl.plover.com/FAQs/Buffering.html</a>.</div> -<div class="standard" id='magicparlabel-4329'>The latest grid <em>should</em> be faster because it combines <span class="flex_cvar">stdout</span> and <span class="flex_cvar">stderr</span>. Instead of having to flush the <span class="flex_cvar">stderr</span> buffer for each <span class="flex_cvar">stdout</span> read, it now just blocks on the combined <span class="flex_cvar">stdout</span>/<span class="flex_cvar">stderr</span>. The downside is that the user must detect errors:<em> <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-4499'>The latest grid <em>should</em> be faster because it combines <span class="flex_cvar">stdout</span> and <span class="flex_cvar">stderr</span>. Instead of having to flush the <span class="flex_cvar">stderr</span> buffer for each <span class="flex_cvar">stdout</span> read, it now just blocks on the combined <span class="flex_cvar">stdout</span>/<span class="flex_cvar">stderr</span>. The downside is that the user must detect errors:<em> <span class='math'>\binarygrid</span> </em>can no longer do it. This is generally not a problem because the user only cares about their own lines of data, prefixed with the appropriate header string (e.g. in <span class="flex_perlcode">parse_bse()</span>).</div> -<div class="standard" id='magicparlabel-4358'>I have also considered whether it is the<em> </em>use of pipes to communicate to/from the evolution code that slows down <em><i>binary_grid</i></em> in an I/O dominated case. One way to test this would be to compress the returned data and send it in (say) <span class="flex_software">7zipped</span> or <span class="flex_software">bzipped</span> chunks of data instead of raw <em>ASCII</em> as at present. However, the overhead required for the compression slows down the data transfer so much that this seems to be a non-starter. I tried to compress the array provided by <span class="flex_perlscript">tbse_lines</span> with <span class="flex_perlmodule">Compress::Zlib::memGzip</span> and, while it works, it slowed the test grid – with lots of I/O! – by more than 30%. Perhaps there is a smarter way to do this, but I haven't found it yet. If you're interested, find the <span class="flex_perlcode">tbse_compressed_lines()</span> function in <em><span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-4528'>I have also considered whether it is the<em> </em>use of pipes to communicate to/from the evolution code that slows down <em><i>binary_grid</i></em> in an I/O dominated case. One way to test this would be to compress the returned data and send it in (say) <span class="flex_software">7zipped</span> or <span class="flex_software">bzipped</span> chunks of data instead of raw <em>ASCII</em> as at present. However, the overhead required for the compression slows down the data transfer so much that this seems to be a non-starter. I tried to compress the array provided by <span class="flex_perlscript">tbse_lines</span> with <span class="flex_perlmodule">Compress::Zlib::memGzip</span> and, while it works, it slowed the test grid – with lots of I/O! – by more than 30%. Perhaps there is a smarter way to do this, but I haven't found it yet. If you're interested, find the <span class="flex_perlcode">tbse_compressed_lines()</span> function in <em><span class='math'>\binarygrid</span> .</em></div> -<div class="standard" id='magicparlabel-4379'>Of course, none of this matters if you don't use <em><span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-4549'>Of course, none of this matters if you don't use <em><span class='math'>\binarygrid</span> </em> the way it's designed. Sure, you can save your million-line data file to disk and reprocess it, but <em>nothing</em> will be faster than processing data on the fly. Also, when using <em><span class="flex_software">HTCondor</span></em>, remember to be smart and join the threads on the machine containing the data rather than across an NFS mountpoint on a PC in another building. Nothing I do in programming <em><span class='math'>\binarygrid</span> </em> better can make up stupid user decisions…</div> -<div class="standard" id='magicparlabel-4384'><br /> +<div class="standard" id='magicparlabel-4554'><br /> </div> -<h2 class="section" id='magicparlabel-4385'><span class="section_label">7</span> <em><i>binary_c</i> </em>API</h2> -<div class="standard" id='magicparlabel-4388'>The following describes functions in the <em><i>binary_c</i></em> <em>C</em> API. These functions are provided for access to <em><i>binary_c</i></em> through its shared library interface, <i>libbinary_c.so</i>, which is used by (for example) <em><i>binary_grid2</i> </em>with its <em>C</em> backend.</div> -<h3 class="subsection" id='magicparlabel-4389'><span class="subsection_label">7.1</span> Naming conventions</h3> +<h2 class="section" id='magicparlabel-4555'><span class="section_label">7</span> <em><i>binary_c</i> </em>API</h2> +<div class="standard" id='magicparlabel-4558'>The following describes functions in the <em><i>binary_c</i></em> <em>C</em> API. These functions are provided for access to <em><i>binary_c</i></em> through its shared library interface, <i>libbinary_c.so</i>, which is used by (for example) <em><i>binary_grid2</i> </em>with its <em>C</em> backend.</div> +<h3 class="subsection" id='magicparlabel-4559'><span class="subsection_label">7.1</span> Naming conventions</h3> -<ul class="itemize" id='magicparlabel-4390'><li class="itemize_item">Names of functions in the <span class='math'>binary_c</i></span> +<ul class="itemize" id='magicparlabel-4560'><li class="itemize_item">Names of functions in the <span class='math'>binary_c</i></span> API start with binary_c_</li> <li class="itemize_item">Functions are declared with the attribute <span class="flex_cmacro">binary_c_API_function</span></li> <li class="itemize_item">The <span class='math'>binary_c</i></span> structure types -<ul class="itemize" id='magicparlabel-4397'><li class="itemize_item"><span class="flex_cstruct">stardata_t</span></li> +<ul class="itemize" id='magicparlabel-4567'><li class="itemize_item"><span class="flex_cstruct">stardata_t</span></li> <li class="itemize_item"><span class="flex_cstruct">star_t</span></li> <li class="itemize_item"><span class="flex_cstruct">preferences_t</span></li> <li class="itemize_item"><span class="flex_cstruct">store_t</span></li> @@ -5666,9 +5715,9 @@ This will automatically be converted into <span class="flex_perlcode">\&main <li class="itemize_item"><span class="flex_cstruct">common_t</span></li> <li class="itemize_item">etc.</li> </ul> -<div class="standard" id='magicparlabel-4433'>should be declared in external code as</div> +<div class="standard" id='magicparlabel-4603'>should be declared in external code as</div> -<ul class="itemize" id='magicparlabel-4434'><li class="itemize_item"><span class="flex_cstruct">libbinary_c_stardata_t</span></li> +<ul class="itemize" id='magicparlabel-4604'><li class="itemize_item"><span class="flex_cstruct">libbinary_c_stardata_t</span></li> <li class="itemize_item"><span class="flex_cstruct">libbinary_c_star_t</span></li> <li class="itemize_item"><span class="flex_cstruct">libbinary_c_preferences_t</span></li> <li class="itemize_item"><span class="flex_cstruct">libbinary_c_store_t</span></li> @@ -5677,29 +5726,29 @@ This will automatically be converted into <span class="flex_perlcode">\&main <li class="itemize_item"><span class="flex_cstruct">libbinary_c_common_t</span></li> <li class="itemize_item"><span class="flex_cstruct">libbinary_c_…</span></li> </ul> -<div class="standard" id='magicparlabel-4474'>This avoids name clashes with the functions of other libraries.</div> +<div class="standard" id='magicparlabel-4644'>This avoids name clashes with the functions of other libraries.</div> </li></ul> -<h4 class="subsubsection" id='magicparlabel-4475'><span class="subsubsection_label">7.1.1</span> <i>binary_c</i> macros</h4> -<div class="standard" id='magicparlabel-4476'><em>Binary_c</em> defines the following:</div> +<h4 class="subsubsection" id='magicparlabel-4645'><span class="subsubsection_label">7.1.1</span> <i>binary_c</i> macros</h4> +<div class="standard" id='magicparlabel-4646'><em>Binary_c</em> defines the following:</div> -<dl class='description' id='magicparlabel-4477'><dt class="description_label"><span class="flex_cmacro">RESTRICT</span></dt> +<dl class='description' id='magicparlabel-4647'><dt class="description_label"><span class="flex_cmacro">RESTRICT</span></dt> <dd class="description_item"> This is set to <span class="flex_cmacro">__restrict__</span> or a suitable equivalent when available (this depends on the compiler). </dd> <dt class="description_label"><span class="flex_cmacro">binary_c_API_function</span></dt> <dd class="description_item"> This is set to <span class="flex_cmacro">__attribute__ ((visibility("default")))</span> which is standard for exporting functions to shared libraries with <span class="flex_software">gcc</span> (and presumably <span class="flex_software">clang</span>). I have not yet investigated the equivalent for other compilers.</dd> </dl> -<h4 class="subsubsection" id='magicparlabel-4503'><span class="subsubsection_label">7.1.2</span> <i>binary_c</i> headers</h4> -<div class="standard" id='magicparlabel-4504'>Most <em><span class='math'>binary_c</i></span> +<h4 class="subsubsection" id='magicparlabel-4673'><span class="subsubsection_label">7.1.2</span> <i>binary_c</i> headers</h4> +<div class="standard" id='magicparlabel-4674'>Most <em><span class='math'>binary_c</i></span> </em> headers are loaded through <span class="flex_headerfile"><i>binary_c</i>.h</span>. While it slows compilation to include <em>all</em> the headers, the convenience (and imposed structure) of having just one file to access headers overrides this.</div> -<h3 class="subsection" id='magicparlabel-4509'><span class="subsection_label">7.2</span> Using the API</h3> -<div class="standard" id='magicparlabel-4510'>Using the API is simple in languages that can embed <span class="flex_programminglanguage">C</span> directly, e.g. <span class="flex_programminglanguage">C</span>, <span class="flex_programminglanguage">C++</span>, <span class="flex_programminglanguage">Perl</span> and <span class="flex_programminglanguage">Python</span>. Some other languages, e.g. <span class="flex_programminglanguage">FORTRAN</span>, require a special set of functions to be written in order to talk to them. Fortunately for you, I have already done this in <span class="flex_scriptinglanguage">FORTRAN</span>.</div> -<h4 class="subsubsection" id='magicparlabel-4539'><span class="subsubsection_label">7.2.1</span> In <i>C</i><div id="subsec_In_C"></div> +<h3 class="subsection" id='magicparlabel-4679'><span class="subsection_label">7.2</span> Using the API</h3> +<div class="standard" id='magicparlabel-4680'>Using the API is simple in languages that can embed <span class="flex_programminglanguage">C</span> directly, e.g. <span class="flex_programminglanguage">C</span>, <span class="flex_programminglanguage">C++</span>, <span class="flex_programminglanguage">Perl</span> and <span class="flex_programminglanguage">Python</span>. Some other languages, e.g. <span class="flex_programminglanguage">FORTRAN</span>, require a special set of functions to be written in order to talk to them. Fortunately for you, I have already done this in <span class="flex_scriptinglanguage">FORTRAN</span>.</div> +<h4 class="subsubsection" id='magicparlabel-4709'><span class="subsubsection_label">7.2.1</span> In <i>C</i><div id="subsec_In_C"></div> </h4> -<div class="standard" id='magicparlabel-4540'>To include the API functions, <span class="flex_headerfile"><i>binary_c</i>.h</span> must be included in your code. </div> -<h4 class="subsubsection" id='magicparlabel-4545'><span class="subsubsection_label">7.2.2</span> Macro clashes</h4> -<div class="standard" id='magicparlabel-4546'>You may find there is a clash between <em><span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-4710'>To include the API functions, <span class="flex_headerfile"><i>binary_c</i>.h</span> must be included in your code. </div> +<h4 class="subsubsection" id='magicparlabel-4715'><span class="subsubsection_label">7.2.2</span> Macro clashes</h4> +<div class="standard" id='magicparlabel-4716'>You may find there is a clash between <em><span class='math'>binary_c</i></span> </em>'s <span class="flex_cmacro">Max</span> and <span class="flex_cmacro">Min</span> macros (and perhaps others) and various standard libraries. In which case, use <span class="flex_software">gcc</span>'s <span class="flex_cmacro">push_macro</span>/<span class="flex_cmacro">pop_macro</span> feature to include your functions in the following way:</div> -<div class="standard" id='magicparlabel-4567'><br /> +<div class="standard" id='magicparlabel-4737'><br /> <pre class ='listings <i>C</i>'>#pragma push_macro("Max") #pragma push_macro("Min") @@ -5719,19 +5768,19 @@ This will automatically be converted into <span class="flex_perlcode">\&main #pragma pop_macro("Max") </pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-4589'><span class="subsubsection_label">7.2.3</span> In <i>C</i>++</h4> -<div class="standard" id='magicparlabel-4590'>I have not written a wrapper in <span class="flex_programminglanguage">C++</span> because I figured you'd just use the <span class="flex_programminglanguage">C</span> functions. However, it might make sense to wrap the <span class="flex_programminglanguage">C</span> functions in some<em> </em><span class="flex_programminglanguage">C++</span> objects and indeed given that the <span class="flex_cstruct">stardata</span> struct functions very much like the data parts an object this should be quite trivial. Please let me know if you want to do this.</div> -<h4 class="subsubsection" id='magicparlabel-4611'><span class="subsubsection_label">7.2.4</span> In <i>FORTRAN</i></h4> -<div class="standard" id='magicparlabel-4612'>The file <span class="flex_file">binary_c_API_fortran.c</span> contains the API interface callable from <span class="flex_programminglanguage">FORTRAN</span>. The example <span class="flex_file">apitest.f90</span> (in the <em>apitest</em> directory) sets up and evolves a stellar system from <em><span class="flex_programminglanguage">FORTRAN</span></em>. Please take note of the following points:</div> +<h4 class="subsubsection" id='magicparlabel-4759'><span class="subsubsection_label">7.2.3</span> In <i>C</i>++</h4> +<div class="standard" id='magicparlabel-4760'>I have not written a wrapper in <span class="flex_programminglanguage">C++</span> because I figured you'd just use the <span class="flex_programminglanguage">C</span> functions. However, it might make sense to wrap the <span class="flex_programminglanguage">C</span> functions in some<em> </em><span class="flex_programminglanguage">C++</span> objects and indeed given that the <span class="flex_cstruct">stardata</span> struct functions very much like the data parts an object this should be quite trivial. Please let me know if you want to do this.</div> +<h4 class="subsubsection" id='magicparlabel-4781'><span class="subsubsection_label">7.2.4</span> In <i>FORTRAN</i></h4> +<div class="standard" id='magicparlabel-4782'>The file <span class="flex_file">binary_c_API_fortran.c</span> contains the API interface callable from <span class="flex_programminglanguage">FORTRAN</span>. The example <span class="flex_file">apitest.f90</span> (in the <em>apitest</em> directory) sets up and evolves a stellar system from <em><span class="flex_programminglanguage">FORTRAN</span></em>. Please take note of the following points:</div> -<ul class="itemize" id='magicparlabel-4629'><li class="itemize_item">Only the <span class="flex_cvar">argstring</span> interface works (no <span class="flex_cvar">argc</span> and <span class="flex_cvar">argv</span>)</li> +<ul class="itemize" id='magicparlabel-4799'><li class="itemize_item">Only the <span class="flex_cvar">argstring</span> interface works (no <span class="flex_cvar">argc</span> and <span class="flex_cvar">argv</span>)</li> <li class="itemize_item">Remember to put a <span class="flex_cmacro">NUL</span> character at the end of the <span class="flex_cvar">argstring</span> with <span class="flex_fortranfunction">char(0)</span></li> <li class="itemize_item">There is a special function <span class="flex_fortranfunction">binary_c_fortran_api_stardata_info</span> which can extract some data from a <span style='font-family:monospace;font-size: 18px;'>stardata</span> struct. You must write code in <span class="flex_programminglanguage">C</span> to extract the data, because <span class="flex_programminglanguage">FORTRAN</span> knows little about <span class="flex_programminglanguage">C</span> structures. This code is meant as an example: you can always write your own function and export it to your <span class='math'>binary_c</i></span> shared library with the <span class="flex_cmacro">binary_c_API_function</span> macro.</li> </ul> -<div class="standard" id='magicparlabel-4676'>The skeleton code below can be used as a basis to do whatever you like, see also <span class="flex_file">aptitest.f90</span> in the <span class="flex_file">apitest</span> directory.</div> +<div class="standard" id='magicparlabel-4846'>The skeleton code below can be used as a basis to do whatever you like, see also <span class="flex_file">aptitest.f90</span> in the <span class="flex_file">apitest</span> directory.</div> -<div class="standard" id='magicparlabel-4685'><br /> +<div class="standard" id='magicparlabel-4855'><br /> <pre class ='listings <i>FORTRAN</i>'>program binary_cinfortran use iso_c_binding @@ -5754,16 +5803,16 @@ This will automatically be converted into <span class="flex_perlcode">\&main end program</pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-4710'><span class="subsubsection_label">7.2.5</span> In Perl</h4> -<div class="standard" id='magicparlabel-4711'>To use the API in <span class="flex_scriptinglanguage">Perl</span>, please use the <span class="flex_perlmodule">Inline::C</span> <span class="flex_scriptinglanguage">Perl</span> module (available on <em>CPAN</em>) and refer to Sec. <a href="#subsec_In_C">7.2.1</a>. It is easier if you copy the examples in the <span class="flex_perlmodule">binary_grid::C.pm</span> <span class="flex_scriptinglanguage">Perl</span> module that is provided with <span class='math'>\binarygrid</span> +<h4 class="subsubsection" id='magicparlabel-4880'><span class="subsubsection_label">7.2.5</span> In Perl</h4> +<div class="standard" id='magicparlabel-4881'>To use the API in <span class="flex_scriptinglanguage">Perl</span>, please use the <span class="flex_perlmodule">Inline::C</span> <span class="flex_scriptinglanguage">Perl</span> module (available on <em>CPAN</em>) and refer to Sec. <a href="#subsec_In_C">7.2.1</a>. It is easier if you copy the examples in the <span class="flex_perlmodule">binary_grid::C.pm</span> <span class="flex_scriptinglanguage">Perl</span> module that is provided with <span class='math'>\binarygrid</span> 2.</div> -<h4 class="subsubsection" id='magicparlabel-4732'><span class="subsubsection_label">7.2.6</span> In <i><a href="https://www.python.org/">Python</a></i></h4> -<div class="standard" id='magicparlabel-4733'>There is a functional <span class="flex_scriptinglanguage">Python</span> currently interface available at <a href="https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i>-python">https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i>-python</a>.</div> -<h3 class="subsection" id='magicparlabel-4742'><span class="subsection_label">7.3</span> Standard functions</h3> -<div class="standard" id='magicparlabel-4743'>The following functions set up, evolve and modify stellar systems which are set up in <span class="flex_cstruct">stardata_t</span> structures.</div> -<h4 class="subsubsection" id='magicparlabel-4748'><span class="subsubsection_label">7.3.1</span> binary_c_new_system<div id="subsec_binary_c_new_system"></div> +<h4 class="subsubsection" id='magicparlabel-4902'><span class="subsubsection_label">7.2.6</span> In <i><a href="https://www.python.org/">Python</a></i></h4> +<div class="standard" id='magicparlabel-4903'>There is a functional <span class="flex_scriptinglanguage">Python</span> currently interface available at <a href="https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i>-python">https://gitlab.eps.surrey.ac.uk/ri0005/<i>binary_c</i>-python</a>.</div> +<h3 class="subsection" id='magicparlabel-4912'><span class="subsection_label">7.3</span> Standard functions</h3> +<div class="standard" id='magicparlabel-4913'>The following functions set up, evolve and modify stellar systems which are set up in <span class="flex_cstruct">stardata_t</span> structures.</div> +<h4 class="subsubsection" id='magicparlabel-4918'><span class="subsubsection_label">7.3.1</span> binary_c_new_system<div id="subsec_binary_c_new_system"></div> </h4> -<div class="standard" id='magicparlabel-4749'><br /> +<div class="standard" id='magicparlabel-4919'><br /> <pre class ='listings <i>C</i>'>void binary_c_API_function binary_c_new_system( struct libbinary_c_stardata_t ** stardata, struct libbinary_c_stardata_t ** previous_stardata, @@ -5774,7 +5823,7 @@ end program</pre><br /> </pre><br /> </div> -<ul class="itemize" id='magicparlabel-4761'><li class="itemize_item"><span class="flex_cstruct">stardata</span> must be a pointer to a <span class="flex_cstruct">libbinary_c_stardata_t</span> struct pointer. The memory for the <span class="flex_cstruct">stardata</span> is allocated by this function.</li> +<ul class="itemize" id='magicparlabel-4931'><li class="itemize_item"><span class="flex_cstruct">stardata</span> must be a pointer to a <span class="flex_cstruct">libbinary_c_stardata_t</span> struct pointer. The memory for the <span class="flex_cstruct">stardata</span> is allocated by this function.</li> <li class="itemize_item"><span class="flex_cstruct">previous_stardata</span> is usually <span class="flex_cmacro"><span style='font-family:monospace;font-size: 18px;'>NULL</span></span>, in which case space for it is allocated. If non-<span class="flex_cmacro"><span style='font-family:monospace;font-size: 18px;'>NULL</span></span>, it must point to a previously allocated <span class="flex_cstruct">libbinary_c_previous_stardata_t</span> struct.</li> <li class="itemize_item"><span class="flex_cstruct">preferences</span> is allocated and set up if <span class="flex_cmacro">NULL</span>, or should be a pointer to a pointer to a previous allocated <span class="flex_cstruct">libbinary_c_preferences_t</span> struct.</li> <li class="itemize_item"><span class="flex_cstruct">store</span> must be a pointer to a <span class="flex_cstruct">libbinary_c_store_t</span> struct pointer which is empty and <span class="flex_cmacro">NULL</span>, or a pointer to a pointer to a previously allocated <span class="flex_cstruct">libbinary_c_store_t</span> struct. This feature enables you to make the store only once, but call <span class="flex_cstruct">binary_c_new_system</span> repeatedly with it, thus saving a lot of CPU time.</li> @@ -5784,9 +5833,9 @@ end program</pre><br /> Alternatively, set <span class="flex_cvar">argc</span> to -1 then <span class="flex_cvar">argv</span> can be a pointer to a string containing a set of arguments (which must start with the word “<i>binary_c</i>” as this would be the first argument in the standard <i>C</i> format). These are split in <span class='math'>binary_c</i></span> and parsed as usual.</li> </ul> -<div class="standard" id='magicparlabel-4846'>For example, the following makes a new stellar system in <span style='font-family:monospace;font-size: 18px;'>stardata</span> and sets up a new store.</div> +<div class="standard" id='magicparlabel-5016'>For example, the following makes a new stellar system in <span style='font-family:monospace;font-size: 18px;'>stardata</span> and sets up a new store.</div> -<div class="standard" id='magicparlabel-4847'><br /> +<div class="standard" id='magicparlabel-5017'><br /> <pre class ='listings <i>C</i>'> struct libbinary_c_stardata_t * stardata = NULL; struct libbinary_c_store_t * store = NULL; @@ -5800,16 +5849,16 @@ Alternatively, set <span class="flex_cvar">argc</span> to -1 then <span class="f -1); /* ... */</pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-4863'><span class="subsubsection_label">7.3.2</span> binary_c_evolve_for_dt<div id="subsec_binary_c_evolve_for_dt"></div> +<h4 class="subsubsection" id='magicparlabel-5033'><span class="subsubsection_label">7.3.2</span> binary_c_evolve_for_dt<div id="subsec_binary_c_evolve_for_dt"></div> </h4> -<div class="standard" id='magicparlabel-4864'>This function evolves a stellar system defined in a <span style='font-family:monospace;font-size: 18px;'>stardata</span> struct for a time <span style='font-family:monospace;font-size: 18px;'>dt</span> Myr.</div> +<div class="standard" id='magicparlabel-5034'>This function evolves a stellar system defined in a <span style='font-family:monospace;font-size: 18px;'>stardata</span> struct for a time <span style='font-family:monospace;font-size: 18px;'>dt</span> Myr.</div> -<div class="standard" id='magicparlabel-4865'><br /> +<div class="standard" id='magicparlabel-5035'><br /> <pre class ='listings <i>C</i>'>int binary_c_API_function binary_c_evolve_for_dt(struct libbinary_c_stardata_t * stardata, double dt);</pre><br /> </div> -<ul class="itemize" id='magicparlabel-4871'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> +<ul class="itemize" id='magicparlabel-5041'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> <li class="itemize_item"><span class="flex_cstruct">dt</span> is the number of MYr (megayears, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mn>1</mn> @@ -5830,74 +5879,74 @@ Alternatively, set <span class="flex_cvar">argc</span> to -1 then <span class="f </mrow> </mrow></mstyle></math>)</li> </ul> -<div class="standard" id='magicparlabel-4881'>Typically, output is sent to <span class="flex_cvar">stdout</span>, but you can capture it in a buffer. Please see Sec. <a href="#subsec_Capturing_the_buffer">7.5.2</a>.</div> -<h4 class="subsubsection" id='magicparlabel-4886'><span class="subsubsection_label">7.3.3</span> binary_c_buffer_info<div id="subsec_binary_c_buffer_info"></div> +<div class="standard" id='magicparlabel-5051'>Typically, output is sent to <span class="flex_cvar">stdout</span>, but you can capture it in a buffer. Please see Sec. <a href="#subsec_Capturing_the_buffer">7.5.2</a>.</div> +<h4 class="subsubsection" id='magicparlabel-5056'><span class="subsubsection_label">7.3.3</span> binary_c_buffer_info<div id="subsec_binary_c_buffer_info"></div> </h4> -<div class="standard" id='magicparlabel-4887'>This function returns a pointer to the <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5057'>This function returns a pointer to the <span class='math'>binary_c</i></span> output buffer and its size.</div> -<div class="standard" id='magicparlabel-4888'><br /> +<div class="standard" id='magicparlabel-5058'><br /> <pre class ='listings'>void binary_c_API_function binary_c_buffer_info(struct libbinary_c_stardata_t * RESTRICT stardata, char ** buffer, int * size);</pre><br /> </div> -<ul class="itemize" id='magicparlabel-4895'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> +<ul class="itemize" id='magicparlabel-5065'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> <li class="itemize_item"><span class="flex_cvar">buffer</span> is a pointer to a <span class="flex_cvar">char*</span> which points to <span class='math'>binary_c</i></span> 's internal buffer. Any changes you make to the contents of buffer thus also change <span class='math'>binary_c</i></span> 's internal buffer.</li> </ul> -<h4 class="subsubsection" id='magicparlabel-4909'><span class="subsubsection_label">7.3.4</span> binary_c_buffer_empty_buffer<div id="subsec_binary_c_buffer_empty_buffer"></div> +<h4 class="subsubsection" id='magicparlabel-5079'><span class="subsubsection_label">7.3.4</span> binary_c_buffer_empty_buffer<div id="subsec_binary_c_buffer_empty_buffer"></div> </h4> -<div class="standard" id='magicparlabel-4910'>This function frees the memory used in <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5080'>This function frees the memory used in <span class='math'>binary_c</i></span> 's internal buffer. See also Sec. <a href="#subsec_binary_c_buffer_info">7.3.3</a>.</div> -<div class="standard" id='magicparlabel-4911'><br /> +<div class="standard" id='magicparlabel-5081'><br /> <pre class ='listings <i>C</i>'>void binary_c_API_function binary_c_buffer_empty_buffer(struct stardata_t * RESTRICT stardata); </pre><br /> </div> -<ul class="itemize" id='magicparlabel-4916'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>) </li> +<ul class="itemize" id='magicparlabel-5086'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>) </li> </ul> -<h4 class="subsubsection" id='magicparlabel-4921'><span class="subsubsection_label">7.3.5</span> binary_c_free_store_contents<div id="subsec_binary_c_free_store_contents"></div> +<h4 class="subsubsection" id='magicparlabel-5091'><span class="subsubsection_label">7.3.5</span> binary_c_free_store_contents<div id="subsec_binary_c_free_store_contents"></div> </h4> -<div class="standard" id='magicparlabel-4922'>Once you have finished running (possibly many) stellar systems, you can free the contents of the <span style='font-family:monospace;font-size: 18px;'>store</span> struct with a call to <span class="flex_cfunction">binary_c_free_store_contents</span></div> +<div class="standard" id='magicparlabel-5092'>Once you have finished running (possibly many) stellar systems, you can free the contents of the <span style='font-family:monospace;font-size: 18px;'>store</span> struct with a call to <span class="flex_cfunction">binary_c_free_store_contents</span></div> -<div class="standard" id='magicparlabel-4927'><br /> +<div class="standard" id='magicparlabel-5097'><br /> <pre class ='listings <i>C</i>'>void binary_c_API_function binary_c_free_store_contents(struct libbinary_c_store_t * RESTRICT store);</pre><br /> </div> -<ul class="itemize" id='magicparlabel-4932'><li class="itemize_item"> <span class="flex_cstruct">store</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> +<ul class="itemize" id='magicparlabel-5102'><li class="itemize_item"> <span class="flex_cstruct">store</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> </ul> -<h4 class="subsubsection" id='magicparlabel-4937'><span class="subsubsection_label">7.3.6</span> binary_c_free_memory<div id="subsec_binary_c_free_memory"></div> +<h4 class="subsubsection" id='magicparlabel-5107'><span class="subsubsection_label">7.3.6</span> binary_c_free_memory<div id="subsec_binary_c_free_memory"></div> </h4> -<div class="standard" id='magicparlabel-4938'>Once your stellar evolution has finished, a <span class="flex_cstruct">stardata</span> struct needs to have its memory freed. This function enables you to free the <span class="flex_cstruct">stardata</span>, <span class="flex_cstruct">preferences</span> and <span class="flex_cstruct">store</span> structs if required. It is possible that <span style='font-family:monospace;font-size: 18px;'>preferences</span> and <span style='font-family:monospace;font-size: 18px;'>store</span> should <em>not</em> be freed, because these can be reused for future evolutionary runs.</div> +<div class="standard" id='magicparlabel-5108'>Once your stellar evolution has finished, a <span class="flex_cstruct">stardata</span> struct needs to have its memory freed. This function enables you to free the <span class="flex_cstruct">stardata</span>, <span class="flex_cstruct">preferences</span> and <span class="flex_cstruct">store</span> structs if required. It is possible that <span style='font-family:monospace;font-size: 18px;'>preferences</span> and <span style='font-family:monospace;font-size: 18px;'>store</span> should <em>not</em> be freed, because these can be reused for future evolutionary runs.</div> -<div class="standard" id='magicparlabel-4955'><br /> +<div class="standard" id='magicparlabel-5125'><br /> <pre class ='listings <i>C</i>'>void binary_c_API_function binary_c_free_memory(struct stardata_t ** RESTRICT stardata, Boolean free_preferences, Boolean free_stardata, Boolean free_store);</pre><br /> </div> -<ul class="itemize" id='magicparlabel-4963'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> +<ul class="itemize" id='magicparlabel-5133'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> <li class="itemize_item"><span class="flex_cvar">free_preferences</span>, <span class="flex_cvar">free_stardata</span> and <span class="flex_cvar">free_store</span> should be either <span class="flex_cmacro">TRUE</span> or <span class="flex_cmacro">FALSE</span>.</li> </ul> -<h3 class="subsection" id='magicparlabel-4989'><span class="subsection_label">7.4</span> Extension functions</h3> -<div class="standard" id='magicparlabel-4990'>A few functions have been defined which provide extensions to the basic API, but are very useful in the <span class="flex_perlmodule">binary_grid::C</span> Perl module. The number of extension functions may increase in the future, so this documentation is always likely to be out of date.</div> -<h4 class="subsubsection" id='magicparlabel-4995'><span class="subsubsection_label">7.4.1</span> binary_c_version<div id="subsec_binary_c_version"></div> +<h3 class="subsection" id='magicparlabel-5159'><span class="subsection_label">7.4</span> Extension functions</h3> +<div class="standard" id='magicparlabel-5160'>A few functions have been defined which provide extensions to the basic API, but are very useful in the <span class="flex_perlmodule">binary_grid::C</span> Perl module. The number of extension functions may increase in the future, so this documentation is always likely to be out of date.</div> +<h4 class="subsubsection" id='magicparlabel-5165'><span class="subsubsection_label">7.4.1</span> binary_c_version<div id="subsec_binary_c_version"></div> </h4> -<div class="standard" id='magicparlabel-4996'>This function provides access to the (long) version string returned by <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5166'>This function provides access to the (long) version string returned by <span class='math'>binary_c</i></span> </div> -<div class="standard" id='magicparlabel-4997'><br /> +<div class="standard" id='magicparlabel-5167'><br /> <pre class ='listings <i>C</i>'>void binary_c_API_function binary_c_version(struct libbinary_c_stardata_t * RESTRICT stardata);</pre><br /> </div> -<ul class="itemize" id='magicparlabel-5002'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> +<ul class="itemize" id='magicparlabel-5172'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> </ul> -<h4 class="subsubsection" id='magicparlabel-5007'><span class="subsubsection_label">7.4.2</span> binary_c_show_instant_RLOF_period_or_separation<div id="subsec_binary_c_show_instant_RLOF_perio"></div> +<h4 class="subsubsection" id='magicparlabel-5177'><span class="subsubsection_label">7.4.2</span> binary_c_show_instant_RLOF_period_or_separation<div id="subsec_binary_c_show_instant_RLOF_perio"></div> </h4> -<div class="standard" id='magicparlabel-5008'>This function provides access to the <i>binary_c</i> function that determines the minimum orbital period or separation that leads to instantaneous Roche-lobe overflow for a given <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-5178'>This function provides access to the <i>binary_c</i> function that determines the minimum orbital period or separation that leads to instantaneous Roche-lobe overflow for a given <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>M</mi> @@ -5915,42 +5964,42 @@ Alternatively, set <span class="flex_cvar">argc</span> to -1 then <span class="f </msub> </mrow></mstyle></math> and metallicity.</div> -<div class="standard" id='magicparlabel-5009'><br /> +<div class="standard" id='magicparlabel-5179'><br /> <pre class ='listings <i>C</i>'>void binary_c_API_function binary_c_show_instant_RLOF_period_or_separation(struct libbinary_c_stardata_t * stardata);</pre><br /> </div> -<ul class="itemize" id='magicparlabel-5014'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> +<ul class="itemize" id='magicparlabel-5184'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> </ul> -<h4 class="subsubsection" id='magicparlabel-5019'><span class="subsubsection_label">7.4.3</span> binary_c_initialize_parameters<div id="subsec_binary_c_initialize_parameters"></div> +<h4 class="subsubsection" id='magicparlabel-5189'><span class="subsubsection_label">7.4.3</span> binary_c_initialize_parameters<div id="subsec_binary_c_initialize_parameters"></div> </h4> -<div class="standard" id='magicparlabel-5020'>This function calls the <em><span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5190'>This function calls the <em><span class='math'>binary_c</i></span> </em> <span class="flex_cfunction">initialize_parameters</span> function which in turn is useful for reporting the initial abundance mixture (it is used for this purpose in <span class="flex_perlmodule">binary_grid::C</span>).</div> -<div class="standard" id='magicparlabel-5029'><br /> +<div class="standard" id='magicparlabel-5199'><br /> <pre class ='listings <i>C</i>'>void binary_c_API_function binary_c_initialize_parameters(struct libbinary_c_stardata_t * RESTRICT stardata);</pre><br /> </div> -<ul class="itemize" id='magicparlabel-5034'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> +<ul class="itemize" id='magicparlabel-5204'><li class="itemize_item"><span class="flex_cstruct">stardata</span> is defined previously (Sec. <a href="#subsec_binary_c_new_system">7.3.1</a>)</li> </ul> -<h3 class="subsection" id='magicparlabel-5039'><span class="subsection_label">7.5</span> API Examples<div id="sec_Examples"></div> +<h3 class="subsection" id='magicparlabel-5209'><span class="subsection_label">7.5</span> API Examples<div id="sec_Examples"></div> </h3> -<div class="standard" id='magicparlabel-5040'>There are several examples of using the API in the <span class="flex_perlmodule">binary_grid::C</span> module.</div> -<h4 class="subsubsection" id='magicparlabel-5045'><span class="subsubsection_label">7.5.1</span> Arguments and/or the argstring<div id="subsec_Arguments_and_the"></div> +<div class="standard" id='magicparlabel-5210'>There are several examples of using the API in the <span class="flex_perlmodule">binary_grid::C</span> module.</div> +<h4 class="subsubsection" id='magicparlabel-5215'><span class="subsubsection_label">7.5.1</span> Arguments and/or the argstring<div id="subsec_Arguments_and_the"></div> </h4> -<div class="standard" id='magicparlabel-5046'>The <span class="flex_cvar">argstring</span>, or a combination of <span class="flex_cvar">argc</span> and <span class="flex_cvar">argv</span>, is used to send commands to <span class='math'>binary_c</i></span>, and this is sent to <span class="flex_cfunction">binary_c_new_system()</span> to specify (say) masses, orbits, metallicity etc. prior to a call to evolve a stellar system. You do not have to send an <span class="flex_cvar">argstring</span>, you could set the system directly, e.g. <br /> +<div class="standard" id='magicparlabel-5216'>The <span class="flex_cvar">argstring</span>, or a combination of <span class="flex_cvar">argc</span> and <span class="flex_cvar">argv</span>, is used to send commands to <span class='math'>binary_c</i></span>, and this is sent to <span class="flex_cfunction">binary_c_new_system()</span> to specify (say) masses, orbits, metallicity etc. prior to a call to evolve a stellar system. You do not have to send an <span class="flex_cvar">argstring</span>, you could set the system directly, e.g. <br /> <pre class ='listings <i>C</i>'>stardata->star[1].mass = 10.0; stardata->common.metallicity = 0.02; stardata->model.max_evolution_time = 15000.0;</pre><br /> </div> -<div class="standard" id='magicparlabel-5073'>but there are some functions which are called <em>after</em> the arguments are parsed which would be skipped if you do it manually. You will have to mimic (or copy from <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5243'>but there are some functions which are called <em>after</em> the arguments are parsed which would be skipped if you do it manually. You will have to mimic (or copy from <span class='math'>binary_c</i></span> ) this functionality.</div> -<h4 class="subsubsection" id='magicparlabel-5074'><span class="subsubsection_label">7.5.2</span> Capturing the buffer output<div id="subsec_Capturing_the_buffer"></div> +<h4 class="subsubsection" id='magicparlabel-5244'><span class="subsubsection_label">7.5.2</span> Capturing the buffer output<div id="subsec_Capturing_the_buffer"></div> </h4> -<div class="standard" id='magicparlabel-5075'>Usually, output is sent to the <span class="flex_cvar">stdout</span> stream. However, it is often more useful to capture the output and process it in an automated way. This is how the<em> <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-5245'>Usually, output is sent to the <span class="flex_cvar">stdout</span> stream. However, it is often more useful to capture the output and process it in an automated way. This is how the<em> <span class='math'>\binarygrid</span> </em><span class="flex_programminglanguage">C</span> backend works. You can do this with the following code which sets up a stellar system, suppresses logging to files, sets up the internal buffer, evolves the system, then grabs the buffer into memory. It is up to you to process this buffer (although see the <span class="flex_perlmodule">binary_grid::C</span> module for ways to do this) but it must then be freed before you finish.</div> -<div class="standard" id='magicparlabel-5088'><br /> +<div class="standard" id='magicparlabel-5258'><br /> <pre class ='listings <i>C</i>'> struct libbinary_c_stardata_t * stardata = NULL; struct libbinary_c_store_t * store = NULL; @@ -5987,12 +6036,12 @@ stardata->model.max_evolution_time = 15000.0;</pre><br /> binary_c_buffer_empty_buffer(stardata); buffer = NULL;</pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-5127'><span class="subsubsection_label">7.5.3</span> Memory management and maintaining a store<div id="subsec_Maintaining_a_store"></div> +<h4 class="subsubsection" id='magicparlabel-5297'><span class="subsubsection_label">7.5.3</span> Memory management and maintaining a store<div id="subsec_Maintaining_a_store"></div> </h4> -<div class="standard" id='magicparlabel-5128'>Memory is allocated during a call to <span class="flex_cfunction">binary_c_new_system()</span> which sets up the <span class="flex_cstruct">stardata</span> struct, the <span class="flex_cstruct">preferences</span> struct and the <span class="flex_cstruct">store</span> struct. Both the preferences and the store can be reused once defined, which means you do not have to go through the costly (in CPU cycles) process of setting up a multitude of data for each stellar system. The example below runs a number of systems while preserving the store. (It is based on the <span class="flex_programminglanguage">C</span> backend for <em><span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-5298'>Memory is allocated during a call to <span class="flex_cfunction">binary_c_new_system()</span> which sets up the <span class="flex_cstruct">stardata</span> struct, the <span class="flex_cstruct">preferences</span> struct and the <span class="flex_cstruct">store</span> struct. Both the preferences and the store can be reused once defined, which means you do not have to go through the costly (in CPU cycles) process of setting up a multitude of data for each stellar system. The example below runs a number of systems while preserving the store. (It is based on the <span class="flex_programminglanguage">C</span> backend for <em><span class='math'>\binarygrid</span> 2</em>.) It is not recommended to preserve the <span class="flex_cstruct">preferences</span> even though it is possible.</div> -<div class="standard" id='magicparlabel-5153'><br /> +<div class="standard" id='magicparlabel-5323'><br /> <pre class ='listings <i>C</i>'> struct libbinary_c_stardata_t * stardata = NULL; struct libbinary_c_store_t * store = NULL; @@ -6025,68 +6074,68 @@ stardata->model.max_evolution_time = 15000.0;</pre><br /> /* ... do your data processing ... */</pre><br /> </div> -<div class="standard" id='magicparlabel-5187'>You can also free <em>everything </em>with the following function call:</div> +<div class="standard" id='magicparlabel-5357'>You can also free <em>everything </em>with the following function call:</div> -<div class="standard" id='magicparlabel-5188'><br /> +<div class="standard" id='magicparlabel-5358'><br /> <pre class ='listings <i>C</i>'> binary_c_free_memory(&stardata,TRUE,TRUE,TRUE); </pre><br /> </div> -<div class="standard" id='magicparlabel-5193'>but beware that your local <span class="flex_cstruct">store</span> and <span class="flex_cstruct">stardata</span> must also be set to <span class="flex_cmacro">NULL</span> if you require it to be regenerated on a subsequent call to <span class="flex_cfunction">binary_c_new_system</span>, e.g. with </div> +<div class="standard" id='magicparlabel-5363'>but beware that your local <span class="flex_cstruct">store</span> and <span class="flex_cstruct">stardata</span> must also be set to <span class="flex_cmacro">NULL</span> if you require it to be regenerated on a subsequent call to <span class="flex_cfunction">binary_c_new_system</span>, e.g. with </div> -<div class="standard" id='magicparlabel-5210'><br /> +<div class="standard" id='magicparlabel-5380'><br /> <pre class ='listings <i>C</i>'> binary_c_free_memory(&stardata,TRUE,TRUE,TRUE); store = NULL; stardata = NULL; </pre><br /> </div> -<div class="standard" id='magicparlabel-5217'>You must not call <span class="flex_cfunction">binary_c_free_memory</span> to free your <span class="flex_cstruct">stardata</span> and <span class="flex_cstruct">store</span> and then immediately use <span class="flex_cmacro">Safe_free</span> on these pointers. They have already been freed, just not set to <span class="flex_cmacro">NULL</span> (because it is impossible to do so in <span class="flex_cfunction">binary_c_free_memory</span>), and freeing them – even with <span class="flex_cmacro">Safe_free</span> – will cause a crash.</div> +<div class="standard" id='magicparlabel-5387'>You must not call <span class="flex_cfunction">binary_c_free_memory</span> to free your <span class="flex_cstruct">stardata</span> and <span class="flex_cstruct">store</span> and then immediately use <span class="flex_cmacro">Safe_free</span> on these pointers. They have already been freed, just not set to <span class="flex_cmacro">NULL</span> (because it is impossible to do so in <span class="flex_cfunction">binary_c_free_memory</span>), and freeing them – even with <span class="flex_cmacro">Safe_free</span> – will cause a crash.</div> -<div class="standard" id='magicparlabel-5246'>If you are concerned that memory has <em>not</em> been freed, try running <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5416'>If you are concerned that memory has <em>not</em> been freed, try running <span class='math'>binary_c</i></span> through <span class="flex_software">valgrind</span> or enable the <span class="flex_cmacro">CODESTATS</span> flag in <span class="flex_headerfile">binary_c_code_options.h</span>. If you cannot find the problem, or if it's a problem not of your making, please contact Rob about it so that it can be fixed for everyone.</div> -<h2 class="section" id='magicparlabel-5259'><span class="section_label">8</span> Code description and internals</h2> -<div class="standard" id='magicparlabel-5260'><div id="sec_Code_description"></div> +<h2 class="section" id='magicparlabel-5429'><span class="section_label">8</span> Code description and internals</h2> +<div class="standard" id='magicparlabel-5430'><div id="sec_Code_description"></div> </div> -<div class="standard" id='magicparlabel-5261'>This section describes some of the internal details of the <em><i>binary_c</i></em> code.</div> -<h3 class="subsection" id='magicparlabel-5262'><span class="subsection_label">8.1</span> History</h3> -<div class="standard" id='magicparlabel-5263'><div id="subsec_History"></div> +<div class="standard" id='magicparlabel-5431'>This section describes some of the internal details of the <em><i>binary_c</i></em> code.</div> +<h3 class="subsection" id='magicparlabel-5432'><span class="subsection_label">8.1</span> History</h3> +<div class="standard" id='magicparlabel-5433'><div id="subsec_History"></div> First, a bit of history. The <em><span class="flex_software">BSE</span></em> code was given to me by Chris Tout in October 2000 and some updates were made in May 2001 (from Jarrod Hurley). Jarrod was responsible for the October 2000 version, written as one monolithic block of evil <span class="flex_programminglanguage">Fortran</span>, although past collaborators such as Chris Tout, Sverre Aarseth, Onno Pols etc. (who else have I forgotten?) had input their talent to the code. The <span class="flex_programminglanguage">Fortran</span> version was converted to <em>C</em> (because I hate <em>Fortran</em> and it was <em>my</em> <em>bloody</em> <em>PhD</em>!) and (some of) the bugs worked out of it. This gave me a chance to lay the code out quite differently.</div> -<div class="standard" id='magicparlabel-5276'>One major change is in the organisation of the variables. In the <span class="flex_programminglanguage">Fortran</span> code there are lots of arrays of size 2 (there are two stars) and a load of evil common blocks. These have been replaced by structures, one for each <span style='font-family:monospace;font-size: 18px;'>star</span>, the <span class="flex_cstruct">common</span> and <span class="flex_cstruct">model</span> structures, a <span class="flex_cstruct">preferences</span> structure to contain user-defined options, and a <span class="flex_cstruct">stardata</span> structure which contains pointers to everything else. Pointers are far quicker to use than passing the actual data around. Conceptually it's useful to have all the information about each star in one space, since most functions deal only with one star and can access all the information through a single pointer (and pointers are fast).</div> +<div class="standard" id='magicparlabel-5446'>One major change is in the organisation of the variables. In the <span class="flex_programminglanguage">Fortran</span> code there are lots of arrays of size 2 (there are two stars) and a load of evil common blocks. These have been replaced by structures, one for each <span style='font-family:monospace;font-size: 18px;'>star</span>, the <span class="flex_cstruct">common</span> and <span class="flex_cstruct">model</span> structures, a <span class="flex_cstruct">preferences</span> structure to contain user-defined options, and a <span class="flex_cstruct">stardata</span> structure which contains pointers to everything else. Pointers are far quicker to use than passing the actual data around. Conceptually it's useful to have all the information about each star in one space, since most functions deal only with one star and can access all the information through a single pointer (and pointers are fast).</div> -<div class="standard" id='magicparlabel-5297'>Throughout the code you'll see lots of <span style='font-family:monospace;font-size: 18px;'>Dprint</span> statements, these are enabled when debugging is turned on. These are very useful when something goes wrong (see section <a href="#sec_debugging">6.23</a>).</div> +<div class="standard" id='magicparlabel-5467'>Throughout the code you'll see lots of <span style='font-family:monospace;font-size: 18px;'>Dprint</span> statements, these are enabled when debugging is turned on. These are very useful when something goes wrong (see section <a href="#sec_debugging">6.23</a>).</div> -<div class="standard" id='magicparlabel-5298'>If you change anything, and would like me to debug it or you would like to commit it to the master branch, I insist on the following.</div> +<div class="standard" id='magicparlabel-5468'>If you change anything, and would like me to debug it or you would like to commit it to the master branch, I insist on the following.</div> -<ul class="itemize" id='magicparlabel-5299'><li class="itemize_item">Learn about how to write <span class="flex_programminglanguage">C</span>, e.g. <a href="https://www.maultech.com/chrislott/resources/cstyle/indhill-cstyle.pdf">https://www.maultech.com/chrislott/resources/cstyle/indhill-cstyle.pdf</a> or <a href="https://en.wikipedia.org/wiki/The_C_Programming_Language">https://en.wikipedia.org/wiki/The_C_Programming_Language</a>.</li> +<ul class="itemize" id='magicparlabel-5469'><li class="itemize_item">Learn about how to write <span class="flex_programminglanguage">C</span>, e.g. <a href="https://www.maultech.com/chrislott/resources/cstyle/indhill-cstyle.pdf">https://www.maultech.com/chrislott/resources/cstyle/indhill-cstyle.pdf</a> or <a href="https://en.wikipedia.org/wiki/The_C_Programming_Language">https://en.wikipedia.org/wiki/The_C_Programming_Language</a>.</li> <li class="itemize_item">Learn how to format your <span class="flex_programminglanguage">C</span> code properly. Please use the <a href="https://en.wikipedia.org/wiki/Indentation_style#Allman_style">Allman style</a> and indent with four spaces (<a href="https://www.gnu.org/software/emacs/">emacs</a> indents <span class="flex_programminglanguage">C</span> like this automatically).</li> <li class="itemize_item">Include <em>good comments</em> even if these are “this is a fudge”. Remember that people who do not know how the code works will want to change the code in the future, and I have to check it before it is committed. Descriptions of the physics, paraphrased from a paper if you have to (but remember to give appropriate credit) are encouraged.</li> <li class="itemize_item">Include <span class="flex_cmacro">Dprint()</span> statements so that if there is a <span class="flex_cmacro">DEBUG</span> flag set there will be some (useful!) output to the screen during runtime.</li> <li class="itemize_item">Make sure the names of your variables <em>describe what they do</em> (in English :-). I do not care if the variable names are long (long is good!) and the computer certainly doesn't either.</li> </ul> -<h3 class="subsection" id='magicparlabel-5324'><span class="subsection_label">8.2</span> How the <em><i>binary_c</i></em> code works</h3> -<div class="standard" id='magicparlabel-5325'><div id="subsec_How_the_code"></div> +<h3 class="subsection" id='magicparlabel-5494'><span class="subsection_label">8.2</span> How the <em><i>binary_c</i></em> code works</h3> +<div class="standard" id='magicparlabel-5495'><div id="subsec_How_the_code"></div> The <em><i>binary_c</i></em> code, based on <em><span class="flex_software">BSE</span></em>, deals with stellar evolution and binary evolution i.e. the mass, core mass, luminosity, radius of both stars, mass loss and gain, orbital changes, supernovae and novae. Its<em> nucleosynthesis</em> (“<em>nucsyn</em>”) code deals with the surface abundance of the stars, follows this as mass is lost or gained and also the luminosity and radius on the TPAGB, dredge-ups, HBB, WR stars, supernova and nova yields. This does not sound like much but it's complicated enough! So as the <em><i>binary_c</i></em> code does the stellar (“structure”)<em> </em>evolution, the <em>nucsyn</em> code identifies when the surface abundances change. </div> -<h3 class="subsection" id='magicparlabel-5332'><span class="subsection_label">8.3</span> Memory management in <span class='math'>binary_c</i></span> +<h3 class="subsection" id='magicparlabel-5502'><span class="subsection_label">8.3</span> Memory management in <span class='math'>binary_c</i></span> </h3> -<div class="standard" id='magicparlabel-5333'><div id="subsec_Memory_management"></div> +<div class="standard" id='magicparlabel-5503'><div id="subsec_Memory_management"></div> </div> -<h4 class="subsubsection" id='magicparlabel-5334'><span class="subsubsection_label">8.3.1</span> Memory allocation</h4> -<div class="standard" id='magicparlabel-5335'>Memory should be allocated using the macros <span class="flex_cmacro">Malloc</span>, <span class="flex_cmacro">Calloc</span> and <span class="flex_cmacro">Realloc</span> which replace the system <span class="flex_cfunction">malloc</span>, <span class="flex_cfunction">calloc</span> and <span class="flex_cfunction">realloc</span>, respectively. These macros allow for automatic error checking, e.g. when an allocation fails (i.e. when <span class="flex_cmacro">ALLOC_CHECKS</span> is defined), as well as the use of aligned memory (which should be faster).</div> -<h4 class="subsubsection" id='magicparlabel-5364'><span class="subsubsection_label">8.3.2</span> Stack size</h4> -<div class="standard" id='magicparlabel-5365'>The allocation of big data tables can require a large stack. Please remember to set your stack size, either in your shell e.g. with <em><span class="flex_software">ulimit</span></em> or in <span class="flex_software">Perl</span>'s threads, e.g.<span style='font-family:monospace;font-size: 18px;'>,<br /> +<h4 class="subsubsection" id='magicparlabel-5504'><span class="subsubsection_label">8.3.1</span> Memory allocation</h4> +<div class="standard" id='magicparlabel-5505'>Memory should be allocated using the macros <span class="flex_cmacro">Malloc</span>, <span class="flex_cmacro">Calloc</span> and <span class="flex_cmacro">Realloc</span> which replace the system <span class="flex_cfunction">malloc</span>, <span class="flex_cfunction">calloc</span> and <span class="flex_cfunction">realloc</span>, respectively. These macros allow for automatic error checking, e.g. when an allocation fails (i.e. when <span class="flex_cmacro">ALLOC_CHECKS</span> is defined), as well as the use of aligned memory (which should be faster).</div> +<h4 class="subsubsection" id='magicparlabel-5534'><span class="subsubsection_label">8.3.2</span> Stack size</h4> +<div class="standard" id='magicparlabel-5535'>The allocation of big data tables can require a large stack. Please remember to set your stack size, either in your shell e.g. with <em><span class="flex_software">ulimit</span></em> or in <span class="flex_software">Perl</span>'s threads, e.g.<span style='font-family:monospace;font-size: 18px;'>,<br /> <pre class ='listings Perl'>use threads 'stack_size'=>4096*10000</pre><br /> </span>appropriately. If your stack is too small, you will get (possibly random) segmentation faults. See section <a href="#subsec_Segmentation_faults">8.5.5</a> for more information.</div> -<h4 class="subsubsection" id='magicparlabel-5378'><span class="subsubsection_label">8.3.3</span> Main Memory Structures: stardata<div id="subsec_Memory_Structures"></div> +<h4 class="subsubsection" id='magicparlabel-5548'><span class="subsubsection_label">8.3.3</span> Main Memory Structures: stardata<div id="subsec_Memory_Structures"></div> </h4> -<div class="standard" id='magicparlabel-5379'>Memory use in <em><span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5549'>Memory use in <em><span class='math'>binary_c</i></span> </em> is divided into structures which are allocated appropriately. The main structure, a pointer to which is passed around all over the place, is <em><span class="flex_cstruct">stardata</span></em>. Normally this is all you need. However, there are structures for specific purposes as described below. Memory allocation is mostly done in the <span class="flex_cfunction">main_allocations</span> subroutine.</div> -<div class="standard" id='magicparlabel-5388'>Variables are stored as arrays within, e.g., <span class="flex_cstruct">stardata</span><em>,</em> which is dynamically allocated on the heap, rather than being dynamically allocated themeslves. You should probably not use <span class="flex_cstruct">stardata</span><em> </em>as a local stack variable, because it is liable to be quite large.</div> +<div class="standard" id='magicparlabel-5558'>Variables are stored as arrays within, e.g., <span class="flex_cstruct">stardata</span><em>,</em> which is dynamically allocated on the heap, rather than being dynamically allocated themeslves. You should probably not use <span class="flex_cstruct">stardata</span><em> </em>as a local stack variable, because it is liable to be quite large.</div> -<dl class='description' id='magicparlabel-5397'><dt class="description_label">stardata_t</dt> +<dl class='description' id='magicparlabel-5567'><dt class="description_label">stardata_t</dt> <dd class="description_item"> The main <span class="flex_cstruct">stardata</span> structure is used to store the information about the stellar system currently being evolved, as well as pointers to all the other memory stores. <span class="flex_cstruct">stardata</span> is set to 0 (the <span style='font-family:monospace;font-size: 18px;'>NULL</span> byte '\0') at the beginning of evolution, so everything inside it is either zero (for floats, doubles, ints etc.), or <span style='font-family:monospace;font-size: 18px;'><span class="flex_cmacro">FALSE</span></span> (for Booleans).</dd> <dt class="description_label">previous_stardata_t</dt> <dd class="description_item"> A pointer to the top of the <span class="flex_cstruct">previous_stardata</span> stack. This is used at the end of an evolutionary step to calculate derivatives and perform logging (e.g. change of stellar type).</dd> @@ -6142,10 +6191,10 @@ The <em><i>binary_c</i></em> code, based on <em><span class="flex_software">BSE< <dt class="description_label">binary_c_event_t</dt> <dd class="description_item"> Used in the events code (see Section <a href="#subsec_Events">8.6</a>). There are various other custom structures which store data for events (see <span class="flex_headerfile">binary_c_structures.h</span>)</dd> </dl> -<h4 class="subsubsection" id='magicparlabel-5604'><span class="subsubsection_label">8.3.4</span> Supplementary data structures</h4> -<div class="standard" id='magicparlabel-5605'>There are a number of other data structures used by <em><i>binary_c</i></em>. A few are listed here and most are not of interest to you.</div> +<h4 class="subsubsection" id='magicparlabel-5774'><span class="subsubsection_label">8.3.4</span> Supplementary data structures</h4> +<div class="standard" id='magicparlabel-5775'>There are a number of other data structures used by <em><i>binary_c</i></em>. A few are listed here and most are not of interest to you.</div> -<dl class='description' id='magicparlabel-5606'><dt class="description_label">data_table_t</dt> +<dl class='description' id='magicparlabel-5776'><dt class="description_label">data_table_t</dt> <dd class="description_item"> This contains information about a data table. Set up (a pointer to, i.e. data_table_t*) the data table through <span class="flex_cmacro">NewDataTable_from_Array</span> or <span class="flex_cmacro">NewDataTable_from_Pointer</span>. Access the data table through the <span class="flex_cmacro">Interpolate</span> macro (which interfaces with <span class="flex_software">librinterpolate</span>). Delete the table with <span class="flex_cmacro">Delete_data_table</span>. The <span class="flex_cvar">data_table_t.data</span> pointer points to an array of doubles which contains the data: this memory is not allocated for you. If set up in the <span class="flex_cstruct">store</span> or <span class="flex_cstruct">tmpstore</span> this can be dynamically allocated, elsewhere you have to be careful and probably point to a data array inside <span class="flex_cstruct">stardata</span>. <br /> @@ -6165,119 +6214,119 @@ If you want to set up a <span class="flex_cstruct">data_table_t</span> rather th <dt class="description_label">binary_system_t</dt> <dd class="description_item"> Used to define the properties of a binary-star system in the disc code.</dd> </dl> -<h4 class="subsubsection" id='magicparlabel-5670'><span class="subsubsection_label">8.3.5</span> Thread safety</h4> -<div class="standard" id='magicparlabel-5671'><em><span class='math'>binary_c</i></span> +<h4 class="subsubsection" id='magicparlabel-5840'><span class="subsubsection_label">8.3.5</span> Thread safety</h4> +<div class="standard" id='magicparlabel-5841'><em><span class='math'>binary_c</i></span> </em>, as of version 2.0pre21 and in all subsequent versions, i.e. in the version you are using!, is designed to be thread-safe, i.e. it can be built as a shared library (<span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ make <i>libbinary_c.so</i></pre><br /> </span>) and deployed in many threads by one process (as in <em><span class='math'>\binarygrid</span> </em> with the <span class="flex_programminglanguage">C</span> backend). To this end:</div> -<ul class="itemize" id='magicparlabel-5680'><li class="itemize_item">You <b>may not</b> use static variables. Put your data into <em><span class="flex_cstruct">stardata</span></em>.</li> +<ul class="itemize" id='magicparlabel-5850'><li class="itemize_item">You <b>may not</b> use static variables. Put your data into <em><span class="flex_cstruct">stardata</span></em>.</li> <li class="itemize_item">You <b>may not</b> use global variables (i.e. no <span style='font-family:monospace;font-size: 18px;'>extern</span> statements). Put your data into <em><span class="flex_cstruct">stardata</span></em>.</li> <li class="itemize_item">You may not use non-thread-safe <span class="flex_programminglanguage">C</span> library functions (e.g. <span class="flex_cfunction">strtok</span> and hash functions, use the <span style='font-family:monospace;font-size: 18px;'>_r</span> or <span style='font-family:monospace;font-size: 18px;'>_s</span> equivalents). Some of these functions have been redefined as macros in <span class='math'>binary_c</i></span> – these macros will deliberately fail the compilation process and hopefully give you a warning.</li> <li class="itemize_item">You must follow the conventions given above regarding memory allocation in <em><span class="flex_cstruct">stardata</span></em>.</li> </ul> -<div class="standard" id='magicparlabel-5704'>Please use the memory structures appropriately (see <a href="#subsec_Memory_Structures">8.3.3</a>). </div> -<h3 class="subsection" id='magicparlabel-5705'><span class="subsection_label">8.4</span> Output</h3> -<div class="standard" id='magicparlabel-5706'><div id="subsec_Output"></div> +<div class="standard" id='magicparlabel-5874'>Please use the memory structures appropriately (see <a href="#subsec_Memory_Structures">8.3.3</a>). </div> +<h3 class="subsection" id='magicparlabel-5875'><span class="subsection_label">8.4</span> Output</h3> +<div class="standard" id='magicparlabel-5876'><div id="subsec_Output"></div> </div> -<div class="standard" id='magicparlabel-5707'><span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5877'><span class='math'>binary_c</i></span> must communicate its results to you <em>somehow</em> otherwise what is the point? When running one star, it is sufficient to send output to either the screen (<span class="flex_cvar">stdout</span>) or to a file (with redirection, e.g. <span style='font-family:monospace;font-size: 18px;'>tbse > file</span>). When running millions of stars, output must be sent to, e.g., a function you define (usually <span class="flex_perlcode">parse_bse</span>) when using the <em><span class='math'>\binarygrid</span> </em>. In this case, either data is sent through a pipe (using the <span class="flex_scriptinglanguage">Perl</span> backend) or in an array in memory (using the <span class="flex_programminglanguage">C</span> backend). Thus, <span class='math'>binary_c</i></span> has to intercept your output and decide where to send it. This is done as follows.</div> -<ol class="enumerate" id='magicparlabel-5724'><li class="enumerate_item">Use <span class="flex_cmacro">Printf</span> instead of <span class="flex_cfunction">printf</span>: <span class="flex_cmacro">Printf</span> sends data to <span class="flex_cfunction">buffered_printf</span>. This stores raw output data in a buffer, and outputs either immediately, at the end of evolution, or not at all, depending on what you want to do with the buffer. It is up to you to clear out the buffer after evolution (or on a switch of <span class="flex_cstruct">stardata</span>) with a call to buffer_empty_buffer. You can get the pointer used to store the buffer from <span class="flex_cfunction">buffer_info</span>.</li> +<ol class="enumerate" id='magicparlabel-5894'><li class="enumerate_item">Use <span class="flex_cmacro">Printf</span> instead of <span class="flex_cfunction">printf</span>: <span class="flex_cmacro">Printf</span> sends data to <span class="flex_cfunction">buffered_printf</span>. This stores raw output data in a buffer, and outputs either immediately, at the end of evolution, or not at all, depending on what you want to do with the buffer. It is up to you to clear out the buffer after evolution (or on a switch of <span class="flex_cstruct">stardata</span>) with a call to buffer_empty_buffer. You can get the pointer used to store the buffer from <span class="flex_cfunction">buffer_info</span>.</li> <li class="enumerate_item">Use _printf to actually output to stdout using the <i>C</i>-library's <span class="flex_cfunction">fprintf</span> function.</li> <li class="enumerate_item"><b>warning: experimental </b>If <span class="flex_cmacro">BUFFERED_STACK</span> is defined, you can use <em><span class="flex_cfunction">binary_c_stack_printf</span></em>, which is a more advanced buffer with a full stack API (e.g. push and pop functions), that can include (<span class="flex_software">zlib</span>) compression. However, at present this is not used, and may never be a standard part of <span class='math'>binary_c</i></span> .</li> </ol> -<h4 class="subsubsection" id='magicparlabel-5767'><span class="subsubsection_label">8.4.1</span> Interaction with <i>binary_grid</i></h4> -<div class="standard" id='magicparlabel-5768'>The interaction between <span class='math'>binary_c</i></span> +<h4 class="subsubsection" id='magicparlabel-5937'><span class="subsubsection_label">8.4.1</span> Interaction with <i>binary_grid</i></h4> +<div class="standard" id='magicparlabel-5938'>The interaction between <span class='math'>binary_c</i></span> and <span class='math'>\binarygrid</span> depends very much on how data is output. When using the Perl backend, pipes are used to funnel data from <span class='math'>binary_c</i></span> to <span class='math'>\binarygrid</span> and vice versa. Output should be sent to <span class="flex_cvar">stdout</span>. When using the <i>C</i> backend, data is sent to the buffer and then the buffer accessed from Perl (via <span class="flex_perlmodule">Inline::C</span>, i.e. using <span class="flex_perlmodule">XS</span>) directly without ever being sent to <span class="flex_cvar">stdout</span>. This <em>should</em> be faster.</div> -<h3 class="subsection" id='magicparlabel-5785'><span class="subsection_label">8.5</span> Debugging <span class='math'>binary_c</i></span> +<h3 class="subsection" id='magicparlabel-5955'><span class="subsection_label">8.5</span> Debugging <span class='math'>binary_c</i></span> </h3> -<div class="standard" id='magicparlabel-5786'>I give here some general strategies for debugging <span class='math'>binary_c</i></span>, but of course there are many ways to debug code: you may know better ways, in which case please contribute to this manual!</div> -<h4 class="subsubsection" id='magicparlabel-5787'><span class="subsubsection_label">8.5.1</span> General strategy: <span class="flex_bashscript">tbse</span>, <span class='math'>\binarygrid</span> +<div class="standard" id='magicparlabel-5956'>I give here some general strategies for debugging <span class='math'>binary_c</i></span>, but of course there are many ways to debug code: you may know better ways, in which case please contribute to this manual!</div> +<h4 class="subsubsection" id='magicparlabel-5957'><span class="subsubsection_label">8.5.1</span> General strategy: <span class="flex_bashscript">tbse</span>, <span class='math'>\binarygrid</span> </h4> -<div class="standard" id='magicparlabel-5792'>The usual problem is that you are running a grid of stars and one star causes <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5962'>The usual problem is that you are running a grid of stars and one star causes <span class='math'>binary_c</i></span> to crash. If you are lucky, this does not bring down the whole grid, but it might (especially if you are using the <span class="flex_programminglanguage">C</span> backend). It is important to identify precisely which star caused the crash. You will find this very hard to do if you are running a grid with more than one thread, because any thread could have caused the crash. So, the first thing you must do is run your grid with only one thread, and with <span class='math'>\binarygrid</span> debugging level at least set to 3 (e.g. run <span style='font-family:monospace;font-size: 18px;'><script> vb=3</span>). This will tell you the arguments which were sent to <span class='math'>binary_c</i></span> that caused the crash. Save these to a file.</div> -<div class="standard" id='magicparlabel-5797'>Next, you should use the <span class="flex_bashscript">tbse</span> (Test Binary Star Evolution) script to run <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5967'>Next, you should use the <span class="flex_bashscript">tbse</span> (Test Binary Star Evolution) script to run <span class='math'>binary_c</i></span> with these arguments. This is very easy, just run</div> -<div class="standard" id='magicparlabel-5802'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-5972'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ tbse <filename></pre><br /> </span></div> -<div class="standard" id='magicparlabel-5807'>You should see output, and (hopefully) the same failure as caused the grid to crash. Now you can debug <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-5977'>You should see output, and (hopefully) the same failure as caused the grid to crash. Now you can debug <span class='math'>binary_c</i></span> properly, in an isolated test case.</div> -<div class="standard" id='magicparlabel-5808'>Note that the idea of isolating a test case which causes a failure is good practice in science and engineering in general, so you're doing nothing unusual here. The strategy now is:</div> +<div class="standard" id='magicparlabel-5978'>Note that the idea of isolating a test case which causes a failure is good practice in science and engineering in general, so you're doing nothing unusual here. The strategy now is:</div> -<ul class="itemize" id='magicparlabel-5809'><li class="itemize_item">If you are seeing a segmentation fault, you probably want to now debug with <span class="flex_software">valgrind</span> or <em><span class="flex_software">gdb</span></em>.</li> +<ul class="itemize" id='magicparlabel-5979'><li class="itemize_item">If you are seeing a segmentation fault, you probably want to now debug with <span class="flex_software">valgrind</span> or <em><span class="flex_software">gdb</span></em>.</li> <li class="itemize_item">If your problem is in your algorithm and is not really a coding error as such, you probably want to use the internal debugging with <span class="flex_cmacro">DEBUG</span>, <span class="flex_cmacro">DEBUG_EXP</span> and <span class="flex_cmacro">Dprint</span>. See Section <a href="#subsec_DEBUG__DEBUG_EXP_and">8.5.3</a> below.</li> </ul> -<h4 class="subsubsection" id='magicparlabel-5831'><span class="subsubsection_label">8.5.2</span> Configure script and debug builds<div id="subsec_debug_builds"></div> +<h4 class="subsubsection" id='magicparlabel-6001'><span class="subsubsection_label">8.5.2</span> Configure script and debug builds<div id="subsec_debug_builds"></div> </h4> -<div class="standard" id='magicparlabel-5832'>When debugging, it is important to disable any optimisation the compiler uses and turn on options that allow the code to be debugged with <span class="flex_software">gdb</span> and/or <em><span class="flex_software">valgrind</span></em>, and use the <span class="flex_cmacro">backtrace</span> feature (you must have <span class="flex_software">libbacktrace</span> installed, see Section <a href="#subsec_Backtrace">8.5.4</a>). To do this, run</div> +<div class="standard" id='magicparlabel-6002'>When debugging, it is important to disable any optimisation the compiler uses and turn on options that allow the code to be debugged with <span class="flex_software">gdb</span> and/or <em><span class="flex_software">valgrind</span></em>, and use the <span class="flex_cmacro">backtrace</span> feature (you must have <span class="flex_software">libbacktrace</span> installed, see Section <a href="#subsec_Backtrace">8.5.4</a>). To do this, run</div> -<div class="standard" id='magicparlabel-5849'><br /> +<div class="standard" id='magicparlabel-6019'><br /> <pre class\s*='listings bash'>$ ./configure debug $ make cleanall $ make</pre><br /> to make a “debug build”. You should use the <span class="flex_software">gcc</span><em> </em>compiler to debug, e.g., <span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ export CC=gcc</pre><br /> </span>prior to running <span class="flex_bashscript">configure</span>. While others, e.g. <em><span class="flex_software">clang</span></em>, probably work just fine, these have not been extensively tested. </div> -<h4 class="subsubsection" id='magicparlabel-5872'><span class="subsubsection_label">8.5.3</span> DEBUG, DEBUG_EXP and Dprint<div id="subsec_DEBUG__DEBUG_EXP_and"></div> +<h4 class="subsubsection" id='magicparlabel-6042'><span class="subsubsection_label">8.5.3</span> DEBUG, DEBUG_EXP and Dprint<div id="subsec_DEBUG__DEBUG_EXP_and"></div> </h4> -<div class="standard" id='magicparlabel-5873'>Internal debugging in <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-6043'>Internal debugging in <span class='math'>binary_c</i></span> is very useful to determine where an algorithm fails. It is not so useful in determining where segmentation faults and memory errors occur, although it is obviously useful in the sense that debugging will continue until a crash. </div> -<div class="standard" id='magicparlabel-5874'>To enable internal debugging, edit code_options.h and set the appropriate line <span style='font-family:monospace;font-size: 18px;'>#define DEBUG 1</span>. You will then need to rebuild the all the code (see <a href="#subsec_debug_builds">8.5.2</a>). </div> +<div class="standard" id='magicparlabel-6044'>To enable internal debugging, edit code_options.h and set the appropriate line <span style='font-family:monospace;font-size: 18px;'>#define DEBUG 1</span>. You will then need to rebuild the all the code (see <a href="#subsec_debug_builds">8.5.2</a>). </div> -<div class="standard" id='magicparlabel-5875'>When you now run <em>tbse</em> you will see many lines of data. These correspond to <span class="flex_cmacro">Dprint</span> (i.e. “debug-print”) lines in the code. </div> +<div class="standard" id='magicparlabel-6045'>When you now run <em>tbse</em> you will see many lines of data. These correspond to <span class="flex_cmacro">Dprint</span> (i.e. “debug-print”) lines in the code. </div> -<div class="standard" id='magicparlabel-5880'>There are often too many lines of data. You can restrict the data output by defining the <span class="flex_cmacro">DEBUG_EXP</span> macro. There is only output when this is true (in a <span class="flex_programminglanguage">C</span> sense of truth) so it is usually set to 1. However, you can always restrict to, say, outputting between 9 and 10 Gyr:</div> +<div class="standard" id='magicparlabel-6050'>There are often too many lines of data. You can restrict the data output by defining the <span class="flex_cmacro">DEBUG_EXP</span> macro. There is only output when this is true (in a <span class="flex_programminglanguage">C</span> sense of truth) so it is usually set to 1. However, you can always restrict to, say, outputting between 9 and 10 Gyr:</div> -<div class="standard" id='magicparlabel-5889'><br /> +<div class="standard" id='magicparlabel-6059'><br /> <pre class ='listings <i>C</i>'>#define DEBUG_EXP (stardata->model.time > 9000 && stardata->model.time < 10000)</pre><br /> You will almost always have <span class="flex_cstruct">stardata</span><em> </em>available to <span class="flex_cmacro">Dprint</span>. </div> -<div class="standard" id='magicparlabel-5902'>There are many other debugging options listed in debug_macros.h, most of which are not useful to you.</div> +<div class="standard" id='magicparlabel-6072'>There are many other debugging options listed in debug_macros.h, most of which are not useful to you.</div> -<div class="standard" id='magicparlabel-5903'>You can change the output of <span class="flex_cmacro">Dprint</span> in <span class="flex_cmacro">src/debug/debug_fprintf.c</span></div> +<div class="standard" id='magicparlabel-6073'>You can change the output of <span class="flex_cmacro">Dprint</span> in <span class="flex_cmacro">src/debug/debug_fprintf.c</span></div> -<div class="standard" id='magicparlabel-5912'>Another macro, <span class="flex_cmacro">Dprint_no_newline</span>, is the same as <span class="flex_cmacro">Dprint</span> but without a “<span class="flex_cmacro">\n</span>” newline at the end of the string.</div> -<h4 class="subsubsection" id='magicparlabel-5925'><span class="subsubsection_label">8.5.4</span> Backtrace<div id="subsec_Backtrace"></div> +<div class="standard" id='magicparlabel-6082'>Another macro, <span class="flex_cmacro">Dprint_no_newline</span>, is the same as <span class="flex_cmacro">Dprint</span> but without a “<span class="flex_cmacro">\n</span>” newline at the end of the string.</div> +<h4 class="subsubsection" id='magicparlabel-6095'><span class="subsubsection_label">8.5.4</span> Backtrace<div id="subsec_Backtrace"></div> </h4> -<div class="standard" id='magicparlabel-5926'>If <span class="flex_cmacro">BACKTRACE</span> is defined (in <span class="flex_headerfile">binary_c_code_options.h</span>) you have access to stack tracing features similar to those used in debuggers. Please install <span class="flex_software">libbacktrace</span> before expecting this to work. Calling the <span class="flex_cmacro">Backtrace</span> macro (with no arguments) allows you to see a list of callers of any function, anywhere in <span class='math'>binary_c</i></span>, through the <span class="flex_cfunction">print_trace</span> function. This is a very useful feature if you want to see which function called the function in which you have a problem. Note that it is, however, quite slow, and requires a debug build.</div> +<div class="standard" id='magicparlabel-6096'>If <span class="flex_cmacro">BACKTRACE</span> is defined (in <span class="flex_headerfile">binary_c_code_options.h</span>) you have access to stack tracing features similar to those used in debuggers. Please install <span class="flex_software">libbacktrace</span> before expecting this to work. Calling the <span class="flex_cmacro">Backtrace</span> macro (with no arguments) allows you to see a list of callers of any function, anywhere in <span class='math'>binary_c</i></span>, through the <span class="flex_cfunction">print_trace</span> function. This is a very useful feature if you want to see which function called the function in which you have a problem. Note that it is, however, quite slow, and requires a debug build.</div> -<div class="standard" id='magicparlabel-5947'>Note that this feature has not been tested on platforms other than Linux.</div> -<h4 class="subsubsection" id='magicparlabel-5948'><span class="subsubsection_label">8.5.5</span> Segmentation faults<div id="subsec_Segmentation_faults"></div> +<div class="standard" id='magicparlabel-6117'>Note that this feature has not been tested on platforms other than Linux.</div> +<h4 class="subsubsection" id='magicparlabel-6118'><span class="subsubsection_label">8.5.5</span> Segmentation faults<div id="subsec_Segmentation_faults"></div> </h4> -<div class="standard" id='magicparlabel-5949'>As with any code with large chunks of data being dynamically allocated, any attempt to access data which is not allocated leads to a segmentation fault. It is often extremely difficult to determine where the cause lies, as it may be somewhere previous in the program, or even on another thread. Should you encounter such a segmentation fault, please try running through <span class="flex_software">gdb</span> and/or <span class="flex_software">valgrind</span>.</div> -<h4 class="subsubsection" id='magicparlabel-5958'><span class="subsubsection_label">8.5.6</span> gdb</h4> -<div class="standard" id='magicparlabel-5959'>The <i>GNU</i> debugger, <span class="flex_software">gdb</span>, is a useful option for quickly finding the location of a segmentation fault. Run</div> +<div class="standard" id='magicparlabel-6119'>As with any code with large chunks of data being dynamically allocated, any attempt to access data which is not allocated leads to a segmentation fault. It is often extremely difficult to determine where the cause lies, as it may be somewhere previous in the program, or even on another thread. Should you encounter such a segmentation fault, please try running through <span class="flex_software">gdb</span> and/or <span class="flex_software">valgrind</span>.</div> +<h4 class="subsubsection" id='magicparlabel-6128'><span class="subsubsection_label">8.5.6</span> gdb</h4> +<div class="standard" id='magicparlabel-6129'>The <i>GNU</i> debugger, <span class="flex_software">gdb</span>, is a useful option for quickly finding the location of a segmentation fault. Run</div> -<div class="standard" id='magicparlabel-5964'><br /> +<div class="standard" id='magicparlabel-6134'><br /> <pre class\s*='listings bash'>$ tbse debug</pre><br /> to launch<em> <span class='math'>binary_c</i></span> </em>with <span class="flex_software">gdb</span>. Once the crash has happened, use the backtrace command <span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings'>bt</pre><br /> </span> to run a back trace and locate the cause of the crash.</div> -<h4 class="subsubsection" id='magicparlabel-5977'><span class="subsubsection_label">8.5.7</span> valgrind and friends</h4> -<div class="standard" id='magicparlabel-5978'><span class="flex_software">Valgrind</span> is a step up in technology from <em><span class="flex_software">gdb</span></em>. It not only locates segmentation faults, it also determines when (heap) memory is overwritten when it should not be, or unallocated memory is accessed. These are the two main causes of segmentation faults, so valgrind really is your friend.</div> +<h4 class="subsubsection" id='magicparlabel-6147'><span class="subsubsection_label">8.5.7</span> valgrind and friends</h4> +<div class="standard" id='magicparlabel-6148'><span class="flex_software">Valgrind</span> is a step up in technology from <em><span class="flex_software">gdb</span></em>. It not only locates segmentation faults, it also determines when (heap) memory is overwritten when it should not be, or unallocated memory is accessed. These are the two main causes of segmentation faults, so valgrind really is your friend.</div> -<div class="standard" id='magicparlabel-5987'>There are many tools associated with <em><span class="flex_software">valgrind</span></em>:</div> +<div class="standard" id='magicparlabel-6157'>There are many tools associated with <em><span class="flex_software">valgrind</span></em>:</div> -<ul class="itemize" id='magicparlabel-5992'><li class="itemize_item"><em>memcheck</em>: this is the standard <span class="flex_software">valgrind</span><em> </em>tool for finding problems with (heap) memory access issues that lead to segfaults. Because the memory allocated in <em><span class='math'>binary_c</i></span> +<ul class="itemize" id='magicparlabel-6162'><li class="itemize_item"><em>memcheck</em>: this is the standard <span class="flex_software">valgrind</span><em> </em>tool for finding problems with (heap) memory access issues that lead to segfaults. Because the memory allocated in <em><span class='math'>binary_c</i></span> </em> is mostly on the the heap (e.g. <span class="flex_cstruct">stardata</span><em> </em>is allocated with <span class="flex_cmacro">MALLOC</span>) it is the most useful of <span class="flex_software">valgrind</span>'s tools. <br /> @@ -6327,24 +6376,24 @@ Run this with <pre class\s*='listings bash'>$ tbse drd</pre><br /> </li> </ul> -<div class="standard" id='magicparlabel-6046'>You can override the arguments sent to <span class="flex_software">valgrind</span> by <span class="flex_bashscript">tbse</span> by setting the environment variable <span class="flex_envvar">VALGRIND_ARGS</span>.</div> -<h4 class="subsubsection" id='magicparlabel-6059'><span class="subsubsection_label">8.5.8</span> Thread safety</h4> -<h4 class="subsubsection" id='magicparlabel-6060'><span class="subsubsection_label">8.5.9</span> NaN (not a number) checks</h4> -<div class="standard" id='magicparlabel-6061'>If <span class="flex_cmacro">NANCHECKS</span> is defined, you can use the <span class="flex_cmacro">Nancheck(X)</span> macro to test whether <span class="flex_cvar">X</span> is NaN. Note that checking for NaNs is computationally expensive, and you normally (once you trust your code) want <span class="flex_cmacro">NANCHECKS</span> to be undefined. If a NaN is detected, <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-6216'>You can override the arguments sent to <span class="flex_software">valgrind</span> by <span class="flex_bashscript">tbse</span> by setting the environment variable <span class="flex_envvar">VALGRIND_ARGS</span>.</div> +<h4 class="subsubsection" id='magicparlabel-6229'><span class="subsubsection_label">8.5.8</span> Thread safety</h4> +<h4 class="subsubsection" id='magicparlabel-6230'><span class="subsubsection_label">8.5.9</span> NaN (not a number) checks</h4> +<div class="standard" id='magicparlabel-6231'>If <span class="flex_cmacro">NANCHECKS</span> is defined, you can use the <span class="flex_cmacro">Nancheck(X)</span> macro to test whether <span class="flex_cvar">X</span> is NaN. Note that checking for NaNs is computationally expensive, and you normally (once you trust your code) want <span class="flex_cmacro">NANCHECKS</span> to be undefined. If a NaN is detected, <span class='math'>binary_c</i></span> will segfault itself.</div> -<h3 class="subsection" id='magicparlabel-6078'><span class="subsection_label">8.6</span> Events<div id="subsec_Events"></div> +<h3 class="subsection" id='magicparlabel-6248'><span class="subsection_label">8.6</span> Events<div id="subsec_Events"></div> </h3> -<div class="standard" id='magicparlabel-6079'>Starting from 2.0pre33 <span class='math'>binary_c</i></span> - has a new events system. It now behaves more like a proper stellar evolution code, in that at each timestep derivatives of variables are calculated, then applied, and events that are set during the calculation (e.g. supernovae, common-envelope evolution, contact) are <em>then</em> applied. This allows the use of more advanced integrators than the standard forward Euler scheme. At the time of writing, RK2, RK4 and a predictor-corrector are alternatives, although the forward Euler is still the standard and fastest<div class="foot"><span class="foot_label">9</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-6083'>Forward Euler is standard except in the tidal calculations, some of which are calculated analytically, then linear derivatives are computed from these assuming everything else (stellar properties, etc.) in a hybrid scheme to avoid numerical instability.</div> +<div class="standard" id='magicparlabel-6249'>Starting from 2.0pre33 <span class='math'>binary_c</i></span> + has a new events system. It now behaves more like a proper stellar evolution code, in that at each timestep derivatives of variables are calculated, then applied, and events that are set during the calculation (e.g. supernovae, common-envelope evolution, contact) are <em>then</em> applied. This allows the use of more advanced integrators than the standard forward Euler scheme. At the time of writing, RK2, RK4 and a predictor-corrector are alternatives, although the forward Euler is still the standard and fastest<div class="foot"><span class="foot_label">10</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-6253'>Forward Euler is standard except in the tidal calculations, some of which are calculated analytically, then linear derivatives are computed from these assuming everything else (stellar properties, etc.) in a hybrid scheme to avoid numerical instability.</div> </div></div>.</div> -<div class="standard" id='magicparlabel-6084'>Events are stored on the event stack and then processed from the top to the bottom of the stack at the end of the timestep, if it is a successful timestep.</div> -<h4 class="subsubsection" id='magicparlabel-6085'><span class="subsubsection_label">8.6.1</span> Queueing an event on the event stack</h4> -<div class="standard" id='magicparlabel-6086'>Events are added with the <span class="flex_cmacro">Add_new_event</span> macro. This returns an integer which is the event number, if greater than or equal to zero, its index number on the event stack. If the integer is <span class="flex_cmacro">BINARY_C_EVENT_DENIED</span> (which is <span style='font-family:monospace;font-size: 18px;'>-1</span> so can never be an index) then the event has, for some reason, been refused.</div> +<div class="standard" id='magicparlabel-6254'>Events are stored on the event stack and then processed from the top to the bottom of the stack at the end of the timestep, if it is a successful timestep.</div> +<h4 class="subsubsection" id='magicparlabel-6255'><span class="subsubsection_label">8.6.1</span> Queueing an event on the event stack</h4> +<div class="standard" id='magicparlabel-6256'>Events are added with the <span class="flex_cmacro">Add_new_event</span> macro. This returns an integer which is the event number, if greater than or equal to zero, its index number on the event stack. If the integer is <span class="flex_cmacro">BINARY_C_EVENT_DENIED</span> (which is <span style='font-family:monospace;font-size: 18px;'>-1</span> so can never be an index) then the event has, for some reason, been refused.</div> -<div class="standard" id='magicparlabel-6095'>The <span class="flex_cmacro">Add_new_event</span> macro call takes a number of arguments:</div> +<div class="standard" id='magicparlabel-6265'>The <span class="flex_cmacro">Add_new_event</span> macro call takes a number of arguments:</div> -<ul class="itemize" id='magicparlabel-6100'><li class="itemize_item"><span class="flex_cstruct">stardata</span>: the usual pointer to a <span class="flex_cstruct">stardata</span> struct</li> +<ul class="itemize" id='magicparlabel-6270'><li class="itemize_item"><span class="flex_cstruct">stardata</span>: the usual pointer to a <span class="flex_cstruct">stardata</span> struct</li> <li class="itemize_item"><span class="flex_cvar">event_type</span>: an integer identifying the event type. There are defined in <span class="flex_headerfile">events_macros.h</span></li> <li class="itemize_item"><span class="flex_cvar">event_handler_function</span>: this is a pointer to a function to be called when the event is triggered. This is required to be non-<span class="flex_cmacro">NULL</span>.</li> <li class="itemize_item"><span class="flex_cvar">erase_event_handler_function</span>: this is a pointer to a function to be called when the event is erased. Ignored if <span class="flex_cmacro">NULL</span>.</li> @@ -6355,9 +6404,9 @@ Run this with <pre class ='listings <i>C</i>'>unique==FALSE</pre><br /> .</li> </ul> -<div class="standard" id='magicparlabel-6162'>The calling function should check the return value, and clean up any memory if required after a denial. For example, the following is the code to initiate dynamical common envelope evolution in the RLOF routines.</div> +<div class="standard" id='magicparlabel-6332'>The calling function should check the return value, and clean up any memory if required after a denial. For example, the following is the code to initiate dynamical common envelope evolution in the RLOF routines.</div> -<div class="standard" id='magicparlabel-6163'><br /> +<div class="standard" id='magicparlabel-6333'><br /> <pre class ='listings <i>C</i>'> struct binary_c_new_common_envelope_event_t * event_data = MALLOC(sizeof(struct binary_c_new_common_envelope_event_t)); if(Add_new_event(stardata, @@ -6377,9 +6426,9 @@ Run this with Dprint("added event!\n"); }</pre><br /> </div> -<h4 class="subsubsection" id='magicparlabel-6185'><span class="subsubsection_label">8.6.2</span> Testing the event stack</h4> +<h4 class="subsubsection" id='magicparlabel-6355'><span class="subsubsection_label">8.6.2</span> Testing the event stack</h4> -<ul class="itemize" id='magicparlabel-6186'><li class="itemize_item">Call the <span class="flex_cfunction">events_pending</span> function to return <span class="flex_cmacro">TRUE</span> if there are events pending, <span class="flex_cmacro">FALSE</span> otherwise.<br /> +<ul class="itemize" id='magicparlabel-6356'><li class="itemize_item">Call the <span class="flex_cfunction">events_pending</span> function to return <span class="flex_cmacro">TRUE</span> if there are events pending, <span class="flex_cmacro">FALSE</span> otherwise.<br /> <pre class ='listings <i>C</i>'>Boolean x = events_pending(stardata);</pre><br /> </li> <li class="itemize_item">Call <span class="flex_cfunction">events_pending_of_type</span> to return <dfn class='lyxnoun'><span class="flex_cmacro"><dfn class='lyxnoun'>TRUE</dfn></span></dfn> if there are events of a given type pending, <span class="flex_cmacro">FALSE</span> otherwise.<br /> @@ -6391,29 +6440,29 @@ printf(“Event stack: %s\n”,evstring); Safe_free(evstring);</pre><br /> </li> </ul> -<h4 class="subsubsection" id='magicparlabel-6239'><span class="subsubsection_label">8.6.3</span> Erase the stack</h4> -<div class="standard" id='magicparlabel-6240'>The entire stack can be deleted by calling <span class="flex_cfunction">erase_events</span>. The <span style='font-family:monospace;font-size: 18px;'><span class="flex_cvar"><span style='font-family:monospace;font-size: 18px;'>void*</span></span></span> data associated with each event is freed.</div> +<h4 class="subsubsection" id='magicparlabel-6409'><span class="subsubsection_label">8.6.3</span> Erase the stack</h4> +<div class="standard" id='magicparlabel-6410'>The entire stack can be deleted by calling <span class="flex_cfunction">erase_events</span>. The <span style='font-family:monospace;font-size: 18px;'><span class="flex_cvar"><span style='font-family:monospace;font-size: 18px;'>void*</span></span></span> data associated with each event is freed.</div> -<div class="standard" id='magicparlabel-6249'><br /> +<div class="standard" id='magicparlabel-6419'><br /> <pre class ='listings <i>C</i>'>erase_events(stardata);</pre><br /> This function is called automatically when a timestep is rejected from <span class="flex_cfunction">evolution_rejected()</span>.</div> -<div class="standard" id='magicparlabel-6258'>You can also call <span class="flex_cfunction">erase_events_of_type</span><br /> +<div class="standard" id='magicparlabel-6428'>You can also call <span class="flex_cfunction">erase_events_of_type</span><br /> <pre class ='listings <i>C</i>'>erase_events_of_type(stardata,type,except);</pre><br /> which will erase all events of given <span class="flex_cvar">type</span> except the event <span class="flex_cvar">except</span>. If the type is <span class="flex_cvar">-1</span> then events of any type are removed, except <span class="flex_cvar">except</span>. If <span class="flex_cvar">except</span> is <span class="flex_cmacro">NULL</span> then all events of the given type are removed.</div> -<div class="standard" id='magicparlabel-6291'>You can erase an event without altering the event stack by calling<br /> +<div class="standard" id='magicparlabel-6461'>You can erase an event without altering the event stack by calling<br /> <pre class ='listings <i>C</i>'>erase_event(stardata,&event);</pre><br /> but beware that this will mess up the stack and <span class='math'>binary_c</i></span> is likely to be very confused.</div> -<div class="standard" id='magicparlabel-6296'>When events are erased, the optional <span class="flex_cfunction">erase_event_handler_function()</span> function is called, with the same arguments as the event handler function. You can use this to clean up any allocated memory.</div> -<h4 class="subsubsection" id='magicparlabel-6301'><span class="subsubsection_label">8.6.4</span> Catch events</h4> -<div class="standard" id='magicparlabel-6302'>At the end of each (successful) timestep, <span class="flex_cfunction">catch_events</span> is called. This function loops through the stack, triggering each event by calling the handler function and sending it the event data as well as <span class="flex_cstruct">stardata</span>. Event data is freed automatically after the event is triggered, as is the event itself.</div> -<h4 class="subsubsection" id='magicparlabel-6311'><span class="subsubsection_label">8.6.5</span> Event handler functions</h4> -<div class="standard" id='magicparlabel-6312'>The event handler functions should look like the following, again using the common-envelope code as an example.</div> +<div class="standard" id='magicparlabel-6466'>When events are erased, the optional <span class="flex_cfunction">erase_event_handler_function()</span> function is called, with the same arguments as the event handler function. You can use this to clean up any allocated memory.</div> +<h4 class="subsubsection" id='magicparlabel-6471'><span class="subsubsection_label">8.6.4</span> Catch events</h4> +<div class="standard" id='magicparlabel-6472'>At the end of each (successful) timestep, <span class="flex_cfunction">catch_events</span> is called. This function loops through the stack, triggering each event by calling the handler function and sending it the event data as well as <span class="flex_cstruct">stardata</span>. Event data is freed automatically after the event is triggered, as is the event itself.</div> +<h4 class="subsubsection" id='magicparlabel-6481'><span class="subsubsection_label">8.6.5</span> Event handler functions</h4> +<div class="standard" id='magicparlabel-6482'>The event handler functions should look like the following, again using the common-envelope code as an example.</div> -<div class="standard" id='magicparlabel-6313'><br /> +<div class="standard" id='magicparlabel-6483'><br /> <pre class ='listings'>Event_handler_function common_envelope_event_handler(void * eventp, struct stardata_t * stardata, void * data) @@ -6431,9 +6480,9 @@ but beware that this will mess up the stack and <span class='math'>binary_c</i>< /* ... now do stuff with donor and accretor ... */</pre><br /> </div> -<h3 class="subsection" id='magicparlabel-6333'><span class="subsection_label">8.7</span> Timestepping<div id="subsec_Timestepping"></div> +<h3 class="subsection" id='magicparlabel-6503'><span class="subsection_label">8.7</span> Timestepping<div id="subsec_Timestepping"></div> </h3> -<div class="standard" id='magicparlabel-6334'>The <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-6504'>The <span class='math'>binary_c</i></span> timestepping algorithm aims to smoothly, but efficiently, evolve your binary-star systems in time while maintaining a reasonable level of accuracy. The subroutine <span class="flex_cfunction">stellar_timestep</span> sets the timestep for each star and/or the binary system as a whole. Usually, timesteps relate a change in variable <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>x</mi> </mrow></mstyle></math> to its time derivative <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -6537,11 +6586,11 @@ but beware that this will mess up the stack and <span class='math'>binary_c</i>< <pre class ='listings <i>C</i>'>#define DT_LIMIT_TIDES 44</pre><br /> </div> -<div class="standard" id='magicparlabel-6367'>If you want to know what is limiting the timestep, the easiest way is to uncomment the line<br /> +<div class="standard" id='magicparlabel-6537'>If you want to know what is limiting the timestep, the easiest way is to uncomment the line<br /> <pre class ='listings <i>C</i>'>#define ___LOGGING</pre><br /> which is near the bottom of the <span class="flex_cfunction">stellar_timestep</span> function. This will output, on every timestep, the timestep for each star and which limiter gave the smallest timestep.</div> -<h4 class="subsubsection" id='magicparlabel-6376'><span class="subsubsection_label">8.7.1</span> Fixed timesteps</h4> -<div class="standard" id='magicparlabel-6377'>Often you will want to output at a given fixed timestep, e.g. every <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<h4 class="subsubsection" id='magicparlabel-6546'><span class="subsubsection_label">8.7.1</span> Fixed timesteps</h4> +<div class="standard" id='magicparlabel-6547'>Often you will want to output at a given fixed timestep, e.g. every <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mn>1</mn><mspace width="6px" /> <mstyle mathvariant='normal'> @@ -6581,76 +6630,76 @@ then in <span class="flex_cfunction">setup_fixed_timesteps</span> define the pro t->previous_trigger = t->previous_test = t->begin; // set trigger</pre><br /> You can also have fixed intervals of logarithmic time by settings <span class="flex_cvar">t->logarithmic</span> to <span class="flex_cmacro">TRUE</span>.</div> -<h3 class="subsection" id='magicparlabel-6412'><span class="subsection_label">8.8</span> Code layout, header files, flow</h3> -<div class="standard" id='magicparlabel-6413'><div id="subsec_Code_layout"></div> +<h3 class="subsection" id='magicparlabel-6582'><span class="subsection_label">8.8</span> Code layout, header files, flow</h3> +<div class="standard" id='magicparlabel-6583'><div id="subsec_Code_layout"></div> The code is split into a series of directories. Some header file information is in <a href="#subsec_Advanced_Configuration">9</a>.</div> -<h4 class="subsubsection" id='magicparlabel-6414'><span class="subsubsection_label">8.8.1</span> API</h4> -<div class="standard" id='magicparlabel-6415'>You can build <i>binary_c</i> as a shared library, and enable the API interface. The functions which do this are in this directory.</div> -<h4 class="subsubsection" id='magicparlabel-6416'><span class="subsubsection_label">8.8.2</span> batchmode</h4> -<div class="standard" id='magicparlabel-6417'>The batch mode functions handle the use of <i>binary_c</i> as part of <i>binary_grid</i>. Essentially they are a loop wrapped around the evolution functions which also scans arguments passed from <i>binary_grid</i> as if they were command line arguments.</div> -<h4 class="subsubsection" id='magicparlabel-6418'><span class="subsubsection_label">8.8.3</span> binary_star_functions</h4> -<div class="standard" id='magicparlabel-6419'><div id="subsec_binary_star_functions"></div> +<h4 class="subsubsection" id='magicparlabel-6584'><span class="subsubsection_label">8.8.1</span> API</h4> +<div class="standard" id='magicparlabel-6585'>You can build <i>binary_c</i> as a shared library, and enable the API interface. The functions which do this are in this directory.</div> +<h4 class="subsubsection" id='magicparlabel-6586'><span class="subsubsection_label">8.8.2</span> batchmode</h4> +<div class="standard" id='magicparlabel-6587'>The batch mode functions handle the use of <i>binary_c</i> as part of <i>binary_grid</i>. Essentially they are a loop wrapped around the evolution functions which also scans arguments passed from <i>binary_grid</i> as if they were command line arguments.</div> +<h4 class="subsubsection" id='magicparlabel-6588'><span class="subsubsection_label">8.8.3</span> binary_star_functions</h4> +<div class="standard" id='magicparlabel-6589'><div id="subsec_binary_star_functions"></div> This directory contains functions which deal with the binary system such as Roche-Lobe radius calculation, contact systems (<span class="flex_sourcefile">contact_system.c</span>), stellar mergers (<span class="flex_sourcefile">mix.c</span>) and common envelope evolution (<span class="flex_sourcefile">common_envelope_evolution.c</span>). </div> -<h4 class="subsubsection" id='magicparlabel-6432'><span class="subsubsection_label">8.8.4</span> buffering</h4> -<div class="standard" id='magicparlabel-6433'>These functions provide an interface with <em><i>binary_grid</i></em> that improves buffering and hence <em><i>binary_grid</i></em>'s performance. When you use the <span class="flex_cmacro">Printf</span> macro, rather than <span class="flex_programminglanguage">C</span>'s native <span class="flex_cfunction">printf</span> routine, you are using the routines in here to put data into a memory buffer which is then sent to <i>binary_grid</i> for processing and statistical analysis.</div> -<h4 class="subsubsection" id='magicparlabel-6446'><span class="subsubsection_label">8.8.5</span> common_envelope</h4> -<div class="standard" id='magicparlabel-6447'>Common envelope evolution is dealt with in here. At present there is only the <span class="flex_software">BSE</span> algorithm, but you could put your own in here too.</div> -<h4 class="subsubsection" id='magicparlabel-6452'><span class="subsubsection_label">8.8.6</span> debug</h4> -<div class="standard" id='magicparlabel-6453'>This contains various debugging functions, such as <span class="flex_cfunction">debug_fprintf</span> which is called when you put <span class="flex_cmacro">Dprint</span> statements into <i>binary_c</i>. The <span class="flex_cfunction">backtrace</span> functionality is also in this directory, as is the <span class="flex_cfunction">show_stardata</span> function which allows you to output, in a readable way, the contents of a <span class="flex_cstruct">stardata</span> structure. Given this you can compare one structure's contents to another quickly and easily.</div> -<h4 class="subsubsection" id='magicparlabel-6474'><span class="subsubsection_label">8.8.7</span> disc</h4> -<div class="standard" id='magicparlabel-6475'>Work in progress, please ask RGI for details.</div> -<h4 class="subsubsection" id='magicparlabel-6476'><span class="subsubsection_label">8.8.8</span> envelope_intgeration</h4> -<div class="standard" id='magicparlabel-6477'>Experimental code.</div> -<h4 class="subsubsection" id='magicparlabel-6478'><span class="subsubsection_label">8.8.9</span> equation_of_state</h4> -<div class="standard" id='magicparlabel-6479'>Experimental code.</div> -<h4 class="subsubsection" id='magicparlabel-6480'><span class="subsubsection_label">8.8.10</span> events</h4> -<div class="standard" id='magicparlabel-6481'>See section <a href="#subsec_Events">8.6</a>.</div> -<h4 class="subsubsection" id='magicparlabel-6482'><span class="subsubsection_label">8.8.11</span> evolution</h4> -<div class="standard" id='magicparlabel-6483'><div id="subsec_evolution"></div> +<h4 class="subsubsection" id='magicparlabel-6602'><span class="subsubsection_label">8.8.4</span> buffering</h4> +<div class="standard" id='magicparlabel-6603'>These functions provide an interface with <em><i>binary_grid</i></em> that improves buffering and hence <em><i>binary_grid</i></em>'s performance. When you use the <span class="flex_cmacro">Printf</span> macro, rather than <span class="flex_programminglanguage">C</span>'s native <span class="flex_cfunction">printf</span> routine, you are using the routines in here to put data into a memory buffer which is then sent to <i>binary_grid</i> for processing and statistical analysis.</div> +<h4 class="subsubsection" id='magicparlabel-6616'><span class="subsubsection_label">8.8.5</span> common_envelope</h4> +<div class="standard" id='magicparlabel-6617'>Common envelope evolution is dealt with in here. At present there is only the <span class="flex_software">BSE</span> algorithm, but you could put your own in here too.</div> +<h4 class="subsubsection" id='magicparlabel-6622'><span class="subsubsection_label">8.8.6</span> debug</h4> +<div class="standard" id='magicparlabel-6623'>This contains various debugging functions, such as <span class="flex_cfunction">debug_fprintf</span> which is called when you put <span class="flex_cmacro">Dprint</span> statements into <i>binary_c</i>. The <span class="flex_cfunction">backtrace</span> functionality is also in this directory, as is the <span class="flex_cfunction">show_stardata</span> function which allows you to output, in a readable way, the contents of a <span class="flex_cstruct">stardata</span> structure. Given this you can compare one structure's contents to another quickly and easily.</div> +<h4 class="subsubsection" id='magicparlabel-6644'><span class="subsubsection_label">8.8.7</span> disc</h4> +<div class="standard" id='magicparlabel-6645'>Work in progress, please ask RGI for details.</div> +<h4 class="subsubsection" id='magicparlabel-6646'><span class="subsubsection_label">8.8.8</span> envelope_intgeration</h4> +<div class="standard" id='magicparlabel-6647'>Experimental code.</div> +<h4 class="subsubsection" id='magicparlabel-6648'><span class="subsubsection_label">8.8.9</span> equation_of_state</h4> +<div class="standard" id='magicparlabel-6649'>Experimental code.</div> +<h4 class="subsubsection" id='magicparlabel-6650'><span class="subsubsection_label">8.8.10</span> events</h4> +<div class="standard" id='magicparlabel-6651'>See section <a href="#subsec_Events">8.6</a>.</div> +<h4 class="subsubsection" id='magicparlabel-6652'><span class="subsubsection_label">8.8.11</span> evolution</h4> +<div class="standard" id='magicparlabel-6653'><div id="subsec_evolution"></div> The time integration, i.e. evolution, of the binary system. This contains the logic flow of the <em><i>binary_c</i></em> code. Of interest to the general user are:</div> -<ul class="itemize" id='magicparlabel-6484'><li class="itemize_item"><span class="flex_cfunction">evolve_system_binary_c</span> is the main time loop which sets up the system at its initiation, loops over time (at each timestep calling <span class="flex_cfunction">evolution</span>, see below) and then cleans up when things are all finished.</li> +<ul class="itemize" id='magicparlabel-6654'><li class="itemize_item"><span class="flex_cfunction">evolve_system_binary_c</span> is the main time loop which sets up the system at its initiation, loops over time (at each timestep calling <span class="flex_cfunction">evolution</span>, see below) and then cleans up when things are all finished.</li> <li class="itemize_item"><span class="flex_cfunction">evolution</span> The main time-evolution function. This calls the appropriate integration scheme to further the binary system under investigation in time. The default scheme is forward-Euler, but Runge-Kutta 2nd and 4th order are also available. The function <span class="flex_cfunction">evolution_step</span> in turn, for all the schemes, calls the other parts of <i>binary_c</i> that do all the appropriate physics.</li> </ul> -<h4 class="subsubsection" id='magicparlabel-6502'><span class="subsubsection_label">8.8.12</span> file</h4> -<div class="standard" id='magicparlabel-6503'>File input/output code. <i>binary_c</i> provides a custom file output routine which can limit output by size of the file, as well as output filtering routines.</div> -<h4 class="subsubsection" id='magicparlabel-6504'><span class="subsubsection_label">8.8.13</span> galactic</h4> -<div class="standard" id='magicparlabel-6505'>Experimental! A set of routines to calculate apparent and bolometric luminosities, and develop a model of galactic coordinates. It's not clear that we should be even doing this in <i>binary_c</i>…</div> -<h4 class="subsubsection" id='magicparlabel-6506'><span class="subsubsection_label">8.8.14</span> libmemoize</h4> -<div class="standard" id='magicparlabel-6507'>This is a copy of RGI's memoizing library <span class="flex_software">libmemoize</span>. The idea is that repeated calls to a function with the same arguments are automatically cached so that the function is actually only called once. Note: if you have <span class="flex_software">libmemoize</span> properly installed on your system, e.g. in <span class="flex_file"><span class="flex_envvar">$HOME</span>/lib</span> or <span class="flex_file">/usr/local/lib</span>, which is what you <em>should</em> do, then the installed version is used. The version in <i>binary_c</i> is a backup version only, and may lack the latest features.</div> -<h4 class="subsubsection" id='magicparlabel-6528'><span class="subsubsection_label">8.8.15</span> librinterpolate</h4> -<div class="standard" id='magicparlabel-6529'>This is a copy of RGI's <span class="flex_software">librinterpolate</span> linear interpolation library. If you have <span class="flex_software">librinterpolate</span> installed properly, e.g. in <span class="flex_file"><span class="flex_envvar">$HOME</span>/lib</span> or <span class="flex_file">/usr/local/lib</span>, which is what you should do, then the version in <i>binary_c</i> is ignored.</div> -<h4 class="subsubsection" id='magicparlabel-6550'><span class="subsubsection_label">8.8.16</span> logging</h4> -<div class="standard" id='magicparlabel-6551'><div id="subsec_logging"></div> +<h4 class="subsubsection" id='magicparlabel-6672'><span class="subsubsection_label">8.8.12</span> file</h4> +<div class="standard" id='magicparlabel-6673'>File input/output code. <i>binary_c</i> provides a custom file output routine which can limit output by size of the file, as well as output filtering routines.</div> +<h4 class="subsubsection" id='magicparlabel-6674'><span class="subsubsection_label">8.8.13</span> galactic</h4> +<div class="standard" id='magicparlabel-6675'>Experimental! A set of routines to calculate apparent and bolometric luminosities, and develop a model of galactic coordinates. It's not clear that we should be even doing this in <i>binary_c</i>…</div> +<h4 class="subsubsection" id='magicparlabel-6676'><span class="subsubsection_label">8.8.14</span> libmemoize</h4> +<div class="standard" id='magicparlabel-6677'>This is a copy of RGI's memoizing library <span class="flex_software">libmemoize</span>. The idea is that repeated calls to a function with the same arguments are automatically cached so that the function is actually only called once. Note: if you have <span class="flex_software">libmemoize</span> properly installed on your system, e.g. in <span class="flex_file"><span class="flex_envvar">$HOME</span>/lib</span> or <span class="flex_file">/usr/local/lib</span>, which is what you <em>should</em> do, then the installed version is used. The version in <i>binary_c</i> is a backup version only, and may lack the latest features.</div> +<h4 class="subsubsection" id='magicparlabel-6698'><span class="subsubsection_label">8.8.15</span> librinterpolate</h4> +<div class="standard" id='magicparlabel-6699'>This is a copy of RGI's <span class="flex_software">librinterpolate</span> linear interpolation library. If you have <span class="flex_software">librinterpolate</span> installed properly, e.g. in <span class="flex_file"><span class="flex_envvar">$HOME</span>/lib</span> or <span class="flex_file">/usr/local/lib</span>, which is what you should do, then the version in <i>binary_c</i> is ignored.</div> +<h4 class="subsubsection" id='magicparlabel-6720'><span class="subsubsection_label">8.8.16</span> logging</h4> +<div class="standard" id='magicparlabel-6721'><div id="subsec_logging"></div> Contains some functions used to output either to the screen or a file. Not very interesting but vital if you are to get anything out of <i>binary_c</i>.</div> -<ul class="itemize" id='magicparlabel-6552'><li class="itemize_item"><span class="flex_cfunction">log_every_timestep</span> which is called every (successful) timestep to output the current state of the star. This is where you want to put your logging code! Please remember: when logging use the <span class="flex_cmacro">Printf</span> macro, not <span class="flex_programminglanguage">C</span>'s <span class="flex_cfunction">printf</span>-type function calls.</li> +<ul class="itemize" id='magicparlabel-6722'><li class="itemize_item"><span class="flex_cfunction">log_every_timestep</span> which is called every (successful) timestep to output the current state of the star. This is where you want to put your logging code! Please remember: when logging use the <span class="flex_cmacro">Printf</span> macro, not <span class="flex_programminglanguage">C</span>'s <span class="flex_cfunction">printf</span>-type function calls.</li> </ul> -<h4 class="subsubsection" id='magicparlabel-6569'><span class="subsubsection_label">8.8.17</span> maths</h4> -<div class="standard" id='magicparlabel-6570'>Contains a selection of routines to do some mathematical tasks that are useful to <em><i>binary_c</i></em>, many of these routines are wrappers to <span class="flex_software">GSL</span> functions. There are not-a-number (NaN) checking routines, random number generators, a Kaps-Rentrop solver, a generic Brent minimizer, and the <span class="flex_cfunction">apply_derivative</span> function which is used by <span class="flex_cfunction">evolution</span> to integrate numerical derivatives at each timestep.</div> +<h4 class="subsubsection" id='magicparlabel-6739'><span class="subsubsection_label">8.8.17</span> maths</h4> +<div class="standard" id='magicparlabel-6740'>Contains a selection of routines to do some mathematical tasks that are useful to <em><i>binary_c</i></em>, many of these routines are wrappers to <span class="flex_software">GSL</span> functions. There are not-a-number (NaN) checking routines, random number generators, a Kaps-Rentrop solver, a generic Brent minimizer, and the <span class="flex_cfunction">apply_derivative</span> function which is used by <span class="flex_cfunction">evolution</span> to integrate numerical derivatives at each timestep.</div> -<ul class="itemize" id='magicparlabel-6583'><li class="itemize_item">Some of the code is experimental so probably not used.</li> +<ul class="itemize" id='magicparlabel-6753'><li class="itemize_item">Some of the code is experimental so probably not used.</li> <li class="itemize_item">Anything you put in this directory must be free and freely distributable software. There are no routines from <em>Numerical Recipes in <i>C</i></em> because these are not free software.</li> </ul> -<h4 class="subsubsection" id='magicparlabel-6585'><span class="subsubsection_label">8.8.18</span> memory</h4> -<div class="standard" id='magicparlabel-6586'>In here reside <i>binary_c</i>'s memory allocation and freeing (garbage collection) routines.</div> -<h4 class="subsubsection" id='magicparlabel-6587'><span class="subsubsection_label">8.8.19</span> misc</h4> -<div class="standard" id='magicparlabel-6588'>Routines that don't go anywhere else. At the moment this contains nothing.</div> -<h4 class="subsubsection" id='magicparlabel-6589'><span class="subsubsection_label">8.8.20</span> nucsyn</h4> -<div class="standard" id='magicparlabel-6590'>See section <a href="#subsec_nucsyn">8.9</a>.</div> -<h4 class="subsubsection" id='magicparlabel-6591'><span class="subsubsection_label">8.8.21</span> opacity</h4> -<div class="standard" id='magicparlabel-6592'>Experimental.</div> -<h4 class="subsubsection" id='magicparlabel-6593'><span class="subsubsection_label">8.8.22</span> orbit</h4> -<div class="standard" id='magicparlabel-6594'>Routines which calculate orbital properties go in here.</div> -<h4 class="subsubsection" id='magicparlabel-6595'><span class="subsubsection_label">8.8.23</span> perl</h4> -<div class="standard" id='magicparlabel-6596'>Not strictly part of the <em><i>binary_c</i></em> <span class="flex_programminglanguage">C</span> source, but contains some useful <span class="flex_scriptinglanguage">Perl</span> modules (e.g.<em> <i>binary_grid</i></em>) and scripts.</div> -<h4 class="subsubsection" id='magicparlabel-6605'><span class="subsubsection_label">8.8.24</span> python</h4> -<div class="standard" id='magicparlabel-6606'><span class="flex_scriptinglanguage">Python</span> scripts, e.g. to access the API through <span class="flex_scriptinglanguage">Python</span>, are in here.</div> -<h4 class="subsubsection" id='magicparlabel-6615'><span class="subsubsection_label">8.8.25</span> RLOF</h4> -<div class="standard" id='magicparlabel-6616'><div id="subsec_RLOF"></div> +<h4 class="subsubsection" id='magicparlabel-6755'><span class="subsubsection_label">8.8.18</span> memory</h4> +<div class="standard" id='magicparlabel-6756'>In here reside <i>binary_c</i>'s memory allocation and freeing (garbage collection) routines.</div> +<h4 class="subsubsection" id='magicparlabel-6757'><span class="subsubsection_label">8.8.19</span> misc</h4> +<div class="standard" id='magicparlabel-6758'>Routines that don't go anywhere else. At the moment this contains nothing.</div> +<h4 class="subsubsection" id='magicparlabel-6759'><span class="subsubsection_label">8.8.20</span> nucsyn</h4> +<div class="standard" id='magicparlabel-6760'>See section <a href="#subsec_nucsyn">8.9</a>.</div> +<h4 class="subsubsection" id='magicparlabel-6761'><span class="subsubsection_label">8.8.21</span> opacity</h4> +<div class="standard" id='magicparlabel-6762'>Experimental.</div> +<h4 class="subsubsection" id='magicparlabel-6763'><span class="subsubsection_label">8.8.22</span> orbit</h4> +<div class="standard" id='magicparlabel-6764'>Routines which calculate orbital properties go in here.</div> +<h4 class="subsubsection" id='magicparlabel-6765'><span class="subsubsection_label">8.8.23</span> perl</h4> +<div class="standard" id='magicparlabel-6766'>Not strictly part of the <em><i>binary_c</i></em> <span class="flex_programminglanguage">C</span> source, but contains some useful <span class="flex_scriptinglanguage">Perl</span> modules (e.g.<em> <i>binary_grid</i></em>) and scripts.</div> +<h4 class="subsubsection" id='magicparlabel-6775'><span class="subsubsection_label">8.8.24</span> python</h4> +<div class="standard" id='magicparlabel-6776'><span class="flex_scriptinglanguage">Python</span> scripts, e.g. to access the API through <span class="flex_scriptinglanguage">Python</span>, are in here.</div> +<h4 class="subsubsection" id='magicparlabel-6785'><span class="subsubsection_label">8.8.25</span> RLOF</h4> +<div class="standard" id='magicparlabel-6786'><div id="subsec_RLOF"></div> This has functions which deal with dynamical timescale Roche lobe overflow. </div> -<div class="standard" id='magicparlabel-6617'>First, there is the question of when <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-6787'>First, there is the question of when <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi>R</mi><mo>=</mo> <msub subscriptshift="0.2ex"> @@ -6692,7 +6741,7 @@ This has functions which deal with dynamical timescale Roche lobe overflow. </di </mrow> </mrow></mstyle></math> to within some threshold (usually 2%). However, this means taking <em>negative</em> timesteps, which plays havoc with logging and nucleosynthesis algorithms.</div> -<div class="standard" id='magicparlabel-6626'>In the latest <em><i>binary_c</i></em>, a simpler (albeit slower) algorithm is used which rejects the evolution when <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-6796'>In the latest <em><i>binary_c</i></em>, a simpler (albeit slower) algorithm is used which rejects the evolution when <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi>R</mi><mo> ≫ </mo> <msub subscriptshift="0.2ex"> @@ -6714,7 +6763,7 @@ This has functions which deal with dynamical timescale Roche lobe overflow. </di </mrow> </mrow></mstyle></math>, always with a positive timestep.</div> -<div class="standard" id='magicparlabel-6635'>RLOF itself is followed according to one of a number of algorithms. First, the system is tested for the stability of RLOF (<span class="flex_cfunction">RLOF_stability_tests</span>). If RLOF is unstable, a merger or common envelope usually entails. Second, if the RLOF is stable, there are several methods for calculating the mass transfer rate. The formulaic approach assumes that for a given <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-6805'>RLOF itself is followed according to one of a number of algorithms. First, the system is tested for the stability of RLOF (<span class="flex_cfunction">RLOF_stability_tests</span>). If RLOF is unstable, a merger or common envelope usually entails. Second, if the RLOF is stable, there are several methods for calculating the mass transfer rate. The formulaic approach assumes that for a given <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi>R</mi><mo> ≥ </mo> <msub subscriptshift="0.2ex"> @@ -6754,42 +6803,42 @@ This has functions which deal with dynamical timescale Roche lobe overflow. </di </msub> </mrow> </mrow></mstyle></math>. This is more exact, but requires more calculation steps. Usually, the two methods give similar answers, but if mass transfer is particularly fast, e.g. in massive stars, this may not be the case.</div> -<h4 class="subsubsection" id='magicparlabel-6640'><span class="subsubsection_label">8.8.26</span> <span style='font-family:monospace;font-size: 18px;'>setup</span></h4> -<div class="standard" id='magicparlabel-6641'><div id="subsec_setup"></div> +<h4 class="subsubsection" id='magicparlabel-6810'><span class="subsubsection_label">8.8.26</span> <span style='font-family:monospace;font-size: 18px;'>setup</span></h4> +<div class="standard" id='magicparlabel-6811'><div id="subsec_setup"></div> This sets the code up because <span class="flex_cfunction">set_up_variables</span> is called by the <span class="flex_cfunction">main</span> function. It reads in the command line arguments and sets them to variables.</div> -<div class="standard" id='magicparlabel-6650'>The <span class="flex_cfunction">parse_arguments</span> function takes command line arguments and puts them into (in particular) the <span style='font-family:monospace;font-size: 18px;'>preferences</span> structure. This function is very useful if you want to put in your own arguments, which should go into <span class="flex_headerfile">cmd_line_args.h</span>.</div> -<h4 class="subsubsection" id='magicparlabel-6659'><span class="subsubsection_label">8.8.27</span> signals</h4> -<div class="standard" id='magicparlabel-6660'><span class="flex_os">Unix</span>/<span class="flex_os">Linux</span> uses signals to communicate with running programs. Code in here allows you to catch signals, as well as catching (and trapping) segmentation faults which is very useful for debugging (e.g. with <span class="flex_software">gdb</span> and/or <span class="flex_software">valgrind</span>).</div> -<h4 class="subsubsection" id='magicparlabel-6677'><span class="subsubsection_label">8.8.28</span> single_star_functions</h4> -<div class="standard" id='magicparlabel-6678'>Many functions which only affect single star, or detached binary, evolution are in this directory.</div> -<h4 class="subsubsection" id='magicparlabel-6679'><span class="subsubsection_label">8.8.29</span> spectra</h4> -<div class="standard" id='magicparlabel-6680'>Functions in here link stars, through their temperature and luminosity, to spectra. At present only a blackbody spectrum is supported, but the algorithm for calculating the blackbody flux in regions of wavelength parameter space is fast and accurate.</div> -<h4 class="subsubsection" id='magicparlabel-6681'><span class="subsubsection_label">8.8.30</span> stellar_colours</h4> -<div class="standard" id='magicparlabel-6682'>This contains some routines to calculate stellar colours, which may or may not be reliable.</div> -<h4 class="subsubsection" id='magicparlabel-6683'><span class="subsubsection_label">8.8.31</span> stellar_structure</h4> -<div class="standard" id='magicparlabel-6684'><div id="subsec_stellar_structure"></div> +<div class="standard" id='magicparlabel-6820'>The <span class="flex_cfunction">parse_arguments</span> function takes command line arguments and puts them into (in particular) the <span style='font-family:monospace;font-size: 18px;'>preferences</span> structure. This function is very useful if you want to put in your own arguments, which should go into <span class="flex_headerfile">cmd_line_args.h</span>.</div> +<h4 class="subsubsection" id='magicparlabel-6829'><span class="subsubsection_label">8.8.27</span> signals</h4> +<div class="standard" id='magicparlabel-6830'><span class="flex_os">Unix</span>/<span class="flex_os">Linux</span> uses signals to communicate with running programs. Code in here allows you to catch signals, as well as catching (and trapping) segmentation faults which is very useful for debugging (e.g. with <span class="flex_software">gdb</span> and/or <span class="flex_software">valgrind</span>).</div> +<h4 class="subsubsection" id='magicparlabel-6847'><span class="subsubsection_label">8.8.28</span> single_star_functions</h4> +<div class="standard" id='magicparlabel-6848'>Many functions which only affect single star, or detached binary, evolution are in this directory.</div> +<h4 class="subsubsection" id='magicparlabel-6849'><span class="subsubsection_label">8.8.29</span> spectra</h4> +<div class="standard" id='magicparlabel-6850'>Functions in here link stars, through their temperature and luminosity, to spectra. At present only a blackbody spectrum is supported, but the algorithm for calculating the blackbody flux in regions of wavelength parameter space is fast and accurate.</div> +<h4 class="subsubsection" id='magicparlabel-6851'><span class="subsubsection_label">8.8.30</span> stellar_colours</h4> +<div class="standard" id='magicparlabel-6852'>This contains some routines to calculate stellar colours, which may or may not be reliable.</div> +<h4 class="subsubsection" id='magicparlabel-6853'><span class="subsubsection_label">8.8.31</span> stellar_structure</h4> +<div class="standard" id='magicparlabel-6854'><div id="subsec_stellar_structure"></div> Sets up a <span class="flex_cstruct">new_structure</span> struct, and passes this to the appropriate stellar structure calculation code. Currently only <span style='font-family:monospace;font-size: 18px;'>stellar_structure_BSE</span> is available, but in future different codes may arise.</div> -<div class="standard" id='magicparlabel-6689'><span class="flex_cfunction">stellar_structure_BSE</span> is based on the <span class="flex_fortranfunction">hrdiag</span> function of <span class="flex_software">SSE/BSE</span>. It computes the stellar structure variables at a given time. In addition, it handles supernova explosions and kicks. Note that this functionality may eventually be removed from the stellar_structure directory.</div> -<h4 class="subsubsection" id='magicparlabel-6702'><span class="subsubsection_label">8.8.32</span> stellar_timescales</h4> -<div class="standard" id='magicparlabel-6703'>This set of functions calculates the timescales required by stellar_evolution, as in the <span class="flex_software">SSE/BSE</span> stellar evolution package (in which it is the function <span class="flex_fortranfunction">star.f</span>, and in <em><i>binary_c</i></em> V1.x it is <span class="flex_cfunction">calc_lum_and_evol_time</span> in <span class="flex_file">claet</span>).</div> -<h4 class="subsubsection" id='magicparlabel-6720'><span class="subsubsection_label">8.8.33</span> string</h4> -<div class="standard" id='magicparlabel-6721'>Functions to manipulate strings go in here, including <span class="flex_cfunction">binary_c_asprintf</span> (to replace asprintf if <span class="flex_software">Gnu</span> or <span class="flex_software">libbsd</span>'s version is not available) and <span class="flex_cfunction">chomp</span> (to remove newlines at the end of a string, identical to <span class="flex_scriptinglanguage">Perl</span>'s <span class="flex_perlcode">chomp</span>).</div> -<h4 class="subsubsection" id='magicparlabel-6746'><span class="subsubsection_label">8.8.34</span> supernovae</h4> -<div class="standard" id='magicparlabel-6747'>Functions which deal with supernovae, e.g. kicks, NS/BH mass as a function of progentior, etc. Note that supernovae are dealt with at the end of a timestep as an event (see section <a href="#subsec_Events">8.6</a>).</div> -<h4 class="subsubsection" id='magicparlabel-6748'><span class="subsubsection_label">8.8.35</span> tables</h4> -<div class="standard" id='magicparlabel-6749'>Various tables of data, used by <span class="flex_software">librinterpolate</span>, are included in <i>binary_c</i>. This directory contains the data for them and the various setup functions. In future, this data may be held elsewhere and its location accessed through an environment variable.</div> -<h4 class="subsubsection" id='magicparlabel-6754'><span class="subsubsection_label">8.8.36</span> timers</h4> -<div class="standard" id='magicparlabel-6755'>These are functions which start and stop the ticks counters. They are used to measure CPU time use, i.e. profiling of the code. Note that there are many ways to profile (including e.g. <span class="flex_software">cachegrind</span> and <span class="flex_software">callgrind</span>, functions of <span class="flex_software">valgrind</span>, and the ever reliable <span class="flex_software">gprof</span>).</div> -<h4 class="subsubsection" id='magicparlabel-6772'><span class="subsubsection_label">8.8.37</span> timestep</h4> -<div class="standard" id='magicparlabel-6773'>Routines for calculating the stellar timestep, see the function <span class="flex_cfunction">stellar_timestep</span> for details.</div> -<h4 class="subsubsection" id='magicparlabel-6778'><span class="subsubsection_label">8.8.38</span> triple_star_functions</h4> -<div class="standard" id='magicparlabel-6779'>Experimental! As the name suggests, these are functions to calculate the various physics in triple stars.</div> -<h4 class="subsubsection" id='magicparlabel-6780'><span class="subsubsection_label">8.8.39</span> wind</h4> -<div class="standard" id='magicparlabel-6781'>Routines for calculating the stellar wind loss rate. Note that the main function that calculates the wind mass-loss rate is actually in <span class="flex_file">src/single_star_functions/calc_stellar_wind_mass_loss.c</span> but that just calls <span class="flex_cfunction">wind_mass_loss_rate</span> which is in this directory.</div> -<h4 class="subsubsection" id='magicparlabel-6790'><span class="subsubsection_label">8.8.40</span> zfuncs</h4> -<div class="standard" id='magicparlabel-6791'><div id="subsec_zfuncs"></div> +<div class="standard" id='magicparlabel-6859'><span class="flex_cfunction">stellar_structure_BSE</span> is based on the <span class="flex_fortranfunction">hrdiag</span> function of <span class="flex_software">SSE/BSE</span>. It computes the stellar structure variables at a given time. In addition, it handles supernova explosions and kicks. Note that this functionality may eventually be removed from the stellar_structure directory.</div> +<h4 class="subsubsection" id='magicparlabel-6872'><span class="subsubsection_label">8.8.32</span> stellar_timescales</h4> +<div class="standard" id='magicparlabel-6873'>This set of functions calculates the timescales required by stellar_evolution, as in the <span class="flex_software">SSE/BSE</span> stellar evolution package (in which it is the function <span class="flex_fortranfunction">star.f</span>, and in <em><i>binary_c</i></em> V1.x it is <span class="flex_cfunction">calc_lum_and_evol_time</span> in <span class="flex_file">claet</span>).</div> +<h4 class="subsubsection" id='magicparlabel-6890'><span class="subsubsection_label">8.8.33</span> string</h4> +<div class="standard" id='magicparlabel-6891'>Functions to manipulate strings go in here, including <span class="flex_cfunction">binary_c_asprintf</span> (to replace asprintf if <span class="flex_software">Gnu</span> or <span class="flex_software">libbsd</span>'s version is not available) and <span class="flex_cfunction">chomp</span> (to remove newlines at the end of a string, identical to <span class="flex_scriptinglanguage">Perl</span>'s <span class="flex_perlcode">chomp</span>).</div> +<h4 class="subsubsection" id='magicparlabel-6916'><span class="subsubsection_label">8.8.34</span> supernovae</h4> +<div class="standard" id='magicparlabel-6917'>Functions which deal with supernovae, e.g. kicks, NS/BH mass as a function of progentior, etc. Note that supernovae are dealt with at the end of a timestep as an event (see section <a href="#subsec_Events">8.6</a>).</div> +<h4 class="subsubsection" id='magicparlabel-6918'><span class="subsubsection_label">8.8.35</span> tables</h4> +<div class="standard" id='magicparlabel-6919'>Various tables of data, used by <span class="flex_software">librinterpolate</span>, are included in <i>binary_c</i>. This directory contains the data for them and the various setup functions. In future, this data may be held elsewhere and its location accessed through an environment variable.</div> +<h4 class="subsubsection" id='magicparlabel-6924'><span class="subsubsection_label">8.8.36</span> timers</h4> +<div class="standard" id='magicparlabel-6925'>These are functions which start and stop the ticks counters. They are used to measure CPU time use, i.e. profiling of the code. Note that there are many ways to profile (including e.g. <span class="flex_software">cachegrind</span> and <span class="flex_software">callgrind</span>, functions of <span class="flex_software">valgrind</span>, and the ever reliable <span class="flex_software">gprof</span>).</div> +<h4 class="subsubsection" id='magicparlabel-6942'><span class="subsubsection_label">8.8.37</span> timestep</h4> +<div class="standard" id='magicparlabel-6943'>Routines for calculating the stellar timestep, see the function <span class="flex_cfunction">stellar_timestep</span> for details.</div> +<h4 class="subsubsection" id='magicparlabel-6948'><span class="subsubsection_label">8.8.38</span> triple_star_functions</h4> +<div class="standard" id='magicparlabel-6949'>Experimental! As the name suggests, these are functions to calculate the various physics in triple stars.</div> +<h4 class="subsubsection" id='magicparlabel-6950'><span class="subsubsection_label">8.8.39</span> wind</h4> +<div class="standard" id='magicparlabel-6951'>Routines for calculating the stellar wind loss rate. Note that the main function that calculates the wind mass-loss rate is actually in <span class="flex_file">src/single_star_functions/calc_stellar_wind_mass_loss.c</span> but that just calls <span class="flex_cfunction">wind_mass_loss_rate</span> which is in this directory.</div> +<h4 class="subsubsection" id='magicparlabel-6960'><span class="subsubsection_label">8.8.40</span> zfuncs</h4> +<div class="standard" id='magicparlabel-6961'><div id="subsec_zfuncs"></div> The so called “metallicity functions” of <span class="flex_software">BSE</span> i.e. the many fits to <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>L</mi> </mrow></mstyle></math>, <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -6810,42 +6859,42 @@ The so called “metallicity functions” of <span class="flex_software" <mrow><mi>Z</mi> </mrow></mstyle></math> (and perhaps other parameters). These are lots of tiny functions which contain fitting formulae.</div> -<div class="standard" id='magicparlabel-6796'>Lately I have added some new functions, such as <span class="flex_cfunction">mc_1DUP</span> (the core mass at which first dredge up occurs), <span class="flex_cfunction">fphase</span> (the fractional age in a given stellar evolution phase), <span class="flex_cfunction">rwd</span> and <span class="flex_cfunction">lwd</span> (radius and luminosity of a white dwarf) etc. This seems a reasonable location for storing small, useful functions.</div> +<div class="standard" id='magicparlabel-6966'>Lately I have added some new functions, such as <span class="flex_cfunction">mc_1DUP</span> (the core mass at which first dredge up occurs), <span class="flex_cfunction">fphase</span> (the fractional age in a given stellar evolution phase), <span class="flex_cfunction">rwd</span> and <span class="flex_cfunction">lwd</span> (radius and luminosity of a white dwarf) etc. This seems a reasonable location for storing small, useful functions.</div> -<div class="standard" id='magicparlabel-6813'>Please note that I have optimized these functions to the hilt because they are called very often.</div> -<h3 class="subsection" id='magicparlabel-6814'><span class="subsection_label">8.9</span> nucsyn</h3> -<div class="standard" id='magicparlabel-6815'><div id="subsec_nucsyn"></div> +<div class="standard" id='magicparlabel-6983'>Please note that I have optimized these functions to the hilt because they are called very often.</div> +<h3 class="subsection" id='magicparlabel-6984'><span class="subsection_label">8.9</span> nucsyn</h3> +<div class="standard" id='magicparlabel-6985'><div id="subsec_nucsyn"></div> The nucleosynthesis functions are in a directory of their own. It contains the functions which deal with the nucleosynthesis part of the code which runs in parallel to <span class="flex_software">SSE/BSE</span>. That is <em>not</em> to say that all the nucleosynthesis is done here, but most of it is.</div> -<div class="standard" id='magicparlabel-6820'>To enable nucleosynthesis in the code you must</div> +<div class="standard" id='magicparlabel-6990'>To enable nucleosynthesis in the code you must</div> -<div class="standard" id='magicparlabel-6821'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-6991'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings <i>C</i>'>#define NUCSYN</pre><br /> </span></div> -<div class="standard" id='magicparlabel-6826'>somewhere, usually in <span class="flex_headerfile">binary_c_parameters.h</span> (which gets included in <span class="flex_headerfile">binary_c_macros.h</span> so <span class="flex_headerfile">nucsyn.h</span> – you should include <span class="flex_headerfile">nucsyn.h</span> in every nucsyn library file). It is vitally important that if you add anything to the nucleosynthesis code you enclose it in something like</div> +<div class="standard" id='magicparlabel-6996'>somewhere, usually in <span class="flex_headerfile">binary_c_parameters.h</span> (which gets included in <span class="flex_headerfile">binary_c_macros.h</span> so <span class="flex_headerfile">nucsyn.h</span> – you should include <span class="flex_headerfile">nucsyn.h</span> in every nucsyn library file). It is vitally important that if you add anything to the nucleosynthesis code you enclose it in something like</div> -<div class="standard" id='magicparlabel-6843'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-7013'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings <i>C</i>'>#ifdef NUCSYN ... #endif /* NUCSYN */</pre><br /> </span></div> -<div class="standard" id='magicparlabel-6850'>so that if nucleosynthesis is not required it can be turned off.</div> +<div class="standard" id='magicparlabel-7020'>so that if nucleosynthesis is not required it can be turned off.</div> -<div class="standard" id='magicparlabel-6851'>There are then further options in <span class="flex_headerfile">nucsyn_parameters.h</span> (see section <a href="#subsec_Advanced_Configuration">9</a>).</div> +<div class="standard" id='magicparlabel-7021'>There are then further options in <span class="flex_headerfile">nucsyn_parameters.h</span> (see section <a href="#subsec_Advanced_Configuration">9</a>).</div> -<div class="standard" id='magicparlabel-6856'>NOTE! <em>Every function in the nucsyn library has</em> <span class="flex_cfunction">nucsyn</span> <em>prepended to the function name - please maintain this convention!</em></div> -<h4 class="subsubsection" id='magicparlabel-6861'><span class="subsubsection_label">8.9.1</span> Header files and isotope arrays</h4> -<div class="standard" id='magicparlabel-6862'><div id="subsec_Header_files_and_isotope_arrays"></div> +<div class="standard" id='magicparlabel-7026'>NOTE! <em>Every function in the nucsyn library has</em> <span class="flex_cfunction">nucsyn</span> <em>prepended to the function name - please maintain this convention!</em></div> +<h4 class="subsubsection" id='magicparlabel-7031'><span class="subsubsection_label">8.9.1</span> Header files and isotope arrays</h4> +<div class="standard" id='magicparlabel-7032'><div id="subsec_Header_files_and_isotope_arrays"></div> All abundances are stored as mass fractions when the array is called <span style='font-family:monospace;font-size: 18px;'>X…</span>, number densities are referred to as <span style='font-family:monospace;font-size: 18px;'>N…</span>. The index for each array ranges from <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mn>0</mn> </mrow></mstyle></math> to <span class="flex_cmacro">ISOTOPE_ARRAY_SIZE</span> which is defined in <span class="flex_headerfile">nucsyn_isotopes.h</span> however you should <em>NEVER</em> manually access the array by number, e.g.<span style='font-family:monospace;font-size: 18px;'> <br /> <pre class ='listings'>X[0]=0.5;</pre><br /> -</span>you should use the predefined macros referring to each isotope in <span class="flex_headerfile">nucsyn_isotopes.h</span> and <span class="flex_headerfile">nucsyn_isotope_list.h</span>. For example, <span class="flex_cmacro">XC12</span> is defined like this<div class="foot"><span class="foot_label">10</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-6890'>Actually, in a modern <i>binary_c</i>, it is defined to be one more than the previous isotope. This is just an integer, of course, and you don't care what that integer is.</div> +</span>you should use the predefined macros referring to each isotope in <span class="flex_headerfile">nucsyn_isotopes.h</span> and <span class="flex_headerfile">nucsyn_isotope_list.h</span>. For example, <span class="flex_cmacro">XC12</span> is defined like this<div class="foot"><span class="foot_label">11</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-7060'>Actually, in a modern <i>binary_c</i>, it is defined to be one more than the previous isotope. This is just an integer, of course, and you don't care what that integer is.</div> </div></div>,</div> -<div class="standard" id='magicparlabel-6891'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-7061'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings'>#define XC12 2</pre><br /> </span>so the second isotope in the array is <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -6873,7 +6922,7 @@ All abundances are stored as mass fractions when the array is called <span style N[XC12]=1e-8;</pre><br /> Perhaps also useful for you is <span class="flex_cmacro">ISOTOPE_MEMSIZE</span> which is just the size (in bytes) of the abundance array.</div> -<div class="standard" id='magicparlabel-6906'>Why is this an advantage? It is very useful to be able to pull isotopes out which are not of interest (this speeds up the code) without breaking all the others, the historical development of the code (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-7076'>Why is this an advantage? It is very useful to be able to pull isotopes out which are not of interest (this speeds up the code) without breaking all the others, the historical development of the code (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> <msup><mrow /> @@ -6896,19 +6945,19 @@ N[XC12]=1e-8;</pre><br /> </mstyle> </mrow> </mrow></mstyle></math> and CNO came first) is not a problem and the addition of new nuclei is easy (but remember section <a href="#subsec_Setup_functions">8.9.2</a>). It also makes the code <em>bloody easy to read</em> since it is painfully obvious which isotope you are referring to! This is important late at night after too much coffee (or other drink!).</div> -<h4 class="subsubsection" id='magicparlabel-6907'><span class="subsubsection_label">8.9.2</span> Setup functions</h4> -<div class="standard" id='magicparlabel-6908'><div id="subsec_Setup_functions"></div> +<h4 class="subsubsection" id='magicparlabel-7077'><span class="subsubsection_label">8.9.2</span> Setup functions</h4> +<div class="standard" id='magicparlabel-7078'><div id="subsec_Setup_functions"></div> <span class="flex_cfunction">nucsyn_set_nuc_masses</span> sets the nuclear masses (in grams) and atomic numbers. If you add an isotope to <span class="flex_headerfile">nucsyn_isotopes.h</span> (see section <a href="#subsec_Header_files_and_isotope_arrays">8.9.1</a>) you <em>MUST</em> change this function to set the nuclear mass or atomic number. If you do not then the number will be undefined and strange things will happen even though your nice new code looks fine (and <span class="flex_software">valgrind</span> will immediately fail because you'll be reading from undefined memory).</div> -<div class="standard" id='magicparlabel-6921'><span class="flex_cfunction">nucsyn_initial_abundances</span> is obviously important because it defines your initial abundance mix, usually as a function of the metallicity.</div> -<h4 class="subsubsection" id='magicparlabel-6926'><span class="subsubsection_label">8.9.3</span> First and Second Dredge-up</h4> -<div class="standard" id='magicparlabel-6927'><div id="subsec_First_and_Second_DUP"></div> +<div class="standard" id='magicparlabel-7091'><span class="flex_cfunction">nucsyn_initial_abundances</span> is obviously important because it defines your initial abundance mix, usually as a function of the metallicity.</div> +<h4 class="subsubsection" id='magicparlabel-7096'><span class="subsubsection_label">8.9.3</span> First and Second Dredge-up</h4> +<div class="standard" id='magicparlabel-7097'><div id="subsec_First_and_Second_DUP"></div> First and second dredge-up are handled by the functions <span class="flex_cfunction">nucsyn_set_1st_dup_abunds</span> and <span class="flex_cfunction">nucsyn_set_2nd_dup_abunds</span> which perturb the surface abundances. There may be problems in binaries because the evolution is different to single stars, but I try to take this into account by scaling the CNO abundances to whatever the stellar CNO abundance is. Thanks to Evert Glebbeek and Richard Stancliffe for helping out with this, the results will be published in one of our CEMP papers soon.</div> -<h4 class="subsubsection" id='magicparlabel-6936'><span class="subsubsection_label">8.9.4</span> TPAGB functions (3rd dredge-up and HBB)</h4> -<div class="standard" id='magicparlabel-6937'><div id="subsec_TPAGB_functions"></div> +<h4 class="subsubsection" id='magicparlabel-7106'><span class="subsubsection_label">8.9.4</span> TPAGB functions (3rd dredge-up and HBB)</h4> +<div class="standard" id='magicparlabel-7107'><div id="subsec_TPAGB_functions"></div> The first section of the library to be written was the synthetic TPAGB evolution (see <a href='#LyXCite-Izzard_et_al_2003b_AGBs'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2004</span></a>). This is controlled by the function <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_tpagb</span></span></span>. The function determines whether the next thermal pulse has been reached by the star and if so it does third dredge-up (and perhaps there's some hot-bottom burning [HBB]).</div> -<div class="standard" id='magicparlabel-6942'>On the first pulse (when the function is first called for the star, actually if <br /> +<div class="standard" id='magicparlabel-7112'>On the first pulse (when the function is first called for the star, actually if <br /> <pre class ='listings <i>C</i>'>num_thermal_pulses < 0</pre><br /> , which is the case for any stellar type other than TPAGB) the function <span class="flex_cfunction">nucsyn_init_first_pulse</span> is called which sets a few things like the interpulse period and <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -6924,7 +6973,7 @@ The first section of the library to be written was the synthetic TPAGB evolution </msub> </mrow></mstyle></math> for dredge-up.</div> -<div class="standard" id='magicparlabel-6951'>For subsequent timesteps the <span class="flex_cfunction">nucsyn_tpagb function</span> calls <span class="flex_cfunction">nucsyn_tpagb_H_shell_burn</span> to burn the hydrogen shell during the interpulse period and save the amount of core mass growth <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-7121'>For subsequent timesteps the <span class="flex_cfunction">nucsyn_tpagb function</span> calls <span class="flex_cfunction">nucsyn_tpagb_H_shell_burn</span> to burn the hydrogen shell during the interpulse period and save the amount of core mass growth <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mo> Δ </mo> <msub subscriptshift="0.2ex"> @@ -6938,9 +6987,9 @@ The first section of the library to be written was the synthetic TPAGB evolution </mrow> </mrow></mstyle></math>. </div> -<div class="standard" id='magicparlabel-6960'>There is then a check to see if the star is hot enough for HBB – this is done by fitting the temperature (see <span class="flex_cfunction">nucsyn_set_hbb_conditions</span>, <span class="flex_cfunction">nucsyn_hbbtmax</span> and <span class="flex_cfunction">nucsyn_tpagb_rhomax</span>) to mass and metallicity. If so the <span class="flex_cfunction">nucsyn_hbb</span> function is called. The free parameters associated with HBB (<a href='#LyXCite-Izzard_et_al_2003b_AGBs'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2004</span></a>) are set in <span class="flex_cfunction">nucsyn_set_tpagb_free_parameters</span> (these are the burn times, mixing fractions etc.).</div> +<div class="standard" id='magicparlabel-7130'>There is then a check to see if the star is hot enough for HBB – this is done by fitting the temperature (see <span class="flex_cfunction">nucsyn_set_hbb_conditions</span>, <span class="flex_cfunction">nucsyn_hbbtmax</span> and <span class="flex_cfunction">nucsyn_tpagb_rhomax</span>) to mass and metallicity. If so the <span class="flex_cfunction">nucsyn_hbb</span> function is called. The free parameters associated with HBB (<a href='#LyXCite-Izzard_et_al_2003b_AGBs'><span class="bib-abbrvciteauthor">Izzard et al.</span>, <span class="bib-year">2004</span></a>) are set in <span class="flex_cfunction">nucsyn_set_tpagb_free_parameters</span> (these are the burn times, mixing fractions etc.).</div> -<div class="standard" id='magicparlabel-6981'>If the next pulse is reached then <span class="flex_cfunction">nucsyn_third_dredge_up</span> is called to deal with third dredge-up. This dredges up a mass <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-7151'>If the next pulse is reached then <span class="flex_cfunction">nucsyn_third_dredge_up</span> is called to deal with third dredge-up. This dredges up a mass <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> λ </mi><mo> × </mo><mo> Δ </mo> <msub subscriptshift="0.2ex"> @@ -6954,9 +7003,9 @@ The first section of the library to be written was the synthetic TPAGB evolution </mrow> </mrow></mstyle></math> and mixes it with the envelope. The abundances of the dredged-up material are set in <span class="flex_cfunction">nucsyn_set_third_dredgeup_abunds</span> (and <span class="flex_cfunction">nucsyn_s_process for s-process</span> elements).</div> -<div class="standard" id='magicparlabel-6994'>Version 1.2 of <i>binary_c</i> included an option to evolve “super AGB” (STPAGB) stars but this has since been deprecated.</div> -<h4 class="subsubsection" id='magicparlabel-6995'><span class="subsubsection_label">8.9.5</span> Hot-Bottom Burning</h4> -<div class="standard" id='magicparlabel-6996'><div id="subsec_Hot_Bottom_Burning"></div> +<div class="standard" id='magicparlabel-7164'>Version 1.2 of <i>binary_c</i> included an option to evolve “super AGB” (STPAGB) stars but this has since been deprecated.</div> +<h4 class="subsubsection" id='magicparlabel-7165'><span class="subsubsection_label">8.9.5</span> Hot-Bottom Burning</h4> +<div class="standard" id='magicparlabel-7166'><div id="subsec_Hot_Bottom_Burning"></div> While this sounds painful, really it's not! HBB is the process where the convective zone in a TPAGB star reaches down into the hydrogen burning shell. This occurs in <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mn>4</mn><mo>-</mo><mn>8</mn> @@ -6977,31 +7026,31 @@ While this sounds painful, really it's not! HBB is the process where the convect </mrow> </mrow></mstyle></math>, lower masses for lower metallicity). I have two burning routines which can deal with this:</div> -<ol class="enumerate" id='magicparlabel-6997'><li class="enumerate_item">The original analytic routine. This uses analytic solutions to the CN, ON, NeNa and MgAl cycles, together with some approximate fudges to join them into the CNO and NeNaMgAl cycles, to solve for the abundances. This is fast but sometimes, when used outside the range of the approximations, <em>very</em> unstable.</li> +<ol class="enumerate" id='magicparlabel-7167'><li class="enumerate_item">The original analytic routine. This uses analytic solutions to the CN, ON, NeNa and MgAl cycles, together with some approximate fudges to join them into the CNO and NeNaMgAl cycles, to solve for the abundances. This is fast but sometimes, when used outside the range of the approximations, <em>very</em> unstable.</li> <li class="enumerate_item">The new numerical solver. This uses a 4th-order implict (Kaps-Rentrop) scheme to solve for the abundances as a function of time. It does <em>not</em> depend on approximations, and currently burns the <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi>p</mi><mi>p</mi> </mrow> </mrow></mstyle></math>-chain, CNO cycles (hot or cold) and the full NeNa/MgAl chains/cycles. In theory it can be extended to any nuclear network (although it is designed for small networks – it will get very slow with larger networks). It turns out that, after much code optimization, the numerical solver is about as fast as the analytic solver! I think this is because to solve numerically requires additions, subtractions, multiplications and divisions, while analytic solutions require lots of exponentials. However, whether the numerical solver quickly converges on a result depends on the initial timestep. Be careful with that, I have a number of schemes which can improve this.</li> </ol> -<h4 class="subsubsection" id='magicparlabel-6999'><span class="subsubsection_label">8.9.6</span> nucsyn_WR</h4> -<div class="standard" id='magicparlabel-7000'><div id="subsec_nucsyn_WR"></div> +<h4 class="subsubsection" id='magicparlabel-7169'><span class="subsubsection_label">8.9.6</span> nucsyn_WR</h4> +<div class="standard" id='magicparlabel-7170'><div id="subsec_nucsyn_WR"></div> This is a set of phenomenological fits to Lynnette Dray's models for massive stars and helium star remnants. It is self-contained (see the details above and in the function) and contains useful stuff regarding logging of O/B and WR stars. I recently updated it to use tabular lookups instead of fitting functions. </div> -<div class="standard" id='magicparlabel-7001'>The latest version includes tables from Richard Stancliffe which follow all isotopes, not just elemental CNO and H, He. Thanks Richard!</div> -<h4 class="subsubsection" id='magicparlabel-7002'><span class="subsubsection_label">8.9.7</span> The <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-7171'>The latest version includes tables from Richard Stancliffe which follow all isotopes, not just elemental CNO and H, He. Thanks Richard!</div> +<h4 class="subsubsection" id='magicparlabel-7172'><span class="subsubsection_label">8.9.7</span> The <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mi>r</mi> </mrow></mstyle></math>-process</h4> -<div class="standard" id='magicparlabel-7003'><div id="subsec_The_r_process"></div> +<div class="standard" id='magicparlabel-7173'><div id="subsec_The_r_process"></div> I have included some yields from <a href='#LyXCite-1999ApJ___525__886A'><span class="bib-abbrvciteauthor">Arlandini et al.</span></a> (<span class="bib-year">1999</span>) and <a href='#LyXCite-2004ApJ___617_1091S'><span class="bib-abbrvciteauthor">Simmerer et al.</span></a> (<span class="bib-year">2004</span>) which you can activate with the appropriate define in <span class="flex_headerfile">nucsyn_parameters.h</span>. This code has <em>not been well tested</em> so beware!</div> -<h4 class="subsubsection" id='magicparlabel-7008'><span class="subsubsection_label">8.9.8</span> Winds and Mixing</h4> -<div class="standard" id='magicparlabel-7009'><div id="subsec_Winds_and_Mixing"></div> +<h4 class="subsubsection" id='magicparlabel-7178'><span class="subsubsection_label">8.9.8</span> Winds and Mixing</h4> +<div class="standard" id='magicparlabel-7179'><div id="subsec_Winds_and_Mixing"></div> Colliding winds and the like are a complicated business! <span class="flex_cfunction">nucsyn_update_abundances</span> is called when to deal with this. The function is well commented so for details please refer to it but briefly it takes the wind loss from each star and the amount of that accreted by the companion, determines whether the accreted matter should reach the surface (by the factor set in <span class="flex_cfunction">nucsyn_choose_wind_mixing_factor</span>) or not and if so mixes it in or makes a new accretion layer on the surface. It also yields the wind loss by a call to <span class="flex_cfunction">nucsyn_calc_yields</span> and the mass accreted by a similar call but with a negative number. Note: mass is removed from the surface of the star by the function <span class="flex_cfunction">nucsyn_remove_dm_from_surface</span> so that it is preferentially removed from the accretion layer rather than the stellar envelope. Convective stars have no accretion layer, if one is present a call to <span class="flex_cfunction">nucsyn_mix_accretion_layer_and_envelope</span> soon removes it.</div> -<h4 class="subsubsection" id='magicparlabel-7030'><span class="subsubsection_label">8.9.9</span> Explosions (supernovae and novae)</h4> -<div class="standard" id='magicparlabel-7031'><div id="subsec_Explosions"></div> +<h4 class="subsubsection" id='magicparlabel-7200'><span class="subsubsection_label">8.9.9</span> Explosions (supernovae and novae)</h4> +<div class="standard" id='magicparlabel-7201'><div id="subsec_Explosions"></div> Supernova yields are looked up in tables and yielded in <span class="flex_cfunction">nucsyn_sn_yield</span>. Nova ejecta are calculated in <span class="flex_cfunction">nucsyn_set_nova_abunds</span>.</div> -<h4 class="subsubsection" id='magicparlabel-7040'><span class="subsubsection_label">8.9.10</span> Yield calculations</h4> -<div class="standard" id='magicparlabel-7041'><div id="subsec_Yield_calculations"></div> +<h4 class="subsubsection" id='magicparlabel-7210'><span class="subsubsection_label">8.9.10</span> Yield calculations</h4> +<div class="standard" id='magicparlabel-7211'><div id="subsec_Yield_calculations"></div> The calls to <span class="flex_cfunction">nucsyn_calc_yields</span> modify the arrays <span class="flex_cvar">Xyield</span> in the star structures. These contain the mass of material of each isotope lost by the star, so if <span class="flex_cfunction">nucsyn_calc_yields</span> is called for (say) wind loss by an amount <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi> δ </mi><mi>m</mi> @@ -7038,7 +7087,7 @@ The calls to <span class="flex_cfunction">nucsyn_calc_yields</span> modify the a </mrow> </mrow></mstyle></math> (or perhaps more mass if some is lost from the system). The total mass lost from the system is then just the sum of the <span class="flex_cvar">Xyield</span> for both stars. </div> -<div class="standard" id='magicparlabel-7066'>The array <span class="flex_cvar">mpyield</span> stores the values of <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-7236'>The array <span class="flex_cvar">mpyield</span> stores the values of <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>p</mi> @@ -7054,7 +7103,7 @@ The calls to <span class="flex_cfunction">nucsyn_calc_yields</span> modify the a <mrow><mi>i</mi> </mrow></mstyle></math> relative to the ZAMS abundance and divided by the initial mass (note use <span class="flex_cvar">pms_mass</span> not <span style='font-family:monospace;font-size: 18px;'>ZAMS_mass</span> since the latter is redefined by accretion processes).</div> -<div class="standard" id='magicparlabel-7075'>Binary system yields are easy to calculate because they are just the sum of both stars' yields, this is done in <span class="flex_cfunction">nucsyn_binary_yield</span>. The appropriate <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<div class="standard" id='magicparlabel-7245'>Binary system yields are easy to calculate because they are just the sum of both stars' yields, this is done in <span class="flex_cfunction">nucsyn_binary_yield</span>. The appropriate <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <msub subscriptshift="0.2ex"> <mrow><mi>p</mi> @@ -7065,11 +7114,11 @@ The calls to <span class="flex_cfunction">nucsyn_calc_yields</span> modify the a </mrow> </msub> </mrow></mstyle></math> yields are more difficult to define but there is an attempt. </div> -<h4 class="subsubsection" id='magicparlabel-7080'><span class="subsubsection_label">8.9.11</span> Logging and minor functions</h4> -<div class="standard" id='magicparlabel-7081'><div id="subsec_Logging_and_minor_functions"></div> +<h4 class="subsubsection" id='magicparlabel-7250'><span class="subsubsection_label">8.9.11</span> Logging and minor functions</h4> +<div class="standard" id='magicparlabel-7251'><div id="subsec_Logging_and_minor_functions"></div> There are numerous logging functions for debugging and general pretty-picture-manufacture, e.g. <span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_log</span></span>, <span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_long_log</span></span>, <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_short_log</span></span></span>, <span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_j_log</span></span>. Most of these are activated or deactivated in <span class="flex_headerfile">nucsyn_log.h</span>. Other minor functions: <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_totalX</span></span></span> calculates the total mass fraction (or actually the total sum of array elements), <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_square_bracket</span></span></span> calculates an abundance in “square bracket notation” by mass fraction (should it be by number?); <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_mix_shells</span></span></span> mixes two isotope arrays together (very useful!) there are the other mixing functions <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_dilute_shell</span></span></span> and <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_dilulte_shell_to</span></span></span> which are similarly useful; <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_radioactive_decay</span></span></span> decays a few isotopes – it is by no means exhaustive, there may be other isotopes you wish to place in here but it's easy to extend; <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_mole_fraction</span></span></span> converts an array of mass fractions to mole fractions, perhaps useful for the square bracket logging?</div> -<h4 class="subsubsection" id='magicparlabel-7130'><span class="subsubsection_label">8.9.12</span> Other stellar remnants</h4> -<div class="standard" id='magicparlabel-7131'><div id="subsec_Other_stellar_remnants"></div> +<h4 class="subsubsection" id='magicparlabel-7300'><span class="subsubsection_label">8.9.12</span> Other stellar remnants</h4> +<div class="standard" id='magicparlabel-7301'><div id="subsec_Other_stellar_remnants"></div> Some stellar types are not dealt with by nucleosynthesis. There include WDs (<span style='font-family:monospace;font-size: 18px;'>nucsyn_set_WD_abunds</span>), which are assumed to: <span class="flex_cmacro">HeWD</span> 100% <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> @@ -7126,19 +7175,19 @@ Some stellar types are not dealt with by nucleosynthesis. There include WDs (<sp </mrow> </mrow></mstyle></math>. This could be improved (to take into account, say, the heavier metals) but note that any accretion onto the surface from a non-degenerate companion will mask the above abundances (since an accretion layer will form on the surface unless there are novae) and the business of accretion onto WDs is very complicated indeed.</div> -<div class="standard" id='magicparlabel-7144'>NSs and BHs are remnants with their abundances set in <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_set_remnant_abunds</span></span></span> are assumed to be all neutrons with<span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-7314'>NSs and BHs are remnants with their abundances set in <span style='font-family:monospace;font-size: 18px;'><span class="flex_cfunction"><span style='font-family:monospace;font-size: 18px;'>nucsyn_set_remnant_abunds</span></span></span> are assumed to be all neutrons with<span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings <i>C</i>'>Xsurf[Xn]=1.0;</pre><br /> </span></div> -<h3 class="subsection" id='magicparlabel-7153'><span class="subsection_label">8.10</span> Coding style</h3> -<div class="standard" id='magicparlabel-7154'><i>binary_c</i> <i>C</i> code follows a particular style to which you should adhere.</div> +<h3 class="subsection" id='magicparlabel-7323'><span class="subsection_label">8.10</span> Coding style</h3> +<div class="standard" id='magicparlabel-7324'><i>binary_c</i> <i>C</i> code follows a particular style to which you should adhere.</div> -<ul class="itemize" id='magicparlabel-7155'><li class="itemize_item">Please use the <a href="https://en.wikipedia.org/wiki/Indentation_style#Allman_style">Allman style</a> </li> +<ul class="itemize" id='magicparlabel-7325'><li class="itemize_item">Please use the <a href="https://en.wikipedia.org/wiki/Indentation_style#Allman_style">Allman style</a> </li> <li class="itemize_item">Indent with four spaces (<a href="https://www.gnu.org/software/emacs/">emacs</a> indents <span class="flex_programminglanguage">C</span> like this automatically).</li> </ul> -<h4 class="subsubsection" id='magicparlabel-7161'><span class="subsubsection_label">8.10.1</span> Macros</h4> -<div class="standard" id='magicparlabel-7162'>C preprocessor macros are a very powerful way to make code more readable, or less, depending on their use, hence <i>binary_c</i> has strict rules for their use.</div> +<h4 class="subsubsection" id='magicparlabel-7331'><span class="subsubsection_label">8.10.1</span> Macros</h4> +<div class="standard" id='magicparlabel-7332'>C preprocessor macros are a very powerful way to make code more readable, or less, depending on their use, hence <i>binary_c</i> has strict rules for their use.</div> -<ul class="itemize" id='magicparlabel-7163'><li class="itemize_item">Macros used as flags should use <span class="flex_cmacro">CAPTIALS</span> and, when used in <span class="flex_cmacro">#ifdef … #endif</span> pairs, you should include a comment at the end of the pair to say specify the opening macro, for example. <br /> +<ul class="itemize" id='magicparlabel-7333'><li class="itemize_item">Macros used as flags should use <span class="flex_cmacro">CAPTIALS</span> and, when used in <span class="flex_cmacro">#ifdef … #endif</span> pairs, you should include a comment at the end of the pair to say specify the opening macro, for example. <br /> <pre class ='listings'>#define FLAG_MACRO @@ -7157,30 +7206,26 @@ Some stellar types are not dealt with by nucleosynthesis. There include WDs (<sp exceptions to this are the macros used for stellar types, <span class="flex_cmacro">PRINTF</span> which is just mapped to <span class="flex_cmacro">Printf</span> for backward compatibility, and macros such as <span class="flex_cmacro">likley</span> and <span class="flex_cmacro">unlikley</span> which are kept in lower case to match external code (in this case the <span class="flex_os">Linux</span> kernel).</li> <li class="itemize_item">Macros which are used only locally, and variables used in macro expressions, should be prefixed with two underscores</li> </ul> -<h3 class="subsection" id='magicparlabel-7215'><span class="subsection_label">8.11</span> Control scripts</h3> -<div class="standard" id='magicparlabel-7216'><div id="subsec_Control_scripts"></div> +<h3 class="subsection" id='magicparlabel-7385'><span class="subsection_label">8.11</span> Control scripts</h3> +<div class="standard" id='magicparlabel-7386'><div id="subsec_Control_scripts"></div> I have a number of control scripts written in <span class="flex_scriptinglanguage">Perl</span> which test the code and output graphs and data for e.g. AGB stars and WR stars (to compare to full evolution models), stellar yields etc. There might be some documentation here eventually… it all depends on whether you prefer writing your own scripts (that way you'll learn how it all works) or just having a black-box that works (you can always look at the source code).</div> -<div class="standard" id='magicparlabel-7221'>A very useful script is <span class="flex_bashscript">zipup</span> which makes a file <span class="flex_file"><i>binary_c</i>.zip</span> containing this manual and all the source code. See also <span class="flex_perlscript">grid.pl</span>.</div> +<div class="standard" id='magicparlabel-7391'>A very useful script is <span class="flex_bashscript">zipup</span> which makes a file <span class="flex_file"><i>binary_c</i>.zip</span> containing this manual and all the source code. See also <span class="flex_perlscript">grid.pl</span>.</div> -<div class="standard" id='magicparlabel-7234'><br /> +<div class="standard" id='magicparlabel-7404'><br /> </div> -<h2 class="section" id='magicparlabel-7235'><span class="section_label">9</span> Advanced Configuration</h2> -<div class="standard" id='magicparlabel-7236'><div id="subsec_Advanced_Configuration"></div> +<h2 class="section" id='magicparlabel-7405'><span class="section_label">9</span> Advanced Configuration</h2> +<div class="standard" id='magicparlabel-7406'><div id="subsec_Advanced_Configuration"></div> </div> -<div class="standard" id='magicparlabel-7237'>There are three main configuration files which affect how the <i>binary_c</i> code is built: <span class="flex_headerfile">binary_c_code_options.h</span>, <span class="flex_headerfile">binary_c_parameters.h</span> and <span class="flex_headerfile">nucsyn/nucsyn_parameters.h</span>.</div> - -<div class="standard" id='magicparlabel-7250'>Also, some options are enabled via the <span class="flex_file">Makefile</span> (set up by the <em><span class="flex_perlscript">configure</span> </em>script). </div> -<h3 class="subsection" id='magicparlabel-7259'><span class="subsection_label">9.1</span> configure</h3> -<div class="standard" id='magicparlabel-7260'>The <span class="flex_perlscript">configure</span><em> </em>script should be run before you do anything else. It makes the <span class="flex_file">Makefile</span> and also makes a source file called <span class="flex_headerfile">nucsyn/nucsyn_unrolled_functions.h</span>. This function contains loop–unrolled versions of a few bottleneck functions which execute more quickly than if they were in loops (yes, even telling the compiler to unroll the loops is not as fast).</div> - -<div class="standard" id='magicparlabel-7273'>When you change something in <span class="flex_headerfile">binary_structures.h</span> you may have to rerun configure because this in turn reruns <span class="flex_perlscript">make_showstruct.pl</span> which builds code to show the contents of <span class="flex_cstruct">stardata_t</span> structures.</div> -<h3 class="subsection" id='magicparlabel-7286'><span class="subsection_label">9.2</span> <i>binary_c</i>-config<div id="subsec_binary_c_config"></div> +<div class="standard" id='magicparlabel-7407'>There are three main <i>C</i> header files which affect how the <i>binary_c</i> code is built: <span class="flex_headerfile">binary_c_code_options.h</span>, <span class="flex_headerfile">binary_c_parameters.h</span> and <span class="flex_headerfile">nucsyn/nucsyn_parameters.h</span>. Some low-level configuration is also performed by the <span class="flex_software">Meson</span> build process.</div> +<h3 class="subsection" id='magicparlabel-7424'><span class="subsection_label">9.1</span> Meson configuation</h3> +<div class="standard" id='magicparlabel-7425'>When you change something in <span class="flex_headerfile">binary_structures.h</span>, or one of the other header files, you may have to reconfigure <span class="flex_software">Meson</span> because this in turn reruns <span class="flex_perlscript">make_showstruct.pl</span> which builds code to show the contents of <span class="flex_cstruct">stardata_t</span> structures.</div> +<h3 class="subsection" id='magicparlabel-7442'><span class="subsection_label">9.2</span> <i>binary_c</i>-config<div id="subsec_binary_c_config"></div> </h3> -<div class="standard" id='magicparlabel-7287'>Many <em><span class="flex_os"><em>Unix</em></span>-</em>type commands have an associated <span class="flex_command">*-config</span> command which gives details of their build flags, version, build date etc. As of recently, so does <i>binary_c</i>, so you can run,</div> +<div class="standard" id='magicparlabel-7443'>Many <em><span class="flex_os"><em>Unix</em></span>-</em>type commands have an associated <span class="flex_command">*-config</span> command which gives details of their build flags, version, build date etc. As of recently, so does <i>binary_c</i>, so you can run,</div> -<div class="standard" id='magicparlabel-7296'><br /> +<div class="standard" id='magicparlabel-7452'><br /> <pre class\s*='listings bash'>$ <i>binary_c</i>-config help</pre><br /> to see the available flags, which at the time of writing are<br /> <pre class ='listings'>--cflags Show the flags which were used to build <i>binary_c</i> (same as --flags) @@ -7206,7 +7251,7 @@ to see the available flags, which at the time of writing are<br /> --undef_macros Show macros undefined by -U... in the CFLAGS</pre><br /> </div> -<div class="standard" id='magicparlabel-7325'>note that the double minus sign is optional (it can be one minus, or none). For example,<br /> +<div class="standard" id='magicparlabel-7481'>note that the double minus sign is optional (it can be one minus, or none). For example,<br /> <pre class ='listings'>$ <i>binary_c</i>-config define_macros -DALIGNSIZE=16 -DCPUFREQ=3500 -DLINUX -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DGIT_REVISION=4132:20190711:e754a8a7 -DGIT_URL=gitlab@gitlab.eps.surrey.ac.uk:ri0005/<i>binary_c</i>.git -DGIT_BRANCH=izzard-discs -D__HAVE_AVX__ -D__HAVE_DRAND48__ -D__HAVE_GSL__ -DUSE_GSL -D__HAVE_LIBBACKTRACE__ -D__HAVE_LIBBFD__ -D__HAVE_LIBBSD__ -D__HAVE_LIBIBERTY__ -D__HAVE_LIBMEMOIZE__ -D__HAVE_MALLOC_H__ -D__HAVE_PKG_CONFIG__ -D__HAVE_VALGRIND__ -D__SHOW_STARDATA__ @@ -7217,24 +7262,24 @@ $ <i>binary_c</i>-config cflags -DALIGNSIZE=16 -fPIC -Wall -Wstrict-prototypes -O3 -mtune=native -march=native -DCPUFREQ=3500 -DLINUX -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -frounding-math -fsignaling-nans -fno-finite-math-only -fno-stack-protector -ffloat-store -fno-fast-math -DGIT_REVISION=4132:20190711:e754a8a7 -DGIT_URL=gitlab@gitlab.eps.surrey.ac.uk:ri0005/<i>binary_c</i>.git -DGIT_BRANCH=izzard-discs -D__HAVE_AVX__ -mavx -D__HAVE_DRAND48__ -D__HAVE_GSL__ -DUSE_GSL -I/home/izzard/include -D__HAVE_LIBBACKTRACE__ -D__HAVE_LIBBFD__ -D__HAVE_LIBBSD__ -D__HAVE_LIBIBERTY__ -D__HAVE_LIBMEMOIZE__ -D__HAVE_MALLOC_H__ -D__HAVE_PKG_CONFIG__ -D__HAVE_VALGRIND__ -D__SHOW_STARDATA__ -mtune=native -ffunction-sections -mtune=native -march=native -fsignaling-nans -fno-finite-math-only -fsignaling-nans -fno-finite-math-only</pre><br /> </div> -<div class="standard" id='magicparlabel-7337'>The <i>binary_grid</i> <span class="flex_scriptinglanguage">Perl</span> module makes extensive use of <span class="flex_bashscript"><i>binary_c</i>-config</span> to determine which flags it should use to build its <span class="flex_programminglanguage">C</span> interface to <i>libbinary_c</i>.</div> +<div class="standard" id='magicparlabel-7493'>The <i>binary_grid</i> <span class="flex_scriptinglanguage">Perl</span> module makes extensive use of <span class="flex_bashscript"><i>binary_c</i>-config</span> to determine which flags it should use to build its <span class="flex_programminglanguage">C</span> interface to <i>libbinary_c</i>.</div> -<div class="standard" id='magicparlabel-7350'>Note that the <span class="flex_command"><i>binary_c</i>-config</span> tool is actually a <span class="flex_scriptinglanguage">bash</span> script that requires <i>binary_c</i> to be built, and working tools such as <span class="flex_command">grep</span>, <span class="flex_command">tr</span>, <span class="flex_command">sed</span> and <span class="flex_command">ldd</span>. These are standard tools on most <span class="flex_os">Unix</span> systems.</div> -<h3 class="subsection" id='magicparlabel-7379'><span class="subsection_label">9.3</span> Makefile -D…</h3> -<div class="standard" id='magicparlabel-7380'>Some options are set up by <span class="flex_command">configure</span><em> </em>and passed into the <span class="flex_file">Makefile</span><em> </em>as <span class="flex_args">-D…</span> arguments to the compiler:</div> +<div class="standard" id='magicparlabel-7506'>Note that the <span class="flex_command"><i>binary_c</i>-config</span> tool is actually a <span class="flex_scriptinglanguage">bash</span> script that requires <i>binary_c</i> to be built, and working tools such as <span class="flex_command">grep</span>, <span class="flex_command">tr</span>, <span class="flex_command">sed</span> and <span class="flex_command">ldd</span>. These are standard tools on most <span class="flex_os">Unix</span> systems.</div> +<h3 class="subsection" id='magicparlabel-7535'><span class="subsection_label">9.3</span> Makefile -D…</h3> +<div class="standard" id='magicparlabel-7536'>Some options are set up by <span class="flex_software">Meson</span><em> </em>and passed<em> </em>as <span class="flex_args">-D…</span> arguments to the compiler:</div> -<ul class="itemize" id='magicparlabel-7393'><li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>LINUX</span> is defined if you're running <span class="flex_os">Linux</span>. This is useful for some timers and segfault catchers which only work with the <span class="flex_os">Linux</span> libraries.</li> +<ul class="itemize" id='magicparlabel-7545'><li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>LINUX</span> is defined if you're running <span class="flex_os">Linux</span>. This is useful for some timers and segfault catchers which only work with the <span class="flex_os">Linux</span> libraries.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>LARGEFILE_SOURCE</span> and <span style='font-family:monospace;font-size: 18px;'>FILE_OFFSET_BITS</span> were once useful for large output files on 64-bit machines (>2GB). This may no longer be a problem but they do not hurt.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>CPUFREQ</span> is the frequency of your CPU (in Mhz) – this is very useful for timing information. (Taken from <span class="flex_file">/proc/cpuinfo</span> if available, <span class="flex_command">sysctl -a</span> on MacOS/Darwin) </li> -<li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>GIT_REVISION</span> and <span style='font-family:monospace;font-size: 18px;'>GIT_URL</span> provide <em><i>binary_c</i></em> with information about the version of the code you are using. This can prove essential when debugging. See section <a href="#subsec_git_revision">11.17</a> for more details.</li> +<li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>GIT_REVISION</span> and <span style='font-family:monospace;font-size: 18px;'>GIT_URL</span> provide <em><i>binary_c</i></em> with information about the version of the code you are using. This can prove essential when debugging. See section <a href="#subsec_git_revision">11.17</a> for more details. </li> </ul> -<h3 class="subsection" id='magicparlabel-7413'><span class="subsection_label">9.4</span> binary_c_code_options.h</h3> -<div class="standard" id='magicparlabel-7414'><div id="subsec_binary_c_code_options_h"></div> +<h3 class="subsection" id='magicparlabel-7565'><span class="subsection_label">9.4</span> binary_c_code_options.h</h3> +<div class="standard" id='magicparlabel-7566'><div id="subsec_binary_c_code_options_h"></div> This contains <em>non-physics</em> options. You probably do not want to change this file unless you have compilation problems or you want to optimize the code (even more!). The options are the following (in the order given in the file)</div> -<ul class="itemize" id='magicparlabel-7415'><li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>SEGFAULTS</span> This should be set if want segfaults on a code failure. This is useful if you are debugging with gdb.</li> -<li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>ACML</span> should be set if you wish to use the AMD math (sic) library. This should not be set here, but with in the <em>Makefile</em> with the <em>configure</em> script.</li> -<li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>DUMA</span> should be set if you wish to use the DUMA memory checking library. This should not be set here, but with in the <em>Makefile</em> with the <em>configure</em> script.</li> +<ul class="itemize" id='magicparlabel-7567'><li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>SEGFAULTS</span> This should be set if want segfaults on a code failure. This is useful if you are debugging with gdb.</li> +<li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>ACML</span> should be set if you wish to use the AMD math (sic) library. Note: this has not been tested for a long time.</li> +<li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>DUMA</span> should be set if you wish to use the DUMA memory checking library. Note: this has not been tested for a long time.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>DEBUG</span> is either zero (<span style='font-family:monospace;font-size: 18px;'>0</span>) or one (<span style='font-family:monospace;font-size: 18px;'>1</span>). All debugging statements should use the <span style='font-family:monospace;font-size: 18px;'>Dprint</span> function instead of the standard <i>C</i>-library function <span style='font-family:monospace;font-size: 18px;'>printf</span>. If <span style='font-family:monospace;font-size: 18px;'>DEBUG</span> is zero, then the compiler should never build the debug statements into the code (modern compilers will behave in this way). However, if in doubt enable the <span style='font-family:monospace;font-size: 18px;'>DISABLE_DPRINT</span> option.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>COMPARE_FORTRAN</span> activates a number of extra print statements for comparison with a version of Jarrod's <i>FORTRAN</i> code I have lying around. It's probably of little interest to you.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>LOGGING</span> Enables logging, you want this otherwise what is the point in running the code?</li> @@ -7255,7 +7300,7 @@ This contains <em>non-physics</em> options. You probably do not want to change t <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>MILLISECOND_RANDOMNESS</span> Improves the resolution of the random number seed. You probably want this.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>IDUM_COMMAND_LINE_SPECIFICATION</span> Allows you to specify the random number (<span style='font-family:monospace;font-size: 18px;'>IDUM</span>) seed on the command line (<span style='font-family:monospace;font-size: 18px;'>--idum xyz</span>)</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>SAVE_IDUM</span> and I<span style='font-family:monospace;font-size: 18px;'>DUM_LOG</span> log the random number which is used, just so you can check it. (<span style='font-family:monospace;font-size: 18px;'>IDUM_LOG_STREAM </span>sets the output stream, usually <span style='font-family:monospace;font-size: 18px;'>stderr</span>).</li> -<li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>UNROLL_NUCSYN_LOOPS</span> allows use of the automatically generated loop unrolling as done in the configure script (see above). This seems to work, and is generally faster, but you should check.</li> +<li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>UNROLL_NUCSYN_LOOPS</span> allows use of the automatically generated loop unrolling. <b>Note: this option is deprecated.</b></li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>NANCHECKS</span> enables checks in many parts of the code for <span style='font-family:monospace;font-size: 18px;'>NaN</span> (Not A Number). While <em>this is slow</em> it is very useful for catching bugs.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>STATIC_ARRAYS</span> prevents memory space which is in stardata or its child structures (star_t, common_t, model_t, preferences_t etc) from being allocated dynamically, i.e. with malloc or calloc. Instead, the space is allocated statically. This has the advantage that the whole stardata structure can be copied and replaced with another (for some experimental code this is <em>required</em>). In later versions the dynamic allocation option may be removed (i.e. <span class="flex_cmacro">STATIC_ARRAYS</span> will be standard). I know this goes against programming ideals, in which all memory should be dynamically allocated, but it makes life much easier.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>CC_TIMER</span> does not work but perhaps you can fix it.</li> @@ -7264,11 +7309,11 @@ This contains <em>non-physics</em> options. You probably do not want to change t <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>RANDOM_SYSTEMS </span>is used in conjunction with <span style='font-family:monospace;font-size: 18px;'>--repeat </span>to run randomly chosen systems to check for bugs. This is deprecated and will be removed in future. Instead you should use the <span style='font-family:monospace;font-size: 18px;'>random_systems.pl</span> script to generate random binaries. </li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>MULTISTAR</span> is an experimental attempt to run many stars in parallel. It does not work and is highly experimental.</li> </ul> -<h3 class="subsection" id='magicparlabel-7452'><span class="subsection_label">9.5</span> binary_c_parameters.h</h3> -<div class="standard" id='magicparlabel-7453'><div id="subsec_binary_c_parameters_h"></div> +<h3 class="subsection" id='magicparlabel-7604'><span class="subsection_label">9.5</span> binary_c_parameters.h</h3> +<div class="standard" id='magicparlabel-7605'><div id="subsec_binary_c_parameters_h"></div> The options in this file are non-nucleosynthesis, (single or) binary stellar evolution options. This file also automatically includes many header files, <span class="flex_headerfile">binary_c_code_options.h</span> and <span class="flex_headerfile">nucsyn_parameters.h</span> so is very useful as a “catch-all” at the top of each source code file. </div> -<ul class="itemize" id='magicparlabel-7462'><li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>AXEL</span> if this is defined then Axel Bonacic's changes to the code are applied (but <em>NOT necessarily</em> <span style='font-family:monospace;font-size: 18px;'>AXEL_RGB_FIX</span>). <em><b>WARNING!</b></em> This is often broken and subject to development. Axel's code is not usually that well tested…</li> +<ul class="itemize" id='magicparlabel-7614'><li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>AXEL</span> if this is defined then Axel Bonacic's changes to the code are applied (but <em>NOT necessarily</em> <span style='font-family:monospace;font-size: 18px;'>AXEL_RGB_FIX</span>). <em><b>WARNING!</b></em> This is often broken and subject to development. Axel's code is not usually that well tested…</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>SMOOTH_AGB</span> enables code to smooth the HR-diagram through the transition between the original overshooting models and Amanda's TPAGB models. May not be reliable – you may want to use <span style='font-family:monospace;font-size: 18px;'>ROBSMOOTH</span> instead.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>ROBSMOOTH</span> does the same as <span style='font-family:monospace;font-size: 18px;'>SMOOTH_AGB</span> but is simpler and more reliable.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>NUMBER_OF_STARS</span> This should always be defined as 2, it is a binary star code…</li> @@ -7621,7 +7666,7 @@ The options in this file are non-nucleosynthesis, (single or) binary stellar evo -<ul class="itemize" id='magicparlabel-7555'><li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>NO_MERGER_NUCLEOSYNTHESIS</span> Stops ignition of helium cores when they merge (<a href='#LyXCite-2002MNRAS_329_897H'><span class="bib-abbrvciteauthor">Hurley et al.</span>, <span class="bib-year">2002</span></a> did this but I do not believe it is correct)</li> +<ul class="itemize" id='magicparlabel-7707'><li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>NO_MERGER_NUCLEOSYNTHESIS</span> Stops ignition of helium cores when they merge (<a href='#LyXCite-2002MNRAS_329_897H'><span class="bib-abbrvciteauthor">Hurley et al.</span>, <span class="bib-year">2002</span></a> did this but I do not believe it is correct)</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>HeWD_HeCORE_MERGER_IGNITION</span> Forces HeWD+GB to form a new GB star, and HeWD+CHeB to form a new CHeB star (a little thought tells you that the latter cannot happen)</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>LOG_COMENV_RSTARS</span> Logs R star mergers resulting from common envelope evolution</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>LOG_RSTARS</span> Logs R stars during the CHeB stage</li> @@ -7795,16 +7840,16 @@ The options in this file are non-nucleosynthesis, (single or) binary stellar evo <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>PN_PROJECT</span> is a catchall for Rob's PN+nucleosynthesis project.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>WRLOF_MASS_TRANSFER</span> is Carlo Abate's wind-RLOF prescription (see Abate et al 2013, MNRAS accepted).</li> </ul> -<h3 class="subsection" id='magicparlabel-7616'><span class="subsection_label">9.6</span> nucsyn/nucsyn_parameters.h</h3> -<div class="standard" id='magicparlabel-7617'><div id="subsec_nucsyn_nucsyn_parameters_h"></div> +<h3 class="subsection" id='magicparlabel-7768'><span class="subsection_label">9.6</span> nucsyn/nucsyn_parameters.h</h3> +<div class="standard" id='magicparlabel-7769'><div id="subsec_nucsyn_nucsyn_parameters_h"></div> While many important options are set on the command line the options governing which nucleosynthesis algorithms to use and what to output are set in the file <span class="flex_headerfile">nucsyn/nucsyn_parameters.h</span>. More detailed descriptions of the variables used in the code are given in section <a href="#sec_Code_description">8</a>.</div> -<ul class="itemize" id='magicparlabel-7622'><li class="itemize_item">Enable <span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP</span> to make first dredge-up happen on the GB. +<ul class="itemize" id='magicparlabel-7774'><li class="itemize_item">Enable <span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP</span> to make first dredge-up happen on the GB. <br /> -<ul class="itemize" id='magicparlabel-7623'><li class="itemize_item">You want this, and probably you want to enable <span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP_AMANDAS_TABLE</span> and <span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP_ACCRETION_CORRECTION</span>. These enable tabular lookups of the abundance changes (better than fitting formulae) and a simple prescription to deal with abundance changes due to accretion.</li> +<ul class="itemize" id='magicparlabel-7775'><li class="itemize_item">You want this, and probably you want to enable <span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP_AMANDAS_TABLE</span> and <span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP_ACCRETION_CORRECTION</span>. These enable tabular lookups of the abundance changes (better than fitting formulae) and a simple prescription to deal with abundance changes due to accretion.</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP_ACCRETION_CORRECTION_FROM_TAMS</span> is similar but bases changes on the <em>terminal-age main sequence</em> abundances – this is better in the case of accretion of e.g. carbon (i.e. for CEMPs). </li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP_PHASE_IN</span> enables a phased change of the abundance to better match detailed models (the default model assumes that 1st DUP happens instantaneously). </li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP_RICHARDS_TABLE</span> should be enabled in addition to <span style='font-family:monospace;font-size: 18px;'>NUCSYN_FIRST_DREDGE_UP_AMANDAS_TABLE</span> to use Richard Stancliffe's models in place of Amanda's when in the appropriate mass/metallicity range (down to <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -7839,7 +7884,7 @@ While many important options are set on the command line the options governing w -<ul class="itemize" id='magicparlabel-7629'><li class="itemize_item">You probably also want <span style='font-family:monospace;font-size: 18px;'>NUCSYN_THIRD_DREDGE_UP_AMANDA</span> to get the intershell abundances from a table based on Amanda's models.</li> +<ul class="itemize" id='magicparlabel-7781'><li class="itemize_item">You probably also want <span style='font-family:monospace;font-size: 18px;'>NUCSYN_THIRD_DREDGE_UP_AMANDA</span> to get the intershell abundances from a table based on Amanda's models.</li> <li class="itemize_item">You can choose whether to get these numbers from either the old data <span style='font-family:monospace;font-size: 18px;'>USE_TABULAR_INTERSHELL_ABUNDANCES_KARAKAS_2002</span> (no s-process; use only for testing!) or the new table <span style='font-family:monospace;font-size: 18px;'>USE_TABULAR_INTERSHELL_ABUNDANCES_KARAKAS_2012</span> (with s-process, deprecates the Busso/Gallino tables which have been removed).</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>MINIMUM_ENVELOPE_MASS_FOR_THIRD_DREDGEUP</span> is the minimum mass for third dredge up, set on the command line with <span style='font-family:monospace;font-size: 18px;'>--minimum_envelope_mass_for_third_dredgeup</span> or <span style='font-family:monospace;font-size: 18px;'>MINIMUM_ENVELOPE_MASS_FOR_THIRD_DREDGEUP_DEFAULT</span> by default (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> @@ -7961,7 +8006,7 @@ While many important options are set on the command line the options governing w -<ul class="itemize" id='magicparlabel-7646'><li class="itemize_item">If you choose <span style='font-family:monospace;font-size: 18px;'>NUCSYN_ANAL_BURN</span> you can specify which nuclear reactions to include: <span style='font-family:monospace;font-size: 18px;'>NUCSYN_TPAGB_HBB_CN_CYCLE</span> and <span style='font-family:monospace;font-size: 18px;'>NUCSYN_TPAGB_HBB_ON_CYCLE</span> are the CN and ON parts of the CNO cycling in HBB, <span style='font-family:monospace;font-size: 18px;'>NUCSYN_TPAGB_HBB_NeNa_CYCLE</span> activates the approximate NeNa cycling, <span style='font-family:monospace;font-size: 18px;'>NUCSYN_TPAGB_HBB_MgAl_CYCLE</span> activates the approximate MgAl cycling. Enable <span style='font-family:monospace;font-size: 18px;'>NUCSYN_CNO_ASSUME_STABLE</span> to assume solutions of the CNO quadratic are always real (i.e. a stable solution, neglect the oscillating parts), <span style='font-family:monospace;font-size: 18px;'>NUCSYN_NENA_LEAK</span> will allow leakage from NeNa to MgAl (do this), <span style='font-family:monospace;font-size: 18px;'>NUCSYN_Na22_EQUILIBRIUM</span> will force Na22 into equilibrium (otherwise it is not calculated because it is unstable and you probably do not care), <span style='font-family:monospace;font-size: 18px;'>NUCSYN_Al26m</span> follows the metastable state of <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> +<ul class="itemize" id='magicparlabel-7798'><li class="itemize_item">If you choose <span style='font-family:monospace;font-size: 18px;'>NUCSYN_ANAL_BURN</span> you can specify which nuclear reactions to include: <span style='font-family:monospace;font-size: 18px;'>NUCSYN_TPAGB_HBB_CN_CYCLE</span> and <span style='font-family:monospace;font-size: 18px;'>NUCSYN_TPAGB_HBB_ON_CYCLE</span> are the CN and ON parts of the CNO cycling in HBB, <span style='font-family:monospace;font-size: 18px;'>NUCSYN_TPAGB_HBB_NeNa_CYCLE</span> activates the approximate NeNa cycling, <span style='font-family:monospace;font-size: 18px;'>NUCSYN_TPAGB_HBB_MgAl_CYCLE</span> activates the approximate MgAl cycling. Enable <span style='font-family:monospace;font-size: 18px;'>NUCSYN_CNO_ASSUME_STABLE</span> to assume solutions of the CNO quadratic are always real (i.e. a stable solution, neglect the oscillating parts), <span style='font-family:monospace;font-size: 18px;'>NUCSYN_NENA_LEAK</span> will allow leakage from NeNa to MgAl (do this), <span style='font-family:monospace;font-size: 18px;'>NUCSYN_Na22_EQUILIBRIUM</span> will force Na22 into equilibrium (otherwise it is not calculated because it is unstable and you probably do not care), <span style='font-family:monospace;font-size: 18px;'>NUCSYN_Al26m</span> follows the metastable state of <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow> <msup><mrow /> @@ -8072,7 +8117,7 @@ While many important options are set on the command line the options governing w -<ul class="itemize" id='magicparlabel-7657'><li class="itemize_item">In the case of <span style='font-family:monospace;font-size: 18px;'>NUCSYN_CCSNE_WOOSLEY_WEAVER_1995</span> you can choose to use their <span style='font-family:monospace;font-size: 18px;'>NUCSYN_SUPERNOVAE_CC_WW95_A</span> or <span style='font-family:monospace;font-size: 18px;'>B</span> or <span style='font-family:monospace;font-size: 18px;'>C</span> models.</li> +<ul class="itemize" id='magicparlabel-7809'><li class="itemize_item">In the case of <span style='font-family:monospace;font-size: 18px;'>NUCSYN_CCSNE_WOOSLEY_WEAVER_1995</span> you can choose to use their <span style='font-family:monospace;font-size: 18px;'>NUCSYN_SUPERNOVAE_CC_WW95_A</span> or <span style='font-family:monospace;font-size: 18px;'>B</span> or <span style='font-family:monospace;font-size: 18px;'>C</span> models.</li> <li class="itemize_item">In the case of <span style='font-family:monospace;font-size: 18px;'>NUCSYN_CCSNE_CHIEFFI_LIMONGI_2004</span> you can either use their yields directly (best to do this as then the yields really are a function of mass cut) or use the Portinari-corrected versions which are less accurate (<span style='font-family:monospace;font-size: 18px;'>NUCSYN_CCSNE_CHIEFFI_LIMONGI_2004_PORTINARI</span>). Define <span style='font-family:monospace;font-size: 18px;'>NUCSYN_CCSNE_CHIEFFI_LIMONGI_2004_EXTRAPOLATE</span> to extrapolate beyond the end of their table at the high metallicity (<math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow> <mrow><mi>Z</mi><mo>></mo><mn>0.02</mn> @@ -8251,79 +8296,64 @@ While many important options are set on the command line the options governing w <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>MATTSSON_MASS_LOSS</span> experimental mass-loss rates from Lars Mattsson (based on carbon abundances).</li> <li class="itemize_item"><span style='font-family:monospace;font-size: 18px;'>LITHIUM_TAB</span>LES experiments to introduce lithium as a function of mass and pulse number in HBBing stars.</li> </ul> -<div class="standard" id='magicparlabel-7703'>Now you have edited this file to your specifications you need to rebuild the code. The simplest way is </div> - -<div class="standard" id='magicparlabel-7704'><br /> -<pre class\s*='listings bash'>$ make</pre><br /> -but if the compile fails, try</div> - -<div class="standard" id='magicparlabel-7709'><br /> -<pre class\s*='listings bash'>$ make clean -$ make</pre><br /> -</div> - -<div class="standard" id='magicparlabel-7715'><span class="flex_command">configure</span> is supposed to detect your CPU but I have limited machines on which to test this feature. Please add your machine to the list in <span class="flex_file">configure</span> if it fails, or as a last resort try,</div> - -<div class="standard" id='magicparlabel-7724'><br /> -<pre class\s*='listings bash'>$ ./configure generic</pre><br /> -</div> +<div class="standard" id='magicparlabel-7855'>Now you have edited this file to your specifications you need to rebuild the code. </div> -<div class="standard" id='magicparlabel-7729'>There are further options in the file <span class="flex_file">binary_c_parameters.h</span> (details below) although it's unlikely you'll want to change any of them.</div> +<div class="standard" id='magicparlabel-7856'>There are further options in the file <span class="flex_file">binary_c_parameters.h</span> (details below) although it's unlikely you'll want to change any of them.</div> -<div class="standard" id='magicparlabel-7734'><br /> +<div class="standard" id='magicparlabel-7861'><br /> </div> -<h2 class="section" id='magicparlabel-7735'><span class="section_label">10</span> <em><i>binary_c</i> </em>software development cycle</h2> -<div class="standard" id='magicparlabel-7738'>This section describes the <span class='math'>binary_c</i></span> +<h2 class="section" id='magicparlabel-7862'><span class="section_label">10</span> <em><i>binary_c</i> </em>software development cycle</h2> +<div class="standard" id='magicparlabel-7865'>This section describes the <span class='math'>binary_c</i></span> software development cycle.</div> -<h3 class="subsection" id='magicparlabel-7739'><span class="subsection_label">10.1</span> The git revolution</h3> -<div class="standard" id='magicparlabel-7740'>In its earliest days, I was the only person using <span class='math'>binary_c</i></span> +<h3 class="subsection" id='magicparlabel-7866'><span class="subsection_label">10.1</span> The git revolution</h3> +<div class="standard" id='magicparlabel-7867'>In its earliest days, I was the only person using <span class='math'>binary_c</i></span> . It didn't really work properly, so this was not surprising. As time went on, I aged and other, younger people started using <span class='math'>binary_c</i></span> . While this is great, it puts some burden on me as the maintainer. However, there is a better way! The decision was made to put <span class='math'>binary_c</i></span> - into subversion (<span class="flex_software">SVN</span>) and all<div class="foot"><span class="foot_label">11</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-7748'>Well, <em>some</em>…</div> + into subversion (<span class="flex_software">SVN</span>) and all<div class="foot"><span class="foot_label">12</span><div class="foot_inner"><div class="plain_layout" id='magicparlabel-7875'>Well, <em>some</em>…</div> </div></div> was solved. Unfortunately, the University of Surrey has no <span class="flex_software">SVN</span> support, so I had to move everything to git which is apparently more modern (although I cannot really tell the difference).</div> -<div class="standard" id='magicparlabel-7753'>You could use a graphical interface, such as <span class="flex_software">Gitkraken</span>, to work with <span class="flex_software">git</span><em> – </em>this may save you a lot of time and effort!</div> -<h3 class="subsection" id='magicparlabel-7762'><span class="subsection_label">10.2</span> The master(trunk)–branch model<div id="sec_The_trunk_branch_model"></div> +<div class="standard" id='magicparlabel-7880'>You could use a graphical interface, such as <span class="flex_software">Gitkraken</span>, to work with <span class="flex_software">git</span><em> – </em>this may save you a lot of time and effort!</div> +<h3 class="subsection" id='magicparlabel-7889'><span class="subsection_label">10.2</span> The master(trunk)–branch model<div id="sec_The_trunk_branch_model"></div> </h3> -<div class="standard" id='magicparlabel-7763'>Code on <span class="flex_software">git</span> is like a tree. The main version of <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-7890'>Code on <span class="flex_software">git</span> is like a tree. The main version of <span class='math'>binary_c</i></span> resides in the <em>master</em> version (like <span class="flex_software">SVN</span>'s <em>trunk</em>). When you first requested access to<em> </em><span class='math'>binary_c</i></span>, Rob will have made you a copy of the latest master version. This copy is called your <em>branch</em>. You could, in theory, have more than one <em>branch</em>, like a real (healthy) tree, but most people have just one branch.</div> -<div class="standard" id='magicparlabel-7772'>To get <span class='math'>binary_c</i></span>, run</div> +<div class="standard" id='magicparlabel-7899'>To get <span class='math'>binary_c</i></span>, run</div> -<div class="standard" id='magicparlabel-7773'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-7900'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings'>git clone gitlab@gitlab.eps.surrey.ac.uk:ri0005/<i>binary_c</i>.git</pre><br /> </span>and you can make a new branch with <span class="flex_software">git</span> branch. </div> -<div class="standard" id='magicparlabel-7782'>In your branch you can do <em>whatever you like</em>! Change the code, delete things, make new things, whatever. It's your branch. But, beware. You will want bug fixes to merge easily, so don't change your branch too radically, and make sure you update with trunk changes regularly (see Section <a href="#subsec_Updating_with_the">10.2.1</a> below).</div> -<h4 class="subsubsection" id='magicparlabel-7783'><span class="subsubsection_label">10.2.1</span> Updating with the latest fixes<div id="subsec_Updating_with_the"></div> +<div class="standard" id='magicparlabel-7909'>In your branch you can do <em>whatever you like</em>! Change the code, delete things, make new things, whatever. It's your branch. But, beware. You will want bug fixes to merge easily, so don't change your branch too radically, and make sure you update with trunk changes regularly (see Section <a href="#subsec_Updating_with_the">10.2.1</a> below).</div> +<h4 class="subsubsection" id='magicparlabel-7910'><span class="subsubsection_label">10.2.1</span> Updating with the latest fixes<div id="subsec_Updating_with_the"></div> </h4> -<div class="standard" id='magicparlabel-7784'>The <em>master</em> is periodically updated with fixes. Only Rob can do this. However, he posts to the <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-7911'>The <em>master</em> is periodically updated with fixes. Only Rob can do this. However, he posts to the <span class='math'>binary_c</i></span> mailing list to describe what he has done. Now, let's say you want to merge these fixes with your branch. You have to do </div> -<div class="standard" id='magicparlabel-7785'><br /> +<div class="standard" id='magicparlabel-7912'><br /> <pre class ='listings'>git merge</pre><br /> and you're done.</div> -<div class="standard" id='magicparlabel-7790'>Beware: there may be conflicts with your code (you will be informed). <em>git</em> tries very hard to merge code automatically, but sometimes this just is not possible. You have to fix these files and then tell git they are fixed.</div> +<div class="standard" id='magicparlabel-7917'>Beware: there may be conflicts with your code (you will be informed). <em>git</em> tries very hard to merge code automatically, but sometimes this just is not possible. You have to fix these files and then tell git they are fixed.</div> -<div class="standard" id='magicparlabel-7791'>Rob <em>assumes</em> you merge the trunk regularly and often. If you leave a long time between merging you will have problems, often because something in the code <em>on which you rely</em> has been changed (hopefully for the better). Do not let this happen! Merge regularly and often.</div> -<h4 class="subsubsection" id='magicparlabel-7792'><span class="subsubsection_label">10.2.2</span> Committing your changes</h4> -<div class="standard" id='magicparlabel-7793'>When you make changes in your branch, you should <em>commit</em> your code. Do this with</div> +<div class="standard" id='magicparlabel-7918'>Rob <em>assumes</em> you merge the trunk regularly and often. If you leave a long time between merging you will have problems, often because something in the code <em>on which you rely</em> has been changed (hopefully for the better). Do not let this happen! Merge regularly and often.</div> +<h4 class="subsubsection" id='magicparlabel-7919'><span class="subsubsection_label">10.2.2</span> Committing your changes</h4> +<div class="standard" id='magicparlabel-7920'>When you make changes in your branch, you should <em>commit</em> your code. Do this with</div> -<div class="standard" id='magicparlabel-7794'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-7921'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings'>git commit </pre><br /> </span>or possibly</div> -<div class="standard" id='magicparlabel-7799'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-7926'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings'>git commit -a</pre><br /> </span>which then will ask you to write a comment describing your changes. Please use your brain – one word comments are not (usually) of much use either to you or anyone else.</div> -<div class="standard" id='magicparlabel-7804'>You should commit regularly and often. I do it every night. You then have a backup of your code for free!</div> -<h4 class="subsubsection" id='magicparlabel-7805'><span class="subsubsection_label">10.2.3</span> Submitting changes to the <em>master</em></h4> -<div class="standard" id='magicparlabel-7806'>Only Rob can/should make changes to the <em>master</em>. If you are ready to have your changes incorporated into the main version of <span class='math'>binary_c</i></span> +<div class="standard" id='magicparlabel-7931'>You should commit regularly and often. I do it every night. You then have a backup of your code for free!</div> +<h4 class="subsubsection" id='magicparlabel-7932'><span class="subsubsection_label">10.2.3</span> Submitting changes to the <em>master</em></h4> +<div class="standard" id='magicparlabel-7933'>Only Rob can/should make changes to the <em>master</em>. If you are ready to have your changes incorporated into the main version of <span class='math'>binary_c</i></span> which, need I remind you, you are obliged to do by the terms of the licence agreement, you should do the following:</div> -<ul class="itemize" id='magicparlabel-7807'><li class="itemize_item">Run <span style='font-family:monospace;font-size: 18px;'><br /> +<ul class="itemize" id='magicparlabel-7934'><li class="itemize_item">Run <span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings'>git pull</pre><br /> </span> to make sure you have the latest version of your code.</li> <li class="itemize_item">Test your code to make sure it works as you expect.</li> @@ -8339,96 +8369,98 @@ and you're done.</div> </span>to send code to the server.</li> <li class="itemize_item">Email Rob, tell him your branch is ready to commit, and tell him the <span class="flex_software">git</span> revision number of your last commit. You can also submit merge requests via the <span class="flex_software">gitlab</span> interface.</li> </ul> -<div class="standard" id='magicparlabel-7838'>The rest is Rob's job. If you want another branch to work on while you wait, just do it.</div> -<h4 class="subsubsection" id='magicparlabel-7839'><span class="subsubsection_label">10.2.4</span> Getting your old code back</h4> -<div class="standard" id='magicparlabel-7840'>If you make a mistake, you can always get your old code back.</div> +<div class="standard" id='magicparlabel-7965'>The rest is Rob's job. If you want another branch to work on while you wait, just do it.</div> +<h4 class="subsubsection" id='magicparlabel-7966'><span class="subsubsection_label">10.2.4</span> Getting your old code back</h4> +<div class="standard" id='magicparlabel-7967'>If you make a mistake, you can always get your old code back.</div> -<div class="standard" id='magicparlabel-7841'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-7968'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings'>git revert </pre><br /> </span> will change a file back to the version currently on the server.</div> -<div class="standard" id='magicparlabel-7846'><br /> +<div class="standard" id='magicparlabel-7973'><br /> </div> -<h2 class="section" id='magicparlabel-7847'><span class="section_label">11</span> Cookbook</h2> -<h3 class="subsection" id='magicparlabel-7848'><span class="subsection_label">11.1</span> How to log output</h3> -<div class="standard" id='magicparlabel-7849'>Put your logging statement into <span class="flex_file">log_every_timestep.c</span> using the <span class="flex_cmacro">Printf</span> macro, e.g.,<br /> +<h2 class="section" id='magicparlabel-7974'><span class="section_label">11</span> Cookbook</h2> +<h3 class="subsection" id='magicparlabel-7975'><span class="subsection_label">11.1</span> How to log output</h3> +<div class="standard" id='magicparlabel-7976'>Put your logging statement into <span class="flex_file">log_every_timestep.c</span> using the <span class="flex_cmacro">Printf</span> macro, e.g.,<br /> <pre class ='listings <i>C</i>'>Printf();</pre><br /> </div> -<h3 class="subsection" id='magicparlabel-7862'><span class="subsection_label">11.2</span> How to find which source files contain a string</h3> -<div class="standard" id='magicparlabel-7863'>Run</div> +<h3 class="subsection" id='magicparlabel-7989'><span class="subsection_label">11.2</span> How to find which source files contain a string</h3> +<div class="standard" id='magicparlabel-7990'>Run</div> -<div class="standard" id='magicparlabel-7864'><br /> +<div class="standard" id='magicparlabel-7991'><br /> <pre class\s*='listings bash'>$ ./rgrep <string> {opts}</pre><br /> The options (<span class="flex_args">{opts}</span>) are passed to <span class="flex_command">grep -r</span>, see <span class="flex_command">man grep</span> for details, and these are not required. Binary (object, executable, shared library) files are automatically skipped. Most often you will want to ignore case, e.g.,</div> -<div class="standard" id='magicparlabel-7881'><b><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-8008'><b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ ./rgrep <string> -i</pre><br /> </span></b></div> -<h3 class="subsection" id='magicparlabel-7886'><span class="subsection_label">11.3</span> How to build with debugging output</h3> -<div class="standard" id='magicparlabel-7887'><em>Binary_c</em> provides the <span style='font-family:monospace;font-size: 18px;'><br /> +<h3 class="subsection" id='magicparlabel-8013'><span class="subsection_label">11.3</span> How to build with debugging output</h3> +<div class="standard" id='magicparlabel-8014'><em>Binary_c</em> provides the <span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings <i>C</i>'>Dprint(...)</pre><br /> </span> macro to allow you to output what is going on to the screen (<span style='font-family:monospace;font-size: 18px;'>stdout</span>). To turn this on, change the line in <em>binary_c_code_options.h</em> to</div> -<div class="standard" id='magicparlabel-7892'><br /> +<div class="standard" id='magicparlabel-8019'><br /> <pre class ='listings <i>C</i>'>#define DEBUG 1</pre><br /> -Then rebuild with <br /> -<pre class\s*='listings bash'>$ ./configure -$ make cleanall -$ make</pre><br /> +Then rebuild with debugging enabled,<br /> +<pre class\s*='listings bash'>$ cd builddir +$ meson --reconfigure --buildtype=debug +$ ninja</pre><br /> You can provide an expression which must return true for debugging to be output. This is <span class="flex_cmacro">DEBUG_EXP</span> in <span class="flex_headerfile">binary_c_debug.h</span>. E.g. to only have output after 10Myr, use:</div> -<div class="standard" id='magicparlabel-7911'><b><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-8038'><b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings <i>C</i>'>#define DEBUG_EXP (stardata->model.time > 10.0)</pre><br /> </span></b>Again, you will need to do a complete rebuild to make this work. You can use<span style='font-family:monospace;font-size: 18px;'> </span><span class="flex_cmacro">Dprint_no_newline()</span><span style='font-family:monospace;font-size: 18px;'> </span>macro to prevent the newline after a debugging statement.</div> -<h3 class="subsection" id='magicparlabel-7920'><span class="subsection_label">11.4</span> How to check for NaNs (not a numbers)</h3> -<div class="standard" id='magicparlabel-7921'>If <span class="flex_cmacro">NANCHECKS</span> is enabled in<span style='font-family:monospace;font-size: 18px;'> </span><span class="flex_headerfile">binary_c_code_options.h</span> you can use the <span class="flex_cmacro">NANCHECK(A)</span> macro, which checks whether <span class="flex_cmacro">A</span> is not a number, exiting with an error if this is the case. This is rather compiler dependent but should work fine with <span class="flex_software">gcc</span>.</div> -<h3 class="subsection" id='magicparlabel-7942'><span class="subsection_label">11.5</span> How to exit <em><i>binary_c</i></em></h3> -<div class="standard" id='magicparlabel-7943'>Do <em>not</em> use <span class="flex_programminglanguage">C</span>'s <span class="flex_cfunction">exit</span> function. Instead use the <span class="flex_cmacro">Exit_binary_c(…)</span> macro, with an error code from <span class="flex_headerfile">binary_c_error_codes.h</span>, e.g.</div> +<h3 class="subsection" id='magicparlabel-8047'><span class="subsection_label">11.4</span> How to check for NaNs (not a numbers)</h3> +<div class="standard" id='magicparlabel-8048'>If <span class="flex_cmacro">NANCHECKS</span> is enabled in<span style='font-family:monospace;font-size: 18px;'> </span><span class="flex_headerfile">binary_c_code_options.h</span> you can use the <span class="flex_cmacro">NANCHECK(A)</span> macro, which checks whether <span class="flex_cmacro">A</span> is not a number, exiting with an error if this is the case. This is rather compiler dependent but should work fine with <span class="flex_software">gcc</span>.</div> +<h3 class="subsection" id='magicparlabel-8069'><span class="subsection_label">11.5</span> How to exit <em><i>binary_c</i></em></h3> +<div class="standard" id='magicparlabel-8070'>Do <em>not</em> use <span class="flex_programminglanguage">C</span>'s <span class="flex_cfunction">exit</span> function. Instead use the <span class="flex_cmacro">Exit_binary_c(…)</span> macro, with an error code from <span class="flex_headerfile">binary_c_error_codes.h</span>, e.g.</div> -<div class="standard" id='magicparlabel-7960'><span style='font-family:monospace;font-size: 18px;'><br /> +<div class="standard" id='magicparlabel-8087'><span style='font-family:monospace;font-size: 18px;'><br /> <pre class ='listings <i>C</i>'>Exit_binary_c(PIPE_FAILURE, “My pipe failed! ARGH!”);</pre><br /> </span></div> -<h3 class="subsection" id='magicparlabel-7965'><span class="subsection_label">11.6</span> How to debug segfaults</h3> -<div class="standard" id='magicparlabel-7966'>Install <span class="flex_software">gdb</span>. Build <i>binary_c</i> with debugging: +<h3 class="subsection" id='magicparlabel-8092'><span class="subsection_label">11.6</span> How to debug segfaults</h3> +<div class="standard" id='magicparlabel-8093'>Install <span class="flex_software">gdb</span>. Build <i>binary_c</i> with debugging: <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> -<pre class\s*='listings bash'>$ ./configure debug -$ make clean -$ make</pre><br /> +<pre class\s*='listings bash'>$ cd builddir +$ meson --reconfigure --buildtype=debug +$ ninja +$ cd ..</pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-7977'>Then run your test star with +<div class="standard" id='magicparlabel-8105'>Then run your test star with <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ tbse debug </pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-7982'>which will run <span class="flex_software">gdb</span> for you with the appropriate arguments to run the star. To find out where the bug is, use “<span class="flex_args">bt</span>” (backtrace) in <span class="flex_software">gdb</span>.</div> +<div class="standard" id='magicparlabel-8110'>which will run <span class="flex_software">gdb</span> for you with the appropriate arguments to run the star. To find out where the bug is, use “<span class="flex_args">bt</span>” (backtrace) in <span class="flex_software">gdb</span>.</div> -<div class="standard" id='magicparlabel-7995'>See also <a href="https://en.wikipedia.org/wiki/GNU_Debugger">https://en.wikipedia.org/wiki/GNU_Debugger</a></div> +<div class="standard" id='magicparlabel-8123'>See also <a href="https://en.wikipedia.org/wiki/GNU_Debugger">https://en.wikipedia.org/wiki/GNU_Debugger</a></div> -<div class="standard" id='magicparlabel-8000'>You may find that <span class="flex_software">valgrind</span> provides more information, especially when your segfault is caused by a memory leak.</div> -<h3 class="subsection" id='magicparlabel-8005'><span class="subsection_label">11.7</span> How to debug memory leaks</h3> -<div class="standard" id='magicparlabel-8006'>Build with debugging: +<div class="standard" id='magicparlabel-8128'>You may find that <span class="flex_software">valgrind</span> provides more information, especially when your segfault is caused by a memory leak.</div> +<h3 class="subsection" id='magicparlabel-8133'><span class="subsection_label">11.7</span> How to debug memory leaks</h3> +<div class="standard" id='magicparlabel-8134'>Build with debugging: <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> -<pre class\s*='listings bash'>$ ./configure debug -$ make clean -$ make</pre><br /> +<pre class\s*='listings bash'>$ cd builddir +$ meson --reconfigure --buildtype=debug +$ ninja +$ cd ..</pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-8013'>Then run +<div class="standard" id='magicparlabel-8142'>Then run <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ tbse valgrind</pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-8018'>Find out how to use <em><span class="flex_software"><em>valgrind</em></span></em> at <a href="http://valgrind.org/">http://valgrind.org/</a> +<div class="standard" id='magicparlabel-8147'>Find out how to use <em><span class="flex_software"><em>valgrind</em></span></em> at <a href="http://valgrind.org/">http://valgrind.org/</a> <br /> You can also run <br /> @@ -8440,65 +8472,65 @@ You can also run <br /> <br /> <pre class\s*='listings bash'>$ tbse sgcheck</pre><br /> </div> -<h3 class="subsection" id='magicparlabel-8043'><span class="subsection_label">11.8</span> How to show the arguments that <em>tbse</em> would use, but do not evolve a star</h3> -<div class="standard" id='magicparlabel-8044'>Run +<h3 class="subsection" id='magicparlabel-8172'><span class="subsection_label">11.8</span> How to show the arguments that <em>tbse</em> would use, but do not evolve a star</h3> +<div class="standard" id='magicparlabel-8173'>Run <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ tbse echo</pre><br /> </span></b></div> -<h3 class="subsection" id='magicparlabel-8049'><span class="subsection_label">11.9</span> How to run a star which has the arguments in a file</h3> -<div class="standard" id='magicparlabel-8050'>This is handy when you have a fail case (e.g. from a population synthesis run). Just run +<h3 class="subsection" id='magicparlabel-8178'><span class="subsection_label">11.9</span> How to run a star which has the arguments in a file</h3> +<div class="standard" id='magicparlabel-8179'>This is handy when you have a fail case (e.g. from a population synthesis run). Just run <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ tbse <filename></pre><br /> </span></b></div> -<h3 class="subsection" id='magicparlabel-8055'><span class="subsection_label">11.10</span> How to use profile guided optimization (PGO)</h3> -<div class="standard" id='magicparlabel-8056'>When compiling with <span class="flex_software">gcc</span>, just run +<h3 class="subsection" id='magicparlabel-8184'><span class="subsection_label">11.10</span> How to use profile guided optimization (PGO)</h3> +<div class="standard" id='magicparlabel-8185'>When compiling with <span class="flex_software">gcc</span>, just run <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ tbse pgo</pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-8065'>You may want to change the <span class="flex_args">REPEAT</span> variable as defined in <span class="flex_bashscript">tbse</span>. It is set to 10000, but if your code is running too slowly, set it to less.</div> +<div class="standard" id='magicparlabel-8194'>You may want to change the <span class="flex_args">REPEAT</span> variable as defined in <span class="flex_bashscript">tbse</span>. It is set to 10000, but if your code is running too slowly, set it to less.</div> -<div class="standard" id='magicparlabel-8074'>For details see <a href="https://en.wikipedia.org/wiki/Profile-guided_optimization">https://en.wikipedia.org/wiki/Profile-guided_optimization</a></div> +<div class="standard" id='magicparlabel-8203'>For details see <a href="https://en.wikipedia.org/wiki/Profile-guided_optimization">https://en.wikipedia.org/wiki/Profile-guided_optimization</a></div> -<div class="standard" id='magicparlabel-8079'>Generally, I find a 5-10% speedup from PGO.</div> -<h3 class="subsection" id='magicparlabel-8080'><span class="subsection_label">11.11</span> How to get help</h3> -<h4 class="subsubsection" id='magicparlabel-8081'><span class="subsubsection_label">11.11.1</span> How to know what a parameter does</h4> -<div class="standard" id='magicparlabel-8082'>Run +<div class="standard" id='magicparlabel-8208'>Generally, I find a 5-10% speedup from PGO.</div> +<h3 class="subsection" id='magicparlabel-8209'><span class="subsection_label">11.11</span> How to get help</h3> +<h4 class="subsubsection" id='magicparlabel-8210'><span class="subsubsection_label">11.11.1</span> How to know what a parameter does</h4> +<div class="standard" id='magicparlabel-8211'>Run <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ <i>binary_c</i> help <parameter_name></pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-8087'>or +<div class="standard" id='magicparlabel-8216'>or <br /> <b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ <i>binary_c</i> help_all</pre><br /> </span></b></div> -<div class="standard" id='magicparlabel-8092'>You can even just give <em><i>binary_c</i></em> part of a parameter name and it will try to find the best match.</div> -<h4 class="subsubsection" id='magicparlabel-8093'><span class="subsubsection_label">11.11.2</span> The mailing lists</h4> -<div class="standard" id='magicparlabel-8094'>There is a development mailing list for <i>binary_c</i>, for details see section <a href="#subsec_mailing_lists">1.3</a>. </div> -<h3 class="subsection" id='magicparlabel-8095'><span class="subsection_label">11.12</span> How to add a parameter</h3> -<div class="standard" id='magicparlabel-8096'>Look at <span class="flex_headerfile">src/setup/cmd_line_args.h</span> . You will need to add a structure to <span class="flex_cmacro">CMD_LINE_ARGS</span>. Please read the comments in that file for instructions.</div> - -<div class="standard" id='magicparlabel-8105'>The storage space for the new parameter goes in the <span class="flex_cstruct">preferences_t</span> structure (see <span class="flex_headerfile">binary_c_structures.h</span>).</div> -<h3 class="subsection" id='magicparlabel-8114'><span class="subsection_label">11.13</span> How to build on a Mac</h3> -<div class="standard" id='magicparlabel-8115'>I hear it is possible! Please ask the mailing list.</div> -<h3 class="subsection" id='magicparlabel-8116'><span class="subsection_label">11.14</span> How to build as a shared library</h3> -<div class="standard" id='magicparlabel-8117'>Easy, just execute<b><span style='font-family:monospace;font-size: 18px;'> <br /> +<div class="standard" id='magicparlabel-8221'>You can even just give <em><i>binary_c</i></em> part of a parameter name and it will try to find the best match.</div> +<h4 class="subsubsection" id='magicparlabel-8222'><span class="subsubsection_label">11.11.2</span> The mailing lists</h4> +<div class="standard" id='magicparlabel-8223'>There is a development mailing list for <i>binary_c</i>, for details see section <a href="#subsec_mailing_lists">1.3</a>. </div> +<h3 class="subsection" id='magicparlabel-8224'><span class="subsection_label">11.12</span> How to add a parameter</h3> +<div class="standard" id='magicparlabel-8225'>Look at <span class="flex_headerfile">src/setup/cmd_line_args.h</span> . You will need to add a structure to <span class="flex_cmacro">CMD_LINE_ARGS</span>. Please read the comments in that file for instructions.</div> + +<div class="standard" id='magicparlabel-8234'>The storage space for the new parameter goes in the <span class="flex_cstruct">preferences_t</span> structure (see <span class="flex_headerfile">binary_c_structures.h</span>).</div> +<h3 class="subsection" id='magicparlabel-8243'><span class="subsection_label">11.13</span> How to build on a Mac</h3> +<div class="standard" id='magicparlabel-8244'>I hear it is possible! Please ask the mailing list.</div> +<h3 class="subsection" id='magicparlabel-8245'><span class="subsection_label">11.14</span> How to build as a shared library</h3> +<div class="standard" id='magicparlabel-8246'>Easy, just execute<b><span style='font-family:monospace;font-size: 18px;'> <br /> <pre class\s*='listings bash'>$ ./make <i>libbinary_c.so</i></pre><br /> </span></b> The API uses this shared library.</div> -<h3 class="subsection" id='magicparlabel-8122'><span class="subsection_label">11.15</span> How to calculate stellar yields or population statistics</h3> +<h3 class="subsection" id='magicparlabel-8251'><span class="subsection_label">11.15</span> How to calculate stellar yields or population statistics</h3> -<ol class="enumerate" id='magicparlabel-8123'><li class="enumerate_item">You have to build <em><i>binary_c</i></em> with <span class="flex_cmacro">NUCSYN</span> and <span class="flex_cmacro">NUCSYN_GCE</span> enabled, as well as the required physics</li> +<ol class="enumerate" id='magicparlabel-8252'><li class="enumerate_item">You have to build <em><i>binary_c</i></em> with <span class="flex_cmacro">NUCSYN</span> and <span class="flex_cmacro">NUCSYN_GCE</span> enabled, as well as the required physics</li> <li class="enumerate_item">You have to (re)build the shared library with <b><span style='font-family:monospace;font-size: 18px;'><br /> <pre class\s*='listings bash'>$ make <i>libbinary_c.so</i></pre><br /> </span></b></li> @@ -8508,8 +8540,8 @@ You can also run <br /> <pre class\s*='listings bash'>$ ./src/perl/scripts2/yield_vs_time.pl dt=10 max_evolution_time=13700 vb=1</pre><br /> </span></b>Note that, depending on the options you choose in <span class="flex_perlscript">yield_vs_time.pl</span>, this may take a long time!</li> </ol> -<h3 class="subsection" id='magicparlabel-8168'><span class="subsection_label">11.16</span> <em>bash</em> autocompletion of <i>binary_c</i> arguments</h3> -<div class="standard" id='magicparlabel-8169'>You can make <span class="flex_software">bash</span> autocomplete arguments to <i>binary_c</i> by putting the following in your <span class="flex_file">.bashrc</span> file (assuming you have <em><i>binary_c</i></em> in the directory specified by the environment variable <span class="flex_envvar">BINARY_C</span>) and restart <em>bash</em>.<br /> +<h3 class="subsection" id='magicparlabel-8297'><span class="subsection_label">11.16</span> <em>bash</em> autocompletion of <i>binary_c</i> arguments</h3> +<div class="standard" id='magicparlabel-8298'>You can make <span class="flex_software">bash</span> autocomplete arguments to <i>binary_c</i> by putting the following in your <span class="flex_file">.bashrc</span> file (assuming you have <em><i>binary_c</i></em> in the directory specified by the environment variable <span class="flex_envvar">BINARY_C</span>) and restart <em>bash</em>.<br /> <pre class ='listings Perl'># completion of <i>binary_c</i> arguments _binary_c() @@ -8524,9 +8556,9 @@ _binary_c() complete -F _binary_c <i>binary_c</i> </pre><br /> </div> -<h3 class="subsection" id='magicparlabel-8198'><span class="subsection_label">11.17</span> <div id="subsec_git_revision"></div> +<h3 class="subsection" id='magicparlabel-8327'><span class="subsection_label">11.17</span> <div id="subsec_git_revision"></div> How to find the <em>git</em> revision and <em>git</em> URL</h3> -<div class="standard" id='magicparlabel-8199'>Put the following into your <span class="flex_bashscript">.bashrc</span> file, restart <em>bash</em> and use the command <span class="flex_command">git_rev</span> to find a suitable <span class="flex_software">git</span> revision string and <span class="flex_command">git_url</span> to find the repository URL.<br /> +<div class="standard" id='magicparlabel-8328'>Put the following into your <span class="flex_bashscript">.bashrc</span> file, restart <em>bash</em> and use the command <span class="flex_command">git_rev</span> to find a suitable <span class="flex_software">git</span> revision string and <span class="flex_command">git_url</span> to find the repository URL.<br /> <pre class ='listings'># git function for review number git_rev () { @@ -8543,10 +8575,10 @@ git_url () } </pre><br /> </div> -<h2 class="section" id='magicparlabel-8234'><span class="section_label">12</span> Changelog</h2> -<div class="standard" id='magicparlabel-8235'>Note this is always an incomplete list!</div> +<h2 class="section" id='magicparlabel-8363'><span class="section_label">12</span> Changelog</h2> +<div class="standard" id='magicparlabel-8364'>Note this is always an incomplete list!</div> -<dl class='description' id='magicparlabel-8236'><dt class="description_label">Version 2.1</dt> +<dl class='description' id='magicparlabel-8365'><dt class="description_label">Version 2.1</dt> <dd class="description_item"> Time integration is now forward-Euler, RK2 or RK4, rationalised the time evolution loop, events subsystem introduced, fixed timesteps now standard, command line macros, update mass transfer rates, many bug fixes.</dd> <dt class="description_label">Version 2.0</dt> <dd class="description_item"> Finally, RGI had some time to sit down and redesign the guts of <em><i>binary_c</i></em>. Version 2.0 is a cleaned up, sensible version of the old code. It has better logic, naming, time resolution, setup, etc.</dd> @@ -8559,13 +8591,13 @@ git_url () <dt class="description_label">Version 1.0</dt> <dd class="description_item"> The original version.</dd> </dl> -<h2 class="section" id='magicparlabel-8262'><span class="section_label">13</span> Acknowledgements</h2> -<div class="standard" id='magicparlabel-8263'>This document was prepared using the wonderful <a href="https://www.lyx.org/">LyX</a>.</div> +<h2 class="section" id='magicparlabel-8391'><span class="section_label">13</span> Acknowledgements</h2> +<div class="standard" id='magicparlabel-8392'>This document was prepared using the wonderful <a href="https://www.lyx.org/">LyX</a>.</div> -<div class="standard" id='magicparlabel-8264'><br /> +<div class="standard" id='magicparlabel-8393'><br /> </div> -<div class="standard" id='magicparlabel-8265'><h2 class='bibtex'>References</h2><div class='bibtex'><div class='bibtexentry' id='LyXCite-1999ApJ___525__886A'><span class='bibtexlabel'>Arlandini et al. 1999</span><span class='bibtexinfo'><span class="bib-fullnames:author">Arlandini, <i>C</i>., Käppeler, F., Wisshak, K., Gallino, R., Lugaro, M., Busso, M., and Straniero, O.</span>, "<span class="bib-title">Neutron Capture in Low-Mass Asymptotic Giant Branch Stars: Cross Sections and Abundance Signatures</span>", <i><span class="bib-journal"></span></i> <span class="bib-volume">525</span> (<span class="bib-year">1999</span>), pp. <span class="bib-pages">886-900</span>.</span></div> +<div class="standard" id='magicparlabel-8394'><h2 class='bibtex'>References</h2><div class='bibtex'><div class='bibtexentry' id='LyXCite-1999ApJ___525__886A'><span class='bibtexlabel'>Arlandini et al. 1999</span><span class='bibtexinfo'><span class="bib-fullnames:author">Arlandini, <i>C</i>., Käppeler, F., Wisshak, K., Gallino, R., Lugaro, M., Busso, M., and Straniero, O.</span>, "<span class="bib-title">Neutron Capture in Low-Mass Asymptotic Giant Branch Stars: Cross Sections and Abundance Signatures</span>", <i><span class="bib-journal"></span></i> <span class="bib-volume">525</span> (<span class="bib-year">1999</span>), pp. <span class="bib-pages">886-900</span>.</span></div> <div class='bibtexentry' id='LyXCite-2007A_A___469_1013B'><span class='bibtexlabel'>BonaÄić Marinović et al. 2007</span><span class='bibtexinfo'><span class="bib-fullnames:author">BonaÄić Marinović, A., Izzard, R.~G., Lugaro, M., and Pols, O.~R.</span>, "<span class="bib-title">The s-process in stellar population synthesis: a new approach to understanding AGB stars</span>", <i><span class="bib-journal"></span></i> <span class="bib-volume">469</span> (<span class="bib-year">2007</span>), pp. <span class="bib-pages">1013-1025</span>.</span></div> <div class='bibtexentry' id='LyXCite-2004ApJ___608__405C'><span class='bibtexlabel'>Chieffi and Limongi 2004</span><span class='bibtexinfo'><span class="bib-fullnames:author">Chieffi, A. and Limongi, M.</span>, "<span class="bib-title">Explosive Yields of Massive Stars from $Z=0$ to $Z = Z_{\odot}$</span>", <i><span class="bib-journal"></span></i> <span class="bib-volume">608</span> (<span class="bib-year">2004</span>), pp. <span class="bib-pages">405-410</span>.</span></div> <div class='bibtexentry' id='LyXCite-2002NewA____7___55D'><span class='bibtexlabel'>De Donder and Vanbeveren 2002</span><span class='bibtexinfo'><span class="bib-fullnames:author">De Donder, E. and Vanbeveren, D.</span>, "<span class="bib-title">The chemical evolution of the solar neighbourhood: the effect of binaries</span>", <i><span class="bib-journal">New Astronomy</span></i> <span class="bib-volume">7</span> (<span class="bib-year">2002</span>), pp. <span class="bib-pages">55-84</span>.</span></div> @@ -8598,19 +8630,19 @@ git_url () <div class='bibtexentry' id='LyXCite-1986ApJ___301__601W'><span class='bibtexlabel'>Woosley et al. 1986</span><span class='bibtexinfo'><span class="bib-fullnames:author">Woosley, S.~E., Taam, R.~E., and Weaver, T.~A.</span>, "<span class="bib-title">Models for Type I supernova. I - Detonations in white dwarfs</span>", <i><span class="bib-journal"></span></i> <span class="bib-volume">301</span> (<span class="bib-year">1986</span>), pp. <span class="bib-pages">601-623</span>.</span></div> </div></div> -<div class="standard" id='magicparlabel-8266'><br /> +<div class="standard" id='magicparlabel-8395'><br /> </div> <HR><H1>Appendix</H1> -<h2 class="section" id='magicparlabel-8269'><span class="section_label">A</span> Grid options (<em>grid_options</em> hash)</h2> -<div class="standard" id='magicparlabel-8270'><div id="sec_grid_options"></div> +<h2 class="section" id='magicparlabel-8398'><span class="section_label">A</span> Grid options (<em>grid_options</em> hash)</h2> +<div class="standard" id='magicparlabel-8399'><div id="sec_grid_options"></div> The following summarises the <span style='font-family:monospace;font-size: 18px;'>grid_options</span> hash elements as stored in <br /> <span style='font-family:monospace;font-size: 18px;'>$binary_grid2_object->{_hash_options}</span>. Please note that some options are (perhaps) no longer used and are left in this manual as a reference guide only. </div> -<dl class='description' id='magicparlabel-8271'><dt class="description_label">alarm_procedure</dt> +<dl class='description' id='magicparlabel-8400'><dt class="description_label">alarm_procedure</dt> <dd class="description_item"> When a signal is captured (usually on a timeout) the alarm_procedure tells us what to do. If <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> <mrow><mn>0</mn> </mrow></mstyle></math> then the grid exits. If <math xmlns="http://www.w3.org/1998/Math/MathML"><mstyle mathvariant='sans-serif-italic' mathsize='85%'> @@ -8788,13 +8820,13 @@ The following summarises the <span style='font-family:monospace;font-size: 18px; <dt class="description_label">weight</dt> <dd class="description_item"> The probability is weighted by this value. </dd> </dl> -<div class="standard" id='magicparlabel-8325'><br /> +<div class="standard" id='magicparlabel-8454'><br /> </div> -<h2 class="section" id='magicparlabel-8326'><span class="section_label">B</span> Binary_c/nucsyn options (<em>bse_options</em> hash)</h2> -<div class="standard" id='magicparlabel-8327'><div id="sec_bse_options"></div> +<h2 class="section" id='magicparlabel-8455'><span class="section_label">B</span> Binary_c/nucsyn options (<em>bse_options</em> hash)</h2> +<div class="standard" id='magicparlabel-8456'><div id="sec_bse_options"></div> The following options correspond to variables in the <span style='font-family:monospace;font-size: 18px;'>$binary_grid2_object->{_bse_options}</span> hash. These correspond to options of <em><i>binary_c</i></em>.</div> -<div class="standard" id='magicparlabel-8328'>The most important options are listed here, however you should consult <em><i>binary_c</i></em> for the main options list because these options are (mostly) just passed to <em><i>binary_c</i></em>. The full list of options is given in <span style='font-family:monospace;font-size: 18px;'>src/setup/cmd_line_args.h</span>. You can access a full list of arguments by running +<div class="standard" id='magicparlabel-8457'>The most important options are listed here, however you should consult <em><i>binary_c</i></em> for the main options list because these options are (mostly) just passed to <em><i>binary_c</i></em>. The full list of options is given in <span style='font-family:monospace;font-size: 18px;'>src/setup/cmd_line_args.h</span>. You can access a full list of arguments by running <br /> <b><span style='font-family:monospace;font-size: 18px;'><i>binary_c</i> --help</span></b> @@ -8802,7 +8834,7 @@ The following summarises the <span style='font-family:monospace;font-size: 18px; <em>BSE</em> refers to <a href='#LyXCite-2002MNRAS_329_897H'><span class="bib-abbrvciteauthor">Hurley et al.</span></a> (<span class="bib-year">2002</span>).</div> -<dl class='description' id='magicparlabel-8329'><dt class="description_label">acc2</dt> +<dl class='description' id='magicparlabel-8458'><dt class="description_label">acc2</dt> <dd class="description_item"> Bondi-Hoyle accretion rate parameter (default 1.5). Deprecated in <i>binary_c</i> V2.0, please use Bondi_Hoyle_accretion_factor instead."</dd> <dt class="description_label">alpha_ce</dt> <dd class="description_item"> Common envelope ejection efficiency, default 1.0.</dd> diff --git a/doc/binary_c2.lyx b/doc/binary_c2.lyx index f02c8152d83e8eae8b5d104fe9dfbad1c8c1c067..bb1c72406f828e04d11787cba05c94b0ea19e6b2 100644 --- a/doc/binary_c2.lyx +++ b/doc/binary_c2.lyx @@ -5059,7 +5059,7 @@ status open \begin_layout Plain Layout -meson -Daccurate=true +meson builddir -Daccurate=true \end_layout \end_inset @@ -5127,7 +5127,7 @@ status open \begin_layout Plain Layout -meson -Dgeneric=true +meson builddir -Dgeneric=true \end_layout \end_inset diff --git a/docker/Dockerfile b/docker/Dockerfile index 16eaf691e70fd5308c730b6fd7ed590b9dd43119..425e81347519eea9327d0be3fc053a71bc15fe96 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -# Dockerfile for binary_c (2.1) and binary_grid2 +# Dockerfile for binary_c (2.1.4) and binary_grid2 (2.1.4) # based on Ubuntu 18.04 FROM ubuntu:18.04 @@ -34,6 +34,11 @@ RUN apt-get -y --no-install-recommends install make RUN apt-get -y --no-install-recommends install libc6-dev RUN apt-get -y --no-install-recommends install sudo RUN apt-get -y --no-install-recommends install okular +RUN apt-get -y --no-install-recommends install python3 +RUN apt-get -y --no-install-recommends install python3-pip +RUN apt-get -y --no-install-recommends install meson +RUN apt-get -y --no-install-recommends install ninja-build +RUN pip3 install meson ############################################################ # apt cleanup @@ -161,9 +166,17 @@ COPY --chown=binary_c ./binary_c_master /home/binary_c/progs/stars/binary_c ############################################################ WORKDIR /home/binary_c/progs/stars/binary_c -RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && wc -c LICENCE |gawk "{print \$1}" > .lread && ./configure generic -RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && ./make -RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && ./make libbinary_c.so || true + +###### old configure/make +#RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && wc -c LICENCE |gawk "{print \$1}" > .lread && ./configure generic +#RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && ./make +#RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && ./make libbinary_c.so || true + +###### new meson/ninja +RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && wc -c LICENCE |gawk "{print \$1}" > .lread && meson builddir -Dgeneric=true +RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && cd builddir && ninja +RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && cd builddir && ninja libbinary_c.so +RUN export LD_LIBRARY_PATH=$HOME/lib LIBRARY_PATH=$HOME/lib && cd builddir && ninja binary_c_symlink ############################################################ # install perl modules for binary_grid @@ -186,7 +199,7 @@ RUN cpanm Sort::Key RUN perl ./install_all.pl RUN cpanm Proc::ProcessTable RUN cpanm Cpanel::JSON::XS -RUN cpanm -v ./binary_grid-v2.1.3.tar.gz +RUN cpanm -v ./binary_grid-v2.1.4.tar.gz ############################################################ # cleanup: cpanm and build directories