diff --git a/Docs/source/networks.rst b/Docs/source/networks.rst index 2ed49ea51b..64aab934ae 100644 --- a/Docs/source/networks.rst +++ b/Docs/source/networks.rst @@ -149,21 +149,34 @@ burning. This network is managed by pynucastro. above). -nova networks -============= +The ``nova`` network: +===================== -The ``nova`` and ``nova2`` networks both are intended for modeling classical novae. +This network is composed of 17 nuclei: $\isotm{H}{1,2}$, $\isotm{He}{3,4}$, $\isotm{Be}{7}$, $\isotm{B}{8}$, +$\isotm{C}{12,13}$, $\isotm{N}{13-15}$, $\isotm{O}{14-17}$, $\isotm{F}{17,18}$ and is used to model the onset of +a classical novae thermonuclear runaway. The first set of nuclei, $\isotm{H}{1,2}$, $\isotm{He}{3,4}$ represent +the pp-chain sector of the reaction network, while the second set, of $\isotm{Be}{7}$, and $\isotm{B}{8}$, describe +the involvement of the x-process. Finally, all the remaining nuclei are active participants of +the CNO cycle with endpoints at $\isotm{F}{17}$ and $\isotm{F}{18}$. The triple-$\alpha$ reaction +$\alpha(\alpha\alpha,\gamma)\isotm{C}{12}$, serves as bridge between the nuclei of first and the last set. +The the cold-CNO chain of reactions of the CN-branch are: -* ``nova`` focuses just on CNO/hot-CNO: +* :math:`\isotm{C}{12}(p,\gamma)\isotm{N}{13}(\beta^{+}\nu_e)\isotm{C}{13}(p,\gamma)` - .. figure:: nova.png - :align: center +while the NO-branch chain of reactions is: -* ``nova2`` expands ``nova`` by adding the pp-chain nuclei: +* :math:`\isotm{N}{14}(p,\gamma)\isotm{O}{15}(\beta^{+})\isotm{N}{15}(p,\gamma)\isotm{O}{16}(p,\gamma)\isotm{F}{17}(\beta^{+}\nu_e)\isotm{O}{17}` - .. figure:: nova2.png - :align: center +where the isotopes $\isotm{N}{15}$ and $\isotm{O}{17}$ may decay back into $\isotm{C}{12}$ and $\isotm{N}{14}$ through +$\isotm{N}{15}(p,\alpha)\isotm{C}{12}$ and $\isotm{O}{17}(p,\alpha)\isotm{N}{14}$ respectively. + +.. figure:: ../../networks/nova/nova.png + :align: center + +Once the temperature reaches a threshold of $\gtrsim 10^8\,\mathrm{K}$, the fast $p$-captures, for example, +$\isotm{N}{13}(p,\gamma)\isotm{O}{14}$, are more likely than the $\beta^{+}$-decays $\isotm{N}{13}(\beta^{+}\nu_e)\isotm{C}{13}$ +reactions. These rates are also included in this network. He-burning networks diff --git a/Docs/source/nova.png b/Docs/source/nova.png deleted file mode 100644 index a9fbc5984d..0000000000 Binary files a/Docs/source/nova.png and /dev/null differ diff --git a/Docs/source/nova2.png b/Docs/source/nova2.png deleted file mode 100644 index 8867d19795..0000000000 Binary files a/Docs/source/nova2.png and /dev/null differ diff --git a/networks/nova2/pynucastro.net b/networks/general_null/nova.net similarity index 84% rename from networks/nova2/pynucastro.net rename to networks/general_null/nova.net index 7012ca4859..ea482a078e 100644 --- a/networks/nova2/pynucastro.net +++ b/networks/general_null/nova.net @@ -1,3 +1,7 @@ +# The nova network contains the pp-chain, some +# nuclei from the x-process, like Be and B, and +# the CNO cycle, allowing a leakage throguh f18. + hydrogen-1 H1 1.0 1.0 hydrogen-2 H2 2.0 1.0 helium-3 He3 3.0 2.0 diff --git a/networks/nova/Make.package b/networks/nova/Make.package index 39c65eca7b..3c406e47f1 100644 --- a/networks/nova/Make.package +++ b/networks/nova/Make.package @@ -5,6 +5,7 @@ ifeq ($(USE_REACT),TRUE) CEXE_headers += actual_network.H CEXE_headers += tfactors.H CEXE_headers += partition_functions.H + CEXE_sources += partition_functions_data.cpp CEXE_headers += actual_rhs.H CEXE_headers += reaclib_rates.H CEXE_headers += table_rates.H diff --git a/networks/nova/actual_network.H b/networks/nova/actual_network.H index 49024f72e2..3c7c18409b 100644 --- a/networks/nova/actual_network.H +++ b/networks/nova/actual_network.H @@ -29,41 +29,53 @@ namespace network if constexpr (spec == H1) { return 0.0_rt; } + else if constexpr (spec == H2) { + return 2.2245662689997516_rt; + } + else if constexpr (spec == He3) { + return 7.718041347999588_rt; + } else if constexpr (spec == He4) { - return 28.29566_rt; + return 28.295662457999697_rt; + } + else if constexpr (spec == Be7) { + return 37.60083855599987_rt; + } + else if constexpr (spec == B8) { + return 37.7372096199997_rt; } else if constexpr (spec == C12) { - return 92.16172800000001_rt; + return 92.16173498399803_rt; } else if constexpr (spec == C13) { - return 97.108037_rt; + return 97.10804378399916_rt; } else if constexpr (spec == N13) { - return 94.105219_rt; + return 94.10522604799917_rt; } else if constexpr (spec == N14) { - return 104.65859599999999_rt; + return 104.65860734799753_rt; } else if constexpr (spec == N15) { - return 115.4919_rt; + return 115.49190414799887_rt; } else if constexpr (spec == O14) { - return 98.731892_rt; + return 98.73189611199996_rt; } else if constexpr (spec == O15) { - return 111.95538_rt; + return 111.95539521199862_rt; } else if constexpr (spec == O16) { - return 127.619296_rt; + return 127.6193154119992_rt; } else if constexpr (spec == O17) { - return 131.76237600000002_rt; + return 131.76239561199873_rt; } else if constexpr (spec == F17) { - return 128.21957600000002_rt; + return 128.21958437599824_rt; } else if constexpr (spec == F18) { - return 137.369484_rt; + return 137.36950247599816_rt; } @@ -125,27 +137,39 @@ namespace Rates k_O14_to_N14_weak_wc12 = 2, k_O15_to_N15_weak_wc12 = 3, k_F17_to_O17_weak_wc12 = 4, - k_p_C12_to_N13 = 5, - k_He4_C12_to_O16 = 6, - k_p_C13_to_N14 = 7, - k_p_N13_to_O14 = 8, - k_p_N14_to_O15 = 9, - k_He4_N14_to_F18 = 10, - k_p_N15_to_O16 = 11, - k_p_O16_to_F17 = 12, - k_p_O17_to_F18 = 13, - k_He4_N13_to_p_O16 = 14, - k_p_N15_to_He4_C12 = 15, - k_He4_O14_to_p_F17 = 16, - k_p_O17_to_He4_N14 = 17, - k_p_F18_to_He4_O15 = 18, - k_He4_He4_He4_to_C12 = 19, + k_B8_to_He4_He4_weak_wc12 = 5, + k_p_p_to_d_weak_bet_pos_ = 6, + k_p_p_to_d_weak_electron_capture = 7, + k_p_d_to_He3 = 8, + k_d_d_to_He4 = 9, + k_p_He3_to_He4_weak_bet_pos_ = 10, + k_He4_He3_to_Be7 = 11, + k_p_Be7_to_B8 = 12, + k_p_C12_to_N13 = 13, + k_He4_C12_to_O16 = 14, + k_p_C13_to_N14 = 15, + k_p_N13_to_O14 = 16, + k_p_N14_to_O15 = 17, + k_He4_N14_to_F18 = 18, + k_p_N15_to_O16 = 19, + k_p_O16_to_F17 = 20, + k_p_O17_to_F18 = 21, + k_d_He3_to_p_He4 = 22, + k_He4_N13_to_p_O16 = 23, + k_p_N15_to_He4_C12 = 24, + k_He4_O14_to_p_F17 = 25, + k_p_O17_to_He4_N14 = 26, + k_p_F18_to_He4_O15 = 27, + k_He3_He3_to_p_p_He4 = 28, + k_d_Be7_to_p_He4_He4 = 29, + k_He3_Be7_to_p_p_He4_He4 = 30, + k_He4_He4_He4_to_C12 = 31, NumRates = k_He4_He4_He4_to_C12 }; // number of reaclib rates - const int NrateReaclib = 19; + const int NrateReaclib = 31; // number of tabular rates @@ -161,21 +185,33 @@ namespace Rates "O14_to_N14_weak_wc12", // 2, "O15_to_N15_weak_wc12", // 3, "F17_to_O17_weak_wc12", // 4, - "p_C12_to_N13", // 5, - "He4_C12_to_O16", // 6, - "p_C13_to_N14", // 7, - "p_N13_to_O14", // 8, - "p_N14_to_O15", // 9, - "He4_N14_to_F18", // 10, - "p_N15_to_O16", // 11, - "p_O16_to_F17", // 12, - "p_O17_to_F18", // 13, - "He4_N13_to_p_O16", // 14, - "p_N15_to_He4_C12", // 15, - "He4_O14_to_p_F17", // 16, - "p_O17_to_He4_N14", // 17, - "p_F18_to_He4_O15", // 18, - "He4_He4_He4_to_C12" // 19, + "B8_to_He4_He4_weak_wc12", // 5, + "p_p_to_d_weak_bet_pos_", // 6, + "p_p_to_d_weak_electron_capture", // 7, + "p_d_to_He3", // 8, + "d_d_to_He4", // 9, + "p_He3_to_He4_weak_bet_pos_", // 10, + "He4_He3_to_Be7", // 11, + "p_Be7_to_B8", // 12, + "p_C12_to_N13", // 13, + "He4_C12_to_O16", // 14, + "p_C13_to_N14", // 15, + "p_N13_to_O14", // 16, + "p_N14_to_O15", // 17, + "He4_N14_to_F18", // 18, + "p_N15_to_O16", // 19, + "p_O16_to_F17", // 20, + "p_O17_to_F18", // 21, + "d_He3_to_p_He4", // 22, + "He4_N13_to_p_O16", // 23, + "p_N15_to_He4_C12", // 24, + "He4_O14_to_p_F17", // 25, + "p_O17_to_He4_N14", // 26, + "p_F18_to_He4_O15", // 27, + "He3_He3_to_p_p_He4", // 28, + "d_Be7_to_p_He4_He4", // 29, + "He3_Be7_to_p_p_He4_He4", // 30, + "He4_He4_He4_to_C12" // 31, }; } @@ -185,7 +221,7 @@ namespace NSE_INDEX { constexpr int H1_index = 0; constexpr int N_index = -1; - constexpr int He4_index = 1; + constexpr int He4_index = 3; // Each row corresponds to the rate in NetworkRates enum // First 3 row indices for reactants, followed by 3 product indices diff --git a/networks/nova/actual_network_data.cpp b/networks/nova/actual_network_data.cpp index 20945fbd20..467e797eec 100644 --- a/networks/nova/actual_network_data.cpp +++ b/networks/nova/actual_network_data.cpp @@ -5,25 +5,37 @@ namespace NSE_INDEX { AMREX_GPU_MANAGED amrex::Array2D rate_indices { - -1, -1, 4, -1, -1, 3, -1, - -1, -1, 7, -1, -1, 5, -1, - -1, -1, 8, -1, -1, 6, -1, - -1, -1, 11, -1, -1, 10, -1, - -1, 0, 2, -1, -1, 4, -1, - -1, 1, 2, -1, -1, 9, -1, - -1, 0, 3, -1, -1, 5, -1, - -1, 0, 4, -1, -1, 7, -1, - -1, 0, 5, -1, -1, 8, -1, - -1, 1, 5, -1, -1, 12, -1, - -1, 0, 6, -1, -1, 9, -1, - -1, 0, 9, -1, -1, 11, -1, - -1, 0, 10, -1, -1, 12, -1, - -1, 1, 4, -1, 0, 9, -1, - -1, 0, 6, -1, 1, 2, -1, - -1, 1, 7, -1, 0, 11, -1, - -1, 0, 10, -1, 1, 5, -1, - -1, 0, 12, -1, 1, 8, -1, - 1, 1, 1, -1, -1, 2, -1 + -1, -1, 8, -1, -1, 7, -1, + -1, -1, 11, -1, -1, 9, -1, + -1, -1, 12, -1, -1, 10, -1, + -1, -1, 15, -1, -1, 14, -1, + -1, -1, 5, -1, 3, 3, -1, + -1, 0, 0, -1, -1, 1, -1, + -1, 0, 0, -1, -1, 1, -1, + -1, 0, 1, -1, -1, 2, -1, + -1, 1, 1, -1, -1, 3, -1, + -1, 0, 2, -1, -1, 3, -1, + -1, 2, 3, -1, -1, 4, -1, + -1, 0, 4, -1, -1, 5, -1, + -1, 0, 6, -1, -1, 8, -1, + -1, 3, 6, -1, -1, 13, -1, + -1, 0, 7, -1, -1, 9, -1, + -1, 0, 8, -1, -1, 11, -1, + -1, 0, 9, -1, -1, 12, -1, + -1, 3, 9, -1, -1, 16, -1, + -1, 0, 10, -1, -1, 13, -1, + -1, 0, 13, -1, -1, 15, -1, + -1, 0, 14, -1, -1, 16, -1, + -1, 1, 2, -1, 0, 3, -1, + -1, 3, 8, -1, 0, 13, -1, + -1, 0, 10, -1, 3, 6, -1, + -1, 3, 11, -1, 0, 15, -1, + -1, 0, 14, -1, 3, 9, -1, + -1, 0, 16, -1, 3, 12, -1, + -1, 2, 2, 0, 0, 3, -1, + -1, 1, 4, 0, 3, 3, -1, + -1, 2, 4, 0, 0, 3, -1, + 3, 3, 3, -1, -1, 6, -1 }; } #endif diff --git a/networks/nova/actual_rhs.H b/networks/nova/actual_rhs.H index 77d0021022..d810e6ebcd 100644 --- a/networks/nova/actual_rhs.H +++ b/networks/nova/actual_rhs.H @@ -10,7 +10,9 @@ #include #include #include +#ifdef NEUTRINOS #include +#endif #include #include @@ -80,6 +82,127 @@ void evaluate_rates(const burn_t& state, T& rate_eval) { [[maybe_unused]] amrex::Real scor2, dscor2_dt; + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 1.0_rt, 1.0_rt); + + + static_assert(scn_fac.z1 == 1.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_p_p_to_d_weak_bet_pos_); + rate_eval.screened_rates(k_p_p_to_d_weak_bet_pos_) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_bet_pos_); + rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_bet_pos_) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_p_to_d_weak_electron_capture); + rate_eval.screened_rates(k_p_p_to_d_weak_electron_capture) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_electron_capture); + rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_electron_capture) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 1.0_rt, 2.0_rt); + + + static_assert(scn_fac.z1 == 1.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_p_d_to_He3); + rate_eval.screened_rates(k_p_d_to_He3) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_d_to_He3); + rate_eval.dscreened_rates_dT(k_p_d_to_He3) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 2.0_rt, 1.0_rt, 2.0_rt); + + + static_assert(scn_fac.z1 == 1.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_d_d_to_He4); + rate_eval.screened_rates(k_d_d_to_He4) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_d_d_to_He4); + rate_eval.dscreened_rates_dT(k_d_d_to_He4) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 2.0_rt, 3.0_rt); + + + static_assert(scn_fac.z1 == 1.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_p_He3_to_He4_weak_bet_pos_); + rate_eval.screened_rates(k_p_He3_to_He4_weak_bet_pos_) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_He3_to_He4_weak_bet_pos_); + rate_eval.dscreened_rates_dT(k_p_He3_to_He4_weak_bet_pos_) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 2.0_rt, 3.0_rt); + + + static_assert(scn_fac.z1 == 2.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_He4_He3_to_Be7); + rate_eval.screened_rates(k_He4_He3_to_Be7) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_He3_to_Be7); + rate_eval.dscreened_rates_dT(k_He4_He3_to_Be7) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 4.0_rt, 7.0_rt); + + + static_assert(scn_fac.z1 == 1.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_p_Be7_to_B8); + rate_eval.screened_rates(k_p_Be7_to_B8) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Be7_to_B8); + rate_eval.dscreened_rates_dT(k_p_Be7_to_B8) = ratraw * dscor_dt + dratraw_dT * scor; + } + + { constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 6.0_rt, 12.0_rt); @@ -265,6 +388,25 @@ void evaluate_rates(const burn_t& state, T& rate_eval) { } + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 2.0_rt, 2.0_rt, 3.0_rt); + + + static_assert(scn_fac.z1 == 1.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_d_He3_to_p_He4); + rate_eval.screened_rates(k_d_He3_to_p_He4) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_d_He3_to_p_He4); + rate_eval.dscreened_rates_dT(k_d_He3_to_p_He4) = ratraw * dscor_dt + dratraw_dT * scor; + } + + { constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 7.0_rt, 13.0_rt); @@ -322,6 +464,63 @@ void evaluate_rates(const burn_t& state, T& rate_eval) { } + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 3.0_rt, 2.0_rt, 3.0_rt); + + + static_assert(scn_fac.z1 == 2.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_He3_He3_to_p_p_He4); + rate_eval.screened_rates(k_He3_He3_to_p_p_He4) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He3_He3_to_p_p_He4); + rate_eval.dscreened_rates_dT(k_He3_He3_to_p_p_He4) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 2.0_rt, 4.0_rt, 7.0_rt); + + + static_assert(scn_fac.z1 == 1.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_d_Be7_to_p_He4_He4); + rate_eval.screened_rates(k_d_Be7_to_p_He4_He4) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_d_Be7_to_p_He4_He4); + rate_eval.dscreened_rates_dT(k_d_Be7_to_p_He4_He4) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 3.0_rt, 4.0_rt, 7.0_rt); + + + static_assert(scn_fac.z1 == 2.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_He3_Be7_to_p_p_He4_He4); + rate_eval.screened_rates(k_He3_Be7_to_p_p_He4_He4) *= scor; + if constexpr (std::is_same_v) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He3_Be7_to_p_p_He4_He4); + rate_eval.dscreened_rates_dT(k_He3_Be7_to_p_p_He4_He4) = ratraw * dscor_dt + dratraw_dT * scor; + } + + { constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 2.0_rt, 4.0_rt); @@ -356,7 +555,7 @@ void evaluate_rates(const burn_t& state, T& rate_eval) { // Fill approximate rates - fill_approx_rates(tfactors, rate_eval); + fill_approx_rates(tfactors, state.rho, Y, rate_eval); // Calculate tabular rates @@ -398,8 +597,16 @@ void get_ydot_weak(const burn_t& state, ydot_nuc(H1) = 0.0_rt; + ydot_nuc(H2) = 0.0_rt; + + ydot_nuc(He3) = 0.0_rt; + ydot_nuc(He4) = 0.0_rt; + ydot_nuc(Be7) = 0.0_rt; + + ydot_nuc(B8) = 0.0_rt; + ydot_nuc(C12) = 0.0_rt; ydot_nuc(C13) = 0.0_rt; @@ -436,6 +643,11 @@ void rhs_nuc(const burn_t& state, using namespace Rates; ydot_nuc(H1) = + -screened_rates(k_p_p_to_d_weak_bet_pos_)*amrex::Math::powi<2>(Y(H1))*state.rho + + -screened_rates(k_p_p_to_d_weak_electron_capture)*amrex::Math::powi<2>(Y(H1))*amrex::Math::powi<2>(state.rho)*state.y_e + + -screened_rates(k_p_d_to_He3)*Y(H2)*Y(H1)*state.rho + + -screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*Y(H1)*state.rho + + -screened_rates(k_p_Be7_to_B8)*Y(Be7)*Y(H1)*state.rho + -screened_rates(k_p_C12_to_N13)*Y(C12)*Y(H1)*state.rho + -screened_rates(k_p_C13_to_N14)*Y(C13)*Y(H1)*state.rho + -screened_rates(k_p_N13_to_O14)*Y(N13)*Y(H1)*state.rho + @@ -443,22 +655,60 @@ void rhs_nuc(const burn_t& state, -screened_rates(k_p_N15_to_O16)*Y(N15)*Y(H1)*state.rho + -screened_rates(k_p_O16_to_F17)*Y(O16)*Y(H1)*state.rho + -screened_rates(k_p_O17_to_F18)*Y(O17)*Y(H1)*state.rho + + screened_rates(k_d_He3_to_p_He4)*Y(He3)*Y(H2)*state.rho + screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho + -screened_rates(k_p_N15_to_He4_C12)*Y(N15)*Y(H1)*state.rho + screened_rates(k_He4_O14_to_p_F17)*Y(He4)*Y(O14)*state.rho + -screened_rates(k_p_O17_to_He4_N14)*Y(O17)*Y(H1)*state.rho + - -screened_rates(k_p_F18_to_He4_O15)*Y(F18)*Y(H1)*state.rho; + -screened_rates(k_p_F18_to_He4_O15)*Y(F18)*Y(H1)*state.rho + + screened_rates(k_He3_He3_to_p_p_He4)*amrex::Math::powi<2>(Y(He3))*state.rho + + screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*Y(H2)*state.rho + + 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*Y(He3)*state.rho; + + ydot_nuc(H2) = + 0.5*screened_rates(k_p_p_to_d_weak_bet_pos_)*amrex::Math::powi<2>(Y(H1))*state.rho + + 0.5*screened_rates(k_p_p_to_d_weak_electron_capture)*amrex::Math::powi<2>(Y(H1))*amrex::Math::powi<2>(state.rho)*state.y_e + + -screened_rates(k_p_d_to_He3)*Y(H2)*Y(H1)*state.rho + + -screened_rates(k_d_d_to_He4)*amrex::Math::powi<2>(Y(H2))*state.rho + + -screened_rates(k_d_He3_to_p_He4)*Y(He3)*Y(H2)*state.rho + + -screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*Y(H2)*state.rho; + + ydot_nuc(He3) = + screened_rates(k_p_d_to_He3)*Y(H2)*Y(H1)*state.rho + + -screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*Y(H1)*state.rho + + -screened_rates(k_He4_He3_to_Be7)*Y(He3)*Y(He4)*state.rho + + -screened_rates(k_d_He3_to_p_He4)*Y(He3)*Y(H2)*state.rho + + -screened_rates(k_He3_He3_to_p_p_He4)*amrex::Math::powi<2>(Y(He3))*state.rho + + -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*Y(He3)*state.rho; ydot_nuc(He4) = + 2.0*screened_rates(k_B8_to_He4_He4_weak_wc12)*Y(B8) + + 0.5*screened_rates(k_d_d_to_He4)*amrex::Math::powi<2>(Y(H2))*state.rho + + screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*Y(H1)*state.rho + + -screened_rates(k_He4_He3_to_Be7)*Y(He3)*Y(He4)*state.rho + -screened_rates(k_He4_C12_to_O16)*Y(C12)*Y(He4)*state.rho + -screened_rates(k_He4_N14_to_F18)*Y(He4)*Y(N14)*state.rho + + screened_rates(k_d_He3_to_p_He4)*Y(He3)*Y(H2)*state.rho + -screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho + screened_rates(k_p_N15_to_He4_C12)*Y(N15)*Y(H1)*state.rho + -screened_rates(k_He4_O14_to_p_F17)*Y(He4)*Y(O14)*state.rho + screened_rates(k_p_O17_to_He4_N14)*Y(O17)*Y(H1)*state.rho + screened_rates(k_p_F18_to_He4_O15)*Y(F18)*Y(H1)*state.rho + + 0.5*screened_rates(k_He3_He3_to_p_p_He4)*amrex::Math::powi<2>(Y(He3))*state.rho + + 2.0*screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*Y(H2)*state.rho + + 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*Y(He3)*state.rho + -0.5*screened_rates(k_He4_He4_He4_to_C12)*amrex::Math::powi<3>(Y(He4))*amrex::Math::powi<2>(state.rho); + ydot_nuc(Be7) = + screened_rates(k_He4_He3_to_Be7)*Y(He3)*Y(He4)*state.rho + + -screened_rates(k_p_Be7_to_B8)*Y(Be7)*Y(H1)*state.rho + + -screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*Y(H2)*state.rho + + -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*Y(He3)*state.rho; + + ydot_nuc(B8) = + -screened_rates(k_B8_to_He4_He4_weak_wc12)*Y(B8) + + screened_rates(k_p_Be7_to_B8)*Y(Be7)*Y(H1)*state.rho; + ydot_nuc(C12) = -screened_rates(k_p_C12_to_N13)*Y(C12)*Y(H1)*state.rho + -screened_rates(k_He4_C12_to_O16)*Y(C12)*Y(He4)*state.rho + @@ -555,9 +805,12 @@ void actual_rhs (burn_t& state, amrex::Array1D& ydot) // Get the thermal neutrino losses - amrex::Real sneut, dsneutdt, dsneutdd, dsnuda, dsnudz; + amrex::Real sneut{}; +#ifdef NEUTRINOS constexpr int do_derivatives{0}; + amrex::Real dsneutdt{}, dsneutdd{}, dsnuda{}, dsnudz{}; sneut5(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, dsnuda, dsnudz); +#endif // Append the energy equation (this is erg/g/s) @@ -576,12 +829,21 @@ void jac_nuc(const burn_t& state, amrex::Real scratch; - scratch = -screened_rates(k_p_C12_to_N13)*Y(C12)*state.rho - screened_rates(k_p_C13_to_N14)*Y(C13)*state.rho - screened_rates(k_p_F18_to_He4_O15)*Y(F18)*state.rho - screened_rates(k_p_N13_to_O14)*Y(N13)*state.rho - screened_rates(k_p_N14_to_O15)*Y(N14)*state.rho - screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho - screened_rates(k_p_N15_to_O16)*Y(N15)*state.rho - screened_rates(k_p_O16_to_F17)*Y(O16)*state.rho - screened_rates(k_p_O17_to_F18)*Y(O17)*state.rho - screened_rates(k_p_O17_to_He4_N14)*Y(O17)*state.rho; + scratch = -screened_rates(k_p_Be7_to_B8)*Y(Be7)*state.rho - screened_rates(k_p_C12_to_N13)*Y(C12)*state.rho - screened_rates(k_p_C13_to_N14)*Y(C13)*state.rho - screened_rates(k_p_F18_to_He4_O15)*Y(F18)*state.rho - screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*state.rho - screened_rates(k_p_N13_to_O14)*Y(N13)*state.rho - screened_rates(k_p_N14_to_O15)*Y(N14)*state.rho - screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho - screened_rates(k_p_N15_to_O16)*Y(N15)*state.rho - screened_rates(k_p_O16_to_F17)*Y(O16)*state.rho - screened_rates(k_p_O17_to_F18)*Y(O17)*state.rho - screened_rates(k_p_O17_to_He4_N14)*Y(O17)*state.rho - screened_rates(k_p_d_to_He3)*Y(H2)*state.rho - 2.0*screened_rates(k_p_p_to_d_weak_bet_pos_)*Y(H1)*state.rho - 2.0*screened_rates(k_p_p_to_d_weak_electron_capture)*Y(H1)*amrex::Math::powi<2>(state.rho)*state.y_e; jac.set(H1, H1, scratch); + scratch = screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*state.rho + screened_rates(k_d_He3_to_p_He4)*Y(He3)*state.rho - screened_rates(k_p_d_to_He3)*Y(H1)*state.rho; + jac.set(H1, H2, scratch); + + scratch = 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*state.rho + 2.0*screened_rates(k_He3_He3_to_p_p_He4)*Y(He3)*state.rho + screened_rates(k_d_He3_to_p_He4)*Y(H2)*state.rho - screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(H1)*state.rho; + jac.set(H1, He3, scratch); + scratch = screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho + screened_rates(k_He4_O14_to_p_F17)*Y(O14)*state.rho; jac.set(H1, He4, scratch); + scratch = 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(He3)*state.rho + screened_rates(k_d_Be7_to_p_He4_He4)*Y(H2)*state.rho - screened_rates(k_p_Be7_to_B8)*Y(H1)*state.rho; + jac.set(H1, Be7, scratch); + scratch = -screened_rates(k_p_C12_to_N13)*Y(H1)*state.rho; jac.set(H1, C12, scratch); @@ -609,12 +871,51 @@ void jac_nuc(const burn_t& state, scratch = -screened_rates(k_p_F18_to_He4_O15)*Y(H1)*state.rho; jac.set(H1, F18, scratch); - scratch = screened_rates(k_p_F18_to_He4_O15)*Y(F18)*state.rho + screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho + screened_rates(k_p_O17_to_He4_N14)*Y(O17)*state.rho; + scratch = -screened_rates(k_p_d_to_He3)*Y(H2)*state.rho + 1.0*screened_rates(k_p_p_to_d_weak_bet_pos_)*Y(H1)*state.rho + 1.0*screened_rates(k_p_p_to_d_weak_electron_capture)*Y(H1)*amrex::Math::powi<2>(state.rho)*state.y_e; + jac.set(H2, H1, scratch); + + scratch = -screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*state.rho - screened_rates(k_d_He3_to_p_He4)*Y(He3)*state.rho - 2.0*screened_rates(k_d_d_to_He4)*Y(H2)*state.rho - screened_rates(k_p_d_to_He3)*Y(H1)*state.rho; + jac.set(H2, H2, scratch); + + scratch = -screened_rates(k_d_He3_to_p_He4)*Y(H2)*state.rho; + jac.set(H2, He3, scratch); + + scratch = -screened_rates(k_d_Be7_to_p_He4_He4)*Y(H2)*state.rho; + jac.set(H2, Be7, scratch); + + scratch = -screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*state.rho + screened_rates(k_p_d_to_He3)*Y(H2)*state.rho; + jac.set(He3, H1, scratch); + + scratch = -screened_rates(k_d_He3_to_p_He4)*Y(He3)*state.rho + screened_rates(k_p_d_to_He3)*Y(H1)*state.rho; + jac.set(He3, H2, scratch); + + scratch = -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*state.rho - 2.0*screened_rates(k_He3_He3_to_p_p_He4)*Y(He3)*state.rho - screened_rates(k_He4_He3_to_Be7)*Y(He4)*state.rho - screened_rates(k_d_He3_to_p_He4)*Y(H2)*state.rho - screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(H1)*state.rho; + jac.set(He3, He3, scratch); + + scratch = -screened_rates(k_He4_He3_to_Be7)*Y(He3)*state.rho; + jac.set(He3, He4, scratch); + + scratch = -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(He3)*state.rho; + jac.set(He3, Be7, scratch); + + scratch = screened_rates(k_p_F18_to_He4_O15)*Y(F18)*state.rho + screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*state.rho + screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho + screened_rates(k_p_O17_to_He4_N14)*Y(O17)*state.rho; jac.set(He4, H1, scratch); - scratch = -screened_rates(k_He4_C12_to_O16)*Y(C12)*state.rho - 1.5*screened_rates(k_He4_He4_He4_to_C12)*amrex::Math::powi<2>(Y(He4))*amrex::Math::powi<2>(state.rho) - screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho - screened_rates(k_He4_N14_to_F18)*Y(N14)*state.rho - screened_rates(k_He4_O14_to_p_F17)*Y(O14)*state.rho; + scratch = 2.0*screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*state.rho + screened_rates(k_d_He3_to_p_He4)*Y(He3)*state.rho + 1.0*screened_rates(k_d_d_to_He4)*Y(H2)*state.rho; + jac.set(He4, H2, scratch); + + scratch = 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*state.rho + 1.0*screened_rates(k_He3_He3_to_p_p_He4)*Y(He3)*state.rho - screened_rates(k_He4_He3_to_Be7)*Y(He4)*state.rho + screened_rates(k_d_He3_to_p_He4)*Y(H2)*state.rho + screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(H1)*state.rho; + jac.set(He4, He3, scratch); + + scratch = -screened_rates(k_He4_C12_to_O16)*Y(C12)*state.rho - screened_rates(k_He4_He3_to_Be7)*Y(He3)*state.rho - 1.5*screened_rates(k_He4_He4_He4_to_C12)*amrex::Math::powi<2>(Y(He4))*amrex::Math::powi<2>(state.rho) - screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho - screened_rates(k_He4_N14_to_F18)*Y(N14)*state.rho - screened_rates(k_He4_O14_to_p_F17)*Y(O14)*state.rho; jac.set(He4, He4, scratch); + scratch = 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(He3)*state.rho + 2.0*screened_rates(k_d_Be7_to_p_He4_He4)*Y(H2)*state.rho; + jac.set(He4, Be7, scratch); + + scratch = 2.0*screened_rates(k_B8_to_He4_He4_weak_wc12); + jac.set(He4, B8, scratch); + scratch = -screened_rates(k_He4_C12_to_O16)*Y(He4)*state.rho; jac.set(He4, C12, scratch); @@ -636,6 +937,30 @@ void jac_nuc(const burn_t& state, scratch = screened_rates(k_p_F18_to_He4_O15)*Y(H1)*state.rho; jac.set(He4, F18, scratch); + scratch = -screened_rates(k_p_Be7_to_B8)*Y(Be7)*state.rho; + jac.set(Be7, H1, scratch); + + scratch = -screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*state.rho; + jac.set(Be7, H2, scratch); + + scratch = -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*state.rho + screened_rates(k_He4_He3_to_Be7)*Y(He4)*state.rho; + jac.set(Be7, He3, scratch); + + scratch = screened_rates(k_He4_He3_to_Be7)*Y(He3)*state.rho; + jac.set(Be7, He4, scratch); + + scratch = -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(He3)*state.rho - screened_rates(k_d_Be7_to_p_He4_He4)*Y(H2)*state.rho - screened_rates(k_p_Be7_to_B8)*Y(H1)*state.rho; + jac.set(Be7, Be7, scratch); + + scratch = screened_rates(k_p_Be7_to_B8)*Y(Be7)*state.rho; + jac.set(B8, H1, scratch); + + scratch = screened_rates(k_p_Be7_to_B8)*Y(H1)*state.rho; + jac.set(B8, Be7, scratch); + + scratch = -screened_rates(k_B8_to_He4_He4_weak_wc12); + jac.set(B8, B8, scratch); + scratch = -screened_rates(k_p_C12_to_N13)*Y(C12)*state.rho + screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho; jac.set(C12, H1, scratch); @@ -815,7 +1140,9 @@ void actual_jac(const burn_t& state, MatrixType& jac) // Account for the thermal neutrino losses - amrex::Real sneut, dsneutdt, dsneutdd, dsnuda, dsnudz; + amrex::Real dsneutdt{}; +#ifdef NEUTRINOS + amrex::Real sneut, dsneutdd, dsnuda, dsnudz; constexpr int do_derivatives{1}; sneut5(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, dsnuda, dsnudz); @@ -823,7 +1150,7 @@ void actual_jac(const burn_t& state, MatrixType& jac) amrex::Real b1 = (-state.abar * state.abar * dsnuda + (zion[j-1] - state.zbar) * state.abar * dsnudz); jac.add(net_ienuc, j, -b1); } - +#endif // Evaluate the Jacobian elements with respect to energy by // calling the RHS using d(rate) / dT and then transform them diff --git a/networks/nova/inputs.burn_cell.VODE b/networks/nova/inputs.burn_cell.VODE index f94d4554b8..66434599a5 100644 --- a/networks/nova/inputs.burn_cell.VODE +++ b/networks/nova/inputs.burn_cell.VODE @@ -37,3 +37,7 @@ unit_test.X10 = 0.0 unit_test.X11 = 0.0 unit_test.X12 = 0.0 unit_test.X13 = 0.0 +unit_test.X14 = 0.0 +unit_test.X15 = 0.0 +unit_test.X16 = 0.0 +unit_test.X17 = 0.0 diff --git a/networks/nova/network_plot.py b/networks/nova/network_plot.py deleted file mode 100644 index 589c7942e2..0000000000 --- a/networks/nova/network_plot.py +++ /dev/null @@ -1,21 +0,0 @@ -# C-burning with A=23 URCA rate module generator - -import pynucastro as pyna -from pynucastro.networks import StarKillerNetwork - -library_file = "20180319default2" -mylibrary = pyna.rates.Library(library_file) - -all_nuclei = ["p", "he4", "c12", "c13", "n13", "n14", "n15", "o14", "o15", "o16", "o17", "f17", "f18"] - -nova_library = mylibrary.linking_nuclei(all_nuclei, with_reverse=False) -print(len(nova_library._rates)) -rc = pyna.RateCollection(libraries=[nova_library]) - -comp = pyna.Composition(rc.get_nuclei()) -comp.set_solar_like() - -rho = 1.e4 -T = 9.e7 - -rc.plot(rho, T, comp, outfile="nova.png") diff --git a/networks/nova/nova.png b/networks/nova/nova.png index a9fbc5984d..d8e3139620 100644 Binary files a/networks/nova/nova.png and b/networks/nova/nova.png differ diff --git a/networks/nova/nova.py b/networks/nova/nova.py index 2e4862202c..4d6bd600aa 100644 --- a/networks/nova/nova.py +++ b/networks/nova/nova.py @@ -1,25 +1,27 @@ import pynucastro as pyna -from pynucastro.networks import AmrexAstroCxxNetwork, RateCollection, Composition +from pynucastro.networks import AmrexAstroCxxNetwork mylibrary = pyna.rates.ReacLibLibrary() -all_nuclei = ["p", "he4", "c12", "c13", "n13", "n14", "n15", "o14", "o15", "o16", "o17", "f17", "f18"] +all_nuclei = ["p", "h2", "he3", "he4", "be7", "b8", + "c12", "c13", "n13", "n14", "n15", + "o14", "o15", "o16", "o17", "f17", "f18"] nova_library = mylibrary.linking_nuclei(all_nuclei, with_reverse=False) -print(nova_library) - net = AmrexAstroCxxNetwork(libraries=[nova_library]) net.write_network() -# make a plot - -rc = RateCollection(libraries=[nova_library]) +rc = pyna.RateCollection(libraries=[nova_library]) -comp = Composition(rc.get_nuclei()) +comp = pyna.Composition(rc.get_nuclei()) comp.set_solar_like() -rho = 1.e4 -T = 9.e7 +rho = 1.e3 +T = 1.e8 + +edge_labels = {(pyna.Nucleus("he4"), pyna.Nucleus("c12")): + r"$\alpha(\alpha\alpha,\gamma){}^{12}\mathrm{C}$"} -rc.plot(rho, T, comp, outfile="nova.png") +rc.plot(rho, T, comp, rotated=False, outfile="nova.png", N_range=(-1,10) , Z_range=(0,10), hide_xalpha=True, hide_xp=True, + curved_edges=True, edge_labels=edge_labels, node_size=300, node_font_size=10) diff --git a/networks/nova/partition_functions.H b/networks/nova/partition_functions.H index a5162644b0..54977f91ed 100644 --- a/networks/nova/partition_functions.H +++ b/networks/nova/partition_functions.H @@ -17,21 +17,21 @@ namespace part_fun { // interpolation routine - template + template AMREX_GPU_HOST_DEVICE AMREX_INLINE - void interpolate_pf(const amrex::Real t9, const amrex::Real (&temp_array)[npts], const amrex::Real (&pf_array)[npts], + void interpolate_pf(const amrex::Real t9, const T& temp_array, const T& pf_array, amrex::Real& pf, amrex::Real& dpf_dT) { - if (t9 >= temp_array[0] && t9 < temp_array[npts-1]) { + if (t9 >= temp_array.lo() && t9 < temp_array.hi()) { // find the largest temperature element <= t9 using a binary search - int left = 0; - int right = npts; + int left = temp_array.lo(); + int right = temp_array.hi(); while (left < right) { int mid = (left + right) / 2; - if (temp_array[mid] > t9) { + if (temp_array(mid) > t9) { right = mid; } else { left = mid + 1; @@ -44,11 +44,12 @@ namespace part_fun { // construct the slope -- this is (log10(pf_{i+1}) - log10(pf_i)) / (T_{i+1} - T_i) - amrex::Real slope = (pf_array[idx+1] - pf_array[idx]) / (temp_array[idx+1] - temp_array[idx]); + amrex::Real slope = (pf_array(idx+1) - pf_array(idx)) / + (temp_array(idx+1) - temp_array(idx)); // find the PF - amrex::Real log10_pf = pf_array[idx] + slope * (t9 - temp_array[idx]); + amrex::Real log10_pf = pf_array(idx) + slope * (t9 - temp_array(idx)); pf = std::pow(10.0_rt, log10_pf); // find the derivative (with respect to T, not T9) @@ -129,6 +130,7 @@ constexpr amrex::Real get_spin_state(const int inuc) { break; case H1: + case He3: case C13: case N13: case N15: @@ -136,11 +138,20 @@ constexpr amrex::Real get_spin_state(const int inuc) { spin = 2; break; + case H2: case N14: case F18: spin = 3; break; + case Be7: + spin = 4; + break; + + case B8: + spin = 5; + break; + case O17: case F17: spin = 6; diff --git a/networks/nova/partition_functions_data.cpp b/networks/nova/partition_functions_data.cpp new file mode 100644 index 0000000000..e4dc2a8c00 --- /dev/null +++ b/networks/nova/partition_functions_data.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +#include + +using namespace amrex; + +namespace part_fun { + + +} + diff --git a/networks/nova/pynucastro.net b/networks/nova/pynucastro.net index d9089af113..7012ca4859 100644 --- a/networks/nova/pynucastro.net +++ b/networks/nova/pynucastro.net @@ -1,5 +1,9 @@ hydrogen-1 H1 1.0 1.0 +hydrogen-2 H2 2.0 1.0 +helium-3 He3 3.0 2.0 helium-4 He4 4.0 2.0 +beryllium-7 Be7 7.0 4.0 +boron-8 B8 8.0 5.0 carbon-12 C12 12.0 6.0 carbon-13 C13 13.0 6.0 nitrogen-13 N13 13.0 7.0 diff --git a/networks/nova/reaclib_rates.H b/networks/nova/reaclib_rates.H index 9e4061f811..ecd427461d 100644 --- a/networks/nova/reaclib_rates.H +++ b/networks/nova/reaclib_rates.H @@ -147,6 +147,312 @@ void rate_F17_to_O17_weak_wc12(const tf_t& tfactors, amrex::Real& rate, amrex::R } +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_B8_to_He4_He4_weak_wc12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // B8 --> He4 + He4 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // wc12w + ln_set_rate = -0.105148; + amrex::ignore_unused(tfactors); + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.0; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_p_to_d_weak_bet_pos_(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // p + p --> d + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // bet+w + ln_set_rate = -34.7863 + -3.51193 * tfactors.T913i + 3.10086 * tfactors.T913 + + -0.198314 * tfactors.T9 + 0.0126251 * tfactors.T953 + -1.02517 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -3.51193 * tfactors.T943i + (1.0/3.0) * 3.10086 * tfactors.T923i + + -0.198314 + (5.0/3.0) * 0.0126251 * tfactors.T923 + -1.02517 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_p_to_d_weak_electron_capture(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // p + p --> d + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // ecw + ln_set_rate = -43.6499 + -0.00246064 * tfactors.T9i + -2.7507 * tfactors.T913i + -0.424877 * tfactors.T913 + + 0.015987 * tfactors.T9 + -0.000690875 * tfactors.T953 + -0.207625 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.00246064 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -2.7507 * tfactors.T943i + (1.0/3.0) * -0.424877 * tfactors.T923i + + 0.015987 + (5.0/3.0) * -0.000690875 * tfactors.T923 + -0.207625 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_d_to_He3(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // d + p --> He3 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // de04 + ln_set_rate = 8.93525 + -3.7208 * tfactors.T913i + 0.198654 * tfactors.T913 + + 0.333333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -3.7208 * tfactors.T943i + (1.0/3.0) * 0.198654 * tfactors.T923i + + 0.333333 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + + // de04n + ln_set_rate = 7.52898 + -3.7208 * tfactors.T913i + 0.871782 * tfactors.T913 + + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -3.7208 * tfactors.T943i + (1.0/3.0) * 0.871782 * tfactors.T923i + + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_d_d_to_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // d + d --> He4 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // nacrn + ln_set_rate = 3.78177 + -4.26166 * tfactors.T913i + -0.119233 * tfactors.T913 + + 0.778829 * tfactors.T9 + -0.0925203 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -4.26166 * tfactors.T943i + (1.0/3.0) * -0.119233 * tfactors.T923i + + 0.778829 + (5.0/3.0) * -0.0925203 * tfactors.T923 + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_He3_to_He4_weak_bet_pos_(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // He3 + p --> He4 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // bet+w + ln_set_rate = -27.7611 + -4.30107e-12 * tfactors.T9i + -6.141 * tfactors.T913i + -1.93473e-09 * tfactors.T913 + + 2.04145e-10 * tfactors.T9 + -1.80372e-11 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 4.30107e-12 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -6.141 * tfactors.T943i + (1.0/3.0) * -1.93473e-09 * tfactors.T923i + + 2.04145e-10 + (5.0/3.0) * -1.80372e-11 * tfactors.T923 + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He4_He3_to_Be7(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // He3 + He4 --> Be7 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // cd08n + ln_set_rate = 17.7075 + -12.8271 * tfactors.T913i + -3.8126 * tfactors.T913 + + 0.0942285 * tfactors.T9 + -0.00301018 * tfactors.T953 + 1.33333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -12.8271 * tfactors.T943i + (1.0/3.0) * -3.8126 * tfactors.T923i + + 0.0942285 + (5.0/3.0) * -0.00301018 * tfactors.T923 + 1.33333 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + + // cd08n + ln_set_rate = 15.6099 + -12.8271 * tfactors.T913i + -0.0308225 * tfactors.T913 + + -0.654685 * tfactors.T9 + 0.0896331 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -12.8271 * tfactors.T943i + (1.0/3.0) * -0.0308225 * tfactors.T923i + + -0.654685 + (5.0/3.0) * 0.0896331 * tfactors.T923 + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_Be7_to_B8(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // Be7 + p --> B8 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // nacrn + ln_set_rate = 12.5315 + -10.264 * tfactors.T913i + -0.203472 * tfactors.T913 + + 0.121083 * tfactors.T9 + -0.00700063 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -10.264 * tfactors.T943i + (1.0/3.0) * -0.203472 * tfactors.T923i + + 0.121083 + (5.0/3.0) * -0.00700063 * tfactors.T923 + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + + // nacrr + ln_set_rate = 7.73399 + -7.345 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 7.345 * tfactors.T9i * tfactors.T9i + + -1.5 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + template AMREX_GPU_HOST_DEVICE AMREX_INLINE void rate_p_C12_to_N13(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { @@ -673,6 +979,55 @@ void rate_p_O17_to_F18(const tf_t& tfactors, amrex::Real& rate, amrex::Real& dra } +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_d_He3_to_p_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // He3 + d --> p + He4 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // de04 + ln_set_rate = 24.6839 + -7.182 * tfactors.T913i + 0.473288 * tfactors.T913 + + 1.46847 * tfactors.T9 + -27.9603 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -7.182 * tfactors.T943i + (1.0/3.0) * 0.473288 * tfactors.T923i + + 1.46847 + (5.0/3.0) * -27.9603 * tfactors.T923 + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + + // de04 + ln_set_rate = 41.2969 + -7.182 * tfactors.T913i + -17.1349 * tfactors.T913 + + 1.36908 * tfactors.T9 + -0.0814423 * tfactors.T953 + 3.35395 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -7.182 * tfactors.T943i + (1.0/3.0) * -17.1349 * tfactors.T923i + + 1.36908 + (5.0/3.0) * -0.0814423 * tfactors.T923 + 3.35395 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + template AMREX_GPU_HOST_DEVICE AMREX_INLINE void rate_He4_N13_to_p_O16(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { @@ -1054,6 +1409,102 @@ void rate_p_F18_to_He4_O15(const tf_t& tfactors, amrex::Real& rate, amrex::Real& } +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He3_He3_to_p_p_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // He3 + He3 --> p + p + He4 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // nacrn + ln_set_rate = 24.7788 + -12.277 * tfactors.T913i + -0.103699 * tfactors.T913 + + -0.0649967 * tfactors.T9 + 0.0168191 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -12.277 * tfactors.T943i + (1.0/3.0) * -0.103699 * tfactors.T923i + + -0.0649967 + (5.0/3.0) * 0.0168191 * tfactors.T923 + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_d_Be7_to_p_He4_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // Be7 + d --> p + He4 + He4 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // cf88n + ln_set_rate = 27.6987 + -12.428 * tfactors.T913i + + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -12.428 * tfactors.T943i + + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He3_Be7_to_p_p_He4_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { + + // Be7 + He3 --> p + p + He4 + He4 + + rate = 0.0; + drate_dT = 0.0; + + amrex::Real ln_set_rate{0.0}; + amrex::Real dln_set_rate_dT9{0.0}; + amrex::Real set_rate{0.0}; + + // mafon + ln_set_rate = 31.7435 + -5.45213e-12 * tfactors.T9i + -21.793 * tfactors.T913i + -1.98126e-09 * tfactors.T913 + + 1.84204e-10 * tfactors.T9 + -1.46403e-11 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 5.45213e-12 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -21.793 * tfactors.T943i + (1.0/3.0) * -1.98126e-09 * tfactors.T923i + + 1.84204e-10 + (5.0/3.0) * -1.46403e-11 * tfactors.T923 + -0.666667 * tfactors.T9i; + } + + // avoid underflows by zeroing rates in [0.0, 1.e-100] + ln_set_rate = std::max(ln_set_rate, -230.0); + set_rate = std::exp(ln_set_rate); + rate += set_rate; + if constexpr (do_T_derivatives) { + drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; + } + +} + template AMREX_GPU_HOST_DEVICE AMREX_INLINE void rate_He4_He4_He4_to_C12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { @@ -1154,6 +1605,54 @@ fill_reaclib_rates(const tf_t& tfactors, T& rate_eval) if constexpr (std::is_same_v) { rate_eval.dscreened_rates_dT(k_F17_to_O17_weak_wc12) = drate_dT; + } + rate_B8_to_He4_He4_weak_wc12(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_B8_to_He4_He4_weak_wc12) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_B8_to_He4_He4_weak_wc12) = drate_dT; + + } + rate_p_p_to_d_weak_bet_pos_(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_p_to_d_weak_bet_pos_) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_bet_pos_) = drate_dT; + + } + rate_p_p_to_d_weak_electron_capture(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_p_to_d_weak_electron_capture) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_electron_capture) = drate_dT; + + } + rate_p_d_to_He3(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_d_to_He3) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_p_d_to_He3) = drate_dT; + + } + rate_d_d_to_He4(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_d_d_to_He4) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_d_d_to_He4) = drate_dT; + + } + rate_p_He3_to_He4_weak_bet_pos_(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_He3_to_He4_weak_bet_pos_) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_p_He3_to_He4_weak_bet_pos_) = drate_dT; + + } + rate_He4_He3_to_Be7(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_He3_to_Be7) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_He4_He3_to_Be7) = drate_dT; + + } + rate_p_Be7_to_B8(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Be7_to_B8) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_p_Be7_to_B8) = drate_dT; + } rate_p_C12_to_N13(tfactors, rate, drate_dT); rate_eval.screened_rates(k_p_C12_to_N13) = rate; @@ -1208,6 +1707,12 @@ fill_reaclib_rates(const tf_t& tfactors, T& rate_eval) if constexpr (std::is_same_v) { rate_eval.dscreened_rates_dT(k_p_O17_to_F18) = drate_dT; + } + rate_d_He3_to_p_He4(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_d_He3_to_p_He4) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_d_He3_to_p_He4) = drate_dT; + } rate_He4_N13_to_p_O16(tfactors, rate, drate_dT); rate_eval.screened_rates(k_He4_N13_to_p_O16) = rate; @@ -1238,6 +1743,24 @@ fill_reaclib_rates(const tf_t& tfactors, T& rate_eval) if constexpr (std::is_same_v) { rate_eval.dscreened_rates_dT(k_p_F18_to_He4_O15) = drate_dT; + } + rate_He3_He3_to_p_p_He4(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He3_He3_to_p_p_He4) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_He3_He3_to_p_p_He4) = drate_dT; + + } + rate_d_Be7_to_p_He4_He4(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_d_Be7_to_p_He4_He4) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_d_Be7_to_p_He4_He4) = drate_dT; + + } + rate_He3_Be7_to_p_p_He4_He4(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He3_Be7_to_p_p_He4_He4) = rate; + if constexpr (std::is_same_v) { + rate_eval.dscreened_rates_dT(k_He3_Be7_to_p_p_He4_He4) = drate_dT; + } rate_He4_He4_He4_to_C12(tfactors, rate, drate_dT); rate_eval.screened_rates(k_He4_He4_He4_to_C12) = rate; @@ -1251,7 +1774,10 @@ fill_reaclib_rates(const tf_t& tfactors, T& rate_eval) template AMREX_GPU_HOST_DEVICE AMREX_INLINE void -fill_approx_rates([[maybe_unused]] const tf_t& tfactors, [[maybe_unused]] T& rate_eval) +fill_approx_rates([[maybe_unused]] const tf_t& tfactors, + [[maybe_unused]] const amrex::Real rho, + [[maybe_unused]] const amrex::Array1D& Y, + [[maybe_unused]] T& rate_eval) { [[maybe_unused]] amrex::Real rate{}; diff --git a/networks/nova2/Make.package b/networks/nova2/Make.package deleted file mode 100644 index 39c65eca7b..0000000000 --- a/networks/nova2/Make.package +++ /dev/null @@ -1,14 +0,0 @@ -CEXE_headers += network_properties.H - -ifeq ($(USE_REACT),TRUE) - CEXE_sources += actual_network_data.cpp - CEXE_headers += actual_network.H - CEXE_headers += tfactors.H - CEXE_headers += partition_functions.H - CEXE_headers += actual_rhs.H - CEXE_headers += reaclib_rates.H - CEXE_headers += table_rates.H - CEXE_sources += table_rates_data.cpp - USE_SCREENING = TRUE - USE_NEUTRINOS = TRUE -endif diff --git a/networks/nova2/_parameters b/networks/nova2/_parameters deleted file mode 100644 index e7a017d5aa..0000000000 --- a/networks/nova2/_parameters +++ /dev/null @@ -1,2 +0,0 @@ -@namespace: network - diff --git a/networks/nova2/actual_network.H b/networks/nova2/actual_network.H deleted file mode 100644 index 6666aa35e0..0000000000 --- a/networks/nova2/actual_network.H +++ /dev/null @@ -1,234 +0,0 @@ -#ifndef actual_network_H -#define actual_network_H - -#include -#include -#include - -#include -#include - -using namespace amrex; - -void actual_network_init(); - -const std::string network_name = "pynucastro-cxx"; - -namespace network -{ - - template - AMREX_GPU_HOST_DEVICE AMREX_INLINE - constexpr amrex::Real bion () { - using namespace Species; - - static_assert(spec >= 1 && spec <= NumSpec); - - // Set the binding energy of the element - - if constexpr (spec == H1) { - return 0.0_rt; - } - else if constexpr (spec == H2) { - return 2.224566_rt; - } - else if constexpr (spec == He3) { - return 7.7180399999999985_rt; - } - else if constexpr (spec == He4) { - return 28.29566_rt; - } - else if constexpr (spec == Be7) { - return 37.600836_rt; - } - else if constexpr (spec == B8) { - return 37.73724_rt; - } - else if constexpr (spec == C12) { - return 92.16172800000001_rt; - } - else if constexpr (spec == C13) { - return 97.108037_rt; - } - else if constexpr (spec == N13) { - return 94.105219_rt; - } - else if constexpr (spec == N14) { - return 104.65859599999999_rt; - } - else if constexpr (spec == N15) { - return 115.4919_rt; - } - else if constexpr (spec == O14) { - return 98.731892_rt; - } - else if constexpr (spec == O15) { - return 111.95538_rt; - } - else if constexpr (spec == O16) { - return 127.619296_rt; - } - else if constexpr (spec == O17) { - return 131.76237600000002_rt; - } - else if constexpr (spec == F17) { - return 128.21957600000002_rt; - } - else if constexpr (spec == F18) { - return 137.369484_rt; - } - - - // Return zero if we don't recognize the species. - return 0.0_rt; - } - - template - AMREX_GPU_HOST_DEVICE AMREX_INLINE - constexpr amrex::Real mion () { - static_assert(spec >= 1 && spec <= NumSpec); - - constexpr amrex::Real A = NetworkProperties::aion(spec); - constexpr amrex::Real Z = NetworkProperties::zion(spec); - - return (A - Z) * C::Legacy::m_n + Z * (C::Legacy::m_p + C::Legacy::m_e) - bion() * C::Legacy::MeV2gr; - } - - // Legacy (non-templated) interfaces - - AMREX_GPU_HOST_DEVICE AMREX_INLINE - amrex::Real bion (int spec) { - using namespace Species; - - amrex::Real b = 0.0_rt; - - // Set the binding energy of the element - constexpr_for<1, NumSpec+1>([&] (auto n) { - if (n == spec) { - b = bion(); - } - }); - - return b; - } - - AMREX_GPU_HOST_DEVICE AMREX_INLINE - amrex::Real mion (int spec) { - using namespace Species; - - amrex::Real m = 0.0_rt; - - constexpr_for<1, NumSpec+1>([&] (auto n) { - if (n == spec) { - m = mion(); - } - }); - - return m; - } -} - -namespace Rates -{ - - enum NetworkRates - { - k_N13_to_C13_weak_wc12 = 1, - k_O14_to_N14_weak_wc12 = 2, - k_O15_to_N15_weak_wc12 = 3, - k_F17_to_O17_weak_wc12 = 4, - k_B8_to_He4_He4_weak_wc12 = 5, - k_p_p_to_d_weak_bet_pos_ = 6, - k_p_p_to_d_weak_electron_capture = 7, - k_p_d_to_He3 = 8, - k_d_d_to_He4 = 9, - k_p_He3_to_He4_weak_bet_pos_ = 10, - k_He4_He3_to_Be7 = 11, - k_p_Be7_to_B8 = 12, - k_p_C12_to_N13 = 13, - k_He4_C12_to_O16 = 14, - k_p_C13_to_N14 = 15, - k_p_N13_to_O14 = 16, - k_p_N14_to_O15 = 17, - k_He4_N14_to_F18 = 18, - k_p_N15_to_O16 = 19, - k_p_O16_to_F17 = 20, - k_p_O17_to_F18 = 21, - k_d_He3_to_p_He4 = 22, - k_He4_N13_to_p_O16 = 23, - k_p_N15_to_He4_C12 = 24, - k_He4_O14_to_p_F17 = 25, - k_p_O17_to_He4_N14 = 26, - k_p_F18_to_He4_O15 = 27, - k_He3_He3_to_p_p_He4 = 28, - k_d_Be7_to_p_He4_He4 = 29, - k_He3_Be7_to_p_p_He4_He4 = 30, - k_He4_He4_He4_to_C12 = 31, - NumRates = k_He4_He4_He4_to_C12 - }; - - // number of reaclib rates - - const int NrateReaclib = 31; - - // number of tabular rates - - const int NrateTabular = 0; - - // rate names -- note: the rates are 1-based, not zero-based, so we pad - // this vector with rate_names[0] = "" so the indices line up with the - // NetworkRates enum - - static const std::vector rate_names = { - "", // 0 - "N13_to_C13_weak_wc12", // 1, - "O14_to_N14_weak_wc12", // 2, - "O15_to_N15_weak_wc12", // 3, - "F17_to_O17_weak_wc12", // 4, - "B8_to_He4_He4_weak_wc12", // 5, - "p_p_to_d_weak_bet_pos_", // 6, - "p_p_to_d_weak_electron_capture", // 7, - "p_d_to_He3", // 8, - "d_d_to_He4", // 9, - "p_He3_to_He4_weak_bet_pos_", // 10, - "He4_He3_to_Be7", // 11, - "p_Be7_to_B8", // 12, - "p_C12_to_N13", // 13, - "He4_C12_to_O16", // 14, - "p_C13_to_N14", // 15, - "p_N13_to_O14", // 16, - "p_N14_to_O15", // 17, - "He4_N14_to_F18", // 18, - "p_N15_to_O16", // 19, - "p_O16_to_F17", // 20, - "p_O17_to_F18", // 21, - "d_He3_to_p_He4", // 22, - "He4_N13_to_p_O16", // 23, - "p_N15_to_He4_C12", // 24, - "He4_O14_to_p_F17", // 25, - "p_O17_to_He4_N14", // 26, - "p_F18_to_He4_O15", // 27, - "He3_He3_to_p_p_He4", // 28, - "d_Be7_to_p_He4_He4", // 29, - "He3_Be7_to_p_p_He4_He4", // 30, - "He4_He4_He4_to_C12" // 31, - }; - -} - -#ifdef NSE_NET -namespace NSE_INDEX -{ - constexpr int H1_index = 0; - constexpr int N_index = -1; - constexpr int He4_index = 3; - - // Each row corresponds to the rate in NetworkRates enum - // First 3 row indices for reactants, followed by 3 product indices - // last index is the corresponding reverse rate index. - - extern AMREX_GPU_MANAGED amrex::Array2D rate_indices; -} -#endif - -#endif diff --git a/networks/nova2/actual_network_data.cpp b/networks/nova2/actual_network_data.cpp deleted file mode 100644 index 467e797eec..0000000000 --- a/networks/nova2/actual_network_data.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include - - -#ifdef NSE_NET -namespace NSE_INDEX -{ - AMREX_GPU_MANAGED amrex::Array2D rate_indices { - -1, -1, 8, -1, -1, 7, -1, - -1, -1, 11, -1, -1, 9, -1, - -1, -1, 12, -1, -1, 10, -1, - -1, -1, 15, -1, -1, 14, -1, - -1, -1, 5, -1, 3, 3, -1, - -1, 0, 0, -1, -1, 1, -1, - -1, 0, 0, -1, -1, 1, -1, - -1, 0, 1, -1, -1, 2, -1, - -1, 1, 1, -1, -1, 3, -1, - -1, 0, 2, -1, -1, 3, -1, - -1, 2, 3, -1, -1, 4, -1, - -1, 0, 4, -1, -1, 5, -1, - -1, 0, 6, -1, -1, 8, -1, - -1, 3, 6, -1, -1, 13, -1, - -1, 0, 7, -1, -1, 9, -1, - -1, 0, 8, -1, -1, 11, -1, - -1, 0, 9, -1, -1, 12, -1, - -1, 3, 9, -1, -1, 16, -1, - -1, 0, 10, -1, -1, 13, -1, - -1, 0, 13, -1, -1, 15, -1, - -1, 0, 14, -1, -1, 16, -1, - -1, 1, 2, -1, 0, 3, -1, - -1, 3, 8, -1, 0, 13, -1, - -1, 0, 10, -1, 3, 6, -1, - -1, 3, 11, -1, 0, 15, -1, - -1, 0, 14, -1, 3, 9, -1, - -1, 0, 16, -1, 3, 12, -1, - -1, 2, 2, 0, 0, 3, -1, - -1, 1, 4, 0, 3, 3, -1, - -1, 2, 4, 0, 0, 3, -1, - 3, 3, 3, -1, -1, 6, -1 - }; -} -#endif - -void actual_network_init() -{ - -} diff --git a/networks/nova2/actual_rhs.H b/networks/nova2/actual_rhs.H deleted file mode 100644 index 5ea5298963..0000000000 --- a/networks/nova2/actual_rhs.H +++ /dev/null @@ -1,1179 +0,0 @@ -#ifndef actual_rhs_H -#define actual_rhs_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace amrex; -using namespace ArrayUtil; - -using namespace Species; -using namespace Rates; - -using namespace rate_tables; - - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void ener_gener_rate(T const& dydt, amrex::Real& enuc) -{ - - // Computes the instantaneous energy generation rate (from the nuclei) - - // This is basically e = m c**2 - - enuc = 0.0_rt; - - for (int n = 1; n <= NumSpec; ++n) { - enuc += dydt(n) * network::mion(n); - } - - enuc *= C::Legacy::enuc_conv2; -} - - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void evaluate_rates(const burn_t& state, T& rate_eval) { - - - // create molar fractions - - amrex::Array1D Y; - for (int n = 1; n <= NumSpec; ++n) { - Y(n) = state.xn[n-1] * aion_inv[n-1]; - } - - [[maybe_unused]] amrex::Real rhoy = state.rho * state.y_e; - - // Calculate Reaclib rates - - using number_t = std::conditional_t; - number_t temp = state.T; - if constexpr (do_T_derivatives) { - // seed the dual number for temperature before calculating anything with it - autodiff::seed(temp); - } - plasma_state_t pstate{}; - fill_plasma_state(pstate, temp, state.rho, Y); - - tf_t tfactors = evaluate_tfactors(state.T); - - fill_reaclib_rates(tfactors, rate_eval); - - - - // Evaluate screening factors - - amrex::Real ratraw, dratraw_dT; - amrex::Real scor, dscor_dt; - [[maybe_unused]] amrex::Real scor2, dscor2_dt; - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 1.0_rt, 1.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_p_to_d_weak_bet_pos_); - rate_eval.screened_rates(k_p_p_to_d_weak_bet_pos_) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_bet_pos_); - rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_bet_pos_) = ratraw * dscor_dt + dratraw_dT * scor; - } - - ratraw = rate_eval.screened_rates(k_p_p_to_d_weak_electron_capture); - rate_eval.screened_rates(k_p_p_to_d_weak_electron_capture) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_electron_capture); - rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_electron_capture) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 1.0_rt, 2.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_d_to_He3); - rate_eval.screened_rates(k_p_d_to_He3) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_d_to_He3); - rate_eval.dscreened_rates_dT(k_p_d_to_He3) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 2.0_rt, 1.0_rt, 2.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_d_d_to_He4); - rate_eval.screened_rates(k_d_d_to_He4) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_d_d_to_He4); - rate_eval.dscreened_rates_dT(k_d_d_to_He4) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 2.0_rt, 3.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_He3_to_He4_weak_bet_pos_); - rate_eval.screened_rates(k_p_He3_to_He4_weak_bet_pos_) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_He3_to_He4_weak_bet_pos_); - rate_eval.dscreened_rates_dT(k_p_He3_to_He4_weak_bet_pos_) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 2.0_rt, 3.0_rt); - - - static_assert(scn_fac.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_He4_He3_to_Be7); - rate_eval.screened_rates(k_He4_He3_to_Be7) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_He3_to_Be7); - rate_eval.dscreened_rates_dT(k_He4_He3_to_Be7) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 4.0_rt, 7.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_Be7_to_B8); - rate_eval.screened_rates(k_p_Be7_to_B8) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Be7_to_B8); - rate_eval.dscreened_rates_dT(k_p_Be7_to_B8) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 6.0_rt, 12.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_C12_to_N13); - rate_eval.screened_rates(k_p_C12_to_N13) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_C12_to_N13); - rate_eval.dscreened_rates_dT(k_p_C12_to_N13) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 6.0_rt, 12.0_rt); - - - static_assert(scn_fac.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_He4_C12_to_O16); - rate_eval.screened_rates(k_He4_C12_to_O16) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_C12_to_O16); - rate_eval.dscreened_rates_dT(k_He4_C12_to_O16) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 6.0_rt, 13.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_C13_to_N14); - rate_eval.screened_rates(k_p_C13_to_N14) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_C13_to_N14); - rate_eval.dscreened_rates_dT(k_p_C13_to_N14) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 7.0_rt, 13.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_N13_to_O14); - rate_eval.screened_rates(k_p_N13_to_O14) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_N13_to_O14); - rate_eval.dscreened_rates_dT(k_p_N13_to_O14) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 7.0_rt, 14.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_N14_to_O15); - rate_eval.screened_rates(k_p_N14_to_O15) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_N14_to_O15); - rate_eval.dscreened_rates_dT(k_p_N14_to_O15) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 7.0_rt, 14.0_rt); - - - static_assert(scn_fac.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_He4_N14_to_F18); - rate_eval.screened_rates(k_He4_N14_to_F18) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_N14_to_F18); - rate_eval.dscreened_rates_dT(k_He4_N14_to_F18) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 7.0_rt, 15.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_N15_to_O16); - rate_eval.screened_rates(k_p_N15_to_O16) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_N15_to_O16); - rate_eval.dscreened_rates_dT(k_p_N15_to_O16) = ratraw * dscor_dt + dratraw_dT * scor; - } - - ratraw = rate_eval.screened_rates(k_p_N15_to_He4_C12); - rate_eval.screened_rates(k_p_N15_to_He4_C12) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_N15_to_He4_C12); - rate_eval.dscreened_rates_dT(k_p_N15_to_He4_C12) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 8.0_rt, 16.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_O16_to_F17); - rate_eval.screened_rates(k_p_O16_to_F17) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_O16_to_F17); - rate_eval.dscreened_rates_dT(k_p_O16_to_F17) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 8.0_rt, 17.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_O17_to_F18); - rate_eval.screened_rates(k_p_O17_to_F18) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_O17_to_F18); - rate_eval.dscreened_rates_dT(k_p_O17_to_F18) = ratraw * dscor_dt + dratraw_dT * scor; - } - - ratraw = rate_eval.screened_rates(k_p_O17_to_He4_N14); - rate_eval.screened_rates(k_p_O17_to_He4_N14) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_O17_to_He4_N14); - rate_eval.dscreened_rates_dT(k_p_O17_to_He4_N14) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 2.0_rt, 2.0_rt, 3.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_d_He3_to_p_He4); - rate_eval.screened_rates(k_d_He3_to_p_He4) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_d_He3_to_p_He4); - rate_eval.dscreened_rates_dT(k_d_He3_to_p_He4) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 7.0_rt, 13.0_rt); - - - static_assert(scn_fac.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_He4_N13_to_p_O16); - rate_eval.screened_rates(k_He4_N13_to_p_O16) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_N13_to_p_O16); - rate_eval.dscreened_rates_dT(k_He4_N13_to_p_O16) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 8.0_rt, 14.0_rt); - - - static_assert(scn_fac.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_He4_O14_to_p_F17); - rate_eval.screened_rates(k_He4_O14_to_p_F17) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_O14_to_p_F17); - rate_eval.dscreened_rates_dT(k_He4_O14_to_p_F17) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 9.0_rt, 18.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_p_F18_to_He4_O15); - rate_eval.screened_rates(k_p_F18_to_He4_O15) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_p_F18_to_He4_O15); - rate_eval.dscreened_rates_dT(k_p_F18_to_He4_O15) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 3.0_rt, 2.0_rt, 3.0_rt); - - - static_assert(scn_fac.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_He3_He3_to_p_p_He4); - rate_eval.screened_rates(k_He3_He3_to_p_p_He4) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_He3_He3_to_p_p_He4); - rate_eval.dscreened_rates_dT(k_He3_He3_to_p_p_He4) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 2.0_rt, 4.0_rt, 7.0_rt); - - - static_assert(scn_fac.z1 == 1.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_d_Be7_to_p_He4_He4); - rate_eval.screened_rates(k_d_Be7_to_p_He4_He4) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_d_Be7_to_p_He4_He4); - rate_eval.dscreened_rates_dT(k_d_Be7_to_p_He4_He4) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 3.0_rt, 4.0_rt, 7.0_rt); - - - static_assert(scn_fac.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - ratraw = rate_eval.screened_rates(k_He3_Be7_to_p_p_He4_He4); - rate_eval.screened_rates(k_He3_Be7_to_p_p_He4_He4) *= scor; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_He3_Be7_to_p_p_He4_He4); - rate_eval.dscreened_rates_dT(k_He3_Be7_to_p_p_He4_He4) = ratraw * dscor_dt + dratraw_dT * scor; - } - - - { - constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 2.0_rt, 4.0_rt); - - - static_assert(scn_fac.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac, scor, dscor_dt); - } - - - - { - constexpr auto scn_fac2 = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 4.0_rt, 8.0_rt); - - - static_assert(scn_fac2.z1 == 2.0_rt); - - - actual_screen(pstate, scn_fac2, scor2, dscor2_dt); - - } - - - ratraw = rate_eval.screened_rates(k_He4_He4_He4_to_C12); - rate_eval.screened_rates(k_He4_He4_He4_to_C12) *= scor * scor2; - if constexpr (std::is_same_v) { - dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_He4_He4_to_C12); - rate_eval.dscreened_rates_dT(k_He4_He4_He4_to_C12) = ratraw * (scor * dscor2_dt + dscor_dt * scor2) + dratraw_dT * scor * scor2; - } - - - // Fill approximate rates - - fill_approx_rates(tfactors, rate_eval); - - // Calculate tabular rates - - [[maybe_unused]] amrex::Real rate, drate_dt, edot_nu, edot_gamma; - - rate_eval.enuc_weak = 0.0_rt; - - -} - -#ifdef NSE_NET -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void get_ydot_weak(const burn_t& state, - amrex::Array1D& ydot_nuc, - amrex::Real& enuc_weak, - [[maybe_unused]] const amrex::Array1D& Y) { - /// - /// Calculate Ydots contribute only from weak reactions. - /// This is used to calculate dyedt and energy generation from - /// weak reactions for self-consistent NSE - /// - - - // initialize ydot_nuc to 0 - - for (int i = 1; i <= neqs; ++i) { - ydot_nuc(i) = 0.0_rt; - } - - rate_t rate_eval; - - [[maybe_unused]] amrex::Real rate, drate_dt, edot_nu, edot_gamma; - [[maybe_unused]] amrex::Real rhoy = state.rho * state.y_e; - - rate_eval.enuc_weak = 0.0_rt; - - // Calculate tabular rates and get ydot_weak - - - ydot_nuc(H1) = 0.0_rt; - - ydot_nuc(H2) = 0.0_rt; - - ydot_nuc(He3) = 0.0_rt; - - ydot_nuc(He4) = 0.0_rt; - - ydot_nuc(Be7) = 0.0_rt; - - ydot_nuc(B8) = 0.0_rt; - - ydot_nuc(C12) = 0.0_rt; - - ydot_nuc(C13) = 0.0_rt; - - ydot_nuc(N13) = 0.0_rt; - - ydot_nuc(N14) = 0.0_rt; - - ydot_nuc(N15) = 0.0_rt; - - ydot_nuc(O14) = 0.0_rt; - - ydot_nuc(O15) = 0.0_rt; - - ydot_nuc(O16) = 0.0_rt; - - ydot_nuc(O17) = 0.0_rt; - - ydot_nuc(F17) = 0.0_rt; - - ydot_nuc(F18) = 0.0_rt; - - enuc_weak = rate_eval.enuc_weak; -} -#endif - - -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rhs_nuc(const burn_t& state, - amrex::Array1D& ydot_nuc, - const amrex::Array1D& Y, - const amrex::Array1D& screened_rates) { - - using namespace Rates; - - ydot_nuc(H1) = - -screened_rates(k_p_p_to_d_weak_bet_pos_)*amrex::Math::powi<2>(Y(H1))*state.rho + - -screened_rates(k_p_p_to_d_weak_electron_capture)*amrex::Math::powi<2>(Y(H1))*amrex::Math::powi<2>(state.rho)*state.y_e + - -screened_rates(k_p_d_to_He3)*Y(H2)*Y(H1)*state.rho + - -screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*Y(H1)*state.rho + - -screened_rates(k_p_Be7_to_B8)*Y(Be7)*Y(H1)*state.rho + - -screened_rates(k_p_C12_to_N13)*Y(C12)*Y(H1)*state.rho + - -screened_rates(k_p_C13_to_N14)*Y(C13)*Y(H1)*state.rho + - -screened_rates(k_p_N13_to_O14)*Y(N13)*Y(H1)*state.rho + - -screened_rates(k_p_N14_to_O15)*Y(N14)*Y(H1)*state.rho + - -screened_rates(k_p_N15_to_O16)*Y(N15)*Y(H1)*state.rho + - -screened_rates(k_p_O16_to_F17)*Y(O16)*Y(H1)*state.rho + - -screened_rates(k_p_O17_to_F18)*Y(O17)*Y(H1)*state.rho + - screened_rates(k_d_He3_to_p_He4)*Y(He3)*Y(H2)*state.rho + - screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho + - -screened_rates(k_p_N15_to_He4_C12)*Y(N15)*Y(H1)*state.rho + - screened_rates(k_He4_O14_to_p_F17)*Y(He4)*Y(O14)*state.rho + - -screened_rates(k_p_O17_to_He4_N14)*Y(O17)*Y(H1)*state.rho + - -screened_rates(k_p_F18_to_He4_O15)*Y(F18)*Y(H1)*state.rho + - screened_rates(k_He3_He3_to_p_p_He4)*amrex::Math::powi<2>(Y(He3))*state.rho + - screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*Y(H2)*state.rho + - 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*Y(He3)*state.rho; - - ydot_nuc(H2) = - 0.5*screened_rates(k_p_p_to_d_weak_bet_pos_)*amrex::Math::powi<2>(Y(H1))*state.rho + - 0.5*screened_rates(k_p_p_to_d_weak_electron_capture)*amrex::Math::powi<2>(Y(H1))*amrex::Math::powi<2>(state.rho)*state.y_e + - -screened_rates(k_p_d_to_He3)*Y(H2)*Y(H1)*state.rho + - -screened_rates(k_d_d_to_He4)*amrex::Math::powi<2>(Y(H2))*state.rho + - -screened_rates(k_d_He3_to_p_He4)*Y(He3)*Y(H2)*state.rho + - -screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*Y(H2)*state.rho; - - ydot_nuc(He3) = - screened_rates(k_p_d_to_He3)*Y(H2)*Y(H1)*state.rho + - -screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*Y(H1)*state.rho + - -screened_rates(k_He4_He3_to_Be7)*Y(He3)*Y(He4)*state.rho + - -screened_rates(k_d_He3_to_p_He4)*Y(He3)*Y(H2)*state.rho + - -screened_rates(k_He3_He3_to_p_p_He4)*amrex::Math::powi<2>(Y(He3))*state.rho + - -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*Y(He3)*state.rho; - - ydot_nuc(He4) = - 2.0*screened_rates(k_B8_to_He4_He4_weak_wc12)*Y(B8) + - 0.5*screened_rates(k_d_d_to_He4)*amrex::Math::powi<2>(Y(H2))*state.rho + - screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*Y(H1)*state.rho + - -screened_rates(k_He4_He3_to_Be7)*Y(He3)*Y(He4)*state.rho + - -screened_rates(k_He4_C12_to_O16)*Y(C12)*Y(He4)*state.rho + - -screened_rates(k_He4_N14_to_F18)*Y(He4)*Y(N14)*state.rho + - screened_rates(k_d_He3_to_p_He4)*Y(He3)*Y(H2)*state.rho + - -screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho + - screened_rates(k_p_N15_to_He4_C12)*Y(N15)*Y(H1)*state.rho + - -screened_rates(k_He4_O14_to_p_F17)*Y(He4)*Y(O14)*state.rho + - screened_rates(k_p_O17_to_He4_N14)*Y(O17)*Y(H1)*state.rho + - screened_rates(k_p_F18_to_He4_O15)*Y(F18)*Y(H1)*state.rho + - 0.5*screened_rates(k_He3_He3_to_p_p_He4)*amrex::Math::powi<2>(Y(He3))*state.rho + - 2.0*screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*Y(H2)*state.rho + - 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*Y(He3)*state.rho + - -0.5*screened_rates(k_He4_He4_He4_to_C12)*amrex::Math::powi<3>(Y(He4))*amrex::Math::powi<2>(state.rho); - - ydot_nuc(Be7) = - screened_rates(k_He4_He3_to_Be7)*Y(He3)*Y(He4)*state.rho + - -screened_rates(k_p_Be7_to_B8)*Y(Be7)*Y(H1)*state.rho + - -screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*Y(H2)*state.rho + - -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*Y(He3)*state.rho; - - ydot_nuc(B8) = - -screened_rates(k_B8_to_He4_He4_weak_wc12)*Y(B8) + - screened_rates(k_p_Be7_to_B8)*Y(Be7)*Y(H1)*state.rho; - - ydot_nuc(C12) = - -screened_rates(k_p_C12_to_N13)*Y(C12)*Y(H1)*state.rho + - -screened_rates(k_He4_C12_to_O16)*Y(C12)*Y(He4)*state.rho + - screened_rates(k_p_N15_to_He4_C12)*Y(N15)*Y(H1)*state.rho + - 0.16666666666666667*screened_rates(k_He4_He4_He4_to_C12)*amrex::Math::powi<3>(Y(He4))*amrex::Math::powi<2>(state.rho); - - ydot_nuc(C13) = - screened_rates(k_N13_to_C13_weak_wc12)*Y(N13) + - -screened_rates(k_p_C13_to_N14)*Y(C13)*Y(H1)*state.rho; - - ydot_nuc(N13) = - -screened_rates(k_N13_to_C13_weak_wc12)*Y(N13) + - screened_rates(k_p_C12_to_N13)*Y(C12)*Y(H1)*state.rho + - -screened_rates(k_p_N13_to_O14)*Y(N13)*Y(H1)*state.rho + - -screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho; - - ydot_nuc(N14) = - screened_rates(k_O14_to_N14_weak_wc12)*Y(O14) + - screened_rates(k_p_C13_to_N14)*Y(C13)*Y(H1)*state.rho + - -screened_rates(k_p_N14_to_O15)*Y(N14)*Y(H1)*state.rho + - -screened_rates(k_He4_N14_to_F18)*Y(He4)*Y(N14)*state.rho + - screened_rates(k_p_O17_to_He4_N14)*Y(O17)*Y(H1)*state.rho; - - ydot_nuc(N15) = - screened_rates(k_O15_to_N15_weak_wc12)*Y(O15) + - -screened_rates(k_p_N15_to_O16)*Y(N15)*Y(H1)*state.rho + - -screened_rates(k_p_N15_to_He4_C12)*Y(N15)*Y(H1)*state.rho; - - ydot_nuc(O14) = - -screened_rates(k_O14_to_N14_weak_wc12)*Y(O14) + - screened_rates(k_p_N13_to_O14)*Y(N13)*Y(H1)*state.rho + - -screened_rates(k_He4_O14_to_p_F17)*Y(He4)*Y(O14)*state.rho; - - ydot_nuc(O15) = - -screened_rates(k_O15_to_N15_weak_wc12)*Y(O15) + - screened_rates(k_p_N14_to_O15)*Y(N14)*Y(H1)*state.rho + - screened_rates(k_p_F18_to_He4_O15)*Y(F18)*Y(H1)*state.rho; - - ydot_nuc(O16) = - screened_rates(k_He4_C12_to_O16)*Y(C12)*Y(He4)*state.rho + - screened_rates(k_p_N15_to_O16)*Y(N15)*Y(H1)*state.rho + - -screened_rates(k_p_O16_to_F17)*Y(O16)*Y(H1)*state.rho + - screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho; - - ydot_nuc(O17) = - screened_rates(k_F17_to_O17_weak_wc12)*Y(F17) + - -screened_rates(k_p_O17_to_F18)*Y(O17)*Y(H1)*state.rho + - -screened_rates(k_p_O17_to_He4_N14)*Y(O17)*Y(H1)*state.rho; - - ydot_nuc(F17) = - -screened_rates(k_F17_to_O17_weak_wc12)*Y(F17) + - screened_rates(k_p_O16_to_F17)*Y(O16)*Y(H1)*state.rho + - screened_rates(k_He4_O14_to_p_F17)*Y(He4)*Y(O14)*state.rho; - - ydot_nuc(F18) = - screened_rates(k_He4_N14_to_F18)*Y(He4)*Y(N14)*state.rho + - screened_rates(k_p_O17_to_F18)*Y(O17)*Y(H1)*state.rho + - -screened_rates(k_p_F18_to_He4_O15)*Y(F18)*Y(H1)*state.rho; - -} - - -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void actual_rhs (burn_t& state, amrex::Array1D& ydot) -{ - for (int i = 1; i <= neqs; ++i) { - ydot(i) = 0.0_rt; - } - - - // Set molar abundances - amrex::Array1D Y; - for (int i = 1; i <= NumSpec; ++i) { - Y(i) = state.xn[i-1] * aion_inv[i-1]; - } - - // build the rates - - rate_t rate_eval; - - constexpr int do_T_derivatives = 0; - - evaluate_rates(state, rate_eval); - - rhs_nuc(state, ydot, Y, rate_eval.screened_rates); - - // ion binding energy contributions - - amrex::Real enuc; - ener_gener_rate(ydot, enuc); - - // include any weak rate neutrino losses - enuc += rate_eval.enuc_weak; - - // Get the thermal neutrino losses - - amrex::Real sneut, dsneutdt, dsneutdd, dsnuda, dsnudz; - constexpr int do_derivatives{0}; - sneut5(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, dsnuda, dsnudz); - - // Append the energy equation (this is erg/g/s) - - ydot(net_ienuc) = enuc - sneut; - -} - - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void jac_nuc(const burn_t& state, - MatrixType& jac, - const amrex::Array1D& Y, - const amrex::Array1D& screened_rates) -{ - - amrex::Real scratch; - - scratch = -screened_rates(k_p_Be7_to_B8)*Y(Be7)*state.rho - screened_rates(k_p_C12_to_N13)*Y(C12)*state.rho - screened_rates(k_p_C13_to_N14)*Y(C13)*state.rho - screened_rates(k_p_F18_to_He4_O15)*Y(F18)*state.rho - screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*state.rho - screened_rates(k_p_N13_to_O14)*Y(N13)*state.rho - screened_rates(k_p_N14_to_O15)*Y(N14)*state.rho - screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho - screened_rates(k_p_N15_to_O16)*Y(N15)*state.rho - screened_rates(k_p_O16_to_F17)*Y(O16)*state.rho - screened_rates(k_p_O17_to_F18)*Y(O17)*state.rho - screened_rates(k_p_O17_to_He4_N14)*Y(O17)*state.rho - screened_rates(k_p_d_to_He3)*Y(H2)*state.rho - 2.0*screened_rates(k_p_p_to_d_weak_bet_pos_)*Y(H1)*state.rho - 2.0*screened_rates(k_p_p_to_d_weak_electron_capture)*Y(H1)*amrex::Math::powi<2>(state.rho)*state.y_e; - jac.set(H1, H1, scratch); - - scratch = screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*state.rho + screened_rates(k_d_He3_to_p_He4)*Y(He3)*state.rho - screened_rates(k_p_d_to_He3)*Y(H1)*state.rho; - jac.set(H1, H2, scratch); - - scratch = 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*state.rho + 2.0*screened_rates(k_He3_He3_to_p_p_He4)*Y(He3)*state.rho + screened_rates(k_d_He3_to_p_He4)*Y(H2)*state.rho - screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(H1)*state.rho; - jac.set(H1, He3, scratch); - - scratch = screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho + screened_rates(k_He4_O14_to_p_F17)*Y(O14)*state.rho; - jac.set(H1, He4, scratch); - - scratch = 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(He3)*state.rho + screened_rates(k_d_Be7_to_p_He4_He4)*Y(H2)*state.rho - screened_rates(k_p_Be7_to_B8)*Y(H1)*state.rho; - jac.set(H1, Be7, scratch); - - scratch = -screened_rates(k_p_C12_to_N13)*Y(H1)*state.rho; - jac.set(H1, C12, scratch); - - scratch = -screened_rates(k_p_C13_to_N14)*Y(H1)*state.rho; - jac.set(H1, C13, scratch); - - scratch = screened_rates(k_He4_N13_to_p_O16)*Y(He4)*state.rho - screened_rates(k_p_N13_to_O14)*Y(H1)*state.rho; - jac.set(H1, N13, scratch); - - scratch = -screened_rates(k_p_N14_to_O15)*Y(H1)*state.rho; - jac.set(H1, N14, scratch); - - scratch = -screened_rates(k_p_N15_to_He4_C12)*Y(H1)*state.rho - screened_rates(k_p_N15_to_O16)*Y(H1)*state.rho; - jac.set(H1, N15, scratch); - - scratch = screened_rates(k_He4_O14_to_p_F17)*Y(He4)*state.rho; - jac.set(H1, O14, scratch); - - scratch = -screened_rates(k_p_O16_to_F17)*Y(H1)*state.rho; - jac.set(H1, O16, scratch); - - scratch = -screened_rates(k_p_O17_to_F18)*Y(H1)*state.rho - screened_rates(k_p_O17_to_He4_N14)*Y(H1)*state.rho; - jac.set(H1, O17, scratch); - - scratch = -screened_rates(k_p_F18_to_He4_O15)*Y(H1)*state.rho; - jac.set(H1, F18, scratch); - - scratch = -screened_rates(k_p_d_to_He3)*Y(H2)*state.rho + 1.0*screened_rates(k_p_p_to_d_weak_bet_pos_)*Y(H1)*state.rho + 1.0*screened_rates(k_p_p_to_d_weak_electron_capture)*Y(H1)*amrex::Math::powi<2>(state.rho)*state.y_e; - jac.set(H2, H1, scratch); - - scratch = -screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*state.rho - screened_rates(k_d_He3_to_p_He4)*Y(He3)*state.rho - 2.0*screened_rates(k_d_d_to_He4)*Y(H2)*state.rho - screened_rates(k_p_d_to_He3)*Y(H1)*state.rho; - jac.set(H2, H2, scratch); - - scratch = -screened_rates(k_d_He3_to_p_He4)*Y(H2)*state.rho; - jac.set(H2, He3, scratch); - - scratch = -screened_rates(k_d_Be7_to_p_He4_He4)*Y(H2)*state.rho; - jac.set(H2, Be7, scratch); - - scratch = -screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*state.rho + screened_rates(k_p_d_to_He3)*Y(H2)*state.rho; - jac.set(He3, H1, scratch); - - scratch = -screened_rates(k_d_He3_to_p_He4)*Y(He3)*state.rho + screened_rates(k_p_d_to_He3)*Y(H1)*state.rho; - jac.set(He3, H2, scratch); - - scratch = -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*state.rho - 2.0*screened_rates(k_He3_He3_to_p_p_He4)*Y(He3)*state.rho - screened_rates(k_He4_He3_to_Be7)*Y(He4)*state.rho - screened_rates(k_d_He3_to_p_He4)*Y(H2)*state.rho - screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(H1)*state.rho; - jac.set(He3, He3, scratch); - - scratch = -screened_rates(k_He4_He3_to_Be7)*Y(He3)*state.rho; - jac.set(He3, He4, scratch); - - scratch = -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(He3)*state.rho; - jac.set(He3, Be7, scratch); - - scratch = screened_rates(k_p_F18_to_He4_O15)*Y(F18)*state.rho + screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(He3)*state.rho + screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho + screened_rates(k_p_O17_to_He4_N14)*Y(O17)*state.rho; - jac.set(He4, H1, scratch); - - scratch = 2.0*screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*state.rho + screened_rates(k_d_He3_to_p_He4)*Y(He3)*state.rho + 1.0*screened_rates(k_d_d_to_He4)*Y(H2)*state.rho; - jac.set(He4, H2, scratch); - - scratch = 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*state.rho + 1.0*screened_rates(k_He3_He3_to_p_p_He4)*Y(He3)*state.rho - screened_rates(k_He4_He3_to_Be7)*Y(He4)*state.rho + screened_rates(k_d_He3_to_p_He4)*Y(H2)*state.rho + screened_rates(k_p_He3_to_He4_weak_bet_pos_)*Y(H1)*state.rho; - jac.set(He4, He3, scratch); - - scratch = -screened_rates(k_He4_C12_to_O16)*Y(C12)*state.rho - screened_rates(k_He4_He3_to_Be7)*Y(He3)*state.rho - 1.5*screened_rates(k_He4_He4_He4_to_C12)*amrex::Math::powi<2>(Y(He4))*amrex::Math::powi<2>(state.rho) - screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho - screened_rates(k_He4_N14_to_F18)*Y(N14)*state.rho - screened_rates(k_He4_O14_to_p_F17)*Y(O14)*state.rho; - jac.set(He4, He4, scratch); - - scratch = 2.0*screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(He3)*state.rho + 2.0*screened_rates(k_d_Be7_to_p_He4_He4)*Y(H2)*state.rho; - jac.set(He4, Be7, scratch); - - scratch = 2.0*screened_rates(k_B8_to_He4_He4_weak_wc12); - jac.set(He4, B8, scratch); - - scratch = -screened_rates(k_He4_C12_to_O16)*Y(He4)*state.rho; - jac.set(He4, C12, scratch); - - scratch = -screened_rates(k_He4_N13_to_p_O16)*Y(He4)*state.rho; - jac.set(He4, N13, scratch); - - scratch = -screened_rates(k_He4_N14_to_F18)*Y(He4)*state.rho; - jac.set(He4, N14, scratch); - - scratch = screened_rates(k_p_N15_to_He4_C12)*Y(H1)*state.rho; - jac.set(He4, N15, scratch); - - scratch = -screened_rates(k_He4_O14_to_p_F17)*Y(He4)*state.rho; - jac.set(He4, O14, scratch); - - scratch = screened_rates(k_p_O17_to_He4_N14)*Y(H1)*state.rho; - jac.set(He4, O17, scratch); - - scratch = screened_rates(k_p_F18_to_He4_O15)*Y(H1)*state.rho; - jac.set(He4, F18, scratch); - - scratch = -screened_rates(k_p_Be7_to_B8)*Y(Be7)*state.rho; - jac.set(Be7, H1, scratch); - - scratch = -screened_rates(k_d_Be7_to_p_He4_He4)*Y(Be7)*state.rho; - jac.set(Be7, H2, scratch); - - scratch = -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(Be7)*state.rho + screened_rates(k_He4_He3_to_Be7)*Y(He4)*state.rho; - jac.set(Be7, He3, scratch); - - scratch = screened_rates(k_He4_He3_to_Be7)*Y(He3)*state.rho; - jac.set(Be7, He4, scratch); - - scratch = -screened_rates(k_He3_Be7_to_p_p_He4_He4)*Y(He3)*state.rho - screened_rates(k_d_Be7_to_p_He4_He4)*Y(H2)*state.rho - screened_rates(k_p_Be7_to_B8)*Y(H1)*state.rho; - jac.set(Be7, Be7, scratch); - - scratch = screened_rates(k_p_Be7_to_B8)*Y(Be7)*state.rho; - jac.set(B8, H1, scratch); - - scratch = screened_rates(k_p_Be7_to_B8)*Y(H1)*state.rho; - jac.set(B8, Be7, scratch); - - scratch = -screened_rates(k_B8_to_He4_He4_weak_wc12); - jac.set(B8, B8, scratch); - - scratch = -screened_rates(k_p_C12_to_N13)*Y(C12)*state.rho + screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho; - jac.set(C12, H1, scratch); - - scratch = -screened_rates(k_He4_C12_to_O16)*Y(C12)*state.rho + 0.5*screened_rates(k_He4_He4_He4_to_C12)*amrex::Math::powi<2>(Y(He4))*amrex::Math::powi<2>(state.rho); - jac.set(C12, He4, scratch); - - scratch = -screened_rates(k_He4_C12_to_O16)*Y(He4)*state.rho - screened_rates(k_p_C12_to_N13)*Y(H1)*state.rho; - jac.set(C12, C12, scratch); - - scratch = screened_rates(k_p_N15_to_He4_C12)*Y(H1)*state.rho; - jac.set(C12, N15, scratch); - - scratch = -screened_rates(k_p_C13_to_N14)*Y(C13)*state.rho; - jac.set(C13, H1, scratch); - - scratch = -screened_rates(k_p_C13_to_N14)*Y(H1)*state.rho; - jac.set(C13, C13, scratch); - - scratch = screened_rates(k_N13_to_C13_weak_wc12); - jac.set(C13, N13, scratch); - - scratch = screened_rates(k_p_C12_to_N13)*Y(C12)*state.rho - screened_rates(k_p_N13_to_O14)*Y(N13)*state.rho; - jac.set(N13, H1, scratch); - - scratch = -screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho; - jac.set(N13, He4, scratch); - - scratch = screened_rates(k_p_C12_to_N13)*Y(H1)*state.rho; - jac.set(N13, C12, scratch); - - scratch = -screened_rates(k_He4_N13_to_p_O16)*Y(He4)*state.rho - screened_rates(k_N13_to_C13_weak_wc12) - screened_rates(k_p_N13_to_O14)*Y(H1)*state.rho; - jac.set(N13, N13, scratch); - - scratch = screened_rates(k_p_C13_to_N14)*Y(C13)*state.rho - screened_rates(k_p_N14_to_O15)*Y(N14)*state.rho + screened_rates(k_p_O17_to_He4_N14)*Y(O17)*state.rho; - jac.set(N14, H1, scratch); - - scratch = -screened_rates(k_He4_N14_to_F18)*Y(N14)*state.rho; - jac.set(N14, He4, scratch); - - scratch = screened_rates(k_p_C13_to_N14)*Y(H1)*state.rho; - jac.set(N14, C13, scratch); - - scratch = -screened_rates(k_He4_N14_to_F18)*Y(He4)*state.rho - screened_rates(k_p_N14_to_O15)*Y(H1)*state.rho; - jac.set(N14, N14, scratch); - - scratch = screened_rates(k_O14_to_N14_weak_wc12); - jac.set(N14, O14, scratch); - - scratch = screened_rates(k_p_O17_to_He4_N14)*Y(H1)*state.rho; - jac.set(N14, O17, scratch); - - scratch = -screened_rates(k_p_N15_to_He4_C12)*Y(N15)*state.rho - screened_rates(k_p_N15_to_O16)*Y(N15)*state.rho; - jac.set(N15, H1, scratch); - - scratch = -screened_rates(k_p_N15_to_He4_C12)*Y(H1)*state.rho - screened_rates(k_p_N15_to_O16)*Y(H1)*state.rho; - jac.set(N15, N15, scratch); - - scratch = screened_rates(k_O15_to_N15_weak_wc12); - jac.set(N15, O15, scratch); - - scratch = screened_rates(k_p_N13_to_O14)*Y(N13)*state.rho; - jac.set(O14, H1, scratch); - - scratch = -screened_rates(k_He4_O14_to_p_F17)*Y(O14)*state.rho; - jac.set(O14, He4, scratch); - - scratch = screened_rates(k_p_N13_to_O14)*Y(H1)*state.rho; - jac.set(O14, N13, scratch); - - scratch = -screened_rates(k_He4_O14_to_p_F17)*Y(He4)*state.rho - screened_rates(k_O14_to_N14_weak_wc12); - jac.set(O14, O14, scratch); - - scratch = screened_rates(k_p_F18_to_He4_O15)*Y(F18)*state.rho + screened_rates(k_p_N14_to_O15)*Y(N14)*state.rho; - jac.set(O15, H1, scratch); - - scratch = screened_rates(k_p_N14_to_O15)*Y(H1)*state.rho; - jac.set(O15, N14, scratch); - - scratch = -screened_rates(k_O15_to_N15_weak_wc12); - jac.set(O15, O15, scratch); - - scratch = screened_rates(k_p_F18_to_He4_O15)*Y(H1)*state.rho; - jac.set(O15, F18, scratch); - - scratch = screened_rates(k_p_N15_to_O16)*Y(N15)*state.rho - screened_rates(k_p_O16_to_F17)*Y(O16)*state.rho; - jac.set(O16, H1, scratch); - - scratch = screened_rates(k_He4_C12_to_O16)*Y(C12)*state.rho + screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho; - jac.set(O16, He4, scratch); - - scratch = screened_rates(k_He4_C12_to_O16)*Y(He4)*state.rho; - jac.set(O16, C12, scratch); - - scratch = screened_rates(k_He4_N13_to_p_O16)*Y(He4)*state.rho; - jac.set(O16, N13, scratch); - - scratch = screened_rates(k_p_N15_to_O16)*Y(H1)*state.rho; - jac.set(O16, N15, scratch); - - scratch = -screened_rates(k_p_O16_to_F17)*Y(H1)*state.rho; - jac.set(O16, O16, scratch); - - scratch = -screened_rates(k_p_O17_to_F18)*Y(O17)*state.rho - screened_rates(k_p_O17_to_He4_N14)*Y(O17)*state.rho; - jac.set(O17, H1, scratch); - - scratch = -screened_rates(k_p_O17_to_F18)*Y(H1)*state.rho - screened_rates(k_p_O17_to_He4_N14)*Y(H1)*state.rho; - jac.set(O17, O17, scratch); - - scratch = screened_rates(k_F17_to_O17_weak_wc12); - jac.set(O17, F17, scratch); - - scratch = screened_rates(k_p_O16_to_F17)*Y(O16)*state.rho; - jac.set(F17, H1, scratch); - - scratch = screened_rates(k_He4_O14_to_p_F17)*Y(O14)*state.rho; - jac.set(F17, He4, scratch); - - scratch = screened_rates(k_He4_O14_to_p_F17)*Y(He4)*state.rho; - jac.set(F17, O14, scratch); - - scratch = screened_rates(k_p_O16_to_F17)*Y(H1)*state.rho; - jac.set(F17, O16, scratch); - - scratch = -screened_rates(k_F17_to_O17_weak_wc12); - jac.set(F17, F17, scratch); - - scratch = -screened_rates(k_p_F18_to_He4_O15)*Y(F18)*state.rho + screened_rates(k_p_O17_to_F18)*Y(O17)*state.rho; - jac.set(F18, H1, scratch); - - scratch = screened_rates(k_He4_N14_to_F18)*Y(N14)*state.rho; - jac.set(F18, He4, scratch); - - scratch = screened_rates(k_He4_N14_to_F18)*Y(He4)*state.rho; - jac.set(F18, N14, scratch); - - scratch = screened_rates(k_p_O17_to_F18)*Y(H1)*state.rho; - jac.set(F18, O17, scratch); - - scratch = -screened_rates(k_p_F18_to_He4_O15)*Y(H1)*state.rho; - jac.set(F18, F18, scratch); - - -} - - - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void actual_jac(const burn_t& state, MatrixType& jac) -{ - - // Set molar abundances - amrex::Array1D Y; - for (int i = 1; i <= NumSpec; ++i) { - Y(i) = state.xn[i-1] * aion_inv[i-1]; - } - - - jac.zero(); - - rate_derivs_t rate_eval; - - constexpr int do_T_derivatives = 1; - - evaluate_rates(state, rate_eval); - - // Species Jacobian elements with respect to other species - - jac_nuc(state, jac, Y, rate_eval.screened_rates); - - // Energy generation rate Jacobian elements with respect to species - - for (int j = 1; j <= NumSpec; ++j) { - auto jac_slice_2 = [&](int i) -> amrex::Real { return jac.get(i, j); }; - ener_gener_rate(jac_slice_2, jac(net_ienuc,j)); - } - - // Account for the thermal neutrino losses - - amrex::Real sneut, dsneutdt, dsneutdd, dsnuda, dsnudz; - constexpr int do_derivatives{1}; - sneut5(state.T, state.rho, state.abar, state.zbar, sneut, dsneutdt, dsneutdd, dsnuda, dsnudz); - - for (int j = 1; j <= NumSpec; ++j) { - amrex::Real b1 = (-state.abar * state.abar * dsnuda + (zion[j-1] - state.zbar) * state.abar * dsnudz); - jac.add(net_ienuc, j, -b1); - } - - - // Evaluate the Jacobian elements with respect to energy by - // calling the RHS using d(rate) / dT and then transform them - // to our energy integration variable. - - amrex::Array1D yderivs; - - rhs_nuc(state, yderivs, Y, rate_eval.dscreened_rates_dT); - - for (int k = 1; k <= NumSpec; k++) { - jac.set(k, net_ienuc, temperature_to_energy_jacobian(state, yderivs(k))); - } - - - // finally, d(de/dt)/de - - amrex::Real jac_e_T; - ener_gener_rate(yderivs, jac_e_T); - jac_e_T -= dsneutdt; - jac.set(net_ienuc, net_ienuc, temperature_to_energy_jacobian(state, jac_e_T)); - -} - - -AMREX_INLINE -void actual_rhs_init () { - - init_tabular(); - -} - - -#endif diff --git a/networks/nova2/inputs.burn_cell.VODE b/networks/nova2/inputs.burn_cell.VODE deleted file mode 100644 index 66434599a5..0000000000 --- a/networks/nova2/inputs.burn_cell.VODE +++ /dev/null @@ -1,43 +0,0 @@ -unit_test.run_prefix = "react_pynucastro_" - -unit_test.small_temp = 1e5 -unit_test.small_dens = 1e5 - -integrator.burner_verbose = 0 - -# Set which jacobian to use -# 1 = analytic jacobian -# 2 = numerical jacobian -integrator.jacobian = 1 - -integrator.renormalize_abundances = 0 - -integrator.rtol_spec = 1.0e-6 -integrator.rtol_enuc = 1.0e-6 -integrator.atol_spec = 1.0e-6 -integrator.atol_enuc = 1.0e-6 - - -unit_test.tmax = 1.0 -unit_test.nsteps = 1000 - -unit_test.density = 1.0e7 -unit_test.temperature = 1.0e8 - -unit_test.X1 = 1.0 -unit_test.X2 = 0.0 -unit_test.X3 = 0.0 -unit_test.X4 = 0.0 -unit_test.X5 = 0.0 -unit_test.X6 = 0.0 -unit_test.X7 = 0.0 -unit_test.X8 = 0.0 -unit_test.X9 = 0.0 -unit_test.X10 = 0.0 -unit_test.X11 = 0.0 -unit_test.X12 = 0.0 -unit_test.X13 = 0.0 -unit_test.X14 = 0.0 -unit_test.X15 = 0.0 -unit_test.X16 = 0.0 -unit_test.X17 = 0.0 diff --git a/networks/nova2/nova.png b/networks/nova2/nova.png deleted file mode 100644 index 8867d19795..0000000000 Binary files a/networks/nova2/nova.png and /dev/null differ diff --git a/networks/nova2/nova2.py b/networks/nova2/nova2.py deleted file mode 100644 index 2a7301f490..0000000000 --- a/networks/nova2/nova2.py +++ /dev/null @@ -1,25 +0,0 @@ -import pynucastro as pyna -from pynucastro.networks import AmrexAstroCxxNetwork - -mylibrary = pyna.rates.ReacLibLibrary() - -all_nuclei = ["p", "h2", "he3", "he4", "be7", "b8", - "c12", "c13", "n13", "n14", "n15", - "o14", "o15", "o16", "o17", "f17", "f18"] - -nova_library = mylibrary.linking_nuclei(all_nuclei, with_reverse=False) - -print(nova_library) - -net = AmrexAstroCxxNetwork(libraries=[nova_library]) -net.write_network() - -rc = pyna.RateCollection(libraries=[nova_library]) - -comp = pyna.Composition(rc.get_nuclei()) -comp.set_solar_like() - -rho = 1.e4 -T = 9.e7 - -rc.plot(rho, T, comp, outfile="nova.png") diff --git a/networks/nova2/partition_functions.H b/networks/nova2/partition_functions.H deleted file mode 100644 index 6fe1122bfb..0000000000 --- a/networks/nova2/partition_functions.H +++ /dev/null @@ -1,167 +0,0 @@ -#ifndef PARTITION_FUNCTIONS_H -#define PARTITION_FUNCTIONS_H - -#include -#include - -#include -#include -#include - -using namespace amrex; -using namespace Species; - -namespace part_fun { - - - - // interpolation routine - - template - AMREX_GPU_HOST_DEVICE AMREX_INLINE - void interpolate_pf(const amrex::Real t9, const amrex::Real (&temp_array)[npts], const amrex::Real (&pf_array)[npts], - amrex::Real& pf, amrex::Real& dpf_dT) { - - if (t9 >= temp_array[0] && t9 < temp_array[npts-1]) { - - // find the largest temperature element <= t9 using a binary search - - int left = 0; - int right = npts; - - while (left < right) { - int mid = (left + right) / 2; - if (temp_array[mid] > t9) { - right = mid; - } else { - left = mid + 1; - } - } - - const int idx = right - 1; - - // now we have temp_array[idx] <= t9 < temp_array[idx+1] - - // construct the slope -- this is (log10(pf_{i+1}) - log10(pf_i)) / (T_{i+1} - T_i) - - amrex::Real slope = (pf_array[idx+1] - pf_array[idx]) / (temp_array[idx+1] - temp_array[idx]); - - // find the PF - - amrex::Real log10_pf = pf_array[idx] + slope * (t9 - temp_array[idx]); - pf = std::pow(10.0_rt, log10_pf); - - // find the derivative (with respect to T, not T9) - - amrex::Real dpf_dT9 = pf * M_LN10 * slope; - dpf_dT = dpf_dT9 / 1.e9_rt; - - } else { - - // T < the smallest T or >= the largest T in the partition function table - pf = 1.0; - dpf_dT = 0.0; - - } - - } - - struct pf_cache_t { - // Store the coefficient and derivative adjacent in memory, as they're - // always accessed at the same time. - // The entries will be default-initialized to zero, which is fine since - // log10(x) is never zero. - amrex::Array2D data{}; - }; - -} - -// main interface - -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void get_partition_function(const int inuc, [[maybe_unused]] const tf_t& tfactors, - amrex::Real& pf, amrex::Real& dpf_dT) { - - // inuc is the 1-based index for the species - - switch (inuc) { - - - default: - - pf = 1.0_rt; - dpf_dT = 0.0_rt; - - } - -} - -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void get_partition_function_cached(const int inuc, const tf_t& tfactors, - part_fun::pf_cache_t& pf_cache, - amrex::Real& pf, amrex::Real& dpf_dT) { - if (pf_cache.data(inuc, 1) != 0.0_rt) { - // present in cache - amrex::ignore_unused(tfactors); - pf = pf_cache.data(inuc, 1); - dpf_dT = pf_cache.data(inuc, 2); - } else { - get_partition_function(inuc, tfactors, pf, dpf_dT); - pf_cache.data(inuc, 1) = pf; - pf_cache.data(inuc, 2) = dpf_dT; - } -} - -// spins - -AMREX_GPU_HOST_DEVICE AMREX_INLINE -constexpr amrex::Real get_spin_state(const int inuc) { - - amrex::Real spin = -1.0; - - switch (inuc) { // NOLINT(bugprone-switch-missing-default-case) - - case He4: - case C12: - case O14: - case O16: - spin = 1; - break; - - case H1: - case He3: - case C13: - case N13: - case N15: - case O15: - spin = 2; - break; - - case H2: - case N14: - case F18: - spin = 3; - break; - - case Be7: - spin = 4; - break; - - case B8: - spin = 5; - break; - - case O17: - case F17: - spin = 6; - break; - - - } - - return spin; - -} - - -#endif diff --git a/networks/nova2/reaclib_rates.H b/networks/nova2/reaclib_rates.H deleted file mode 100644 index 56c0bc24d0..0000000000 --- a/networks/nova2/reaclib_rates.H +++ /dev/null @@ -1,1786 +0,0 @@ -#ifndef REACLIB_RATES_H -#define REACLIB_RATES_H - -#include -#include - -#include -#include -#include - -using namespace Rates; -using namespace Species; - -struct rate_t { - amrex::Array1D screened_rates; - amrex::Real enuc_weak; -}; - -struct rate_derivs_t { - amrex::Array1D screened_rates; - amrex::Array1D dscreened_rates_dT; - amrex::Real enuc_weak; -}; - - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_N13_to_C13_weak_wc12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // N13 --> C13 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // wc12w - ln_set_rate = -6.7601; - amrex::ignore_unused(tfactors); - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.0; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_O14_to_N14_weak_wc12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // O14 --> N14 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // wc12w - ln_set_rate = -4.62354; - amrex::ignore_unused(tfactors); - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.0; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_O15_to_N15_weak_wc12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // O15 --> N15 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // wc12w - ln_set_rate = -5.17053; - amrex::ignore_unused(tfactors); - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.0; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_F17_to_O17_weak_wc12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // F17 --> O17 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // wc12w - ln_set_rate = -4.53318; - amrex::ignore_unused(tfactors); - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.0; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_B8_to_He4_He4_weak_wc12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // B8 --> He4 + He4 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // wc12w - ln_set_rate = -0.105148; - amrex::ignore_unused(tfactors); - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.0; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_p_to_d_weak_bet_pos_(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // p + p --> d - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // bet+w - ln_set_rate = -34.7863 + -3.51193 * tfactors.T913i + 3.10086 * tfactors.T913 - + -0.198314 * tfactors.T9 + 0.0126251 * tfactors.T953 + -1.02517 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -3.51193 * tfactors.T943i + (1.0/3.0) * 3.10086 * tfactors.T923i - + -0.198314 + (5.0/3.0) * 0.0126251 * tfactors.T923 + -1.02517 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_p_to_d_weak_electron_capture(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // p + p --> d - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // ecw - ln_set_rate = -43.6499 + -0.00246064 * tfactors.T9i + -2.7507 * tfactors.T913i + -0.424877 * tfactors.T913 - + 0.015987 * tfactors.T9 + -0.000690875 * tfactors.T953 + -0.207625 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.00246064 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -2.7507 * tfactors.T943i + (1.0/3.0) * -0.424877 * tfactors.T923i - + 0.015987 + (5.0/3.0) * -0.000690875 * tfactors.T923 + -0.207625 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_d_to_He3(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // d + p --> He3 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // de04 - ln_set_rate = 8.93525 + -3.7208 * tfactors.T913i + 0.198654 * tfactors.T913 - + 0.333333 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -3.7208 * tfactors.T943i + (1.0/3.0) * 0.198654 * tfactors.T923i - + 0.333333 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // de04n - ln_set_rate = 7.52898 + -3.7208 * tfactors.T913i + 0.871782 * tfactors.T913 - + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -3.7208 * tfactors.T943i + (1.0/3.0) * 0.871782 * tfactors.T923i - + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_d_d_to_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // d + d --> He4 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // nacrn - ln_set_rate = 3.78177 + -4.26166 * tfactors.T913i + -0.119233 * tfactors.T913 - + 0.778829 * tfactors.T9 + -0.0925203 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -4.26166 * tfactors.T943i + (1.0/3.0) * -0.119233 * tfactors.T923i - + 0.778829 + (5.0/3.0) * -0.0925203 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_He3_to_He4_weak_bet_pos_(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // He3 + p --> He4 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // bet+w - ln_set_rate = -27.7611 + -4.30107e-12 * tfactors.T9i + -6.141 * tfactors.T913i + -1.93473e-09 * tfactors.T913 - + 2.04145e-10 * tfactors.T9 + -1.80372e-11 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 4.30107e-12 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -6.141 * tfactors.T943i + (1.0/3.0) * -1.93473e-09 * tfactors.T923i - + 2.04145e-10 + (5.0/3.0) * -1.80372e-11 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_He4_He3_to_Be7(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // He3 + He4 --> Be7 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // cd08n - ln_set_rate = 17.7075 + -12.8271 * tfactors.T913i + -3.8126 * tfactors.T913 - + 0.0942285 * tfactors.T9 + -0.00301018 * tfactors.T953 + 1.33333 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -12.8271 * tfactors.T943i + (1.0/3.0) * -3.8126 * tfactors.T923i - + 0.0942285 + (5.0/3.0) * -0.00301018 * tfactors.T923 + 1.33333 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // cd08n - ln_set_rate = 15.6099 + -12.8271 * tfactors.T913i + -0.0308225 * tfactors.T913 - + -0.654685 * tfactors.T9 + 0.0896331 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -12.8271 * tfactors.T943i + (1.0/3.0) * -0.0308225 * tfactors.T923i - + -0.654685 + (5.0/3.0) * 0.0896331 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_Be7_to_B8(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // Be7 + p --> B8 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // nacrn - ln_set_rate = 12.5315 + -10.264 * tfactors.T913i + -0.203472 * tfactors.T913 - + 0.121083 * tfactors.T9 + -0.00700063 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -10.264 * tfactors.T943i + (1.0/3.0) * -0.203472 * tfactors.T923i - + 0.121083 + (5.0/3.0) * -0.00700063 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // nacrr - ln_set_rate = 7.73399 + -7.345 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 7.345 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_C12_to_N13(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // C12 + p --> N13 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // ls09n - ln_set_rate = 17.1482 + -13.692 * tfactors.T913i + -0.230881 * tfactors.T913 - + 4.44362 * tfactors.T9 + -3.15898 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -13.692 * tfactors.T943i + (1.0/3.0) * -0.230881 * tfactors.T923i - + 4.44362 + (5.0/3.0) * -3.15898 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // ls09r - ln_set_rate = 17.5428 + -3.77849 * tfactors.T9i + -5.10735 * tfactors.T913i + -2.24111 * tfactors.T913 - + 0.148883 * tfactors.T9 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 3.77849 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -5.10735 * tfactors.T943i + (1.0/3.0) * -2.24111 * tfactors.T923i - + 0.148883 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_He4_C12_to_O16(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // C12 + He4 --> O16 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // nac2 - ln_set_rate = 254.634 + -1.84097 * tfactors.T9i + 103.411 * tfactors.T913i + -420.567 * tfactors.T913 - + 64.0874 * tfactors.T9 + -12.4624 * tfactors.T953 + 137.303 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 1.84097 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 103.411 * tfactors.T943i + (1.0/3.0) * -420.567 * tfactors.T923i - + 64.0874 + (5.0/3.0) * -12.4624 * tfactors.T923 + 137.303 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // nac2 - ln_set_rate = 69.6526 + -1.39254 * tfactors.T9i + 58.9128 * tfactors.T913i + -148.273 * tfactors.T913 - + 9.08324 * tfactors.T9 + -0.541041 * tfactors.T953 + 70.3554 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 1.39254 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 58.9128 * tfactors.T943i + (1.0/3.0) * -148.273 * tfactors.T923i - + 9.08324 + (5.0/3.0) * -0.541041 * tfactors.T923 + 70.3554 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_C13_to_N14(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // C13 + p --> N14 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // nacrr - ln_set_rate = 15.1825 + -13.5543 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 13.5543 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // nacrn - ln_set_rate = 18.5155 + -13.72 * tfactors.T913i + -0.450018 * tfactors.T913 - + 3.70823 * tfactors.T9 + -1.70545 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -13.72 * tfactors.T943i + (1.0/3.0) * -0.450018 * tfactors.T923i - + 3.70823 + (5.0/3.0) * -1.70545 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // nacrr - ln_set_rate = 13.9637 + -5.78147 * tfactors.T9i + -0.196703 * tfactors.T913 - + 0.142126 * tfactors.T9 + -0.0238912 * tfactors.T953 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 5.78147 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * -0.196703 * tfactors.T923i - + 0.142126 + (5.0/3.0) * -0.0238912 * tfactors.T923 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_N13_to_O14(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // N13 + p --> O14 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // lg06r - ln_set_rate = 10.9971 + -6.12602 * tfactors.T9i + 1.57122 * tfactors.T913i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 6.12602 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 1.57122 * tfactors.T943i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // lg06n - ln_set_rate = 18.1356 + -15.1676 * tfactors.T913i + 0.0955166 * tfactors.T913 - + 3.0659 * tfactors.T9 + -0.507339 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -15.1676 * tfactors.T943i + (1.0/3.0) * 0.0955166 * tfactors.T923i - + 3.0659 + (5.0/3.0) * -0.507339 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_N14_to_O15(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // N14 + p --> O15 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // im05n - ln_set_rate = 17.01 + -15.193 * tfactors.T913i + -0.161954 * tfactors.T913 - + -7.52123 * tfactors.T9 + -0.987565 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -15.193 * tfactors.T943i + (1.0/3.0) * -0.161954 * tfactors.T923i - + -7.52123 + (5.0/3.0) * -0.987565 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // im05r - ln_set_rate = 6.73578 + -4.891 * tfactors.T9i - + 0.0682 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 4.891 * tfactors.T9i * tfactors.T9i - + 0.0682 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // im05r - ln_set_rate = 7.65444 + -2.998 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 2.998 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // im05n - ln_set_rate = 20.1169 + -15.193 * tfactors.T913i + -4.63975 * tfactors.T913 - + 9.73458 * tfactors.T9 + -9.55051 * tfactors.T953 + 0.333333 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -15.193 * tfactors.T943i + (1.0/3.0) * -4.63975 * tfactors.T923i - + 9.73458 + (5.0/3.0) * -9.55051 * tfactors.T923 + 0.333333 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_He4_N14_to_F18(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // N14 + He4 --> F18 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // il10n - ln_set_rate = 21.5339 + -36.2504 * tfactors.T913i - + -5.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -36.2504 * tfactors.T943i - + (5.0/3.0) * -5.0 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10r - ln_set_rate = 13.8995 + -10.9656 * tfactors.T9i + -5.6227 * tfactors.T913i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 10.9656 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -5.6227 * tfactors.T943i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10r - ln_set_rate = 0.196838 + -5.16034 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 5.16034 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_N15_to_O16(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // N15 + p --> O16 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // li10n - ln_set_rate = 20.0176 + -15.24 * tfactors.T913i + 0.334926 * tfactors.T913 - + 4.59088 * tfactors.T9 + -4.78468 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -15.24 * tfactors.T943i + (1.0/3.0) * 0.334926 * tfactors.T923i - + 4.59088 + (5.0/3.0) * -4.78468 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // li10r - ln_set_rate = 14.5444 + -10.2295 * tfactors.T9i - + 0.0459037 * tfactors.T9 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 10.2295 * tfactors.T9i * tfactors.T9i - + 0.0459037 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // li10r - ln_set_rate = 6.59056 + -2.92315 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 2.92315 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_O16_to_F17(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // O16 + p --> F17 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // ia08n - ln_set_rate = 19.0904 + -16.696 * tfactors.T913i + -1.16252 * tfactors.T913 - + 0.267703 * tfactors.T9 + -0.0338411 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -16.696 * tfactors.T943i + (1.0/3.0) * -1.16252 * tfactors.T923i - + 0.267703 + (5.0/3.0) * -0.0338411 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_O17_to_F18(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // O17 + p --> F18 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // il10n - ln_set_rate = 15.8929 + -16.4035 * tfactors.T913i + 4.31885 * tfactors.T913 - + -0.709921 * tfactors.T9 + -2.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -16.4035 * tfactors.T943i + (1.0/3.0) * 4.31885 * tfactors.T923i - + -0.709921 + (5.0/3.0) * -2.0 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10r - ln_set_rate = 9.39048 + -6.22828 * tfactors.T9i + 2.31435 * tfactors.T913 - + -0.302835 * tfactors.T9 + 0.020133 * tfactors.T953 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 6.22828 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 2.31435 * tfactors.T923i - + -0.302835 + (5.0/3.0) * 0.020133 * tfactors.T923 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10r - ln_set_rate = -13.077 + -0.746296 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.746296 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_d_He3_to_p_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // He3 + d --> p + He4 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // de04 - ln_set_rate = 24.6839 + -7.182 * tfactors.T913i + 0.473288 * tfactors.T913 - + 1.46847 * tfactors.T9 + -27.9603 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -7.182 * tfactors.T943i + (1.0/3.0) * 0.473288 * tfactors.T923i - + 1.46847 + (5.0/3.0) * -27.9603 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // de04 - ln_set_rate = 41.2969 + -7.182 * tfactors.T913i + -17.1349 * tfactors.T913 - + 1.36908 * tfactors.T9 + -0.0814423 * tfactors.T953 + 3.35395 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -7.182 * tfactors.T943i + (1.0/3.0) * -17.1349 * tfactors.T923i - + 1.36908 + (5.0/3.0) * -0.0814423 * tfactors.T923 + 3.35395 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_He4_N13_to_p_O16(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // N13 + He4 --> p + O16 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // cf88n - ln_set_rate = 40.4644 + -35.829 * tfactors.T913i + -0.530275 * tfactors.T913 - + -0.982462 * tfactors.T9 + 0.0808059 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -35.829 * tfactors.T943i + (1.0/3.0) * -0.530275 * tfactors.T923i - + -0.982462 + (5.0/3.0) * 0.0808059 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_N15_to_He4_C12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // N15 + p --> He4 + C12 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // nacrn - ln_set_rate = 27.4764 + -15.253 * tfactors.T913i + 1.59318 * tfactors.T913 - + 2.4479 * tfactors.T9 + -2.19708 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -15.253 * tfactors.T943i + (1.0/3.0) * 1.59318 * tfactors.T923i - + 2.4479 + (5.0/3.0) * -2.19708 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // nacrr - ln_set_rate = -6.57522 + -1.1638 * tfactors.T9i + 22.7105 * tfactors.T913 - + -2.90707 * tfactors.T9 + 0.205754 * tfactors.T953 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 1.1638 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 22.7105 * tfactors.T923i - + -2.90707 + (5.0/3.0) * 0.205754 * tfactors.T923 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // nacrr - ln_set_rate = 20.8972 + -7.406 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 7.406 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // nacrr - ln_set_rate = -4.87347 + -2.02117 * tfactors.T9i + 30.8497 * tfactors.T913 - + -8.50433 * tfactors.T9 + -1.54426 * tfactors.T953 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 2.02117 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 30.8497 * tfactors.T923i - + -8.50433 + (5.0/3.0) * -1.54426 * tfactors.T923 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_He4_O14_to_p_F17(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // O14 + He4 --> p + F17 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // Ha96n - ln_set_rate = 40.8358 + -39.388 * tfactors.T913i + -17.4673 * tfactors.T913 - + 35.3029 * tfactors.T9 + -24.8162 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -39.388 * tfactors.T943i + (1.0/3.0) * -17.4673 * tfactors.T923i - + 35.3029 + (5.0/3.0) * -24.8162 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // Ha96r - ln_set_rate = 16.3087 + -22.51 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 22.51 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // Ha96r - ln_set_rate = 11.1184 + -13.6 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 13.6 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // Ha96r - ln_set_rate = -106.091 + -0.453036 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.453036 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // Ha96r - ln_set_rate = 12.1289 + -12.0223 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 12.0223 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // Ha96r - ln_set_rate = 18.6518 + -26.0 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 26.0 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_O17_to_He4_N14(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // O17 + p --> He4 + N14 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // il10r - ln_set_rate = 5.5336 + -2.11477 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 2.11477 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10r - ln_set_rate = -7.20763 + -0.753395 * tfactors.T9i - + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.753395 * tfactors.T9i * tfactors.T9i - + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10n - ln_set_rate = 19.579 + -16.9078 * tfactors.T913i - + -2.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -16.9078 * tfactors.T943i - + (5.0/3.0) * -2.0 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10r - ln_set_rate = 10.174 + -4.95865 * tfactors.T9i + 5.10182 * tfactors.T913 - + 0.379373 * tfactors.T9 + -0.0672515 * tfactors.T953 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 4.95865 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 5.10182 * tfactors.T923i - + 0.379373 + (5.0/3.0) * -0.0672515 * tfactors.T923 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_p_F18_to_He4_O15(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // F18 + p --> He4 + O15 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // il10n - ln_set_rate = 62.0058 + -21.4023 * tfactors.T913i + -80.8891 * tfactors.T913 - + 134.6 * tfactors.T9 + -126.504 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -21.4023 * tfactors.T943i + (1.0/3.0) * -80.8891 * tfactors.T923i - + 134.6 + (5.0/3.0) * -126.504 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10r - ln_set_rate = 1.75704 + -3.01675 * tfactors.T9i + 13.3223 * tfactors.T913 - + -1.36696 * tfactors.T9 + 0.0757363 * tfactors.T953 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 3.01675 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 13.3223 * tfactors.T923i - + -1.36696 + (5.0/3.0) * 0.0757363 * tfactors.T923 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // il10r - ln_set_rate = -31.7388 + -0.376432 * tfactors.T9i + 61.738 * tfactors.T913 - + -108.29 * tfactors.T9 + -34.2365 * tfactors.T953 + -1.5 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 0.376432 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 61.738 * tfactors.T923i - + -108.29 + (5.0/3.0) * -34.2365 * tfactors.T923 + -1.5 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_He3_He3_to_p_p_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // He3 + He3 --> p + p + He4 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // nacrn - ln_set_rate = 24.7788 + -12.277 * tfactors.T913i + -0.103699 * tfactors.T913 - + -0.0649967 * tfactors.T9 + 0.0168191 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -12.277 * tfactors.T943i + (1.0/3.0) * -0.103699 * tfactors.T923i - + -0.0649967 + (5.0/3.0) * 0.0168191 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_d_Be7_to_p_He4_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // Be7 + d --> p + He4 + He4 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // cf88n - ln_set_rate = 27.6987 + -12.428 * tfactors.T913i - + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -12.428 * tfactors.T943i - + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_He3_Be7_to_p_p_He4_He4(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // Be7 + He3 --> p + p + He4 + He4 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // mafon - ln_set_rate = 31.7435 + -5.45213e-12 * tfactors.T9i + -21.793 * tfactors.T913i + -1.98126e-09 * tfactors.T913 - + 1.84204e-10 * tfactors.T9 + -1.46403e-11 * tfactors.T953 + -0.666667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 5.45213e-12 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -21.793 * tfactors.T943i + (1.0/3.0) * -1.98126e-09 * tfactors.T923i - + 1.84204e-10 + (5.0/3.0) * -1.46403e-11 * tfactors.T923 + -0.666667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void rate_He4_He4_He4_to_C12(const tf_t& tfactors, amrex::Real& rate, amrex::Real& drate_dT) { - - // He4 + He4 + He4 --> C12 - - rate = 0.0; - drate_dT = 0.0; - - amrex::Real ln_set_rate{0.0}; - amrex::Real dln_set_rate_dT9{0.0}; - amrex::Real set_rate{0.0}; - - // fy05r - ln_set_rate = -24.3505 + -4.12656 * tfactors.T9i + -13.49 * tfactors.T913i + 21.4259 * tfactors.T913 - + -1.34769 * tfactors.T9 + 0.0879816 * tfactors.T953 + -13.1653 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 4.12656 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -13.49 * tfactors.T943i + (1.0/3.0) * 21.4259 * tfactors.T923i - + -1.34769 + (5.0/3.0) * 0.0879816 * tfactors.T923 + -13.1653 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // fy05r - ln_set_rate = -11.7884 + -1.02446 * tfactors.T9i + -23.57 * tfactors.T913i + 20.4886 * tfactors.T913 - + -12.9882 * tfactors.T9 + -20.0 * tfactors.T953 + -2.16667 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = 1.02446 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -23.57 * tfactors.T943i + (1.0/3.0) * 20.4886 * tfactors.T923i - + -12.9882 + (5.0/3.0) * -20.0 * tfactors.T923 + -2.16667 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - - // fy05n - ln_set_rate = -0.971052 + -37.06 * tfactors.T913i + 29.3493 * tfactors.T913 - + -115.507 * tfactors.T9 + -10.0 * tfactors.T953 + -1.33333 * tfactors.lnT9; - - if constexpr (do_T_derivatives) { - dln_set_rate_dT9 = + -(1.0/3.0) * -37.06 * tfactors.T943i + (1.0/3.0) * 29.3493 * tfactors.T923i - + -115.507 + (5.0/3.0) * -10.0 * tfactors.T923 + -1.33333 * tfactors.T9i; - } - - // avoid underflows by zeroing rates in [0.0, 1.e-100] - ln_set_rate = std::max(ln_set_rate, -230.0); - set_rate = std::exp(ln_set_rate); - rate += set_rate; - if constexpr (do_T_derivatives) { - drate_dT += set_rate * dln_set_rate_dT9 / 1.0e9; - } - -} - - - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void -fill_reaclib_rates(const tf_t& tfactors, T& rate_eval) -{ - - amrex::Real rate; - amrex::Real drate_dT; - - rate_N13_to_C13_weak_wc12(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_N13_to_C13_weak_wc12) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_N13_to_C13_weak_wc12) = drate_dT; - - } - rate_O14_to_N14_weak_wc12(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_O14_to_N14_weak_wc12) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_O14_to_N14_weak_wc12) = drate_dT; - - } - rate_O15_to_N15_weak_wc12(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_O15_to_N15_weak_wc12) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_O15_to_N15_weak_wc12) = drate_dT; - - } - rate_F17_to_O17_weak_wc12(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_F17_to_O17_weak_wc12) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_F17_to_O17_weak_wc12) = drate_dT; - - } - rate_B8_to_He4_He4_weak_wc12(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_B8_to_He4_He4_weak_wc12) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_B8_to_He4_He4_weak_wc12) = drate_dT; - - } - rate_p_p_to_d_weak_bet_pos_(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_p_to_d_weak_bet_pos_) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_bet_pos_) = drate_dT; - - } - rate_p_p_to_d_weak_electron_capture(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_p_to_d_weak_electron_capture) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_p_to_d_weak_electron_capture) = drate_dT; - - } - rate_p_d_to_He3(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_d_to_He3) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_d_to_He3) = drate_dT; - - } - rate_d_d_to_He4(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_d_d_to_He4) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_d_d_to_He4) = drate_dT; - - } - rate_p_He3_to_He4_weak_bet_pos_(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_He3_to_He4_weak_bet_pos_) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_He3_to_He4_weak_bet_pos_) = drate_dT; - - } - rate_He4_He3_to_Be7(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_He4_He3_to_Be7) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_He4_He3_to_Be7) = drate_dT; - - } - rate_p_Be7_to_B8(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_Be7_to_B8) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_Be7_to_B8) = drate_dT; - - } - rate_p_C12_to_N13(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_C12_to_N13) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_C12_to_N13) = drate_dT; - - } - rate_He4_C12_to_O16(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_He4_C12_to_O16) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_He4_C12_to_O16) = drate_dT; - - } - rate_p_C13_to_N14(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_C13_to_N14) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_C13_to_N14) = drate_dT; - - } - rate_p_N13_to_O14(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_N13_to_O14) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_N13_to_O14) = drate_dT; - - } - rate_p_N14_to_O15(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_N14_to_O15) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_N14_to_O15) = drate_dT; - - } - rate_He4_N14_to_F18(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_He4_N14_to_F18) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_He4_N14_to_F18) = drate_dT; - - } - rate_p_N15_to_O16(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_N15_to_O16) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_N15_to_O16) = drate_dT; - - } - rate_p_O16_to_F17(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_O16_to_F17) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_O16_to_F17) = drate_dT; - - } - rate_p_O17_to_F18(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_O17_to_F18) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_O17_to_F18) = drate_dT; - - } - rate_d_He3_to_p_He4(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_d_He3_to_p_He4) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_d_He3_to_p_He4) = drate_dT; - - } - rate_He4_N13_to_p_O16(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_He4_N13_to_p_O16) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_He4_N13_to_p_O16) = drate_dT; - - } - rate_p_N15_to_He4_C12(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_N15_to_He4_C12) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_N15_to_He4_C12) = drate_dT; - - } - rate_He4_O14_to_p_F17(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_He4_O14_to_p_F17) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_He4_O14_to_p_F17) = drate_dT; - - } - rate_p_O17_to_He4_N14(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_O17_to_He4_N14) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_O17_to_He4_N14) = drate_dT; - - } - rate_p_F18_to_He4_O15(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_p_F18_to_He4_O15) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_p_F18_to_He4_O15) = drate_dT; - - } - rate_He3_He3_to_p_p_He4(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_He3_He3_to_p_p_He4) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_He3_He3_to_p_p_He4) = drate_dT; - - } - rate_d_Be7_to_p_He4_He4(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_d_Be7_to_p_He4_He4) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_d_Be7_to_p_He4_He4) = drate_dT; - - } - rate_He3_Be7_to_p_p_He4_He4(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_He3_Be7_to_p_p_He4_He4) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_He3_Be7_to_p_p_He4_He4) = drate_dT; - - } - rate_He4_He4_He4_to_C12(tfactors, rate, drate_dT); - rate_eval.screened_rates(k_He4_He4_He4_to_C12) = rate; - if constexpr (std::is_same_v) { - rate_eval.dscreened_rates_dT(k_He4_He4_He4_to_C12) = drate_dT; - - } - -} - -template -AMREX_GPU_HOST_DEVICE AMREX_INLINE -void -fill_approx_rates([[maybe_unused]] const tf_t& tfactors, [[maybe_unused]] T& rate_eval) -{ - - [[maybe_unused]] amrex::Real rate{}; - [[maybe_unused]] amrex::Real drate_dT{}; - - -} - -#endif diff --git a/networks/nova2/table_rates.H b/networks/nova2/table_rates.H deleted file mode 100644 index a2c5b79b54..0000000000 --- a/networks/nova2/table_rates.H +++ /dev/null @@ -1,399 +0,0 @@ -#ifndef TABLE_RATES_H -#define TABLE_RATES_H - -#include -#include -#include -#include - -#include - -using namespace amrex; - -void init_tabular(); - -// Table is expected to be in terms of dens*ye and temp (logarithmic, cgs units) -// Table energy units are expected in terms of ergs - -// all tables are expected to have columns: -// Log(rhoY) Log(T) mu dQ Vs Log(e-cap-rate) Log(nu-energy-loss) Log(gamma-energy) -// Log(g/cm^3) Log(K) erg erg erg Log(1/s) Log(erg/s) Log(erg/s) -// - -const int num_tables = 0; - -enum TableVars -{ - jtab_mu = 1, - jtab_dq = 2, - jtab_vs = 3, - jtab_rate = 4, - jtab_nuloss = 5, - jtab_gamma = 6, - num_vars = jtab_gamma -}; - - -struct table_t -{ - int ntemp; - int nrhoy; - int nvars; - int nheader; -}; - -// we add a 7th index, k_index_dlogr_dlogt used for computing the derivative -// of Log(rate) with respect of Log(temperature) by using the table -// values. It isn't an index into the table but into the 'entries' -// array. Is important to mention that although we compute dlogr/dlogT is -// the computed quantity in 'entries', we pursue ultimately -// dr/dt as the final desired quantity to be computed for this index. - -const int k_index_dlogr_dlogt = 7; -const int add_vars = 1; // 1 Additional Var in entries - - -namespace rate_tables -{ -} - -template -void init_tab_info(const table_t& tf, const std::string& file, R& log_rhoy_table, T& log_temp_table, D& data) -{ - // This function initializes the selected tabular-rate tables. From the tables we are interested - // on the rate, neutrino-energy-loss and the gamma-energy entries. - - std::ifstream table; - table.open(file); - - if (!table.is_open()) { - // the table was not present or we could not open it; abort - amrex::Error("table could not be opened"); - } - - std::string line; - - // read and skip over the header - - for (int i = 0; i < tf.nheader; ++i) { - std::getline(table, line); - } - - // now the data -- there are 2 extra columns, for log_temp and log_rhoy - - for (int j = 1; j <= tf.nrhoy; ++j) { - for (int i = 1; i <= tf.ntemp; ++i) { - std::getline(table, line); - if (line.empty()) { - amrex::Error("Error reading table data"); - } - - std::istringstream sdata(line); - - sdata >> log_rhoy_table(j) >> log_temp_table(i); - - for (int n = 1; n <= tf.nvars; ++n) { - sdata >> data(i, j, n); - } - } - } - table.close(); -} - - -template -AMREX_INLINE AMREX_GPU_HOST_DEVICE -int vector_index_lu(const int vlen, const V& vector, const amrex::Real fvar) -{ - - // Returns the greatest index of vector for which vector(index) < fvar. - // Return 1 if fvar < vector(1) - // Return size(vector)-1 if fvar > vector(size(vector)) - // The interval [index, index+1] brackets fvar for fvar within the range of vector. - - int index; - - if (fvar < vector(1)) { - index = 1; - } else if (fvar > vector(vlen)) { - index = vlen - 1; - } else { - int nup = vlen; - int ndn = 1; - for (int i = 1; i <= vlen; ++i) { - int j = ndn + (nup - ndn)/2; - if (fvar < vector(j)) { - nup = j; - } else { - ndn = j; - } - if ((nup - ndn) == 1) { - break; - } - } - index = ndn; - } - return index; -} - - -AMREX_INLINE AMREX_GPU_HOST_DEVICE -amrex::Real -evaluate_linear_1d(const amrex::Real fhi, const amrex::Real flo, const amrex::Real xhi, const amrex::Real xlo, const amrex::Real x) -{ - // This function is a 1-D linear interpolator, that keeps x constant to xlo or xhi, based - // on the side, if x is outside [xlo, xhi] respectively. - - amrex::Real xx = Clamp(x, xlo, xhi); - amrex::Real f = flo + (fhi - flo) * (xx - xlo) / (xhi - xlo); - - return f; -} - -AMREX_INLINE AMREX_GPU_HOST_DEVICE -amrex::Real -evaluate_linear_2d(const amrex::Real fip1jp1, const amrex::Real fip1j, const amrex::Real fijp1, const amrex::Real fij, - const amrex::Real xhi, const amrex::Real xlo, const amrex::Real yhi, const amrex::Real ylo, - const amrex::Real x, const amrex::Real y) -{ - // This is the 2-D linear interpolator, as an extension of evaluate_linear_1d. - - amrex::Real f; - amrex::Real dx = xhi - xlo; - amrex::Real dy = yhi - ylo; - - amrex::Real E = fij; - amrex::Real C = (fijp1 - fij) / dy; - amrex::Real B = (fip1j - fij) / dx; - amrex::Real A = (fip1jp1 - B * dx - C * dy - E) / (dx * dy); - - amrex::Real xx = Clamp(x, xlo, xhi); - amrex::Real yy = Clamp(y, ylo, yhi); - - f = A * (xx - xlo) * (yy - ylo) + - B * (xx - xlo) + - C * (yy - ylo) + - E; - - return f; -} - - -template -AMREX_INLINE AMREX_GPU_HOST_DEVICE -amrex::Real -evaluate_vars(const table_t& table_meta, const R& log_rhoy_table, const T& log_temp_table, const D& data, - const amrex::Real log_rhoy, const amrex::Real log_temp, const int component) -{ - // This function evaluates the 2-D interpolator, for several pairs of rho_ye and temperature. - - int jtemp_lo = vector_index_lu(table_meta.ntemp, log_temp_table, log_temp); - int jtemp_hi = jtemp_lo + 1; - - int irhoy_lo = vector_index_lu(table_meta.nrhoy, log_rhoy_table, log_rhoy); - int irhoy_hi = irhoy_lo + 1; - - amrex::Real rhoy_lo = log_rhoy_table(irhoy_lo); - amrex::Real rhoy_hi = log_rhoy_table(irhoy_hi); - - amrex::Real t_lo = log_temp_table(jtemp_lo); - amrex::Real t_hi = log_temp_table(jtemp_hi); - - amrex::Real fij = data(jtemp_lo, irhoy_lo, component); - amrex::Real fip1j = data(jtemp_lo, irhoy_hi, component); - amrex::Real fijp1 = data(jtemp_hi, irhoy_lo, component); - amrex::Real fip1jp1 = data(jtemp_hi, irhoy_hi, component); - - amrex::Real r = evaluate_linear_2d(fip1jp1, fip1j, fijp1, fij, - rhoy_hi, rhoy_lo, t_hi, t_lo, log_rhoy, log_temp); - - return r; -} - - -template -AMREX_INLINE AMREX_GPU_HOST_DEVICE -amrex::Real -evaluate_dr_dtemp(const table_t& table_meta, const R& log_rhoy_table, const T& log_temp_table, const D& data, - const amrex::Real log_rhoy, const amrex::Real log_temp) -{ - // The main objective of this function is compute dlogr_dlogt. - - int irhoy_lo = vector_index_lu(table_meta.nrhoy, log_rhoy_table, log_rhoy); - int irhoy_hi = irhoy_lo + 1; - - int jtemp_lo = vector_index_lu(table_meta.ntemp, log_temp_table, log_temp); - int jtemp_hi = jtemp_lo + 1; - - amrex::Real dlogr_dlogt; - - //Now we compute the forward finite difference on the boundary - - if ((jtemp_lo - 1 < 1) || (jtemp_hi + 1 > table_meta.ntemp)) { - - // In this case we are in the boundaries of the table. - // At the boundary, we compute the forward-j finite difference - // to compute dlogr_dlogt_i and dlogr_dlogt_ip1, using the - // following stencil: - // - // - // fijp1-----------fip1jp1 - // | | - // | | - // | | - // | | - // | | - // | | - // | | - // fij-------------fip1j - // - // with the following result: - // - // dlogr_dlogt_i --------dlogr_dlogt_ip1 - // - // Finally, we perform a 1d-linear interpolation between dlogr_dlogt_ip1 - // and dlogr_dlogt_i to compute dlogr_dlogt - - amrex::Real log_rhoy_lo = log_rhoy_table(irhoy_lo); - amrex::Real log_rhoy_hi = log_rhoy_table(irhoy_hi); - - amrex::Real log_temp_lo = log_temp_table(jtemp_lo); - amrex::Real log_temp_hi = log_temp_table(jtemp_hi); - - amrex::Real fij = data(jtemp_lo, irhoy_lo, jtab_rate); - amrex::Real fip1j = data(jtemp_lo, irhoy_hi, jtab_rate); - amrex::Real fijp1 = data(jtemp_hi, irhoy_lo, jtab_rate); - amrex::Real fip1jp1 = data(jtemp_hi, irhoy_hi, jtab_rate); - - amrex::Real dlogr_dlogt_i = (fijp1 - fij) / (log_temp_hi - log_temp_lo); - amrex::Real dlogr_dlogt_ip1 = (fip1jp1 - fip1j) / (log_temp_hi - log_temp_lo); - - if ((log_temp < log_temp_lo) || (log_temp > log_temp_hi)) { - dlogr_dlogt = 0.0_rt; - } else { - dlogr_dlogt = evaluate_linear_1d(dlogr_dlogt_ip1, dlogr_dlogt_i, log_rhoy_hi, log_rhoy_lo, log_rhoy); - } - - } else { - - // In this case, we use a bigger stencil to reconstruct the - // temperature derivatives in the j and j+1 temperature positions, - // using the cetral-j finite differences: - // - // fijp2 ------------fip1jp2 - // | | - // | | - // | | - // | | - // | | - // | | - // | | - // fijp1------------fip1jp1 - // | | - // | | - // | | - // | | - // | | - // | | - // | | - // fij------------- fip1j - // | | - // | | - // | | - // | | - // | | - // | | - // | | - // fijm1------------fip1jm1 - // - // with the following result: - // - // - // dr_dt_ijp1 --------dr_dt_ip1jp1 - // | | - // | | - // | | - // | | - // | | - // | | - // | | - // dr_dt_ij-----------dr_dt_ip1j - // - // Finally, we perform a 2d-linear interpolation to - // compute dlogr_dlogt. - - amrex::Real log_temp_jm1 = log_temp_table(jtemp_lo-1); - amrex::Real log_temp_j = log_temp_table(jtemp_lo); - amrex::Real log_temp_jp1 = log_temp_table(jtemp_hi); - amrex::Real log_temp_jp2 = log_temp_table(jtemp_hi+1); - - amrex::Real log_rhoy_lo = log_rhoy_table(irhoy_lo); - amrex::Real log_rhoy_hi = log_rhoy_table(irhoy_hi); - - amrex::Real fijm1 = data(jtemp_lo-1, irhoy_lo, jtab_rate); - amrex::Real fij = data(jtemp_lo, irhoy_lo, jtab_rate); - amrex::Real fijp1 = data(jtemp_hi, irhoy_lo, jtab_rate); - amrex::Real fijp2 = data(jtemp_hi+1, irhoy_lo, jtab_rate); - - amrex::Real fip1jm1 = data(jtemp_lo-1, irhoy_hi, jtab_rate); - amrex::Real fip1j = data(jtemp_lo, irhoy_hi, jtab_rate); - amrex::Real fip1jp1 = data(jtemp_hi, irhoy_hi, jtab_rate); - amrex::Real fip1jp2 = data(jtemp_hi+1, irhoy_hi, jtab_rate); - - amrex::Real dlogr_dlogt_ij = (fijp1 - fijm1)/(log_temp_jp1 - log_temp_jm1); - amrex::Real dlogr_dlogt_ijp1 = (fijp2 - fij)/(log_temp_jp2 - log_temp_j); - amrex::Real dlogr_dlogt_ip1j = (fip1jp1 - fip1jm1)/(log_temp_jp1 - log_temp_jm1); - amrex::Real dlogr_dlogt_ip1jp1 = (fip1jp2 - fip1j)/(log_temp_jp2 - log_temp_j); - - dlogr_dlogt = evaluate_linear_2d(dlogr_dlogt_ip1jp1, dlogr_dlogt_ip1j, dlogr_dlogt_ijp1, dlogr_dlogt_ij, - log_rhoy_hi, log_rhoy_lo, log_temp_jp1, log_temp_j, - log_rhoy, log_temp); - - } - return dlogr_dlogt; -} - - -template -AMREX_INLINE AMREX_GPU_HOST_DEVICE -void -get_entries(const table_t& table_meta, const R& log_rhoy_table, const T& log_temp_table, const D& data, - const amrex::Real log_rhoy, const amrex::Real log_temp, amrex::Array1D& entries) -{ - for (int ivar = 1; ivar <= num_vars; ivar++) { - entries(ivar) = evaluate_vars(table_meta, log_rhoy_table, log_temp_table, data, - log_rhoy, log_temp, ivar); - } - - entries(k_index_dlogr_dlogt) = evaluate_dr_dtemp(table_meta, log_rhoy_table, log_temp_table, data, - log_rhoy, log_temp); -} - -template -AMREX_INLINE AMREX_GPU_HOST_DEVICE -void -tabular_evaluate(const table_t& table_meta, - const R& log_rhoy_table, const T& log_temp_table, const D& data, - const amrex::Real rhoy, const amrex::Real temp, - amrex::Real& rate, amrex::Real& drate_dt, amrex::Real& edot_nu, amrex::Real& edot_gamma) -{ - amrex::Array1D entries; - - // Get the table entries at this rhoy, temp - - amrex::Real log_rhoy = std::log10(rhoy); - amrex::Real log_temp = std::log10(temp); - - get_entries(table_meta, log_rhoy_table, log_temp_table, data, - log_rhoy, log_temp, entries); - - // Fill outputs: rate, d(rate)/d(temperature), and - // (negative) neutrino loss contribution to energy generation - - rate = std::pow(10.0_rt, entries(jtab_rate)); - drate_dt = rate * entries(k_index_dlogr_dlogt) / temp; - edot_nu = -std::pow(10.0_rt, entries(jtab_nuloss)); - edot_gamma = std::pow(10.0_rt, entries(jtab_gamma)); -} - -#endif diff --git a/networks/nova2/table_rates_data.cpp b/networks/nova2/table_rates_data.cpp deleted file mode 100644 index 63b38aff19..0000000000 --- a/networks/nova2/table_rates_data.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include -#include -#include - -using namespace amrex; - -namespace rate_tables -{ - - -} - - -void init_tabular() -{ - - amrex::Print() << "reading in network electron-capture / beta-decay tables..." << std::endl; - - using namespace rate_tables; - - -} diff --git a/networks/nova2/tfactors.H b/networks/nova2/tfactors.H deleted file mode 100644 index 3ec02d562f..0000000000 --- a/networks/nova2/tfactors.H +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef TFACTORS_H -#define TFACTORS_H - -struct tf_t { - amrex::Real T9; - amrex::Real T9i; - amrex::Real T943i; - amrex::Real T923i; - amrex::Real T913i; - amrex::Real T913; - amrex::Real T923; - amrex::Real T953; - amrex::Real lnT9; -}; - -AMREX_GPU_HOST_DEVICE AMREX_INLINE -tf_t evaluate_tfactors(const amrex::Real T) -{ - - tf_t tf; - tf.T9 = T / 1.e9_rt; - tf.T9i = 1.0_rt / tf.T9; - tf.T913 = std::cbrt(tf.T9); - tf.T913i = 1.0_rt / tf.T913; - tf.T923i = tf.T913i * tf.T913i; - tf.T943i = tf.T9i * tf.T913i; - tf.T923 = tf.T913 * tf.T913; - tf.T953 = tf.T9 * tf.T923; - tf.lnT9 = std::log(tf.T9); - - return tf; -} - -#endif