Skip to content

Commit

Permalink
Add functionality for time-variable abundances and radiative losses (#87
Browse files Browse the repository at this point in the history
)

* Add functionality to calculate abundance factor

* add search function for nearest value in array

* add misc.cpp and misc.h

* add radiative loss data

* add function to read abundance tables and calculate new losses

* lots of debugging to get it to run

* fixed format and input of radiative loss files

* add correction for draining and later upflow events

* use original radiation for initial conditions

* add include guard for misc.h

* change bool use_variable_abundances to string radiation input

* add radiation to test configurations

* revert config file to original values

* use the power law by default in config

* add descriptions of variables in helper.h

* revert the config file

* rename function

* remove hardcoding of radiation filenames and number of files -- requires > C++ 17

* use_variable_abundances -> use_lookup_table_losses

* remove hardcoding of indices

* add comment about initial conditions radiation

* remove overloaded find_closest

* add tests for new radiative loss option

* document radiative loss options

---------

Co-authored-by: Jeffrey Reep <[email protected]>
Co-authored-by: Will Barnes <[email protected]>
  • Loading branch information
3 people authored Jul 5, 2024
1 parent f1f42fb commit 39d7c82
Show file tree
Hide file tree
Showing 20 changed files with 1,127 additions and 13 deletions.
10 changes: 7 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AddOption('--linkflags', dest='linkflags', type='string', nargs=1, action='store


subdirs = ['source']
cxx_flags = ['-std=c++14',]
cxx_flags = ['-std=c++17',]
try:
CXX = os.environ['CXX']
except KeyError:
Expand All @@ -31,9 +31,13 @@ env = Environment(CXX=CXX, CXXFLAGS=cxx_flags)

if 'darwin' in sys.platform:
print("Using Mac OS X compile options.")
env.Append(CPPPATH=['/opt/local/include', '/usr/include/malloc'])
if 'HOMEBREW_PREFIX' in os.environ:
env.Append(CPPPATH=['/opt/local/include','/usr/include/malloc','/opt/homebrew/include'])
env.Append(LIBPATH=['/opt/homebrew/lib'])
else:
env.Append(CPPPATH=['/opt/local/include', '/usr/include/malloc'])
env.Append(LIBPATH=['/opt/local/lib'])
env.Append(LIBS=['boost_program_options-mt'])
env.Append(LIBPATH=['/opt/local/lib'])
elif 'linux' in sys.platform:
print("Using Linux compile options.")
env.Append(CPPPATH=['/usr/include'])
Expand Down
3 changes: 2 additions & 1 deletion config/ebtel.example.cfg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<total_time>5000.0</total_time>
<tau>1.0</tau>
<tau_max>1e+300</tau_max>
<loop_length>40.0e+8</loop_length>
<loop_length>40e+8</loop_length>
<saturation_limit>1.0</saturation_limit>
<force_single_fluid>False</force_single_fluid>
<use_c1_loss_correction>True</use_c1_loss_correction>
Expand All @@ -12,6 +12,7 @@
<calculate_dem>False</calculate_dem>
<save_terms>False</save_terms>
<use_adaptive_solver>False</use_adaptive_solver>
<radiation>power_law</radiation>
<output_filename>ebtel++_results_file.txt</output_filename>
<adaptive_solver_error>1e-6</adaptive_solver_error>
<adaptive_solver_safety>0.5</adaptive_solver_safety>
Expand Down
102 changes: 102 additions & 0 deletions data/radiation/abund_10_rad_loss.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
1.0,8.0,8.69897,9.0,9.69897,10.0,10.69897,11.0
04.00,-23.309,-23.274,-23.265,-23.259,-23.259,-23.260,-23.260
04.05,-22.814,-22.770,-22.760,-22.751,-22.751,-22.751,-22.751
04.10,-22.365,-22.318,-22.307,-22.299,-22.298,-22.298,-22.298
04.15,-22.007,-21.960,-21.951,-21.943,-21.942,-21.942,-21.942
04.20,-21.811,-21.768,-21.760,-21.753,-21.753,-21.753,-21.753
04.25,-21.791,-21.753,-21.746,-21.742,-21.741,-21.742,-21.742
04.30,-21.866,-21.834,-21.829,-21.827,-21.827,-21.828,-21.829
04.35,-21.962,-21.937,-21.933,-21.933,-21.935,-21.937,-21.938
04.40,-22.035,-22.017,-22.015,-22.018,-22.021,-22.025,-22.026
04.45,-22.067,-22.055,-22.055,-22.061,-22.064,-22.070,-22.072
04.50,-22.068,-22.061,-22.063,-22.071,-22.075,-22.082,-22.084
04.55,-22.048,-22.046,-22.048,-22.059,-22.063,-22.071,-22.074
04.60,-22.007,-22.009,-22.012,-22.025,-22.030,-22.039,-22.043
04.65,-21.943,-21.948,-21.952,-21.967,-21.973,-21.983,-21.987
04.70,-21.858,-21.864,-21.869,-21.884,-21.891,-21.901,-21.905
04.75,-21.757,-21.764,-21.769,-21.784,-21.789,-21.798,-21.801
04.80,-21.650,-21.656,-21.661,-21.674,-21.678,-21.683,-21.685
04.85,-21.550,-21.556,-21.560,-21.571,-21.574,-21.576,-21.577
04.90,-21.477,-21.482,-21.486,-21.495,-21.497,-21.498,-21.499
04.95,-21.430,-21.435,-21.438,-21.446,-21.448,-21.450,-21.452
05.00,-21.405,-21.409,-21.412,-21.419,-21.421,-21.425,-21.427
05.05,-21.413,-21.416,-21.418,-21.423,-21.425,-21.431,-21.435
05.10,-21.431,-21.433,-21.434,-21.438,-21.440,-21.449,-21.454
05.15,-21.426,-21.428,-21.429,-21.432,-21.434,-21.446,-21.453
05.20,-21.405,-21.407,-21.408,-21.410,-21.413,-21.426,-21.434
05.25,-21.386,-21.388,-21.389,-21.391,-21.394,-21.407,-21.417
05.30,-21.379,-21.381,-21.381,-21.384,-21.386,-21.399,-21.409
05.35,-21.376,-21.378,-21.379,-21.381,-21.383,-21.396,-21.406
05.40,-21.386,-21.387,-21.388,-21.390,-21.391,-21.403,-21.412
05.45,-21.442,-21.444,-21.444,-21.446,-21.447,-21.456,-21.464
05.50,-21.565,-21.566,-21.567,-21.568,-21.569,-21.575,-21.580
05.55,-21.696,-21.697,-21.698,-21.699,-21.700,-21.703,-21.706
05.60,-21.776,-21.778,-21.778,-21.780,-21.780,-21.782,-21.784
05.65,-21.807,-21.808,-21.809,-21.810,-21.811,-21.812,-21.814
05.70,-21.815,-21.816,-21.817,-21.818,-21.819,-21.821,-21.821
05.75,-21.826,-21.827,-21.828,-21.830,-21.830,-21.832,-21.833
05.80,-21.849,-21.850,-21.851,-21.853,-21.854,-21.856,-21.857
05.85,-21.868,-21.869,-21.870,-21.873,-21.875,-21.877,-21.877
05.90,-21.872,-21.874,-21.875,-21.879,-21.880,-21.883,-21.884
05.95,-21.869,-21.871,-21.873,-21.877,-21.879,-21.882,-21.883
06.00,-21.872,-21.874,-21.875,-21.879,-21.881,-21.884,-21.885
06.05,-21.884,-21.886,-21.887,-21.891,-21.893,-21.896,-21.897
06.10,-21.902,-21.903,-21.904,-21.908,-21.909,-21.912,-21.913
06.15,-21.922,-21.923,-21.924,-21.927,-21.928,-21.930,-21.931
06.20,-21.950,-21.951,-21.952,-21.954,-21.955,-21.956,-21.957
06.25,-21.994,-21.995,-21.996,-21.998,-21.998,-22.000,-22.000
06.30,-22.065,-22.066,-22.066,-22.068,-22.069,-22.070,-22.070
06.35,-22.162,-22.163,-22.163,-22.165,-22.165,-22.167,-22.167
06.40,-22.265,-22.266,-22.266,-22.268,-22.268,-22.269,-22.269
06.45,-22.359,-22.359,-22.359,-22.360,-22.361,-22.362,-22.362
06.50,-22.434,-22.434,-22.434,-22.435,-22.435,-22.436,-22.436
06.55,-22.487,-22.487,-22.487,-22.487,-22.487,-22.488,-22.488
06.60,-22.519,-22.519,-22.519,-22.519,-22.519,-22.520,-22.520
06.65,-22.535,-22.535,-22.535,-22.535,-22.535,-22.536,-22.536
06.70,-22.539,-22.539,-22.539,-22.539,-22.540,-22.540,-22.540
06.75,-22.536,-22.536,-22.536,-22.536,-22.536,-22.536,-22.536
06.80,-22.529,-22.529,-22.529,-22.529,-22.529,-22.529,-22.529
06.85,-22.521,-22.521,-22.521,-22.521,-22.521,-22.521,-22.521
06.90,-22.516,-22.516,-22.516,-22.516,-22.516,-22.516,-22.516
06.95,-22.518,-22.518,-22.518,-22.518,-22.518,-22.518,-22.518
07.00,-22.529,-22.530,-22.530,-22.530,-22.530,-22.530,-22.530
07.05,-22.554,-22.554,-22.554,-22.554,-22.554,-22.554,-22.554
07.10,-22.592,-22.592,-22.592,-22.592,-22.592,-22.592,-22.593
07.15,-22.641,-22.641,-22.641,-22.641,-22.641,-22.641,-22.641
07.20,-22.689,-22.689,-22.689,-22.689,-22.689,-22.689,-22.689
07.25,-22.727,-22.727,-22.727,-22.727,-22.727,-22.727,-22.727
07.30,-22.752,-22.752,-22.752,-22.752,-22.752,-22.752,-22.752
07.35,-22.766,-22.766,-22.766,-22.766,-22.766,-22.766,-22.766
07.40,-22.771,-22.771,-22.771,-22.771,-22.771,-22.770,-22.770
07.45,-22.768,-22.768,-22.768,-22.768,-22.768,-22.768,-22.768
07.50,-22.762,-22.762,-22.762,-22.762,-22.762,-22.762,-22.762
07.55,-22.751,-22.751,-22.751,-22.751,-22.751,-22.751,-22.751
07.60,-22.738,-22.738,-22.738,-22.738,-22.738,-22.738,-22.738
07.65,-22.723,-22.723,-22.723,-22.723,-22.723,-22.723,-22.723
07.70,-22.706,-22.706,-22.706,-22.706,-22.706,-22.706,-22.706
07.75,-22.688,-22.688,-22.688,-22.688,-22.688,-22.688,-22.688
07.80,-22.670,-22.670,-22.670,-22.670,-22.670,-22.670,-22.670
07.85,-22.651,-22.651,-22.651,-22.651,-22.651,-22.651,-22.651
07.90,-22.632,-22.632,-22.632,-22.632,-22.632,-22.632,-22.632
07.95,-22.612,-22.612,-22.612,-22.612,-22.612,-22.612,-22.612
08.00,-22.592,-22.592,-22.592,-22.592,-22.592,-22.592,-22.592
08.05,-22.572,-22.572,-22.572,-22.572,-22.572,-22.572,-22.572
08.10,-22.552,-22.552,-22.552,-22.552,-22.552,-22.552,-22.552
08.15,-22.531,-22.531,-22.531,-22.531,-22.531,-22.531,-22.531
08.20,-22.510,-22.510,-22.510,-22.510,-22.510,-22.510,-22.510
08.25,-22.488,-22.488,-22.488,-22.488,-22.488,-22.488,-22.488
08.30,-22.467,-22.467,-22.467,-22.467,-22.467,-22.467,-22.467
08.35,-22.444,-22.444,-22.444,-22.444,-22.444,-22.444,-22.444
08.40,-22.422,-22.422,-22.422,-22.422,-22.422,-22.422,-22.422
08.45,-22.399,-22.399,-22.399,-22.399,-22.399,-22.399,-22.399
08.50,-22.376,-22.376,-22.376,-22.376,-22.376,-22.376,-22.376
08.55,-22.353,-22.353,-22.353,-22.353,-22.353,-22.353,-22.353
08.60,-22.330,-22.330,-22.330,-22.330,-22.330,-22.330,-22.330
08.65,-22.306,-22.306,-22.306,-22.306,-22.306,-22.306,-22.306
08.70,-22.283,-22.283,-22.283,-22.283,-22.283,-22.283,-22.283
08.75,-22.259,-22.259,-22.259,-22.259,-22.259,-22.259,-22.259
08.80,-22.235,-22.235,-22.235,-22.235,-22.235,-22.235,-22.235
08.85,-22.211,-22.211,-22.211,-22.211,-22.211,-22.211,-22.211
08.90,-22.187,-22.187,-22.187,-22.187,-22.187,-22.187,-22.187
08.95,-22.163,-22.163,-22.163,-22.163,-22.163,-22.163,-22.163
09.00,-22.138,-22.138,-22.138,-22.138,-22.138,-22.138,-22.138
102 changes: 102 additions & 0 deletions data/radiation/abund_15_rad_loss.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
1.5,8.0,8.69897,9.0,9.69897,10.0,10.69897,11.0
04.00,-23.249,-23.220,-23.213,-23.208,-23.208,-23.209,-23.210
04.05,-22.775,-22.735,-22.726,-22.718,-22.718,-22.718,-22.719
04.10,-22.340,-22.296,-22.286,-22.278,-22.277,-22.277,-22.278
04.15,-21.990,-21.945,-21.936,-21.929,-21.928,-21.928,-21.928
04.20,-21.796,-21.755,-21.747,-21.741,-21.740,-21.740,-21.740
04.25,-21.775,-21.739,-21.732,-21.728,-21.728,-21.728,-21.728
04.30,-21.848,-21.818,-21.813,-21.811,-21.811,-21.813,-21.813
04.35,-21.941,-21.917,-21.914,-21.915,-21.916,-21.919,-21.920
04.40,-22.010,-21.993,-21.992,-21.995,-21.998,-22.003,-22.005
04.45,-22.036,-22.025,-22.025,-22.031,-22.035,-22.041,-22.044
04.50,-22.030,-22.025,-22.026,-22.034,-22.037,-22.045,-22.048
04.55,-22.005,-22.004,-22.006,-22.015,-22.019,-22.028,-22.032
04.60,-21.962,-21.965,-21.968,-21.979,-21.983,-21.993,-21.997
04.65,-21.900,-21.905,-21.909,-21.922,-21.927,-21.938,-21.942
04.70,-21.817,-21.824,-21.828,-21.842,-21.848,-21.858,-21.863
04.75,-21.720,-21.727,-21.731,-21.745,-21.751,-21.759,-21.763
04.80,-21.618,-21.624,-21.628,-21.640,-21.645,-21.650,-21.652
04.85,-21.525,-21.531,-21.535,-21.545,-21.548,-21.550,-21.551
04.90,-21.462,-21.467,-21.470,-21.479,-21.481,-21.482,-21.483
04.95,-21.422,-21.427,-21.430,-21.439,-21.441,-21.443,-21.444
05.00,-21.401,-21.405,-21.408,-21.415,-21.417,-21.422,-21.424
05.05,-21.410,-21.414,-21.415,-21.420,-21.422,-21.429,-21.433
05.10,-21.428,-21.431,-21.432,-21.435,-21.438,-21.446,-21.452
05.15,-21.423,-21.425,-21.426,-21.429,-21.432,-21.443,-21.450
05.20,-21.401,-21.403,-21.404,-21.407,-21.410,-21.423,-21.431
05.25,-21.382,-21.384,-21.385,-21.387,-21.390,-21.403,-21.412
05.30,-21.373,-21.375,-21.376,-21.378,-21.381,-21.394,-21.403
05.35,-21.369,-21.371,-21.372,-21.374,-21.376,-21.388,-21.398
05.40,-21.376,-21.377,-21.378,-21.380,-21.382,-21.393,-21.402
05.45,-21.427,-21.429,-21.430,-21.431,-21.433,-21.442,-21.449
05.50,-21.539,-21.541,-21.541,-21.543,-21.544,-21.550,-21.555
05.55,-21.653,-21.654,-21.655,-21.656,-21.657,-21.661,-21.663
05.60,-21.713,-21.714,-21.715,-21.717,-21.718,-21.720,-21.721
05.65,-21.726,-21.728,-21.728,-21.730,-21.731,-21.733,-21.734
05.70,-21.719,-21.721,-21.721,-21.723,-21.724,-21.726,-21.727
05.75,-21.715,-21.716,-21.717,-21.719,-21.720,-21.722,-21.723
05.80,-21.720,-21.722,-21.723,-21.725,-21.727,-21.729,-21.729
05.85,-21.723,-21.725,-21.726,-21.730,-21.731,-21.734,-21.734
05.90,-21.718,-21.720,-21.721,-21.725,-21.727,-21.730,-21.731
05.95,-21.710,-21.712,-21.714,-21.718,-21.720,-21.724,-21.725
06.00,-21.711,-21.713,-21.715,-21.719,-21.721,-21.725,-21.726
06.05,-21.723,-21.726,-21.727,-21.731,-21.733,-21.736,-21.737
06.10,-21.742,-21.744,-21.745,-21.749,-21.750,-21.753,-21.754
06.15,-21.765,-21.766,-21.767,-21.770,-21.771,-21.773,-21.774
06.20,-21.795,-21.796,-21.797,-21.800,-21.801,-21.802,-21.803
06.25,-21.844,-21.845,-21.846,-21.848,-21.849,-21.850,-21.851
06.30,-21.922,-21.923,-21.924,-21.926,-21.927,-21.928,-21.928
06.35,-22.030,-22.031,-22.031,-22.033,-22.034,-22.035,-22.035
06.40,-22.145,-22.145,-22.146,-22.147,-22.148,-22.149,-22.149
06.45,-22.246,-22.247,-22.247,-22.248,-22.248,-22.249,-22.250
06.50,-22.325,-22.326,-22.326,-22.326,-22.327,-22.328,-22.328
06.55,-22.379,-22.379,-22.379,-22.380,-22.380,-22.380,-22.380
06.60,-22.409,-22.409,-22.410,-22.410,-22.410,-22.410,-22.410
06.65,-22.422,-22.422,-22.422,-22.422,-22.422,-22.422,-22.422
06.70,-22.422,-22.422,-22.422,-22.422,-22.422,-22.422,-22.422
06.75,-22.415,-22.415,-22.415,-22.415,-22.415,-22.415,-22.415
06.80,-22.404,-22.404,-22.404,-22.404,-22.404,-22.404,-22.404
06.85,-22.394,-22.394,-22.394,-22.394,-22.394,-22.394,-22.394
06.90,-22.388,-22.388,-22.388,-22.388,-22.388,-22.388,-22.388
06.95,-22.390,-22.390,-22.390,-22.390,-22.390,-22.390,-22.390
07.00,-22.404,-22.404,-22.404,-22.404,-22.404,-22.404,-22.404
07.05,-22.432,-22.432,-22.433,-22.433,-22.433,-22.433,-22.433
07.10,-22.479,-22.479,-22.479,-22.479,-22.479,-22.479,-22.479
07.15,-22.539,-22.539,-22.539,-22.539,-22.539,-22.539,-22.539
07.20,-22.600,-22.600,-22.600,-22.600,-22.600,-22.600,-22.600
07.25,-22.651,-22.651,-22.651,-22.651,-22.651,-22.651,-22.651
07.30,-22.688,-22.688,-22.688,-22.688,-22.688,-22.688,-22.688
07.35,-22.711,-22.711,-22.711,-22.711,-22.711,-22.711,-22.711
07.40,-22.723,-22.723,-22.723,-22.723,-22.723,-22.723,-22.723
07.45,-22.727,-22.727,-22.727,-22.727,-22.727,-22.727,-22.727
07.50,-22.724,-22.724,-22.724,-22.724,-22.724,-22.724,-22.724
07.55,-22.717,-22.717,-22.717,-22.717,-22.717,-22.717,-22.717
07.60,-22.707,-22.707,-22.707,-22.707,-22.707,-22.707,-22.707
07.65,-22.693,-22.693,-22.693,-22.693,-22.693,-22.693,-22.693
07.70,-22.679,-22.679,-22.679,-22.679,-22.679,-22.679,-22.679
07.75,-22.662,-22.662,-22.662,-22.662,-22.662,-22.662,-22.662
07.80,-22.645,-22.645,-22.645,-22.645,-22.645,-22.645,-22.645
07.85,-22.628,-22.628,-22.628,-22.628,-22.628,-22.628,-22.628
07.90,-22.610,-22.610,-22.610,-22.610,-22.610,-22.610,-22.610
07.95,-22.592,-22.592,-22.592,-22.592,-22.592,-22.592,-22.592
08.00,-22.573,-22.573,-22.573,-22.573,-22.573,-22.573,-22.573
08.05,-22.554,-22.554,-22.554,-22.554,-22.554,-22.554,-22.554
08.10,-22.535,-22.535,-22.535,-22.535,-22.535,-22.535,-22.535
08.15,-22.516,-22.516,-22.516,-22.516,-22.516,-22.516,-22.516
08.20,-22.496,-22.496,-22.496,-22.496,-22.496,-22.496,-22.496
08.25,-22.475,-22.475,-22.475,-22.475,-22.475,-22.475,-22.475
08.30,-22.454,-22.454,-22.454,-22.454,-22.454,-22.454,-22.454
08.35,-22.433,-22.433,-22.433,-22.433,-22.433,-22.433,-22.433
08.40,-22.411,-22.411,-22.411,-22.411,-22.411,-22.411,-22.411
08.45,-22.389,-22.389,-22.389,-22.389,-22.389,-22.389,-22.389
08.50,-22.367,-22.367,-22.367,-22.367,-22.367,-22.367,-22.367
08.55,-22.344,-22.344,-22.344,-22.344,-22.344,-22.344,-22.344
08.60,-22.321,-22.321,-22.321,-22.321,-22.321,-22.321,-22.321
08.65,-22.298,-22.298,-22.298,-22.298,-22.298,-22.298,-22.298
08.70,-22.275,-22.275,-22.275,-22.275,-22.275,-22.275,-22.275
08.75,-22.251,-22.251,-22.251,-22.251,-22.251,-22.251,-22.251
08.80,-22.227,-22.227,-22.227,-22.227,-22.227,-22.227,-22.227
08.85,-22.204,-22.204,-22.204,-22.204,-22.204,-22.204,-22.204
08.90,-22.180,-22.180,-22.180,-22.180,-22.180,-22.180,-22.180
08.95,-22.156,-22.156,-22.156,-22.156,-22.156,-22.156,-22.156
09.00,-22.131,-22.131,-22.131,-22.131,-22.131,-22.131,-22.131
Loading

0 comments on commit 39d7c82

Please sign in to comment.