Skip to content

Commit 79462bd

Browse files
authored
Merge branch 'development' into joss_paper
2 parents 900ac23 + c846aaa commit 79462bd

28 files changed

Lines changed: 267 additions & 179 deletions

CHANGES.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
# Changelog
22

3-
## 23.03
3+
## 25.05
4+
5+
* some clang-tidy cleaning (#1784)
6+
7+
* with HIP we were disabling inlining due to ROCm issues. This is
8+
now an option, with the default enabling inlining, since it works
9+
as expected for ROCm >= 6.3.1 (#1780)
10+
11+
* clean up the pynucastro scripts that derived reverse rates (#1781)
12+
13+
## 25.04
14+
15+
* the "he-burn" networks now will look for weak rates for
16+
all nuclei, not just the Fe-group (#1763)
17+
18+
* clean up the ECSN network generation script (#1776)
19+
20+
* Allow for single-step backward Euler (#1773)
21+
22+
## 25.03
423

524
* the `nova2` net was renamed `nova`, and the old `nova`
625
net was removed (#1746, #1768)

Docs/source/rp_intro.rst

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,31 @@ The behavior of the network and EOS are controlled by many runtime
66
parameters. These parameters are defined in plain-text files
77
``_parameters`` located in the different directories that hold the
88
microphysics code. At compile time, a script in the AMReX build
9-
system, ``findparams.py``, locates all of the ``_parameters`` files that
10-
are needed for the given choice of network, integrator, and EOS, and
11-
assembles all of the runtime parameters into a set of header files
12-
(using the ``write_probin.py`` script).
9+
system, ``findparams.py``, locates all of the ``_parameters`` files
10+
that are needed for the given choice of network, integrator, and EOS,
11+
and other modules, and assembles all of the runtime parameters into a
12+
set of header files (using the ``write_probin.py`` script).
1313

14+
A ``_parameter`` file starts with a namespace declaration like:
1415

15-
Parameter definitions take the form::
16+
.. code::
17+
18+
@namespace: integrator
19+
20+
Followed by a list of parameters. Each parameter defined after the namespace
21+
declaration would be prefixed by the namespace in an inputs file or commandline,
22+
like ``integrator.parameter``.
23+
24+
The individual parameter definitions take the form::
1625

1726
# comment describing the parameter
1827
name data-type default-value priority
1928

20-
Here, the priority is simply an integer. When two directories
21-
define the same parameter, but with different defaults, the version of
29+
where "data-type" can be: ``real``, ``bool``, ``int``, ``string``.
30+
31+
The "priority" is simply an integer that is used to determine
32+
what happens when two different ``_paramerter`` files define the same
33+
parameter but with different defaults. In this case, the version of
2234
the parameter with the highest priority takes precedence. This allows
2335
specific implementations to override the general parameter defaults.
2436

Make.Microphysics_extern

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# This is the main include makefile for applications that want to use Microphysics
22
# You should set NETWORK_OUTPUT_PATH before including this file
33

4-
# For HIP, inlining produces large kernels that seem to cause memory issues
4+
# For some (older?) versions of HIP, inlining produces large kernels
5+
# that seem to cause memory issues
56
ifeq ($(USE_HIP),TRUE)
7+
ifeq ($(DISABLE_HIP_INLINE),TRUE)
68
EXTRACXXFLAGS += -mllvm -amdgpu-function-calls=true
9+
endif
710
endif
811

912
# for common code paths between simplified-SDC and true-SDC, we'll

networks/ECSN/Make.package

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ifeq ($(USE_REACT),TRUE)
55
CEXE_headers += actual_network.H
66
CEXE_headers += tfactors.H
77
CEXE_headers += partition_functions.H
8+
CEXE_sources += partition_functions_data.cpp
89
CEXE_headers += actual_rhs.H
910
CEXE_headers += reaclib_rates.H
1011
CEXE_headers += table_rates.H

networks/ECSN/actual_network.H

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,34 @@ namespace network
3030
return 0.0_rt;
3131
}
3232
else if constexpr (spec == He4) {
33-
return 28.29566_rt;
33+
return 28.295662457999697_rt;
3434
}
3535
else if constexpr (spec == O16) {
36-
return 127.619296_rt;
36+
return 127.6193154119992_rt;
3737
}
3838
else if constexpr (spec == O20) {
39-
return 151.3714_rt;
39+
return 151.37138571200194_rt;
4040
}
4141
else if constexpr (spec == F20) {
42-
return 154.40268_rt;
42+
return 154.40270167600102_rt;
4343
}
4444
else if constexpr (spec == Ne20) {
45-
return 160.6448_rt;
45+
return 160.64482384000075_rt;
4646
}
4747
else if constexpr (spec == Mg24) {
48-
return 198.25701600000002_rt;
48+
return 198.2570479679962_rt;
4949
}
5050
else if constexpr (spec == Al27) {
51-
return 224.951931_rt;
51+
return 224.95193723199915_rt;
5252
}
5353
else if constexpr (spec == Si28) {
54-
return 236.536832_rt;
54+
return 236.53684539599638_rt;
5555
}
5656
else if constexpr (spec == P31) {
57-
return 262.91617699999995_rt;
57+
return 262.9161999600037_rt;
5858
}
5959
else if constexpr (spec == S32) {
60-
return 271.78012800000005_rt;
60+
return 271.78016372399725_rt;
6161
}
6262

6363

@@ -129,11 +129,11 @@ namespace Rates
129129
k_p_Al27_to_He4_Mg24 = 12,
130130
k_He4_Si28_to_p_P31 = 13,
131131
k_p_P31_to_He4_Si28 = 14,
132-
k_F20_to_O20 = 15,
133-
k_Ne20_to_F20 = 16,
134-
k_O20_to_F20 = 17,
135-
k_F20_to_Ne20 = 18,
136-
NumRates = k_F20_to_Ne20
132+
k_F20_to_Ne20 = 15,
133+
k_F20_to_O20 = 16,
134+
k_Ne20_to_F20 = 17,
135+
k_O20_to_F20 = 18,
136+
NumRates = k_O20_to_F20
137137
};
138138

139139
// number of reaclib rates
@@ -164,10 +164,10 @@ namespace Rates
164164
"p_Al27_to_He4_Mg24", // 12,
165165
"He4_Si28_to_p_P31", // 13,
166166
"p_P31_to_He4_Si28", // 14,
167-
"F20_to_O20", // 15,
168-
"Ne20_to_F20", // 16,
169-
"O20_to_F20", // 17,
170-
"F20_to_Ne20" // 18,
167+
"F20_to_Ne20", // 15,
168+
"F20_to_O20", // 16,
169+
"Ne20_to_F20", // 17,
170+
"O20_to_F20" // 18,
171171
};
172172

173173
}

networks/ECSN/actual_network_data.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace NSE_INDEX
1919
-1, 0, 7, -1, 1, 6, 11,
2020
-1, 1, 8, -1, 0, 9, -1,
2121
-1, 0, 9, -1, 1, 8, 13,
22+
-1, -1, 4, -1, -1, 5, 17,
2223
-1, -1, 4, -1, -1, 3, -1,
2324
-1, -1, 5, -1, -1, 4, -1,
24-
-1, -1, 3, -1, -1, 4, 15,
25-
-1, -1, 4, -1, -1, 5, 16
25+
-1, -1, 3, -1, -1, 4, 16
2626
};
2727
}
2828
#endif

networks/ECSN/actual_rhs.H

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
#include <jacobian_utilities.H>
1111
#include <screen.H>
1212
#include <microphysics_autodiff.H>
13+
#ifdef NEUTRINOS
1314
#include <sneut5.H>
15+
#endif
1416
#include <reaclib_rates.H>
1517
#include <table_rates.H>
1618

@@ -269,14 +271,22 @@ void evaluate_rates(const burn_t& state, T& rate_eval) {
269271

270272
// Fill approximate rates
271273

272-
fill_approx_rates<do_T_derivatives, T>(tfactors, rate_eval);
274+
fill_approx_rates<do_T_derivatives, T>(tfactors, state.rho, Y, rate_eval);
273275

274276
// Calculate tabular rates
275277

276278
[[maybe_unused]] amrex::Real rate, drate_dt, edot_nu, edot_gamma;
277279

278280
rate_eval.enuc_weak = 0.0_rt;
279281

282+
tabular_evaluate(j_F20_Ne20_meta, j_F20_Ne20_rhoy, j_F20_Ne20_temp, j_F20_Ne20_data,
283+
rhoy, state.T, rate, drate_dt, edot_nu, edot_gamma);
284+
rate_eval.screened_rates(k_F20_to_Ne20) = rate;
285+
if constexpr (std::is_same_v<T, rate_derivs_t>) {
286+
rate_eval.dscreened_rates_dT(k_F20_to_Ne20) = drate_dt;
287+
}
288+
rate_eval.enuc_weak += C::Legacy::n_A * Y(F20) * (edot_nu + edot_gamma);
289+
280290
tabular_evaluate(j_F20_O20_meta, j_F20_O20_rhoy, j_F20_O20_temp, j_F20_O20_data,
281291
rhoy, state.T, rate, drate_dt, edot_nu, edot_gamma);
282292
rate_eval.screened_rates(k_F20_to_O20) = rate;
@@ -301,14 +311,6 @@ void evaluate_rates(const burn_t& state, T& rate_eval) {
301311
}
302312
rate_eval.enuc_weak += C::Legacy::n_A * Y(O20) * (edot_nu + edot_gamma);
303313

304-
tabular_evaluate(j_F20_Ne20_meta, j_F20_Ne20_rhoy, j_F20_Ne20_temp, j_F20_Ne20_data,
305-
rhoy, state.T, rate, drate_dt, edot_nu, edot_gamma);
306-
rate_eval.screened_rates(k_F20_to_Ne20) = rate;
307-
if constexpr (std::is_same_v<T, rate_derivs_t>) {
308-
rate_eval.dscreened_rates_dT(k_F20_to_Ne20) = drate_dt;
309-
}
310-
rate_eval.enuc_weak += C::Legacy::n_A * Y(F20) * (edot_nu + edot_gamma);
311-
312314

313315
}
314316

@@ -340,6 +342,11 @@ void get_ydot_weak(const burn_t& state,
340342

341343
// Calculate tabular rates and get ydot_weak
342344

345+
tabular_evaluate(j_F20_Ne20_meta, j_F20_Ne20_rhoy, j_F20_Ne20_temp, j_F20_Ne20_data,
346+
rhoy, state.T, rate, drate_dt, edot_nu, edot_gamma);
347+
rate_eval.screened_rates(k_F20_to_Ne20) = rate;
348+
rate_eval.enuc_weak += C::Legacy::n_A * Y(F20) * (edot_nu + edot_gamma);
349+
343350
tabular_evaluate(j_F20_O20_meta, j_F20_O20_rhoy, j_F20_O20_temp, j_F20_O20_data,
344351
rhoy, state.T, rate, drate_dt, edot_nu, edot_gamma);
345352
rate_eval.screened_rates(k_F20_to_O20) = rate;
@@ -355,11 +362,6 @@ void get_ydot_weak(const burn_t& state,
355362
rate_eval.screened_rates(k_O20_to_F20) = rate;
356363
rate_eval.enuc_weak += C::Legacy::n_A * Y(O20) * (edot_nu + edot_gamma);
357364

358-
tabular_evaluate(j_F20_Ne20_meta, j_F20_Ne20_rhoy, j_F20_Ne20_temp, j_F20_Ne20_data,
359-
rhoy, state.T, rate, drate_dt, edot_nu, edot_gamma);
360-
rate_eval.screened_rates(k_F20_to_Ne20) = rate;
361-
rate_eval.enuc_weak += C::Legacy::n_A * Y(F20) * (edot_nu + edot_gamma);
362-
363365
auto screened_rates = rate_eval.screened_rates;
364366

365367
ydot_nuc(H1) = 0.0_rt;
@@ -372,8 +374,8 @@ void get_ydot_weak(const burn_t& state,
372374
(-screened_rates(k_O20_to_F20)*Y(O20) + screened_rates(k_F20_to_O20)*Y(F20));
373375

374376
ydot_nuc(F20) =
375-
(screened_rates(k_O20_to_F20)*Y(O20) + -screened_rates(k_F20_to_O20)*Y(F20)) +
376-
(-screened_rates(k_F20_to_Ne20)*Y(F20) + screened_rates(k_Ne20_to_F20)*Y(Ne20));
377+
(-screened_rates(k_F20_to_Ne20)*Y(F20) + screened_rates(k_Ne20_to_F20)*Y(Ne20)) +
378+
(screened_rates(k_O20_to_F20)*Y(O20) + -screened_rates(k_F20_to_O20)*Y(F20));
377379

378380
ydot_nuc(Ne20) =
379381
(screened_rates(k_F20_to_Ne20)*Y(F20) + -screened_rates(k_Ne20_to_F20)*Y(Ne20));
@@ -427,13 +429,13 @@ void rhs_nuc(const burn_t& state,
427429
(-screened_rates(k_O20_to_F20)*Y(O20) + screened_rates(k_F20_to_O20)*Y(F20));
428430

429431
ydot_nuc(F20) =
430-
(screened_rates(k_O20_to_F20)*Y(O20) + -screened_rates(k_F20_to_O20)*Y(F20)) +
431-
(-screened_rates(k_F20_to_Ne20)*Y(F20) + screened_rates(k_Ne20_to_F20)*Y(Ne20));
432+
(-screened_rates(k_F20_to_Ne20)*Y(F20) + screened_rates(k_Ne20_to_F20)*Y(Ne20)) +
433+
(screened_rates(k_O20_to_F20)*Y(O20) + -screened_rates(k_F20_to_O20)*Y(F20));
432434

433435
ydot_nuc(Ne20) =
434-
(screened_rates(k_F20_to_Ne20)*Y(F20) + -screened_rates(k_Ne20_to_F20)*Y(Ne20)) +
435436
(screened_rates(k_He4_O16_to_Ne20)*Y(He4)*Y(O16)*state.rho + -screened_rates(k_Ne20_to_He4_O16)*Y(Ne20)) +
436-
-screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*Y(Ne20)*state.rho;
437+
-screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*Y(Ne20)*state.rho +
438+
(screened_rates(k_F20_to_Ne20)*Y(F20) + -screened_rates(k_Ne20_to_F20)*Y(Ne20));
437439

438440
ydot_nuc(Mg24) =
439441
screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*Y(Ne20)*state.rho +
@@ -499,9 +501,12 @@ void actual_rhs (burn_t& state, amrex::Array1D<amrex::Real, 1, neqs>& ydot)
499501

500502
// Get the thermal neutrino losses
501503

502-
amrex::Real sneut, dsneutdt, dsneutdd, dsnuda, dsnudz;
504+
amrex::Real sneut{};
505+
#ifdef NEUTRINOS
503506
constexpr int do_derivatives{0};
507+
amrex::Real dsneutdt{}, dsneutdd{}, dsnuda{}, dsnudz{};
504508
sneut5<do_derivatives>(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, dsnuda, dsnudz);
509+
#endif
505510

506511
// Append the energy equation (this is erg/g/s)
507512

@@ -717,15 +722,17 @@ void actual_jac(const burn_t& state, MatrixType& jac)
717722

718723
// Account for the thermal neutrino losses
719724

720-
amrex::Real sneut, dsneutdt, dsneutdd, dsnuda, dsnudz;
725+
amrex::Real dsneutdt{};
726+
#ifdef NEUTRINOS
727+
amrex::Real sneut, dsneutdd, dsnuda, dsnudz;
721728
constexpr int do_derivatives{1};
722729
sneut5<do_derivatives>(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, dsnuda, dsnudz);
723730

724731
for (int j = 1; j <= NumSpec; ++j) {
725732
amrex::Real b1 = (-state.abar * state.abar * dsnuda + (zion[j-1] - state.zbar) * state.abar * dsnudz);
726733
jac.add(net_ienuc, j, -b1);
727734
}
728-
735+
#endif
729736

730737
// Evaluate the Jacobian elements with respect to energy by
731738
// calling the RHS using d(rate) / dT and then transform them

networks/ECSN/ecsn_network_generation.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55

66
data_list = mylibrary.get_rates()
77

8-
all_nuclei = ["p","he4","ne20","o20","f20","mg24","al27","o16","si28","s32","p31"]
8+
all_nuclei = ["p", "he4", "ne20", "o20", "f20",
9+
"mg24", "al27", "o16", "si28",
10+
"s32", "p31"]
911

10-
escn_library = mylibrary.linking_nuclei(all_nuclei,with_reverse=True)
11-
escn_tabular = ["f20--o20-toki","ne20--f20-toki","o20--f20-toki","f20--ne20-toki"]
12+
escn_library = mylibrary.linking_nuclei(all_nuclei, with_reverse=True)
13+
14+
sl = pyna.SuzukiLibrary()
15+
tabular_rates = sl.linking_nuclei(["f20", "o20", "ne20"])
1216

1317
rc = pyna.RateCollection(libraries=[escn_library])
1418

@@ -36,7 +40,8 @@
3640
if ydots[rate] >= 1.e-20 and rate.weak == False:
3741
new_rate_list.append(rate)
3842

39-
wd_net = AmrexAstroCxxNetwork(rates=new_rate_list, rate_files=escn_tabular)
43+
44+
wd_net = AmrexAstroCxxNetwork(rates=new_rate_list, libraries=[tabular_rates])
4045
wd_net.write_network()
4146

4247
wd_net.plot(rho, T, comp, outfile="ECSN.png",

networks/ECSN/partition_functions.H

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ namespace part_fun {
1717

1818
// interpolation routine
1919

20-
template <int npts>
20+
template <typename T>
2121
AMREX_GPU_HOST_DEVICE AMREX_INLINE
22-
void interpolate_pf(const amrex::Real t9, const amrex::Real (&temp_array)[npts], const amrex::Real (&pf_array)[npts],
22+
void interpolate_pf(const amrex::Real t9, const T& temp_array, const T& pf_array,
2323
amrex::Real& pf, amrex::Real& dpf_dT) {
2424

25-
if (t9 >= temp_array[0] && t9 < temp_array[npts-1]) {
25+
if (t9 >= temp_array.lo() && t9 < temp_array.hi()) {
2626

2727
// find the largest temperature element <= t9 using a binary search
2828

29-
int left = 0;
30-
int right = npts;
29+
int left = temp_array.lo();
30+
int right = temp_array.hi();
3131

3232
while (left < right) {
3333
int mid = (left + right) / 2;
34-
if (temp_array[mid] > t9) {
34+
if (temp_array(mid) > t9) {
3535
right = mid;
3636
} else {
3737
left = mid + 1;
@@ -44,11 +44,12 @@ namespace part_fun {
4444

4545
// construct the slope -- this is (log10(pf_{i+1}) - log10(pf_i)) / (T_{i+1} - T_i)
4646

47-
amrex::Real slope = (pf_array[idx+1] - pf_array[idx]) / (temp_array[idx+1] - temp_array[idx]);
47+
amrex::Real slope = (pf_array(idx+1) - pf_array(idx)) /
48+
(temp_array(idx+1) - temp_array(idx));
4849

4950
// find the PF
5051

51-
amrex::Real log10_pf = pf_array[idx] + slope * (t9 - temp_array[idx]);
52+
amrex::Real log10_pf = pf_array(idx) + slope * (t9 - temp_array(idx));
5253
pf = std::pow(10.0_rt, log10_pf);
5354

5455
// find the derivative (with respect to T, not T9)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <AMReX_Array.H>
2+
#include <string>
3+
#include <table_rates.H>
4+
#include <AMReX_Print.H>
5+
6+
#include <partition_functions.H>
7+
8+
using namespace amrex;
9+
10+
namespace part_fun {
11+
12+
13+
}
14+

0 commit comments

Comments
 (0)