diff --git a/networks/subch_base/Make.package b/networks/subch_base/Make.package new file mode 100644 index 0000000000..39c65eca7b --- /dev/null +++ b/networks/subch_base/Make.package @@ -0,0 +1,14 @@ +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/subch_base/README.md b/networks/subch_base/README.md new file mode 100644 index 0000000000..130aaf0b30 --- /dev/null +++ b/networks/subch_base/README.md @@ -0,0 +1,8 @@ +# subch_base + +This network is a further simplification of subch_simple by +excluding N14, F18, Ne21, and Na22. +These nuclei were added to include n14(a, g)f18(a, p)ne21 rate sequence, +which allows an enhancement to the c12(p, g)n13(a, p)o16 rate due to the +proton release. However, we find that the effect is not very significant, +and they also caused an artificial endpoint at Na22. diff --git a/networks/subch_base/_parameters b/networks/subch_base/_parameters new file mode 100644 index 0000000000..e98e970b5e --- /dev/null +++ b/networks/subch_base/_parameters @@ -0,0 +1,4 @@ +@namespace: network + +disable_p_C12_to_N13 int 0 +disable_He4_N13_to_p_O16 int 0 diff --git a/networks/subch_base/actual_network.H b/networks/subch_base/actual_network.H new file mode 100644 index 0000000000..c68b18904d --- /dev/null +++ b/networks/subch_base/actual_network.H @@ -0,0 +1,233 @@ +#ifndef actual_network_H +#define actual_network_H + +#include +#include + +#include +#include + +using namespace amrex; + +void actual_network_init(); + +const std::string network_name = "pynucastro-cxx"; + +namespace network +{ + extern AMREX_GPU_MANAGED amrex::Array1D bion; + extern AMREX_GPU_MANAGED amrex::Array1D mion; +} + +namespace Rates +{ + + enum NetworkRates + { + k_p_C12_to_N13 = 1, + k_He4_C12_to_O16 = 2, + k_He4_O16_to_Ne20 = 3, + k_He4_Ne20_to_Mg24 = 4, + k_p_Na23_to_Mg24 = 5, + k_He4_Mg24_to_Si28 = 6, + k_p_Al27_to_Si28 = 7, + k_He4_Si28_to_S32 = 8, + k_p_P31_to_S32 = 9, + k_C12_C12_to_p_Na23 = 10, + k_C12_C12_to_He4_Ne20 = 11, + k_He4_N13_to_p_O16 = 12, + k_C12_O16_to_p_Al27 = 13, + k_C12_O16_to_He4_Mg24 = 14, + k_O16_O16_to_p_P31 = 15, + k_O16_O16_to_He4_Si28 = 16, + k_p_Na23_to_He4_Ne20 = 17, + k_p_Al27_to_He4_Mg24 = 18, + k_p_P31_to_He4_Si28 = 19, + k_He4_He4_He4_to_C12 = 20, + k_C12_C12_to_Mg24_modified = 21, + k_O16_O16_to_S32_modified = 22, + k_C12_O16_to_Si28_modified = 23, + k_He4_S32_to_Ar36_removed = 24, + k_p_Cl35_to_Ar36_removed = 25, + k_p_Cl35_to_He4_S32_removed = 26, + k_He4_Ar36_to_Ca40_removed = 27, + k_p_K39_to_Ca40_removed = 28, + k_p_K39_to_He4_Ar36_removed = 29, + k_He4_Ca40_to_Ti44_removed = 30, + k_p_Sc43_to_Ti44_removed = 31, + k_p_Sc43_to_He4_Ca40_removed = 32, + k_He4_Ti44_to_Cr48_removed = 33, + k_He4_Ti44_to_p_V47_removed = 34, + k_p_V47_to_Cr48_removed = 35, + k_He4_Cr48_to_Fe52_removed = 36, + k_He4_Cr48_to_p_Mn51_removed = 37, + k_p_Mn51_to_Fe52_removed = 38, + k_He4_Fe52_to_Ni56_removed = 39, + k_He4_Fe52_to_p_Co55_removed = 40, + k_p_Co55_to_Ni56_removed = 41, + k_S32_He4_to_Ar36_approx = 42, + k_Ar36_to_S32_He4_approx = 43, + k_Ar36_He4_to_Ca40_approx = 44, + k_Ca40_to_Ar36_He4_approx = 45, + k_Ca40_He4_to_Ti44_approx = 46, + k_Ti44_to_Ca40_He4_approx = 47, + k_Ti44_He4_to_Cr48_approx = 48, + k_Cr48_to_Ti44_He4_approx = 49, + k_Cr48_He4_to_Fe52_approx = 50, + k_Fe52_to_Cr48_He4_approx = 51, + k_Fe52_He4_to_Ni56_approx = 52, + k_Ni56_to_Fe52_He4_approx = 53, + k_N13_to_p_C12_derived = 54, + k_O16_to_He4_C12_derived = 55, + k_Ne20_to_He4_O16_derived = 56, + k_Mg24_to_p_Na23_derived = 57, + k_Mg24_to_He4_Ne20_derived = 58, + k_Si28_to_p_Al27_derived = 59, + k_Si28_to_He4_Mg24_derived = 60, + k_S32_to_p_P31_derived = 61, + k_S32_to_He4_Si28_derived = 62, + k_C12_to_He4_He4_He4_derived = 63, + k_p_O16_to_He4_N13_derived = 64, + k_He4_Ne20_to_p_Na23_derived = 65, + k_He4_Mg24_to_p_Al27_derived = 66, + k_He4_Si28_to_p_P31_derived = 67, + k_He4_S32_to_p_Cl35_derived_removed = 68, + k_Ar36_to_He4_S32_derived_removed = 69, + k_Ar36_to_p_Cl35_derived_removed = 70, + k_He4_Ar36_to_p_K39_derived_removed = 71, + k_Ca40_to_He4_Ar36_derived_removed = 72, + k_Ca40_to_p_K39_derived_removed = 73, + k_He4_Ca40_to_p_Sc43_derived_removed = 74, + k_Ti44_to_He4_Ca40_derived_removed = 75, + k_Ti44_to_p_Sc43_derived_removed = 76, + k_Cr48_to_He4_Ti44_derived_removed = 77, + k_Cr48_to_p_V47_derived_removed = 78, + k_p_V47_to_He4_Ti44_derived_removed = 79, + k_Fe52_to_He4_Cr48_derived_removed = 80, + k_Fe52_to_p_Mn51_derived_removed = 81, + k_p_Mn51_to_He4_Cr48_derived_removed = 82, + k_Ni56_to_He4_Fe52_derived_removed = 83, + k_Ni56_to_p_Co55_derived_removed = 84, + k_p_Co55_to_He4_Fe52_derived_removed = 85, + NumRates = k_p_Co55_to_He4_Fe52_derived_removed + }; + + // number of reaclib rates + + const int NrateReaclib = 73; + + // 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 + "p_C12_to_N13", // 1, + "He4_C12_to_O16", // 2, + "He4_O16_to_Ne20", // 3, + "He4_Ne20_to_Mg24", // 4, + "p_Na23_to_Mg24", // 5, + "He4_Mg24_to_Si28", // 6, + "p_Al27_to_Si28", // 7, + "He4_Si28_to_S32", // 8, + "p_P31_to_S32", // 9, + "C12_C12_to_p_Na23", // 10, + "C12_C12_to_He4_Ne20", // 11, + "He4_N13_to_p_O16", // 12, + "C12_O16_to_p_Al27", // 13, + "C12_O16_to_He4_Mg24", // 14, + "O16_O16_to_p_P31", // 15, + "O16_O16_to_He4_Si28", // 16, + "p_Na23_to_He4_Ne20", // 17, + "p_Al27_to_He4_Mg24", // 18, + "p_P31_to_He4_Si28", // 19, + "He4_He4_He4_to_C12", // 20, + "C12_C12_to_Mg24_modified", // 21, + "O16_O16_to_S32_modified", // 22, + "C12_O16_to_Si28_modified", // 23, + "He4_S32_to_Ar36_removed", // 24, + "p_Cl35_to_Ar36_removed", // 25, + "p_Cl35_to_He4_S32_removed", // 26, + "He4_Ar36_to_Ca40_removed", // 27, + "p_K39_to_Ca40_removed", // 28, + "p_K39_to_He4_Ar36_removed", // 29, + "He4_Ca40_to_Ti44_removed", // 30, + "p_Sc43_to_Ti44_removed", // 31, + "p_Sc43_to_He4_Ca40_removed", // 32, + "He4_Ti44_to_Cr48_removed", // 33, + "He4_Ti44_to_p_V47_removed", // 34, + "p_V47_to_Cr48_removed", // 35, + "He4_Cr48_to_Fe52_removed", // 36, + "He4_Cr48_to_p_Mn51_removed", // 37, + "p_Mn51_to_Fe52_removed", // 38, + "He4_Fe52_to_Ni56_removed", // 39, + "He4_Fe52_to_p_Co55_removed", // 40, + "p_Co55_to_Ni56_removed", // 41, + "S32_He4_to_Ar36_approx", // 42, + "Ar36_to_S32_He4_approx", // 43, + "Ar36_He4_to_Ca40_approx", // 44, + "Ca40_to_Ar36_He4_approx", // 45, + "Ca40_He4_to_Ti44_approx", // 46, + "Ti44_to_Ca40_He4_approx", // 47, + "Ti44_He4_to_Cr48_approx", // 48, + "Cr48_to_Ti44_He4_approx", // 49, + "Cr48_He4_to_Fe52_approx", // 50, + "Fe52_to_Cr48_He4_approx", // 51, + "Fe52_He4_to_Ni56_approx", // 52, + "Ni56_to_Fe52_He4_approx", // 53, + "N13_to_p_C12_derived", // 54, + "O16_to_He4_C12_derived", // 55, + "Ne20_to_He4_O16_derived", // 56, + "Mg24_to_p_Na23_derived", // 57, + "Mg24_to_He4_Ne20_derived", // 58, + "Si28_to_p_Al27_derived", // 59, + "Si28_to_He4_Mg24_derived", // 60, + "S32_to_p_P31_derived", // 61, + "S32_to_He4_Si28_derived", // 62, + "C12_to_He4_He4_He4_derived", // 63, + "p_O16_to_He4_N13_derived", // 64, + "He4_Ne20_to_p_Na23_derived", // 65, + "He4_Mg24_to_p_Al27_derived", // 66, + "He4_Si28_to_p_P31_derived", // 67, + "He4_S32_to_p_Cl35_derived_removed", // 68, + "Ar36_to_He4_S32_derived_removed", // 69, + "Ar36_to_p_Cl35_derived_removed", // 70, + "He4_Ar36_to_p_K39_derived_removed", // 71, + "Ca40_to_He4_Ar36_derived_removed", // 72, + "Ca40_to_p_K39_derived_removed", // 73, + "He4_Ca40_to_p_Sc43_derived_removed", // 74, + "Ti44_to_He4_Ca40_derived_removed", // 75, + "Ti44_to_p_Sc43_derived_removed", // 76, + "Cr48_to_He4_Ti44_derived_removed", // 77, + "Cr48_to_p_V47_derived_removed", // 78, + "p_V47_to_He4_Ti44_derived_removed", // 79, + "Fe52_to_He4_Cr48_derived_removed", // 80, + "Fe52_to_p_Mn51_derived_removed", // 81, + "p_Mn51_to_He4_Cr48_derived_removed", // 82, + "Ni56_to_He4_Fe52_derived_removed", // 83, + "Ni56_to_p_Co55_derived_removed", // 84, + "p_Co55_to_He4_Fe52_derived_removed" // 85, + }; + +} + +#ifdef NSE_NET +namespace NSE_INDEX +{ + constexpr int H1_index = 0; + constexpr int N_index = -1; + constexpr int He4_index = 1; + + // 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/subch_base/actual_network_data.cpp b/networks/subch_base/actual_network_data.cpp new file mode 100644 index 0000000000..f113c3de9c --- /dev/null +++ b/networks/subch_base/actual_network_data.cpp @@ -0,0 +1,140 @@ +#include + + +namespace network +{ + AMREX_GPU_MANAGED amrex::Array1D bion; + AMREX_GPU_MANAGED amrex::Array1D mion; +} + +#ifdef NSE_NET +namespace NSE_INDEX +{ + AMREX_GPU_MANAGED amrex::Array2D rate_indices { + -1, 0, 2, -1, -1, 3, 54, + -1, 1, 2, -1, -1, 4, 55, + -1, 1, 4, -1, -1, 5, 56, + -1, 1, 5, -1, -1, 7, 58, + -1, 0, 6, -1, -1, 7, 57, + -1, 1, 7, -1, -1, 9, 60, + -1, 0, 8, -1, -1, 9, 59, + -1, 1, 9, -1, -1, 11, 62, + -1, 0, 10, -1, -1, 11, 61, + -1, 2, 2, -1, 0, 6, -1, + -1, 2, 2, -1, 1, 5, -1, + -1, 1, 3, -1, 0, 4, 64, + -1, 2, 4, -1, 0, 8, -1, + -1, 2, 4, -1, 1, 7, -1, + -1, 4, 4, -1, 0, 10, -1, + -1, 4, 4, -1, 1, 9, -1, + -1, 0, 6, -1, 1, 5, 65, + -1, 0, 8, -1, 1, 7, 66, + -1, 0, 10, -1, 1, 9, 67, + 1, 1, 1, -1, -1, 2, 63, + -1, 2, 2, -1, -1, 7, -1, + -1, 4, 4, -1, -1, 11, -1, + -1, 2, 4, -1, -1, 9, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, 1, 11, -1, -1, 12, 43, + -1, -1, 12, -1, 1, 11, -1, + -1, 1, 12, -1, -1, 13, 45, + -1, -1, 13, -1, 1, 12, -1, + -1, 1, 13, -1, -1, 14, 47, + -1, -1, 14, -1, 1, 13, -1, + -1, 1, 14, -1, -1, 15, 49, + -1, -1, 15, -1, 1, 14, -1, + -1, 1, 15, -1, -1, 16, 51, + -1, -1, 16, -1, 1, 15, -1, + -1, 1, 16, -1, -1, 17, 53, + -1, -1, 17, -1, 1, 16, -1, + -1, -1, 3, -1, 0, 2, -1, + -1, -1, 4, -1, 1, 2, -1, + -1, -1, 5, -1, 1, 4, -1, + -1, -1, 7, -1, 0, 6, -1, + -1, -1, 7, -1, 1, 5, -1, + -1, -1, 9, -1, 0, 8, -1, + -1, -1, 9, -1, 1, 7, -1, + -1, -1, 11, -1, 0, 10, -1, + -1, -1, 11, -1, 1, 9, -1, + -1, -1, 2, 1, 1, 1, -1, + -1, 0, 4, -1, 1, 3, -1, + -1, 1, 5, -1, 0, 6, -1, + -1, 1, 7, -1, 0, 8, -1, + -1, 1, 9, -1, 0, 10, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1 + }; +} +#endif + +void actual_network_init() +{ + using namespace Species; + using namespace network; + + // binding energies per nucleon in MeV + amrex::Array1D ebind_per_nucleon; + + ebind_per_nucleon(H1) = 0.0_rt; + ebind_per_nucleon(He4) = 7.073915_rt; + ebind_per_nucleon(C12) = 7.680144_rt; + ebind_per_nucleon(N13) = 7.238863_rt; + ebind_per_nucleon(O16) = 7.976206_rt; + ebind_per_nucleon(Ne20) = 8.03224_rt; + ebind_per_nucleon(Na23) = 8.111493000000001_rt; + ebind_per_nucleon(Mg24) = 8.260709_rt; + ebind_per_nucleon(Al27) = 8.331553_rt; + ebind_per_nucleon(Si28) = 8.447744_rt; + ebind_per_nucleon(P31) = 8.481167_rt; + ebind_per_nucleon(S32) = 8.493129000000001_rt; + ebind_per_nucleon(Ar36) = 8.519909_rt; + ebind_per_nucleon(Ca40) = 8.551303_rt; + ebind_per_nucleon(Ti44) = 8.533520000000001_rt; + ebind_per_nucleon(Cr48) = 8.572269_rt; + ebind_per_nucleon(Fe52) = 8.609574_rt; + ebind_per_nucleon(Ni56) = 8.642779_rt; + + // convert to binding energies per nucleus in MeV + for (int i = 1; i <= NumSpec; ++i) { + bion(i) = ebind_per_nucleon(i) * aion[i-1]; + } + + // Set the mass -- this will be in grams + for (int i = 1; i <= NumSpec; ++i) { + mion(i) = (aion[i-1] - zion[i-1]) * C::Legacy::m_n + zion[i-1] * (C::Legacy::m_p + C::Legacy::m_e) - bion(i) * C::Legacy::MeV2gr; + } + +} diff --git a/networks/subch_base/actual_rhs.H b/networks/subch_base/actual_rhs.H new file mode 100644 index 0000000000..32ff1f91f6 --- /dev/null +++ b/networks/subch_base/actual_rhs.H @@ -0,0 +1,1436 @@ +#ifndef actual_rhs_H +#define actual_rhs_H + +#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, 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 + + Array1D Y; + for (int n = 1; n <= NumSpec; ++n) { + Y(n) = state.xn[n-1] * aion_inv[n-1]; + } + + [[maybe_unused]] Real rhoy = state.rho * state.y_e; + + // Calculate Reaclib rates + + plasma_state_t pstate{}; + fill_plasma_state(pstate, state.T, state.rho, Y); + + tf_t tfactors = evaluate_tfactors(state.T); + + fill_reaclib_rates(tfactors, rate_eval); + + if (disable_p_C12_to_N13) { + rate_eval.screened_rates(k_p_C12_to_N13) = 0.0; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_C12_to_N13) = 0.0; + } + rate_eval.screened_rates(k_N13_to_p_C12_derived) = 0.0; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_N13_to_p_C12_derived) = 0.0; + } + } + + if (disable_He4_N13_to_p_O16) { + rate_eval.screened_rates(k_He4_N13_to_p_O16) = 0.0; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_N13_to_p_O16) = 0.0; + } + rate_eval.screened_rates(k_p_O16_to_He4_N13_derived) = 0.0; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_O16_to_He4_N13_derived) = 0.0; + } + } + + + + // Evaluate screening factors + + Real ratraw, dratraw_dT; + Real scor, dscor_dt; + [[maybe_unused]] Real scor2, dscor2_dt; + + + { + 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::value) { + 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::value) { + 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(2.0_rt, 4.0_rt, 8.0_rt, 16.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_O16_to_Ne20); + rate_eval.screened_rates(k_He4_O16_to_Ne20) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_O16_to_Ne20); + rate_eval.dscreened_rates_dT(k_He4_O16_to_Ne20) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 10.0_rt, 20.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_Ne20_to_Mg24); + rate_eval.screened_rates(k_He4_Ne20_to_Mg24) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Ne20_to_Mg24); + rate_eval.dscreened_rates_dT(k_He4_Ne20_to_Mg24) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_Ne20_to_p_Na23_derived); + rate_eval.screened_rates(k_He4_Ne20_to_p_Na23_derived) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Ne20_to_p_Na23_derived); + rate_eval.dscreened_rates_dT(k_He4_Ne20_to_p_Na23_derived) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 11.0_rt, 23.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_Na23_to_Mg24); + rate_eval.screened_rates(k_p_Na23_to_Mg24) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Na23_to_Mg24); + rate_eval.dscreened_rates_dT(k_p_Na23_to_Mg24) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_Na23_to_He4_Ne20); + rate_eval.screened_rates(k_p_Na23_to_He4_Ne20) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Na23_to_He4_Ne20); + rate_eval.dscreened_rates_dT(k_p_Na23_to_He4_Ne20) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 12.0_rt, 24.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_Mg24_to_Si28); + rate_eval.screened_rates(k_He4_Mg24_to_Si28) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Mg24_to_Si28); + rate_eval.dscreened_rates_dT(k_He4_Mg24_to_Si28) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_Mg24_to_p_Al27_derived); + rate_eval.screened_rates(k_He4_Mg24_to_p_Al27_derived) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Mg24_to_p_Al27_derived); + rate_eval.dscreened_rates_dT(k_He4_Mg24_to_p_Al27_derived) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 13.0_rt, 27.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_Al27_to_Si28); + rate_eval.screened_rates(k_p_Al27_to_Si28) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Al27_to_Si28); + rate_eval.dscreened_rates_dT(k_p_Al27_to_Si28) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_Al27_to_He4_Mg24); + rate_eval.screened_rates(k_p_Al27_to_He4_Mg24) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Al27_to_He4_Mg24); + rate_eval.dscreened_rates_dT(k_p_Al27_to_He4_Mg24) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 14.0_rt, 28.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_Si28_to_S32); + rate_eval.screened_rates(k_He4_Si28_to_S32) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Si28_to_S32); + rate_eval.dscreened_rates_dT(k_He4_Si28_to_S32) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_Si28_to_p_P31_derived); + rate_eval.screened_rates(k_He4_Si28_to_p_P31_derived) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Si28_to_p_P31_derived); + rate_eval.dscreened_rates_dT(k_He4_Si28_to_p_P31_derived) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 15.0_rt, 31.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_P31_to_S32); + rate_eval.screened_rates(k_p_P31_to_S32) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_P31_to_S32); + rate_eval.dscreened_rates_dT(k_p_P31_to_S32) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_P31_to_He4_Si28); + rate_eval.screened_rates(k_p_P31_to_He4_Si28) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_P31_to_He4_Si28); + rate_eval.dscreened_rates_dT(k_p_P31_to_He4_Si28) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(6.0_rt, 12.0_rt, 6.0_rt, 12.0_rt); + + + static_assert(scn_fac.z1 == 6.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_C12_C12_to_p_Na23); + rate_eval.screened_rates(k_C12_C12_to_p_Na23) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_C12_C12_to_p_Na23); + rate_eval.dscreened_rates_dT(k_C12_C12_to_p_Na23) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_C12_C12_to_He4_Ne20); + rate_eval.screened_rates(k_C12_C12_to_He4_Ne20) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_C12_C12_to_He4_Ne20); + rate_eval.dscreened_rates_dT(k_C12_C12_to_He4_Ne20) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_C12_C12_to_Mg24_modified); + rate_eval.screened_rates(k_C12_C12_to_Mg24_modified) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_C12_C12_to_Mg24_modified); + rate_eval.dscreened_rates_dT(k_C12_C12_to_Mg24_modified) = 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::value) { + 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(6.0_rt, 12.0_rt, 8.0_rt, 16.0_rt); + + + static_assert(scn_fac.z1 == 6.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_C12_O16_to_p_Al27); + rate_eval.screened_rates(k_C12_O16_to_p_Al27) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_C12_O16_to_p_Al27); + rate_eval.dscreened_rates_dT(k_C12_O16_to_p_Al27) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_C12_O16_to_He4_Mg24); + rate_eval.screened_rates(k_C12_O16_to_He4_Mg24) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_C12_O16_to_He4_Mg24); + rate_eval.dscreened_rates_dT(k_C12_O16_to_He4_Mg24) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_C12_O16_to_Si28_modified); + rate_eval.screened_rates(k_C12_O16_to_Si28_modified) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_C12_O16_to_Si28_modified); + rate_eval.dscreened_rates_dT(k_C12_O16_to_Si28_modified) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(8.0_rt, 16.0_rt, 8.0_rt, 16.0_rt); + + + static_assert(scn_fac.z1 == 8.0_rt); + + + actual_screen(pstate, scn_fac, scor, dscor_dt); + } + + + ratraw = rate_eval.screened_rates(k_O16_O16_to_p_P31); + rate_eval.screened_rates(k_O16_O16_to_p_P31) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_O16_O16_to_p_P31); + rate_eval.dscreened_rates_dT(k_O16_O16_to_p_P31) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_O16_O16_to_He4_Si28); + rate_eval.screened_rates(k_O16_O16_to_He4_Si28) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_O16_O16_to_He4_Si28); + rate_eval.dscreened_rates_dT(k_O16_O16_to_He4_Si28) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_O16_O16_to_S32_modified); + rate_eval.screened_rates(k_O16_O16_to_S32_modified) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_O16_O16_to_S32_modified); + rate_eval.dscreened_rates_dT(k_O16_O16_to_S32_modified) = 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::value) { + 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; + } + + + { + 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_He4_N13_derived); + rate_eval.screened_rates(k_p_O16_to_He4_N13_derived) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_O16_to_He4_N13_derived); + rate_eval.dscreened_rates_dT(k_p_O16_to_He4_N13_derived) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 16.0_rt, 32.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_S32_to_Ar36_removed); + rate_eval.screened_rates(k_He4_S32_to_Ar36_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_S32_to_Ar36_removed); + rate_eval.dscreened_rates_dT(k_He4_S32_to_Ar36_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_S32_to_p_Cl35_derived_removed); + rate_eval.screened_rates(k_He4_S32_to_p_Cl35_derived_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_S32_to_p_Cl35_derived_removed); + rate_eval.dscreened_rates_dT(k_He4_S32_to_p_Cl35_derived_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 17.0_rt, 35.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_Cl35_to_Ar36_removed); + rate_eval.screened_rates(k_p_Cl35_to_Ar36_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Cl35_to_Ar36_removed); + rate_eval.dscreened_rates_dT(k_p_Cl35_to_Ar36_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_Cl35_to_He4_S32_removed); + rate_eval.screened_rates(k_p_Cl35_to_He4_S32_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Cl35_to_He4_S32_removed); + rate_eval.dscreened_rates_dT(k_p_Cl35_to_He4_S32_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 18.0_rt, 36.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_Ar36_to_Ca40_removed); + rate_eval.screened_rates(k_He4_Ar36_to_Ca40_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Ar36_to_Ca40_removed); + rate_eval.dscreened_rates_dT(k_He4_Ar36_to_Ca40_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_Ar36_to_p_K39_derived_removed); + rate_eval.screened_rates(k_He4_Ar36_to_p_K39_derived_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Ar36_to_p_K39_derived_removed); + rate_eval.dscreened_rates_dT(k_He4_Ar36_to_p_K39_derived_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 19.0_rt, 39.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_K39_to_Ca40_removed); + rate_eval.screened_rates(k_p_K39_to_Ca40_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_K39_to_Ca40_removed); + rate_eval.dscreened_rates_dT(k_p_K39_to_Ca40_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_K39_to_He4_Ar36_removed); + rate_eval.screened_rates(k_p_K39_to_He4_Ar36_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_K39_to_He4_Ar36_removed); + rate_eval.dscreened_rates_dT(k_p_K39_to_He4_Ar36_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 20.0_rt, 40.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_Ca40_to_Ti44_removed); + rate_eval.screened_rates(k_He4_Ca40_to_Ti44_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Ca40_to_Ti44_removed); + rate_eval.dscreened_rates_dT(k_He4_Ca40_to_Ti44_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_Ca40_to_p_Sc43_derived_removed); + rate_eval.screened_rates(k_He4_Ca40_to_p_Sc43_derived_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Ca40_to_p_Sc43_derived_removed); + rate_eval.dscreened_rates_dT(k_He4_Ca40_to_p_Sc43_derived_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 21.0_rt, 43.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_Sc43_to_Ti44_removed); + rate_eval.screened_rates(k_p_Sc43_to_Ti44_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Sc43_to_Ti44_removed); + rate_eval.dscreened_rates_dT(k_p_Sc43_to_Ti44_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_Sc43_to_He4_Ca40_removed); + rate_eval.screened_rates(k_p_Sc43_to_He4_Ca40_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Sc43_to_He4_Ca40_removed); + rate_eval.dscreened_rates_dT(k_p_Sc43_to_He4_Ca40_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 22.0_rt, 44.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_Ti44_to_Cr48_removed); + rate_eval.screened_rates(k_He4_Ti44_to_Cr48_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Ti44_to_Cr48_removed); + rate_eval.dscreened_rates_dT(k_He4_Ti44_to_Cr48_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_Ti44_to_p_V47_removed); + rate_eval.screened_rates(k_He4_Ti44_to_p_V47_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Ti44_to_p_V47_removed); + rate_eval.dscreened_rates_dT(k_He4_Ti44_to_p_V47_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 23.0_rt, 47.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_V47_to_Cr48_removed); + rate_eval.screened_rates(k_p_V47_to_Cr48_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_V47_to_Cr48_removed); + rate_eval.dscreened_rates_dT(k_p_V47_to_Cr48_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_V47_to_He4_Ti44_derived_removed); + rate_eval.screened_rates(k_p_V47_to_He4_Ti44_derived_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_V47_to_He4_Ti44_derived_removed); + rate_eval.dscreened_rates_dT(k_p_V47_to_He4_Ti44_derived_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 24.0_rt, 48.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_Cr48_to_Fe52_removed); + rate_eval.screened_rates(k_He4_Cr48_to_Fe52_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Cr48_to_Fe52_removed); + rate_eval.dscreened_rates_dT(k_He4_Cr48_to_Fe52_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_Cr48_to_p_Mn51_removed); + rate_eval.screened_rates(k_He4_Cr48_to_p_Mn51_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Cr48_to_p_Mn51_removed); + rate_eval.dscreened_rates_dT(k_He4_Cr48_to_p_Mn51_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 25.0_rt, 51.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_Mn51_to_Fe52_removed); + rate_eval.screened_rates(k_p_Mn51_to_Fe52_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Mn51_to_Fe52_removed); + rate_eval.dscreened_rates_dT(k_p_Mn51_to_Fe52_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_Mn51_to_He4_Cr48_derived_removed); + rate_eval.screened_rates(k_p_Mn51_to_He4_Cr48_derived_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Mn51_to_He4_Cr48_derived_removed); + rate_eval.dscreened_rates_dT(k_p_Mn51_to_He4_Cr48_derived_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(2.0_rt, 4.0_rt, 26.0_rt, 52.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_Fe52_to_Ni56_removed); + rate_eval.screened_rates(k_He4_Fe52_to_Ni56_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Fe52_to_Ni56_removed); + rate_eval.dscreened_rates_dT(k_He4_Fe52_to_Ni56_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_He4_Fe52_to_p_Co55_removed); + rate_eval.screened_rates(k_He4_Fe52_to_p_Co55_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_He4_Fe52_to_p_Co55_removed); + rate_eval.dscreened_rates_dT(k_He4_Fe52_to_p_Co55_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + { + constexpr auto scn_fac = scrn::calculate_screen_factor(1.0_rt, 1.0_rt, 27.0_rt, 55.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_Co55_to_Ni56_removed); + rate_eval.screened_rates(k_p_Co55_to_Ni56_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Co55_to_Ni56_removed); + rate_eval.dscreened_rates_dT(k_p_Co55_to_Ni56_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + ratraw = rate_eval.screened_rates(k_p_Co55_to_He4_Fe52_derived_removed); + rate_eval.screened_rates(k_p_Co55_to_He4_Fe52_derived_removed) *= scor; + if constexpr (std::is_same::value) { + dratraw_dT = rate_eval.dscreened_rates_dT(k_p_Co55_to_He4_Fe52_derived_removed); + rate_eval.dscreened_rates_dT(k_p_Co55_to_He4_Fe52_derived_removed) = ratraw * dscor_dt + dratraw_dT * scor; + } + + + // Fill approximate rates + + fill_approx_rates(tfactors, rate_eval); + + // Calculate tabular rates + + [[maybe_unused]] Real rate, drate_dt, edot_nu, edot_gamma; + + rate_eval.enuc_weak = 0.0; + + +} + +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rhs_nuc(const burn_t& state, + Array1D& ydot_nuc, + const Array1D& Y, + const Array1D& screened_rates) { + + using namespace Rates; + + ydot_nuc(H1) = + (-screened_rates(k_p_C12_to_N13)*Y(C12)*Y(H1)*state.rho + screened_rates(k_N13_to_p_C12_derived)*Y(N13)) + + (-screened_rates(k_p_Na23_to_Mg24)*Y(Na23)*Y(H1)*state.rho + screened_rates(k_Mg24_to_p_Na23_derived)*Y(Mg24)) + + (-screened_rates(k_p_Al27_to_Si28)*Y(Al27)*Y(H1)*state.rho + screened_rates(k_Si28_to_p_Al27_derived)*Y(Si28)) + + (-screened_rates(k_p_P31_to_S32)*Y(P31)*Y(H1)*state.rho + screened_rates(k_S32_to_p_P31_derived)*Y(S32)) + + 0.5*screened_rates(k_C12_C12_to_p_Na23)*std::pow(Y(C12), 2)*state.rho + + (screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho + -screened_rates(k_p_O16_to_He4_N13_derived)*Y(O16)*Y(H1)*state.rho) + + screened_rates(k_C12_O16_to_p_Al27)*Y(C12)*Y(O16)*state.rho + + 0.5*screened_rates(k_O16_O16_to_p_P31)*std::pow(Y(O16), 2)*state.rho + + (-screened_rates(k_p_Na23_to_He4_Ne20)*Y(Na23)*Y(H1)*state.rho + screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(He4)*Y(Ne20)*state.rho) + + (-screened_rates(k_p_Al27_to_He4_Mg24)*Y(Al27)*Y(H1)*state.rho + screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(He4)*Y(Mg24)*state.rho) + + (-screened_rates(k_p_P31_to_He4_Si28)*Y(P31)*Y(H1)*state.rho + screened_rates(k_He4_Si28_to_p_P31_derived)*Y(He4)*Y(Si28)*state.rho); + + ydot_nuc(He4) = + (-screened_rates(k_He4_C12_to_O16)*Y(C12)*Y(He4)*state.rho + screened_rates(k_O16_to_He4_C12_derived)*Y(O16)) + + (-screened_rates(k_He4_O16_to_Ne20)*Y(He4)*Y(O16)*state.rho + screened_rates(k_Ne20_to_He4_O16_derived)*Y(Ne20)) + + (-screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*Y(Ne20)*state.rho + screened_rates(k_Mg24_to_He4_Ne20_derived)*Y(Mg24)) + + (-screened_rates(k_He4_Mg24_to_Si28)*Y(He4)*Y(Mg24)*state.rho + screened_rates(k_Si28_to_He4_Mg24_derived)*Y(Si28)) + + (-screened_rates(k_He4_Si28_to_S32)*Y(He4)*Y(Si28)*state.rho + screened_rates(k_S32_to_He4_Si28_derived)*Y(S32)) + + 0.5*screened_rates(k_C12_C12_to_He4_Ne20)*std::pow(Y(C12), 2)*state.rho + + (-screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho + screened_rates(k_p_O16_to_He4_N13_derived)*Y(O16)*Y(H1)*state.rho) + + screened_rates(k_C12_O16_to_He4_Mg24)*Y(C12)*Y(O16)*state.rho + + 0.5*screened_rates(k_O16_O16_to_He4_Si28)*std::pow(Y(O16), 2)*state.rho + + (screened_rates(k_p_Na23_to_He4_Ne20)*Y(Na23)*Y(H1)*state.rho + -screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(He4)*Y(Ne20)*state.rho) + + (screened_rates(k_p_Al27_to_He4_Mg24)*Y(Al27)*Y(H1)*state.rho + -screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(He4)*Y(Mg24)*state.rho) + + (screened_rates(k_p_P31_to_He4_Si28)*Y(P31)*Y(H1)*state.rho + -screened_rates(k_He4_Si28_to_p_P31_derived)*Y(He4)*Y(Si28)*state.rho) + + (-0.5*screened_rates(k_He4_He4_He4_to_C12)*std::pow(Y(He4), 3)*std::pow(state.rho, 2) + 3.0*screened_rates(k_C12_to_He4_He4_He4_derived)*Y(C12)) + + (-screened_rates(k_S32_He4_to_Ar36_approx)*Y(He4)*Y(S32)*state.rho + screened_rates(k_Ar36_to_S32_He4_approx)*Y(Ar36)) + + (-screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(Ar36)*Y(He4)*state.rho + screened_rates(k_Ca40_to_Ar36_He4_approx)*Y(Ca40)) + + (-screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(Ca40)*Y(He4)*state.rho + screened_rates(k_Ti44_to_Ca40_He4_approx)*Y(Ti44)) + + (-screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(He4)*Y(Ti44)*state.rho + screened_rates(k_Cr48_to_Ti44_He4_approx)*Y(Cr48)) + + (-screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(Cr48)*Y(He4)*state.rho + screened_rates(k_Fe52_to_Cr48_He4_approx)*Y(Fe52)) + + (-screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(Fe52)*Y(He4)*state.rho + screened_rates(k_Ni56_to_Fe52_He4_approx)*Y(Ni56)); + + ydot_nuc(C12) = + (-screened_rates(k_p_C12_to_N13)*Y(C12)*Y(H1)*state.rho + screened_rates(k_N13_to_p_C12_derived)*Y(N13)) + + (-screened_rates(k_He4_C12_to_O16)*Y(C12)*Y(He4)*state.rho + screened_rates(k_O16_to_He4_C12_derived)*Y(O16)) + + -screened_rates(k_C12_C12_to_p_Na23)*std::pow(Y(C12), 2)*state.rho + + -screened_rates(k_C12_C12_to_He4_Ne20)*std::pow(Y(C12), 2)*state.rho + + -screened_rates(k_C12_O16_to_p_Al27)*Y(C12)*Y(O16)*state.rho + + -screened_rates(k_C12_O16_to_He4_Mg24)*Y(C12)*Y(O16)*state.rho + + (0.16666666666666667*screened_rates(k_He4_He4_He4_to_C12)*std::pow(Y(He4), 3)*std::pow(state.rho, 2) + -screened_rates(k_C12_to_He4_He4_He4_derived)*Y(C12)) + + -screened_rates(k_C12_C12_to_Mg24_modified)*std::pow(Y(C12), 2)*state.rho + + -screened_rates(k_C12_O16_to_Si28_modified)*Y(C12)*Y(O16)*state.rho; + + ydot_nuc(N13) = + (screened_rates(k_p_C12_to_N13)*Y(C12)*Y(H1)*state.rho + -screened_rates(k_N13_to_p_C12_derived)*Y(N13)) + + (-screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho + screened_rates(k_p_O16_to_He4_N13_derived)*Y(O16)*Y(H1)*state.rho); + + ydot_nuc(O16) = + (screened_rates(k_He4_C12_to_O16)*Y(C12)*Y(He4)*state.rho + -screened_rates(k_O16_to_He4_C12_derived)*Y(O16)) + + (-screened_rates(k_He4_O16_to_Ne20)*Y(He4)*Y(O16)*state.rho + screened_rates(k_Ne20_to_He4_O16_derived)*Y(Ne20)) + + (screened_rates(k_He4_N13_to_p_O16)*Y(He4)*Y(N13)*state.rho + -screened_rates(k_p_O16_to_He4_N13_derived)*Y(O16)*Y(H1)*state.rho) + + -screened_rates(k_C12_O16_to_p_Al27)*Y(C12)*Y(O16)*state.rho + + -screened_rates(k_C12_O16_to_He4_Mg24)*Y(C12)*Y(O16)*state.rho + + -screened_rates(k_O16_O16_to_p_P31)*std::pow(Y(O16), 2)*state.rho + + -screened_rates(k_O16_O16_to_He4_Si28)*std::pow(Y(O16), 2)*state.rho + + -screened_rates(k_O16_O16_to_S32_modified)*std::pow(Y(O16), 2)*state.rho + + -screened_rates(k_C12_O16_to_Si28_modified)*Y(C12)*Y(O16)*state.rho; + + ydot_nuc(Ne20) = + (screened_rates(k_He4_O16_to_Ne20)*Y(He4)*Y(O16)*state.rho + -screened_rates(k_Ne20_to_He4_O16_derived)*Y(Ne20)) + + (-screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*Y(Ne20)*state.rho + screened_rates(k_Mg24_to_He4_Ne20_derived)*Y(Mg24)) + + 0.5*screened_rates(k_C12_C12_to_He4_Ne20)*std::pow(Y(C12), 2)*state.rho + + (screened_rates(k_p_Na23_to_He4_Ne20)*Y(Na23)*Y(H1)*state.rho + -screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(He4)*Y(Ne20)*state.rho); + + ydot_nuc(Na23) = + (-screened_rates(k_p_Na23_to_Mg24)*Y(Na23)*Y(H1)*state.rho + screened_rates(k_Mg24_to_p_Na23_derived)*Y(Mg24)) + + 0.5*screened_rates(k_C12_C12_to_p_Na23)*std::pow(Y(C12), 2)*state.rho + + (-screened_rates(k_p_Na23_to_He4_Ne20)*Y(Na23)*Y(H1)*state.rho + screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(He4)*Y(Ne20)*state.rho); + + ydot_nuc(Mg24) = + (screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*Y(Ne20)*state.rho + -screened_rates(k_Mg24_to_He4_Ne20_derived)*Y(Mg24)) + + (screened_rates(k_p_Na23_to_Mg24)*Y(Na23)*Y(H1)*state.rho + -screened_rates(k_Mg24_to_p_Na23_derived)*Y(Mg24)) + + (-screened_rates(k_He4_Mg24_to_Si28)*Y(He4)*Y(Mg24)*state.rho + screened_rates(k_Si28_to_He4_Mg24_derived)*Y(Si28)) + + screened_rates(k_C12_O16_to_He4_Mg24)*Y(C12)*Y(O16)*state.rho + + (screened_rates(k_p_Al27_to_He4_Mg24)*Y(Al27)*Y(H1)*state.rho + -screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(He4)*Y(Mg24)*state.rho) + + 0.5*screened_rates(k_C12_C12_to_Mg24_modified)*std::pow(Y(C12), 2)*state.rho; + + ydot_nuc(Al27) = + (-screened_rates(k_p_Al27_to_Si28)*Y(Al27)*Y(H1)*state.rho + screened_rates(k_Si28_to_p_Al27_derived)*Y(Si28)) + + screened_rates(k_C12_O16_to_p_Al27)*Y(C12)*Y(O16)*state.rho + + (-screened_rates(k_p_Al27_to_He4_Mg24)*Y(Al27)*Y(H1)*state.rho + screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(He4)*Y(Mg24)*state.rho); + + ydot_nuc(Si28) = + (screened_rates(k_He4_Mg24_to_Si28)*Y(He4)*Y(Mg24)*state.rho + -screened_rates(k_Si28_to_He4_Mg24_derived)*Y(Si28)) + + (screened_rates(k_p_Al27_to_Si28)*Y(Al27)*Y(H1)*state.rho + -screened_rates(k_Si28_to_p_Al27_derived)*Y(Si28)) + + (-screened_rates(k_He4_Si28_to_S32)*Y(He4)*Y(Si28)*state.rho + screened_rates(k_S32_to_He4_Si28_derived)*Y(S32)) + + 0.5*screened_rates(k_O16_O16_to_He4_Si28)*std::pow(Y(O16), 2)*state.rho + + (screened_rates(k_p_P31_to_He4_Si28)*Y(P31)*Y(H1)*state.rho + -screened_rates(k_He4_Si28_to_p_P31_derived)*Y(He4)*Y(Si28)*state.rho) + + screened_rates(k_C12_O16_to_Si28_modified)*Y(C12)*Y(O16)*state.rho; + + ydot_nuc(P31) = + (-screened_rates(k_p_P31_to_S32)*Y(P31)*Y(H1)*state.rho + screened_rates(k_S32_to_p_P31_derived)*Y(S32)) + + 0.5*screened_rates(k_O16_O16_to_p_P31)*std::pow(Y(O16), 2)*state.rho + + (-screened_rates(k_p_P31_to_He4_Si28)*Y(P31)*Y(H1)*state.rho + screened_rates(k_He4_Si28_to_p_P31_derived)*Y(He4)*Y(Si28)*state.rho); + + ydot_nuc(S32) = + (screened_rates(k_He4_Si28_to_S32)*Y(He4)*Y(Si28)*state.rho + -screened_rates(k_S32_to_He4_Si28_derived)*Y(S32)) + + (screened_rates(k_p_P31_to_S32)*Y(P31)*Y(H1)*state.rho + -screened_rates(k_S32_to_p_P31_derived)*Y(S32)) + + 0.5*screened_rates(k_O16_O16_to_S32_modified)*std::pow(Y(O16), 2)*state.rho + + (-screened_rates(k_S32_He4_to_Ar36_approx)*Y(He4)*Y(S32)*state.rho + screened_rates(k_Ar36_to_S32_He4_approx)*Y(Ar36)); + + ydot_nuc(Ar36) = + (screened_rates(k_S32_He4_to_Ar36_approx)*Y(He4)*Y(S32)*state.rho + -screened_rates(k_Ar36_to_S32_He4_approx)*Y(Ar36)) + + (-screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(Ar36)*Y(He4)*state.rho + screened_rates(k_Ca40_to_Ar36_He4_approx)*Y(Ca40)); + + ydot_nuc(Ca40) = + (screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(Ar36)*Y(He4)*state.rho + -screened_rates(k_Ca40_to_Ar36_He4_approx)*Y(Ca40)) + + (-screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(Ca40)*Y(He4)*state.rho + screened_rates(k_Ti44_to_Ca40_He4_approx)*Y(Ti44)); + + ydot_nuc(Ti44) = + (screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(Ca40)*Y(He4)*state.rho + -screened_rates(k_Ti44_to_Ca40_He4_approx)*Y(Ti44)) + + (-screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(He4)*Y(Ti44)*state.rho + screened_rates(k_Cr48_to_Ti44_He4_approx)*Y(Cr48)); + + ydot_nuc(Cr48) = + (screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(He4)*Y(Ti44)*state.rho + -screened_rates(k_Cr48_to_Ti44_He4_approx)*Y(Cr48)) + + (-screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(Cr48)*Y(He4)*state.rho + screened_rates(k_Fe52_to_Cr48_He4_approx)*Y(Fe52)); + + ydot_nuc(Fe52) = + (screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(Cr48)*Y(He4)*state.rho + -screened_rates(k_Fe52_to_Cr48_He4_approx)*Y(Fe52)) + + (-screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(Fe52)*Y(He4)*state.rho + screened_rates(k_Ni56_to_Fe52_He4_approx)*Y(Ni56)); + + ydot_nuc(Ni56) = + (screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(Fe52)*Y(He4)*state.rho + -screened_rates(k_Ni56_to_Fe52_He4_approx)*Y(Ni56)); + +} + + +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void actual_rhs (burn_t& state, Array1D& ydot) +{ + for (int i = 1; i <= neqs; ++i) { + ydot(i) = 0.0_rt; + } + + + // Set molar abundances + 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 + + Real enuc; + ener_gener_rate(ydot, enuc); + + // include any weak rate neutrino losses + enuc += rate_eval.enuc_weak; + + // Get the thermal neutrino losses + + 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 Array1D& Y, + const Array1D& screened_rates) +{ + + Real scratch; + + scratch = -screened_rates(k_p_Al27_to_He4_Mg24)*Y(Al27)*state.rho - screened_rates(k_p_Al27_to_Si28)*Y(Al27)*state.rho - screened_rates(k_p_C12_to_N13)*Y(C12)*state.rho - screened_rates(k_p_Na23_to_He4_Ne20)*Y(Na23)*state.rho - screened_rates(k_p_Na23_to_Mg24)*Y(Na23)*state.rho - screened_rates(k_p_O16_to_He4_N13_derived)*Y(O16)*state.rho - screened_rates(k_p_P31_to_He4_Si28)*Y(P31)*state.rho - screened_rates(k_p_P31_to_S32)*Y(P31)*state.rho; + jac.set(H1, H1, scratch); + + scratch = screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(Mg24)*state.rho + screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho + screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(Ne20)*state.rho + screened_rates(k_He4_Si28_to_p_P31_derived)*Y(Si28)*state.rho; + jac.set(H1, He4, scratch); + + scratch = 1.0*screened_rates(k_C12_C12_to_p_Na23)*Y(C12)*state.rho + screened_rates(k_C12_O16_to_p_Al27)*Y(O16)*state.rho - screened_rates(k_p_C12_to_N13)*Y(H1)*state.rho; + jac.set(H1, C12, scratch); + + scratch = screened_rates(k_He4_N13_to_p_O16)*Y(He4)*state.rho + screened_rates(k_N13_to_p_C12_derived); + jac.set(H1, N13, scratch); + + scratch = screened_rates(k_C12_O16_to_p_Al27)*Y(C12)*state.rho + 1.0*screened_rates(k_O16_O16_to_p_P31)*Y(O16)*state.rho - screened_rates(k_p_O16_to_He4_N13_derived)*Y(H1)*state.rho; + jac.set(H1, O16, scratch); + + scratch = screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(He4)*state.rho; + jac.set(H1, Ne20, scratch); + + scratch = -screened_rates(k_p_Na23_to_He4_Ne20)*Y(H1)*state.rho - screened_rates(k_p_Na23_to_Mg24)*Y(H1)*state.rho; + jac.set(H1, Na23, scratch); + + scratch = screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(He4)*state.rho + screened_rates(k_Mg24_to_p_Na23_derived); + jac.set(H1, Mg24, scratch); + + scratch = -screened_rates(k_p_Al27_to_He4_Mg24)*Y(H1)*state.rho - screened_rates(k_p_Al27_to_Si28)*Y(H1)*state.rho; + jac.set(H1, Al27, scratch); + + scratch = screened_rates(k_He4_Si28_to_p_P31_derived)*Y(He4)*state.rho + screened_rates(k_Si28_to_p_Al27_derived); + jac.set(H1, Si28, scratch); + + scratch = -screened_rates(k_p_P31_to_He4_Si28)*Y(H1)*state.rho - screened_rates(k_p_P31_to_S32)*Y(H1)*state.rho; + jac.set(H1, P31, scratch); + + scratch = screened_rates(k_S32_to_p_P31_derived); + jac.set(H1, S32, scratch); + + scratch = screened_rates(k_p_Al27_to_He4_Mg24)*Y(Al27)*state.rho + screened_rates(k_p_Na23_to_He4_Ne20)*Y(Na23)*state.rho + screened_rates(k_p_O16_to_He4_N13_derived)*Y(O16)*state.rho + screened_rates(k_p_P31_to_He4_Si28)*Y(P31)*state.rho; + jac.set(He4, H1, scratch); + + scratch = -screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(Ar36)*state.rho - screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(Ca40)*state.rho - screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(Cr48)*state.rho - screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(Fe52)*state.rho - screened_rates(k_He4_C12_to_O16)*Y(C12)*state.rho - 1.5*screened_rates(k_He4_He4_He4_to_C12)*std::pow(Y(He4), 2)*std::pow(state.rho, 2) - screened_rates(k_He4_Mg24_to_Si28)*Y(Mg24)*state.rho - screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(Mg24)*state.rho - screened_rates(k_He4_N13_to_p_O16)*Y(N13)*state.rho - screened_rates(k_He4_Ne20_to_Mg24)*Y(Ne20)*state.rho - screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(Ne20)*state.rho - screened_rates(k_He4_O16_to_Ne20)*Y(O16)*state.rho - screened_rates(k_He4_Si28_to_S32)*Y(Si28)*state.rho - screened_rates(k_He4_Si28_to_p_P31_derived)*Y(Si28)*state.rho - screened_rates(k_S32_He4_to_Ar36_approx)*Y(S32)*state.rho - screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(Ti44)*state.rho; + jac.set(He4, He4, scratch); + + scratch = 1.0*screened_rates(k_C12_C12_to_He4_Ne20)*Y(C12)*state.rho + screened_rates(k_C12_O16_to_He4_Mg24)*Y(O16)*state.rho + 3.0*screened_rates(k_C12_to_He4_He4_He4_derived) - 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_C12_O16_to_He4_Mg24)*Y(C12)*state.rho - screened_rates(k_He4_O16_to_Ne20)*Y(He4)*state.rho + 1.0*screened_rates(k_O16_O16_to_He4_Si28)*Y(O16)*state.rho + screened_rates(k_O16_to_He4_C12_derived) + screened_rates(k_p_O16_to_He4_N13_derived)*Y(H1)*state.rho; + jac.set(He4, O16, scratch); + + scratch = -screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*state.rho - screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(He4)*state.rho + screened_rates(k_Ne20_to_He4_O16_derived); + jac.set(He4, Ne20, scratch); + + scratch = screened_rates(k_p_Na23_to_He4_Ne20)*Y(H1)*state.rho; + jac.set(He4, Na23, scratch); + + scratch = -screened_rates(k_He4_Mg24_to_Si28)*Y(He4)*state.rho - screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(He4)*state.rho + screened_rates(k_Mg24_to_He4_Ne20_derived); + jac.set(He4, Mg24, scratch); + + scratch = screened_rates(k_p_Al27_to_He4_Mg24)*Y(H1)*state.rho; + jac.set(He4, Al27, scratch); + + scratch = -screened_rates(k_He4_Si28_to_S32)*Y(He4)*state.rho - screened_rates(k_He4_Si28_to_p_P31_derived)*Y(He4)*state.rho + screened_rates(k_Si28_to_He4_Mg24_derived); + jac.set(He4, Si28, scratch); + + scratch = screened_rates(k_p_P31_to_He4_Si28)*Y(H1)*state.rho; + jac.set(He4, P31, scratch); + + scratch = -screened_rates(k_S32_He4_to_Ar36_approx)*Y(He4)*state.rho + screened_rates(k_S32_to_He4_Si28_derived); + jac.set(He4, S32, scratch); + + scratch = -screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(He4)*state.rho + screened_rates(k_Ar36_to_S32_He4_approx); + jac.set(He4, Ar36, scratch); + + scratch = -screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(He4)*state.rho + screened_rates(k_Ca40_to_Ar36_He4_approx); + jac.set(He4, Ca40, scratch); + + scratch = -screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(He4)*state.rho + screened_rates(k_Ti44_to_Ca40_He4_approx); + jac.set(He4, Ti44, scratch); + + scratch = -screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(He4)*state.rho + screened_rates(k_Cr48_to_Ti44_He4_approx); + jac.set(He4, Cr48, scratch); + + scratch = -screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(He4)*state.rho + screened_rates(k_Fe52_to_Cr48_He4_approx); + jac.set(He4, Fe52, scratch); + + scratch = screened_rates(k_Ni56_to_Fe52_He4_approx); + jac.set(He4, Ni56, scratch); + + scratch = -screened_rates(k_p_C12_to_N13)*Y(C12)*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)*std::pow(Y(He4), 2)*std::pow(state.rho, 2); + jac.set(C12, He4, scratch); + + scratch = -2.0*screened_rates(k_C12_C12_to_He4_Ne20)*Y(C12)*state.rho - 2.0*screened_rates(k_C12_C12_to_Mg24_modified)*Y(C12)*state.rho - 2.0*screened_rates(k_C12_C12_to_p_Na23)*Y(C12)*state.rho - screened_rates(k_C12_O16_to_He4_Mg24)*Y(O16)*state.rho - screened_rates(k_C12_O16_to_Si28_modified)*Y(O16)*state.rho - screened_rates(k_C12_O16_to_p_Al27)*Y(O16)*state.rho - screened_rates(k_C12_to_He4_He4_He4_derived) - 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_N13_to_p_C12_derived); + jac.set(C12, N13, scratch); + + scratch = -screened_rates(k_C12_O16_to_He4_Mg24)*Y(C12)*state.rho - screened_rates(k_C12_O16_to_Si28_modified)*Y(C12)*state.rho - screened_rates(k_C12_O16_to_p_Al27)*Y(C12)*state.rho + screened_rates(k_O16_to_He4_C12_derived); + jac.set(C12, O16, scratch); + + scratch = screened_rates(k_p_C12_to_N13)*Y(C12)*state.rho + screened_rates(k_p_O16_to_He4_N13_derived)*Y(O16)*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_p_C12_derived); + jac.set(N13, N13, scratch); + + scratch = screened_rates(k_p_O16_to_He4_N13_derived)*Y(H1)*state.rho; + jac.set(N13, O16, scratch); + + scratch = -screened_rates(k_p_O16_to_He4_N13_derived)*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 - screened_rates(k_He4_O16_to_Ne20)*Y(O16)*state.rho; + jac.set(O16, He4, scratch); + + scratch = -screened_rates(k_C12_O16_to_He4_Mg24)*Y(O16)*state.rho - screened_rates(k_C12_O16_to_Si28_modified)*Y(O16)*state.rho - screened_rates(k_C12_O16_to_p_Al27)*Y(O16)*state.rho + 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_C12_O16_to_He4_Mg24)*Y(C12)*state.rho - screened_rates(k_C12_O16_to_Si28_modified)*Y(C12)*state.rho - screened_rates(k_C12_O16_to_p_Al27)*Y(C12)*state.rho - screened_rates(k_He4_O16_to_Ne20)*Y(He4)*state.rho - 2.0*screened_rates(k_O16_O16_to_He4_Si28)*Y(O16)*state.rho - 2.0*screened_rates(k_O16_O16_to_S32_modified)*Y(O16)*state.rho - 2.0*screened_rates(k_O16_O16_to_p_P31)*Y(O16)*state.rho - screened_rates(k_O16_to_He4_C12_derived) - screened_rates(k_p_O16_to_He4_N13_derived)*Y(H1)*state.rho; + jac.set(O16, O16, scratch); + + scratch = screened_rates(k_Ne20_to_He4_O16_derived); + jac.set(O16, Ne20, scratch); + + scratch = screened_rates(k_p_Na23_to_He4_Ne20)*Y(Na23)*state.rho; + jac.set(Ne20, H1, scratch); + + scratch = -screened_rates(k_He4_Ne20_to_Mg24)*Y(Ne20)*state.rho - screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(Ne20)*state.rho + screened_rates(k_He4_O16_to_Ne20)*Y(O16)*state.rho; + jac.set(Ne20, He4, scratch); + + scratch = 1.0*screened_rates(k_C12_C12_to_He4_Ne20)*Y(C12)*state.rho; + jac.set(Ne20, C12, scratch); + + scratch = screened_rates(k_He4_O16_to_Ne20)*Y(He4)*state.rho; + jac.set(Ne20, O16, scratch); + + scratch = -screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*state.rho - screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(He4)*state.rho - screened_rates(k_Ne20_to_He4_O16_derived); + jac.set(Ne20, Ne20, scratch); + + scratch = screened_rates(k_p_Na23_to_He4_Ne20)*Y(H1)*state.rho; + jac.set(Ne20, Na23, scratch); + + scratch = screened_rates(k_Mg24_to_He4_Ne20_derived); + jac.set(Ne20, Mg24, scratch); + + scratch = -screened_rates(k_p_Na23_to_He4_Ne20)*Y(Na23)*state.rho - screened_rates(k_p_Na23_to_Mg24)*Y(Na23)*state.rho; + jac.set(Na23, H1, scratch); + + scratch = screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(Ne20)*state.rho; + jac.set(Na23, He4, scratch); + + scratch = 1.0*screened_rates(k_C12_C12_to_p_Na23)*Y(C12)*state.rho; + jac.set(Na23, C12, scratch); + + scratch = screened_rates(k_He4_Ne20_to_p_Na23_derived)*Y(He4)*state.rho; + jac.set(Na23, Ne20, scratch); + + scratch = -screened_rates(k_p_Na23_to_He4_Ne20)*Y(H1)*state.rho - screened_rates(k_p_Na23_to_Mg24)*Y(H1)*state.rho; + jac.set(Na23, Na23, scratch); + + scratch = screened_rates(k_Mg24_to_p_Na23_derived); + jac.set(Na23, Mg24, scratch); + + scratch = screened_rates(k_p_Al27_to_He4_Mg24)*Y(Al27)*state.rho + screened_rates(k_p_Na23_to_Mg24)*Y(Na23)*state.rho; + jac.set(Mg24, H1, scratch); + + scratch = -screened_rates(k_He4_Mg24_to_Si28)*Y(Mg24)*state.rho - screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(Mg24)*state.rho + screened_rates(k_He4_Ne20_to_Mg24)*Y(Ne20)*state.rho; + jac.set(Mg24, He4, scratch); + + scratch = 1.0*screened_rates(k_C12_C12_to_Mg24_modified)*Y(C12)*state.rho + screened_rates(k_C12_O16_to_He4_Mg24)*Y(O16)*state.rho; + jac.set(Mg24, C12, scratch); + + scratch = screened_rates(k_C12_O16_to_He4_Mg24)*Y(C12)*state.rho; + jac.set(Mg24, O16, scratch); + + scratch = screened_rates(k_He4_Ne20_to_Mg24)*Y(He4)*state.rho; + jac.set(Mg24, Ne20, scratch); + + scratch = screened_rates(k_p_Na23_to_Mg24)*Y(H1)*state.rho; + jac.set(Mg24, Na23, scratch); + + scratch = -screened_rates(k_He4_Mg24_to_Si28)*Y(He4)*state.rho - screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(He4)*state.rho - screened_rates(k_Mg24_to_He4_Ne20_derived) - screened_rates(k_Mg24_to_p_Na23_derived); + jac.set(Mg24, Mg24, scratch); + + scratch = screened_rates(k_p_Al27_to_He4_Mg24)*Y(H1)*state.rho; + jac.set(Mg24, Al27, scratch); + + scratch = screened_rates(k_Si28_to_He4_Mg24_derived); + jac.set(Mg24, Si28, scratch); + + scratch = -screened_rates(k_p_Al27_to_He4_Mg24)*Y(Al27)*state.rho - screened_rates(k_p_Al27_to_Si28)*Y(Al27)*state.rho; + jac.set(Al27, H1, scratch); + + scratch = screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(Mg24)*state.rho; + jac.set(Al27, He4, scratch); + + scratch = screened_rates(k_C12_O16_to_p_Al27)*Y(O16)*state.rho; + jac.set(Al27, C12, scratch); + + scratch = screened_rates(k_C12_O16_to_p_Al27)*Y(C12)*state.rho; + jac.set(Al27, O16, scratch); + + scratch = screened_rates(k_He4_Mg24_to_p_Al27_derived)*Y(He4)*state.rho; + jac.set(Al27, Mg24, scratch); + + scratch = -screened_rates(k_p_Al27_to_He4_Mg24)*Y(H1)*state.rho - screened_rates(k_p_Al27_to_Si28)*Y(H1)*state.rho; + jac.set(Al27, Al27, scratch); + + scratch = screened_rates(k_Si28_to_p_Al27_derived); + jac.set(Al27, Si28, scratch); + + scratch = screened_rates(k_p_Al27_to_Si28)*Y(Al27)*state.rho + screened_rates(k_p_P31_to_He4_Si28)*Y(P31)*state.rho; + jac.set(Si28, H1, scratch); + + scratch = screened_rates(k_He4_Mg24_to_Si28)*Y(Mg24)*state.rho - screened_rates(k_He4_Si28_to_S32)*Y(Si28)*state.rho - screened_rates(k_He4_Si28_to_p_P31_derived)*Y(Si28)*state.rho; + jac.set(Si28, He4, scratch); + + scratch = screened_rates(k_C12_O16_to_Si28_modified)*Y(O16)*state.rho; + jac.set(Si28, C12, scratch); + + scratch = screened_rates(k_C12_O16_to_Si28_modified)*Y(C12)*state.rho + 1.0*screened_rates(k_O16_O16_to_He4_Si28)*Y(O16)*state.rho; + jac.set(Si28, O16, scratch); + + scratch = screened_rates(k_He4_Mg24_to_Si28)*Y(He4)*state.rho; + jac.set(Si28, Mg24, scratch); + + scratch = screened_rates(k_p_Al27_to_Si28)*Y(H1)*state.rho; + jac.set(Si28, Al27, scratch); + + scratch = -screened_rates(k_He4_Si28_to_S32)*Y(He4)*state.rho - screened_rates(k_He4_Si28_to_p_P31_derived)*Y(He4)*state.rho - screened_rates(k_Si28_to_He4_Mg24_derived) - screened_rates(k_Si28_to_p_Al27_derived); + jac.set(Si28, Si28, scratch); + + scratch = screened_rates(k_p_P31_to_He4_Si28)*Y(H1)*state.rho; + jac.set(Si28, P31, scratch); + + scratch = screened_rates(k_S32_to_He4_Si28_derived); + jac.set(Si28, S32, scratch); + + scratch = -screened_rates(k_p_P31_to_He4_Si28)*Y(P31)*state.rho - screened_rates(k_p_P31_to_S32)*Y(P31)*state.rho; + jac.set(P31, H1, scratch); + + scratch = screened_rates(k_He4_Si28_to_p_P31_derived)*Y(Si28)*state.rho; + jac.set(P31, He4, scratch); + + scratch = 1.0*screened_rates(k_O16_O16_to_p_P31)*Y(O16)*state.rho; + jac.set(P31, O16, scratch); + + scratch = screened_rates(k_He4_Si28_to_p_P31_derived)*Y(He4)*state.rho; + jac.set(P31, Si28, scratch); + + scratch = -screened_rates(k_p_P31_to_He4_Si28)*Y(H1)*state.rho - screened_rates(k_p_P31_to_S32)*Y(H1)*state.rho; + jac.set(P31, P31, scratch); + + scratch = screened_rates(k_S32_to_p_P31_derived); + jac.set(P31, S32, scratch); + + scratch = screened_rates(k_p_P31_to_S32)*Y(P31)*state.rho; + jac.set(S32, H1, scratch); + + scratch = screened_rates(k_He4_Si28_to_S32)*Y(Si28)*state.rho - screened_rates(k_S32_He4_to_Ar36_approx)*Y(S32)*state.rho; + jac.set(S32, He4, scratch); + + scratch = 1.0*screened_rates(k_O16_O16_to_S32_modified)*Y(O16)*state.rho; + jac.set(S32, O16, scratch); + + scratch = screened_rates(k_He4_Si28_to_S32)*Y(He4)*state.rho; + jac.set(S32, Si28, scratch); + + scratch = screened_rates(k_p_P31_to_S32)*Y(H1)*state.rho; + jac.set(S32, P31, scratch); + + scratch = -screened_rates(k_S32_He4_to_Ar36_approx)*Y(He4)*state.rho - screened_rates(k_S32_to_He4_Si28_derived) - screened_rates(k_S32_to_p_P31_derived); + jac.set(S32, S32, scratch); + + scratch = screened_rates(k_Ar36_to_S32_He4_approx); + jac.set(S32, Ar36, scratch); + + scratch = -screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(Ar36)*state.rho + screened_rates(k_S32_He4_to_Ar36_approx)*Y(S32)*state.rho; + jac.set(Ar36, He4, scratch); + + scratch = screened_rates(k_S32_He4_to_Ar36_approx)*Y(He4)*state.rho; + jac.set(Ar36, S32, scratch); + + scratch = -screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(He4)*state.rho - screened_rates(k_Ar36_to_S32_He4_approx); + jac.set(Ar36, Ar36, scratch); + + scratch = screened_rates(k_Ca40_to_Ar36_He4_approx); + jac.set(Ar36, Ca40, scratch); + + scratch = screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(Ar36)*state.rho - screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(Ca40)*state.rho; + jac.set(Ca40, He4, scratch); + + scratch = screened_rates(k_Ar36_He4_to_Ca40_approx)*Y(He4)*state.rho; + jac.set(Ca40, Ar36, scratch); + + scratch = -screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(He4)*state.rho - screened_rates(k_Ca40_to_Ar36_He4_approx); + jac.set(Ca40, Ca40, scratch); + + scratch = screened_rates(k_Ti44_to_Ca40_He4_approx); + jac.set(Ca40, Ti44, scratch); + + scratch = screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(Ca40)*state.rho - screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(Ti44)*state.rho; + jac.set(Ti44, He4, scratch); + + scratch = screened_rates(k_Ca40_He4_to_Ti44_approx)*Y(He4)*state.rho; + jac.set(Ti44, Ca40, scratch); + + scratch = -screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(He4)*state.rho - screened_rates(k_Ti44_to_Ca40_He4_approx); + jac.set(Ti44, Ti44, scratch); + + scratch = screened_rates(k_Cr48_to_Ti44_He4_approx); + jac.set(Ti44, Cr48, scratch); + + scratch = -screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(Cr48)*state.rho + screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(Ti44)*state.rho; + jac.set(Cr48, He4, scratch); + + scratch = screened_rates(k_Ti44_He4_to_Cr48_approx)*Y(He4)*state.rho; + jac.set(Cr48, Ti44, scratch); + + scratch = -screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(He4)*state.rho - screened_rates(k_Cr48_to_Ti44_He4_approx); + jac.set(Cr48, Cr48, scratch); + + scratch = screened_rates(k_Fe52_to_Cr48_He4_approx); + jac.set(Cr48, Fe52, scratch); + + scratch = screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(Cr48)*state.rho - screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(Fe52)*state.rho; + jac.set(Fe52, He4, scratch); + + scratch = screened_rates(k_Cr48_He4_to_Fe52_approx)*Y(He4)*state.rho; + jac.set(Fe52, Cr48, scratch); + + scratch = -screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(He4)*state.rho - screened_rates(k_Fe52_to_Cr48_He4_approx); + jac.set(Fe52, Fe52, scratch); + + scratch = screened_rates(k_Ni56_to_Fe52_He4_approx); + jac.set(Fe52, Ni56, scratch); + + scratch = screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(Fe52)*state.rho; + jac.set(Ni56, He4, scratch); + + scratch = screened_rates(k_Fe52_He4_to_Ni56_approx)*Y(He4)*state.rho; + jac.set(Ni56, Fe52, scratch); + + scratch = -screened_rates(k_Ni56_to_Fe52_He4_approx); + jac.set(Ni56, Ni56, scratch); + + +} + + + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void actual_jac(const burn_t& state, MatrixType& jac) +{ + + // Set molar abundances + 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) -> Real { return jac.get(i, j); }; + ener_gener_rate(jac_slice_2, jac(net_ienuc,j)); + } + + // Account for the thermal neutrino losses + + 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) { + 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. + + 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 + + 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/subch_base/inputs.burn_cell.VODE b/networks/subch_base/inputs.burn_cell.VODE new file mode 100644 index 0000000000..97d030b678 --- /dev/null +++ b/networks/subch_base/inputs.burn_cell.VODE @@ -0,0 +1,44 @@ +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 +unit_test.X18 = 0.0 diff --git a/networks/subch_base/partition_functions.H b/networks/subch_base/partition_functions.H new file mode 100644 index 0000000000..109f71d59a --- /dev/null +++ b/networks/subch_base/partition_functions.H @@ -0,0 +1,650 @@ +#ifndef PARTITION_FUNCTIONS_H +#define PARTITION_FUNCTIONS_H + +#include +#include + +#include +#include +#include + +using namespace amrex; +using namespace Species; + +namespace part_fun { + + constexpr int npts_1 = 72; + + // this is T9 + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real temp_array_1[npts_1] = { + 0.01, 0.15, 0.2, 0.3, 0.4, + 0.5, 0.6, 0.7, 0.8, 0.9, + 1.0, 1.5, 2.0, 2.5, 3.0, + 3.5, 4.0, 4.5, 5.0, 6.0, + 7.0, 8.0, 9.0, 10.0, 12.0, + 14.0, 16.0, 18.0, 20.0, 22.0, + 24.0, 26.0, 28.0, 30.0, 35.0, + 40.0, 45.0, 50.0, 55.0, 60.0, + 65.0, 70.0, 75.0, 80.0, 85.0, + 90.0, 95.0, 100.0, 105.0, 110.0, + 115.0, 120.0, 125.0, 130.0, 135.0, + 140.0, 145.0, 150.0, 155.0, 160.0, + 165.0, 170.0, 175.0, 180.0, 190.0, + 200.0, 210.0, 220.0, 230.0, 240.0, + 250.0, 275.0, + }; + + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real O16_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.012837224705172217, + 0.03742649794062367, 0.07188200730612536, 0.1205739312058499, 0.1846914308175988, 0.26245108973042947, + 0.3463529744506387, 0.437750562820388, 0.534026106056135, 0.6344772701607315, 0.8981764834976765, + 1.1760912590556813, 1.4668676203541096, 1.7641761323903307, 2.0644579892269186, 2.367355921026019, + 2.667452952889954, 2.9656719712201065, 3.2624510897304293, 3.555094448578319, 3.845098040014257, + 4.133538908370218, 4.419955748489758, 4.704150516839799, 4.986771734266245, 5.267171728403014, + 5.547774705387822, 5.8267225201689925, 6.103803720955957, 6.380211241711606, 6.6551384348113825, + 6.929929560084588, 7.204119982655925, 7.477121254719663, 7.748962861256161, 8.021189299069938, + 8.292256071356476, 8.562292864456476, 8.832508912706237, 9.100370545117563, 9.640481436970422, + 10.178976947293169, 10.714329759745233, 11.250420002308894, 11.785329835010767, 12.320146286111054, + 12.856124444242301, 14.195899652409233, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Ne20_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 6.948656121358244e-06, 0.00016586881316040883, 0.0011034421778731533, 0.003892457497077877, + 0.00954097493969645, 0.01859524021829981, 0.03107544483336982, 0.04661767038571622, 0.0846241727916796, + 0.12822183093465686, 0.174311933665943, 0.22124805254602342, 0.2683385291343481, 0.36172783601759284, + 0.456366033129043, 0.5514499979728752, 0.6483600109809317, 0.7466341989375788, 0.8481891169913987, + 0.9532763366673044, 1.0644579892269186, 1.1789769472931695, 1.3031960574204888, 1.6434526764861874, + 2.0170333392987803, 2.4099331233312946, 2.8068580295188172, 3.2013971243204513, 3.5899496013257077, + 3.9731278535996988, 4.352182518111363, 4.725911632295048, 5.096910013008056, 5.465382851448418, + 5.830588668685144, 6.193124598354461, 6.556302500767288, 6.916980047320382, 7.276461804173244, + 7.6344772701607315, 7.991669007379948, 8.34830486304816, 8.703291378118662, 9.056904851336473, + 9.411619705963231, 9.763427993562937, 10.117271295655764, 10.46686762035411, 10.818225893613956, + 11.170261715394957, 11.519827993775719, 11.869231719730976, 12.217483944213907, 12.916453948549925, + 13.613841821876068, 14.3096301674259, 15.004321373782643, 15.702430536445526, 16.399673721481037, + 17.096910013008056, 18.838849090737256, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Na23_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 1.7371744532199383e-06, + 2.3885539658322847e-05, 0.00013113713282427166, 0.0004423207528904243, 0.0010999766245234136, 0.002232173197636284, + 0.003929471989446119, 0.021128907257497758, 0.0479649055541949, 0.07726249885377771, 0.10525805048344757, + 0.13079227003361296, 0.15390201926318714, 0.17503899265296466, 0.19472325248715508, 0.23147162936712465, + 0.26668504599022796, 0.3016913566252569, 0.33713446730536967, 0.37335950050705796, 0.4487063199050799, + 0.5314789170422551, 0.6211762817750351, 0.7218106152125465, 0.8344207036815325, 0.9590413923210935, + 1.0934216851622351, 1.2405492482825997, 1.3926969532596658, 1.5514499979728753, 1.9628426812012425, + 2.383815365980431, 2.803457115648414, 3.220108088040055, 3.6344772701607315, 4.045322978786658, + 4.453318340047038, 4.857935264719429, 5.26245108973043, 5.664641975556125, 6.064457989226918, + 6.466867620354109, 6.867467487859051, 7.267171728403014, 7.666517980554881, 8.064457989226918, + 8.463892988985908, 8.861534410859038, 9.260071387985075, 9.656098202012831, 10.05307844348342, + 10.450249108319362, 10.846337112129806, 11.243038048686294, 11.638489256954637, 12.03342375548695, + 12.429752280002408, 12.826074802700827, 13.222716471147583, 13.6170003411209, 14.40823996531185, + 15.20139712432045, 15.993876914941211, 16.787460474518415, 17.582063362911708, 18.378397900948137, + 19.17609125905568, 21.173186268412273, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Mg24_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 4.342942647204277e-07, 5.471765757979972e-05, 0.0007714899373308071, 0.0037633124724497633, 0.010764115210255056, + 0.022625058328435317, 0.039160607597355665, 0.05951911533271758, 0.08262238957783377, 0.13324118689139802, + 0.185518640557017, 0.2370005304649223, 0.2870228837145503, 0.3357157930198095, 0.43136376415898736, + 0.5263392773898441, 0.6253124509616739, 0.7307822756663892, 0.8463371121298052, 0.9749719942980689, + 1.1172712956557642, 1.2741578492636798, 1.4424797690644486, 1.6232492903979006, 2.103803720955957, + 2.598790506763115, 3.089905111439398, 3.577491799837225, 4.05307844348342, 4.52244423350632, + 4.984527313343793, 5.440909082065217, 5.894869656745253, 6.344392273685111, 6.791690649020118, + 7.235528446907549, 7.6785183790401135, 8.12057393120585, 8.558708570533165, 8.99563519459755, + 9.431363764158988, 9.866287339084195, 10.301029995663981, 10.732393759822969, 11.164352855784436, + 11.594392550375426, 12.02530586526477, 12.453318340047037, 12.881384656770573, 13.3096301674259, + 13.736396502276643, 14.161368002234974, 14.588831725594208, 15.012837224705173, 15.86569605991607, + 16.715167357848458, 17.56466606425209, 18.413299764081252, 19.26245108973043, 20.113943352306837, + 20.96284268120124, 23.089905111439396, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Al27_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 8.685880952436747e-07, 3.4743419578801875e-06, + 1.0422942490878872e-05, 0.00032429686817590634, 0.0018833542475028369, 0.005477808032249925, 0.011239204769804155, + 0.01890428637893266, 0.028126564553716336, 0.03862016194970278, 0.05018673657450416, 0.07608019569340022, + 0.10530099179798431, 0.13774106877747655, 0.1734986149135784, 0.21278880583973628, 0.30319605742048883, + 0.4099331233312945, 0.5352941200427705, 0.6794278966121189, 0.8394780473741984, 1.0128372247051722, + 1.1958996524092338, 1.3873898263387294, 1.5843312243675307, 1.783903579272735, 2.287801729930226, + 2.7944880466591697, 3.296665190261531, 3.7944880466591697, 4.2878017299302265, 4.779596491257824, + 5.269512944217916, 5.7558748556724915, 6.2405492482825995, 6.725094521081469, 7.209515014542631, + 7.691081492122969, 8.173186268412275, 8.653212513775344, 9.133538908370218, 9.611723308007342, + 10.089905111439398, 10.568201724066995, 11.045322978786658, 11.521138083704036, 11.997386384397313, + 12.472756449317213, 12.947923619831727, 13.423245873936807, 13.89707700320942, 14.371067862271737, + 14.845098040014257, 15.320146286111054, 15.79309160017658, 16.267171728403014, 17.214843848047696, + 18.161368002234976, 19.110589710299248, 20.060697840353612, 21.012837224705173, 21.96284268120124, + 22.915927211697117, 25.305351369446623, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Si28_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 2.1714669808675565e-06, 7.12184552784347e-05, 0.0005624812393818785, 0.002223099674110693, + 0.0059171580771474625, 0.012282407118825528, 0.02157709561709228, 0.03370716078346824, 0.06502557053071237, + 0.1027522772573885, 0.14387160800291654, 0.1866035043986153, 0.2302807913268337, 0.3222192947339193, + 0.42324587393680785, 0.541579243946581, 0.6839471307515121, 0.8518696007297664, 1.041392685158225, + 1.250420002308894, 1.4727564493172123, 1.7024305364455252, 1.9375178920173466, 2.531478917042255, + 3.12057393120585, 3.7024305364455254, 4.271841606536499, 4.834420703681532, 5.389166084364533, + 5.937517892017347, 6.481442628502305, 7.021189299069938, 7.557507201905658, 8.089905111439398, + 8.622214022966295, 9.14921911265538, 9.675778341674086, 10.198657086954423, 10.721810615212547, + 11.2405492482826, 11.75966784468963, 12.276461804173245, 12.791690649020119, 13.305351369446624, + 13.818225893613956, 14.330413773349191, 14.840733234611807, 15.350248018334163, 15.85913829729453, + 16.367355921026018, 16.8750612633917, 17.38201704257487, 17.88874096068289, 18.90036712865647, + 19.911157608739977, 20.921166050637737, 21.9304395947667, 22.93951925261862, 23.948901760970212, + 24.958563883221967, 27.48572142648158, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real P31_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 4.342942647204277e-07, 4.820401221806151e-05, 0.0005624812393818785, 0.002468018295084159, 0.006670091319158333, + 0.013688955408210905, 0.023674199668938998, 0.03655105068012579, 0.05215275629691826, 0.09085986215557586, + 0.13887811232360858, 0.19608052467040618, 0.26289299085539924, 0.33982852740425823, 0.5237464668115644, + 0.7419390777291989, 0.9827233876685453, 1.235528446907549, 1.4899584794248346, 1.7442929831226763, + 1.9960736544852753, 2.24551266781415, 2.4913616938342726, 2.733999286538387, 3.330413773349191, + 3.9132839017604186, 4.48572142648158, 5.049218022670182, 5.608526033577194, 6.164352855784437, + 6.714329759745233, 7.264817823009537, 7.812913356642856, 8.359835482339887, 8.90687353472207, + 9.453318340047037, 9.997823080745725, 10.54282542695918, 11.086359830674748, 11.629409599102718, + 12.170261715394957, 12.712649701627212, 13.255272505103306, 13.79448804665917, 14.334453751150932, + 14.874481817699467, 15.414973347970818, 15.953276336667304, 16.492760389026838, 17.029383777685208, + 17.570542939881896, 18.10720996964787, 18.64738297011462, 19.187520720836464, 20.264817823009537, + 21.342422680822207, 22.42160392686983, 23.503790683057183, 24.5854607295085, 25.66931688056611, + 26.75511226639507, 29.477121254719663, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real S32_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 5.211502513843472e-06, 6.948155872801059e-05, 0.0003893875360542875, + 0.001336870159627728, 0.003378232401258555, 0.006963377556787149, 0.012456734172197398, 0.03011415790845077, + 0.057484285853877215, 0.0950053699501746, 0.14295136988131382, 0.20165707691270435, 0.3521825181113625, + 0.5502283530550941, 0.787460474518415, 1.0569048513364727, 1.3404441148401183, 1.631443769013172, + 1.92272545799326, 2.2121876044039577, 2.4955443375464483, 2.7737864449811935, 3.44870631990508, + 4.096910013008056, 4.726727209026572, 5.3404441148401185, 5.944975908412048, 6.541579243946581, + 7.133538908370218, 7.720985744153739, 8.305351369446624, 8.888740960682892, 9.469822015978163, + 10.049218022670182, 10.628388930050312, 11.20682587603185, 11.78175537465247, 12.356025857193123, + 12.9304395947667, 13.502427119984432, 14.075546961392531, 14.645422269349092, 15.214843848047698, + 15.783903579272735, 16.352182518111363, 16.920123326290724, 17.487138375477187, 18.053078443483418, + 18.621176281775035, 19.187520720836464, 19.753583058892907, 20.318063334962762, 21.450249108319362, + 22.580924975675618, 23.71264970162721, 24.84385542262316, 25.976808337338067, 27.110589710299248, + 28.24551266781415, 31.08635983067475, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Cl35_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 1.8239985202970884e-05, 0.00020710907627919203, 0.0009431313908907785, 0.002698987769012708, + 0.005906875936599731, 0.010907713111778477, 0.017957319425972694, 0.027253766962590423, 0.0532486689285615, + 0.09021853774459236, 0.13964204799692437, 0.20296975189964023, 0.28111453407611076, 0.48000694295715063, + 0.7234556720351858, 0.9934362304976116, 1.2741578492636798, 1.5587085705331658, 1.841984804590114, + 2.123851640967086, 2.401400540781544, 2.678518379040114, 2.951823035315912, 3.6263403673750423, + 4.2878017299302265, 4.942008053022313, 5.588831725594207, 6.230448921378274, 6.870988813760575, + 7.509202522331103, 8.146128035678238, 8.781036938621131, 9.414973347970818, 10.049218022670182, + 10.681241237375588, 11.313867220369154, 11.943988875073773, 12.574031267727719, 13.204119982655925, + 13.831229693867064, 14.457881896733992, 15.086359830674748, 15.710963118995275, 16.33645973384853, + 16.96189547366785, 17.586587304671756, 18.212187604403958, 18.835056101720117, 19.45939248775923, + 20.08278537031645, 20.705863712283918, 21.33041377334919, 21.95375969173323, 23.20139712432045, + 24.450249108319362, 25.699837725867244, 26.950364854376122, 28.20139712432045, 29.456366033129044, + 30.71264970162721, 33.862131379313034, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Ar36_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 4.342942647204277e-07, 2.3451268844214655e-05, 0.00023141729162330258, 0.0010622869460975197, + 0.0031540913067783544, 0.007135153007315866, 0.013474284663478431, 0.02245187936733961, 0.048771089883939175, + 0.08643600351808534, 0.13560900039779808, 0.1965840257248699, 0.2696980636423851, 0.45331834004703764, + 0.6848453616444125, 0.9585638832219674, 1.2624510897304295, 1.5809249756756194, 1.9057958803678685, + 2.230448921378274, 2.550228353055094, 2.8662873390841948, 3.1760912590556813, 3.929418925714293, + 4.657055852857104, 5.365487984890899, 6.060697840353612, 6.746634198937579, 7.426511261364575, + 8.100370545117563, 8.773054693364262, 9.442479769064448, 10.11058971029925, 10.77451696572855, + 11.437750562820387, 12.100370545117563, 12.758911892397974, 13.41664050733828, 14.071882007306126, + 14.727541257028557, 15.38201704257487, 16.03342375548695, 16.684845361644413, 17.33445375115093, + 17.983626287124533, 18.63144376901317, 19.27875360095283, 19.92582757462474, 20.57170883180869, + 21.217483944213907, 21.863322860120455, 22.50785587169583, 23.152288344383056, 24.440909082065218, + 25.72916478969277, 27.01703333929878, 28.305351369446623, 29.595496221825574, 30.885926339801433, + 32.17897694729317, 35.41329976408125, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real K39_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 3.908632748276029e-06, 3.4307908925770636e-05, + 0.00016282990201490303, 0.0005394928156396339, 0.0014074368520356395, 0.0031075244141559894, 0.010846721573671135, + 0.028297088943748088, 0.06095682921468604, 0.11414775667614005, 0.1912997955319451, 0.4132997640812518, + 0.7015679850559274, 1.0170333392987803, 1.3384564936046048, 1.6599162000698502, 1.9772662124272926, + 2.292256071356476, 2.6020599913279625, 2.910090545594068, 3.214843848047698, 3.9684829485539352, + 4.710963118995275, 5.444044795918076, 6.173186268412274, 6.897627091290442, 7.619093330626742, + 8.338456493604605, 9.056904851336473, 9.771587480881255, 10.48572142648158, 11.198657086954423, + 11.907948521612273, 12.6170003411209, 13.324282455297693, 14.02938377768521, 14.733999286538387, + 15.437750562820389, 16.139879086401237, 16.839478047374197, 17.539076098792776, 18.238046103128795, + 18.936513742478894, 19.633468455579585, 20.33041377334919, 21.02530586526477, 21.723455672035186, + 22.418301291319747, 23.113943352306837, 23.809559714635267, 24.505149978319906, 25.89542254603941, + 27.285557309007775, 28.678518379040113, 30.071882007306126, 31.465382851448418, 32.860936620700095, + 34.25767857486918, 37.761927838420526, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Ca40_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 3.4743419578801875e-06, + 2.6056887215373325e-05, 0.00012419046343446514, 0.0004254001802063995, 0.0011532564515138494, 0.005324252203746658, + 0.016451245325404363, 0.03938040551055626, 0.07909980819723089, 0.13972800117379408, 0.33041377334919086, + 0.6063813651106049, 0.9385197251764918, 1.2988530764097066, 1.6693168805661123, 2.037426497940624, + 2.403120521175818, 2.761927838420529, 3.113943352306837, 3.459392487759231, 4.301029995663981, + 5.117271295655764, 5.9148718175400505, 6.701567985055927, 7.478566495593843, 8.250420002308894, + 9.01703333929878, 9.781036938621131, 10.540329474790873, 11.296665190261532, 12.049218022670182, + 12.801403710017356, 13.549003262025789, 14.294466226161592, 15.037426497940624, 15.779596491257825, + 16.518513939877888, 17.255272505103306, 17.99211148778695, 18.72591163229505, 19.45939248775923, + 20.19033169817029, 20.920645001406786, 21.650307523131936, 22.378397900948137, 23.10720996964787, + 23.832508912706235, 24.558708570533167, 25.285557309007775, 26.008600171761916, 27.45939248775923, + 28.907948521612273, 30.356025857193124, 31.804820678721164, 33.25285303097989, 34.704150516839796, + 36.15533603746506, 39.78816837114117, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Sc43_pf_array[npts_1] = { + 0.0, 1.7371744532199383e-06, 3.2136602621167924e-05, 0.0006088881229004689, 0.0026394223512168323, + 0.006348788305828209, 0.011375876688411647, 0.017242084547645732, 0.02355944464942603, 0.03006796257543875, + 0.03661053325876141, 0.06810122175372875, 0.09804672309111766, 0.12848424511267922, 0.16058766813472455, + 0.1946644458530261, 0.23055748142930874, 0.26792627543589265, 0.3064134462100847, 0.3856843680943845, + 0.4672642331672854, 0.5514418243762168, 0.6393550853495756, 0.732465412501299, 0.9380190974762103, + 1.1760912590556813, 1.4456042032735976, 1.7371926427047373, 2.0453229787866576, 2.359835482339888, + 2.678518379040114, 3.0, 3.322219294733919, 3.6424645202421213, 4.439332693830263, + 5.230448921378274, 6.017033339298781, 6.8020892578817325, 7.585460729508501, 8.36735592102602, + 9.14921911265538, 9.929418925714293, 10.710117365111817, 11.489958479424836, 12.267171728403014, + 13.045322978786658, 13.822168079368018, 14.597695185925513, 15.371067862271737, 16.146128035678238, + 16.916453948549925, 17.687528961214635, 18.45788189673399, 19.227886704613674, 19.99694924849538, + 20.76492298464989, 21.532754378992497, 22.30102999566398, 23.068185861746162, 23.835690571492425, + 24.602059991327963, 25.369215857410143, 26.136720567156406, 26.903632516084237, 28.439332693830263, + 29.97497199429807, 31.511883360978874, 33.05307844348342, 34.59217675739587, 36.13672056715641, + 37.68214507637383, 41.55870857053316, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Ti44_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 4.342942647204277e-07, 1.7371744532199383e-06, + 7.382943437485089e-06, 0.0004987179011085028, 0.004043078170724821, 0.01413521502778782, 0.032426549056877405, + 0.05856115101668825, 0.09131586357749837, 0.1294359425571275, 0.17190802974603506, 0.2667731684215763, + 0.37035022176288673, 0.47788465213962983, 0.5860935485551829, 0.693748838923791, 0.9116901587538612, + 1.1522883443830565, 1.4409090820652177, 1.7788744720027396, 2.1522883443830563, 2.5415792439465807, + 2.9334872878487053, 3.322219294733919, 3.7041505168397992, 4.079181246047625, 4.996073654485276, + 5.885361220031512, 6.757396028793024, 7.619093330626742, 8.472756449317213, 9.32221929473392, + 10.167317334748176, 11.008600171761918, 11.85003325768977, 12.687528961214634, 13.52244423350632, + 14.354108439147401, 15.1846914308176, 16.012837224705173, 16.836956737059552, 17.65991620006985, + 18.481442628502304, 19.298853076409706, 20.117271295655765, 20.9329808219232, 21.746634198937578, + 22.559906625036113, 23.371067862271737, 24.181843587944773, 24.991226075692495, 25.799340549453582, + 26.60745502321467, 27.414973347970818, 28.220108088040057, 29.02530586526477, 30.63748972951251, + 32.247973266361804, 33.8561244442423, 35.46538285144842, 37.07554696139253, 38.68484536164441, + 40.29666519026153, 44.33041377334919, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real V47_pf_array[npts_1] = { + 2.518834949526704e-05, 0.0007584840322833457, 0.004226764680268442, 0.024475815916759104, 0.05998274311239668, + 0.10280266491559079, 0.14672973694476377, 0.1885209834473098, 0.22688178294786615, 0.2615226538586488, + 0.29260868165003595, 0.4071409645052156, 0.48021742410342627, 0.5329079468954852, 0.5750746363992424, + 0.6115960803783954, 0.6450760714077263, 0.6770396273057074, 0.708482088001612, 0.7725618227871047, + 0.8417322779915452, 0.9194240819892174, 1.0083997539725875, 1.110602503281611, 1.3560258571931227, + 1.651278013998144, 1.9813655090785445, 2.330413773349191, 2.6884198220027105, 3.0492180226701815, + 3.41161970596323, 3.7708520116421442, 4.127104798364807, 4.484299839346786, 5.365487984890899, + 6.238046103128795, 7.103803720955957, 7.967547976218862, 8.830588668685145, 9.69460519893357, + 10.557507201905658, 11.421603926869832, 12.285557309007773, 13.146128035678238, 14.008600171761918, + 14.869231719730976, 15.728353782021228, 16.586587304671756, 17.442479769064448, 18.298853076409706, + 19.152288344383056, 20.00432137378264, 20.85793526471943, 21.70926996097583, 22.559906625036113, + 23.409933123331296, 24.260071387985075, 25.10720996964787, 25.956648579205204, 26.804820678721164, + 27.652246341003323, 28.50105926221775, 29.34830486304816, 30.195899652409235, 31.891537457672566, + 33.588831725594204, 35.28555730900777, 36.985875357308394, 38.68752896121463, 40.39093510710338, + 42.096910013008056, 46.372912002970104, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Cr48_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 8.685880952436747e-07, 8.251516766996927e-06, 3.951899976600419e-05, 0.00013330794422173613, + 0.00035120219371925, 0.006401856055765157, 0.02685304570895992, 0.06215311825135839, 0.10696594975266842, + 0.15598699109465686, 0.205815844445829, 0.25471214514215257, 0.30198352738731143, 0.39152612205819926, + 0.47640596203905256, 0.5602400543128645, 0.6474755901642433, 0.7433846322638775, 0.983175072037813, + 1.3096301674258988, 1.7067177823367587, 2.1398790864012365, 2.577491799837225, 3.012837224705172, + 3.437750562820388, 3.8549130223078554, 4.264817823009537, 4.666517980554881, 5.648360010980932, + 6.606381365110605, 7.550228353055094, 8.484299839346786, 9.414973347970818, 10.340444114840118, + 11.264817823009537, 12.1846914308176, 13.103803720955957, 14.021189299069938, 14.935003151453655, + 15.846337112129806, 16.75511226639507, 17.66181268553726, 18.565847818673518, 19.468347330412158, + 20.369215857410143, 21.267171728403014, 22.161368002234976, 23.056904851336473, 23.94939000664491, + 24.840733234611807, 25.73078227566639, 26.619093330626743, 27.50785587169583, 28.394451680826215, + 29.281033367247726, 30.164352855784436, 31.049218022670182, 31.934498451243567, 33.70156798505593, + 35.46834733041216, 37.23299611039215, 38.99913054128737, 40.764922984649886, 42.5327543789925, + 44.30102999566398, 48.727541257028555, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Mn51_pf_array[npts_1] = { + 0.0, 0.0, 4.342942647204277e-07, 6.0362737871404116e-05, 0.0005954436481690331, + 0.002352703452491265, 0.0058636025937444025, 0.011219737158250306, 0.018191443590229183, 0.026405776501228783, + 0.035473365577059296, 0.08393991903492294, 0.12694077261184436, 0.16267998396542166, 0.19356340377635362, + 0.22185561141496238, 0.2491212785730439, 0.27638918590325057, 0.30436276263857276, 0.36442247019537943, + 0.4326074417788097, 0.5117005179251304, 0.6041057952026397, 0.7115562776994953, 0.9717395908877782, + 1.287801729930226, 1.640481436970422, 2.0170333392987803, 2.403120521175818, 2.7944880466591697, + 3.1903316981702914, 3.5854607295085006, 3.9827233876685453, 4.380211241711606, 5.372912002970106, + 6.363611979892144, 7.354108439147401, 8.342422680822207, 9.328379603438737, 10.311753861055754, + 11.292256071356476, 12.269512944217917, 13.24551266781415, 14.214843848047698, 15.1846914308176, + 16.14921911265538, 17.110589710299248, 18.071882007306126, 19.029383777685208, 19.985426474083003, + 20.93851972517649, 21.88986172125819, 22.839478047374197, 23.787460474518415, 24.73399928653839, + 25.67942789661212, 26.6232492903979, 27.56702636615906, 28.5092025223311, 29.45178643552429, + 30.392696953259666, 31.33445375115093, 32.27415784926368, 33.2148438480477, 35.093421685162234, + 36.97451169273733, 38.8555191556678, 40.737192642704734, 42.620136054973756, 44.505149978319906, + 46.392696953259666, 51.12057393120585, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Fe52_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 1.7371744532199383e-06, 9.554373504133797e-06, 3.778197643341552e-05, + 0.00011333607006293108, 0.0030242952161453874, 0.015422212189991184, 0.040215337130588114, 0.07478865660777631, + 0.11488541698288196, 0.15714990338033966, 0.19960737134331175, 0.24132628928072955, 0.3217032118192907, + 0.3993396534463543, 0.4778337814344742, 0.5623989859221217, 0.6594581913549248, 0.9153998352122699, + 1.2695129442179163, 1.6910814921229684, 2.143014800254095, 2.6009728956867484, 3.0569048513364727, + 3.503790683057181, 3.946452265013073, 4.383815365980431, 4.818225893613955, 5.888740960682893, + 6.944482672150168, 7.989894563718773, 9.02938377768521, 10.060697840353612, 11.086359830674748, + 12.11058971029925, 13.127104798364808, 14.139879086401237, 15.14921911265538, 16.152288344383056, + 17.152288344383056, 18.14921911265538, 19.143014800254097, 20.133538908370216, 21.12057393120585, + 22.103803720955955, 23.08635983067475, 24.06445798922692, 25.041392685158225, 26.01703333929878, + 26.989449817666692, 27.960946195733833, 28.930949031167522, 29.899273187317604, 30.8668778143375, + 31.833784374656478, 32.79934054945358, 33.76417613239033, 34.72835378202123, 36.655138434811384, + 38.58092497567562, 40.505149978319906, 42.42975228000241, 44.3541084391474, 46.28103336724773, + 48.20682587603185, 53.02938377768521, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Co55_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 8.685880952436747e-07, 1.4331481434642371e-05, 9.336327741651445e-05, + 0.00038114325769492564, 0.001151090732337307, 0.0028275866787247843, 0.0059861278100218065, 0.019727612600003865, + 0.049238961363648255, 0.10167663281566902, 0.18228879723157643, 0.29243817096179087, 0.5865873046717549, + 0.9449759084120479, 1.3324384599156054, 1.7363965022766423, 2.1492191126553797, 2.56702636615906, + 2.991226075692495, 3.419955748489758, 3.851869600729766, 4.2878017299302265, 5.382017042574868, + 6.482873583608754, 7.5820633629117085, 8.677606952720494, 9.767155866082181, 10.85003325768977, + 11.927370363039023, 12.998695158311655, 14.064457989226918, 15.127104798364808, 16.181843587944773, + 17.232996110392154, 18.281033367247726, 19.32428245529769, 20.3654879848909, 21.401400540781545, + 22.436162647040756, 23.468347330412158, 24.4983105537896, 25.525044807036846, 26.550228353055093, + 27.57403126772772, 28.59659709562646, 29.6170003411209, 30.636487896353366, 31.65609820201283, + 32.673941998634085, 33.69108149212297, 34.70757017609794, 35.72427586960079, 37.75587485567249, + 39.786751422145564, 41.818225893613956, 43.850033257689766, 45.88309335857569, 47.91750550955255, + 49.954242509439325, 55.05690485133647, + }; + + // this is log10(partition function) + + MICROPHYSICS_UNUSED HIP_CONSTEXPR static AMREX_GPU_MANAGED amrex::Real Ni56_pf_array[npts_1] = { + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 4.342942647204277e-07, 7.817230319428646e-06, 6.42708273977769e-05, + 0.0002904458650804842, 0.0009123622824012837, 0.0022498876258026487, 0.0046944487518873, 0.014735532704563181, + 0.03529042138996706, 0.07190703372466718, 0.13162956968664008, 0.22190042758492473, 0.5092025223311029, + 0.9132839017604184, 1.374748346010104, 1.8555191556678001, 2.3404441148401185, 2.8221680793680175, + 3.3031960574204886, 3.783903579272735, 4.26245108973043, 4.7419390777291985, 5.9344984512435675, + 7.117271295655764, 8.292256071356476, 9.456366033129044, 10.608526033577194, 11.750508394851346, + 12.88309335857569, 14.008600171761918, 15.123851640967086, 16.232996110392154, 17.33645973384853, + 18.432969290874407, 19.525044807036846, 20.612783856719737, 21.695481676490196, 22.773786444981194, + 23.8481891169914, 24.919078092376076, 25.987219229908003, 27.053078443483418, 28.113943352306837, + 29.17609125905568, 30.232996110392154, 31.287801729930226, 32.3424226808222, 33.39619934709574, + 34.44715803134222, 35.49692964807321, 36.54530711646582, 37.594392550375424, 39.68752896121463, + 41.77959649125783, 43.86981820797933, 45.959518376973, 48.04921802267018, 50.13987908640124, + 52.230448921378276, 57.462397997898954, + }; + + + + // interpolation routine + + template + AMREX_GPU_HOST_DEVICE AMREX_INLINE + void interpolate_pf(const Real t9, const Real (&temp_array)[npts], const Real (&pf_array)[npts], + Real& pf, 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) + + Real slope = (pf_array[idx+1] - pf_array[idx]) / (temp_array[idx+1] - temp_array[idx]); + + // find the PF + + 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) + + 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; + + } + + } + +} + +// main interface + +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void get_partition_function(const int inuc, [[maybe_unused]] const tf_t& tfactors, + Real& pf, Real& dpf_dT) { + + // inuc is the 1-based index for the species + + switch (inuc) { + + case O16: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::O16_pf_array, pf, dpf_dT); + break; + + case Ne20: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Ne20_pf_array, pf, dpf_dT); + break; + + case Na23: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Na23_pf_array, pf, dpf_dT); + break; + + case Mg24: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Mg24_pf_array, pf, dpf_dT); + break; + + case Al27: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Al27_pf_array, pf, dpf_dT); + break; + + case Si28: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Si28_pf_array, pf, dpf_dT); + break; + + case P31: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::P31_pf_array, pf, dpf_dT); + break; + + case S32: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::S32_pf_array, pf, dpf_dT); + break; + + case Cl35: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Cl35_pf_array, pf, dpf_dT); + break; + + case Ar36: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Ar36_pf_array, pf, dpf_dT); + break; + + case K39: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::K39_pf_array, pf, dpf_dT); + break; + + case Ca40: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Ca40_pf_array, pf, dpf_dT); + break; + + case Sc43: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Sc43_pf_array, pf, dpf_dT); + break; + + case Ti44: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Ti44_pf_array, pf, dpf_dT); + break; + + case V47: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::V47_pf_array, pf, dpf_dT); + break; + + case Cr48: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Cr48_pf_array, pf, dpf_dT); + break; + + case Mn51: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Mn51_pf_array, pf, dpf_dT); + break; + + case Fe52: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Fe52_pf_array, pf, dpf_dT); + break; + + case Co55: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Co55_pf_array, pf, dpf_dT); + break; + + case Ni56: + part_fun::interpolate_pf(tfactors.T9, part_fun::temp_array_1, part_fun::Ni56_pf_array, pf, dpf_dT); + break; + + + default: + + pf = 1.0_rt; + dpf_dT = 0.0_rt; + + } + +} + +// spins + +AMREX_GPU_HOST_DEVICE AMREX_INLINE +constexpr Real get_spin_state(const int inuc) { + + Real spin = -1.0; + + switch (inuc) { + + case He4: + case C12: + case O16: + case Ne20: + case Mg24: + case Si28: + case S32: + case Ar36: + case Ca40: + case Ti44: + case Cr48: + case Fe52: + case Ni56: + spin = 1; + break; + + case H1: + case N13: + case P31: + spin = 2; + break; + + case Na23: + case Cl35: + case K39: + case V47: + spin = 4; + break; + + case Al27: + case Mn51: + spin = 6; + break; + + case Sc43: + case Co55: + spin = 8; + break; + + + } + + return spin; + +} + + +#endif diff --git a/networks/subch_base/pynucastro.net b/networks/subch_base/pynucastro.net new file mode 100644 index 0000000000..83e465c183 --- /dev/null +++ b/networks/subch_base/pynucastro.net @@ -0,0 +1,24 @@ +hydrogen-1 H1 1.0 1.0 +helium-4 He4 4.0 2.0 +carbon-12 C12 12.0 6.0 +nitrogen-13 N13 13.0 7.0 +oxygen-16 O16 16.0 8.0 +neon-20 Ne20 20.0 10.0 +sodium-23 Na23 23.0 11.0 +magnesium-24 Mg24 24.0 12.0 +aluminum-27 Al27 27.0 13.0 +silicon-28 Si28 28.0 14.0 +phosphorus-31 P31 31.0 15.0 +sulfur-32 S32 32.0 16.0 +argon-36 Ar36 36.0 18.0 +calcium-40 Ca40 40.0 20.0 +titanium-44 Ti44 44.0 22.0 +chromium-48 Cr48 48.0 24.0 +iron-52 Fe52 52.0 26.0 +nickel-56 Ni56 56.0 28.0 +__extra_chlorine-35 Cl35 35.0 17.0 +__extra_potassium-39 K39 39.0 19.0 +__extra_scandium-43 Sc43 43.0 21.0 +__extra_vanadium-47 V47 47.0 23.0 +__extra_manganese-51 Mn51 51.0 25.0 +__extra_cobalt-55 Co55 55.0 27.0 diff --git a/networks/subch_base/reaclib_rates.H b/networks/subch_base/reaclib_rates.H new file mode 100644 index 0000000000..6dc547b4c2 --- /dev/null +++ b/networks/subch_base/reaclib_rates.H @@ -0,0 +1,5083 @@ +#ifndef REACLIB_RATES_H +#define REACLIB_RATES_H + +#include +#include + +#include +#include +#include + +using namespace Rates; +using namespace Species; + +struct rate_t { + Array1D screened_rates; + Real enuc_weak; +}; + +struct rate_derivs_t { + Array1D screened_rates; + Array1D dscreened_rates_dT; + Real enuc_weak; +}; + + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_C12_to_N13(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // C12 + p --> N13 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + 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, Real& rate, Real& drate_dT) { + + // C12 + He4 --> O16 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + 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_He4_O16_to_Ne20(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 + He4 --> Ne20 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // co10r + ln_set_rate = 9.50848 + -12.7643 * tfactors.T9i + -3.65925 * tfactors.T913 + + 0.714224 * tfactors.T9 + -0.00107508 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 12.7643 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * -3.65925 * tfactors.T923i + + 0.714224 + (5.0/3.0) * -0.00107508 * 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; + } + + // co10r + ln_set_rate = 3.88571 + -10.3585 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 10.3585 * 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; + } + + // co10n + ln_set_rate = 23.903 + -39.7262 * tfactors.T913i + -0.210799 * tfactors.T913 + + 0.442879 * tfactors.T9 + -0.0797753 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -39.7262 * tfactors.T943i + (1.0/3.0) * -0.210799 * tfactors.T923i + + 0.442879 + (5.0/3.0) * -0.0797753 * 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_Ne20_to_Mg24(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ne20 + He4 --> Mg24 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10r + ln_set_rate = -38.7055 + -2.50605 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 2.50605 * 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 = 24.5058 + -46.2525 * tfactors.T913i + 5.58901 * tfactors.T913 + + 7.61843 * tfactors.T9 + -3.683 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -46.2525 * tfactors.T943i + (1.0/3.0) * 5.58901 * tfactors.T923i + + 7.61843 + (5.0/3.0) * -3.683 * 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 = -8.79827 + -12.7809 * tfactors.T9i + 16.9229 * tfactors.T913 + + -2.57325 * tfactors.T9 + 0.208997 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 12.7809 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 16.9229 * tfactors.T923i + + -2.57325 + (5.0/3.0) * 0.208997 * 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 = 1.98307 + -9.22026 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 9.22026 * 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_Na23_to_Mg24(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Na23 + p --> Mg24 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10n + ln_set_rate = 18.9075 + -20.6428 * tfactors.T913i + 1.52954 * tfactors.T913 + + 2.7487 * tfactors.T9 + -1.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -20.6428 * tfactors.T943i + (1.0/3.0) * 1.52954 * tfactors.T923i + + 2.7487 + (5.0/3.0) * -1.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.0594 + -3.28029 * tfactors.T9i + -0.360588 * tfactors.T913 + + 1.4187 * tfactors.T9 + -0.184061 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 3.28029 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * -0.360588 * tfactors.T923i + + 1.4187 + (5.0/3.0) * -0.184061 * 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 = -5.02585 + -1.61219 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 1.61219 * 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_He4_Mg24_to_Si28(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Mg24 + He4 --> Si28 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // st08r + ln_set_rate = -50.5494 + -12.8332 * tfactors.T9i + 21.3721 * tfactors.T913i + 37.7649 * tfactors.T913 + + -4.10635 * tfactors.T9 + 0.249618 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 12.8332 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 21.3721 * tfactors.T943i + (1.0/3.0) * 37.7649 * tfactors.T923i + + -4.10635 + (5.0/3.0) * 0.249618 * 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; + } + + // st08r + ln_set_rate = 8.03977 + -15.629 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 15.629 * 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_Al27_to_Si28(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Al27 + p --> Si28 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10r + ln_set_rate = -13.6664 + -1.90396 * tfactors.T9i + 23.8634 * tfactors.T913 + + -3.70135 * tfactors.T9 + 0.28964 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 1.90396 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 23.8634 * tfactors.T923i + + -3.70135 + (5.0/3.0) * 0.28964 * 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 = 86.0234 + -0.387313 * tfactors.T9i + -26.8327 * tfactors.T913i + -116.137 * tfactors.T913 + + 0.00950567 * tfactors.T9 + 0.00999755 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.387313 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -26.8327 * tfactors.T943i + (1.0/3.0) * -116.137 * tfactors.T923i + + 0.00950567 + (5.0/3.0) * 0.00999755 * 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; + } + + // il10n + ln_set_rate = 21.1065 + -23.2205 * tfactors.T913i + + -2.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -23.2205 * 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; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He4_Si28_to_S32(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Si28 + He4 --> S32 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 47.9212 + -59.4896 * tfactors.T913i + 4.47205 * tfactors.T913 + + -4.78989 * tfactors.T9 + 0.557201 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -59.4896 * tfactors.T943i + (1.0/3.0) * 4.47205 * tfactors.T923i + + -4.78989 + (5.0/3.0) * 0.557201 * 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_P31_to_S32(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // P31 + p --> S32 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10r + ln_set_rate = 0.821556 + -3.77704 * tfactors.T9i + 8.09341 * tfactors.T913 + + -0.615971 * tfactors.T9 + 0.031159 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 3.77704 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 8.09341 * tfactors.T923i + + -0.615971 + (5.0/3.0) * 0.031159 * 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 = -2.66839 + -2.25958 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 2.25958 * 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.2596 + -25.3278 * tfactors.T913i + 6.4931 * tfactors.T913 + + -9.27513 * tfactors.T9 + -0.610439 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -25.3278 * tfactors.T943i + (1.0/3.0) * 6.4931 * tfactors.T923i + + -9.27513 + (5.0/3.0) * -0.610439 * 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_C12_C12_to_p_Na23(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // C12 + C12 --> p + Na23 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = 60.9649 + -84.165 * tfactors.T913i + -1.4191 * tfactors.T913 + + -0.114619 * tfactors.T9 + -0.070307 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -84.165 * tfactors.T943i + (1.0/3.0) * -1.4191 * tfactors.T923i + + -0.114619 + (5.0/3.0) * -0.070307 * 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_C12_C12_to_He4_Ne20(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // C12 + C12 --> He4 + Ne20 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = 61.2863 + -84.165 * tfactors.T913i + -1.56627 * tfactors.T913 + + -0.0736084 * tfactors.T9 + -0.072797 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -84.165 * tfactors.T943i + (1.0/3.0) * -1.56627 * tfactors.T923i + + -0.0736084 + (5.0/3.0) * -0.072797 * 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_N13_to_p_O16(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // N13 + He4 --> p + O16 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + 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_C12_O16_to_p_Al27(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 + C12 --> p + Al27 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = 68.5253 + 0.205134 * tfactors.T9i + -119.242 * tfactors.T913i + 13.3667 * tfactors.T913 + + 0.295425 * tfactors.T9 + -0.267288 * tfactors.T953 + -9.91729 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = -0.205134 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -119.242 * tfactors.T943i + (1.0/3.0) * 13.3667 * tfactors.T923i + + 0.295425 + (5.0/3.0) * -0.267288 * tfactors.T923 + -9.91729 * 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_C12_O16_to_He4_Mg24(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 + C12 --> He4 + Mg24 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = 48.5341 + 0.37204 * tfactors.T9i + -133.413 * tfactors.T913i + 50.1572 * tfactors.T913 + + -3.15987 * tfactors.T9 + 0.0178251 * tfactors.T953 + -23.7027 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = -0.37204 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -133.413 * tfactors.T943i + (1.0/3.0) * 50.1572 * tfactors.T923i + + -3.15987 + (5.0/3.0) * 0.0178251 * tfactors.T923 + -23.7027 * 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_O16_O16_to_p_P31(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 + O16 --> p + P31 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = 85.2628 + 0.223453 * tfactors.T9i + -145.844 * tfactors.T913i + 8.72612 * tfactors.T913 + + -0.554035 * tfactors.T9 + -0.137562 * tfactors.T953 + -6.88807 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = -0.223453 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -145.844 * tfactors.T943i + (1.0/3.0) * 8.72612 * tfactors.T923i + + -0.554035 + (5.0/3.0) * -0.137562 * tfactors.T923 + -6.88807 * 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_O16_O16_to_He4_Si28(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 + O16 --> He4 + Si28 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = 97.2435 + -0.268514 * tfactors.T9i + -119.324 * tfactors.T913i + -32.2497 * tfactors.T913 + + 1.46214 * tfactors.T9 + -0.200893 * tfactors.T953 + 13.2148 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.268514 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -119.324 * tfactors.T943i + (1.0/3.0) * -32.2497 * tfactors.T923i + + 1.46214 + (5.0/3.0) * -0.200893 * tfactors.T923 + 13.2148 * 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_Na23_to_He4_Ne20(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Na23 + p --> He4 + Ne20 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10r + ln_set_rate = -6.58736 + -2.31577 * tfactors.T9i + 19.7297 * tfactors.T913 + + -2.20987 * tfactors.T9 + 0.153374 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 2.31577 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 19.7297 * tfactors.T923i + + -2.20987 + (5.0/3.0) * 0.153374 * 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 = 0.0178295 + -1.86103 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 1.86103 * 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 = 18.9756 + -20.0024 * tfactors.T913i + 11.5988 * tfactors.T913 + + -1.37398 * tfactors.T9 + -1.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -20.0024 * tfactors.T943i + (1.0/3.0) * 11.5988 * tfactors.T923i + + -1.37398 + (5.0/3.0) * -1.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; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_Al27_to_He4_Mg24(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Al27 + p --> He4 + Mg24 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10r + ln_set_rate = -7.02789 + -4.2425 * tfactors.T9i + 18.0416 * tfactors.T913 + + -1.54137 * tfactors.T9 + 0.0847506 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 4.2425 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 18.0416 * tfactors.T923i + + -1.54137 + (5.0/3.0) * 0.0847506 * 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 = -26.8683 + -0.963012 * tfactors.T9i + 5.18642 * tfactors.T913i + -34.7936 * tfactors.T913 + + 168.225 * tfactors.T9 + -115.825 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.963012 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 5.18642 * tfactors.T943i + (1.0/3.0) * -34.7936 * tfactors.T923i + + 168.225 + (5.0/3.0) * -115.825 * 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; + } + + // il10n + ln_set_rate = 29.4576 + -26.4162 * tfactors.T913i + + -2.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -26.4162 * 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; + } + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_P31_to_He4_Si28(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // P31 + p --> He4 + Si28 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10r + ln_set_rate = -10.893 + -3.42575 * tfactors.T9i + 21.521 * tfactors.T913 + + -1.90355 * tfactors.T9 + 0.092724 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 3.42575 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 21.521 * tfactors.T923i + + -1.90355 + (5.0/3.0) * 0.092724 * 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 = -12.919 + -1.87716 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 1.87716 * 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 = 60.8829 + -31.932 * tfactors.T913i + -77.0334 * tfactors.T913 + + -43.6847 * tfactors.T9 + -4.28955 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -31.932 * tfactors.T943i + (1.0/3.0) * -77.0334 * tfactors.T923i + + -43.6847 + (5.0/3.0) * -4.28955 * 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, Real& rate, Real& drate_dT) { + + // He4 + He4 + He4 --> C12 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + 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 rate_C12_C12_to_Mg24_modified(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // C12 + C12 --> Mg24 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = -12.8056 + -30.1498 * tfactors.T9i + 11.4826 * tfactors.T913 + + 1.82849 * tfactors.T9 + -0.34844 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 30.1498 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 11.4826 * tfactors.T923i + + 1.82849 + (5.0/3.0) * -0.34844 * tfactors.T923; + } + + // 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_O16_O16_to_S32_modified(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 + O16 --> S32 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = 77.5491 + -0.373641 * tfactors.T9i + -120.83 * tfactors.T913i + -7.72334 * tfactors.T913 + + -2.27939 * tfactors.T9 + 0.167655 * tfactors.T953 + 7.62001 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.373641 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -120.83 * tfactors.T943i + (1.0/3.0) * -7.72334 * tfactors.T923i + + -2.27939 + (5.0/3.0) * 0.167655 * tfactors.T923 + 7.62001 * 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_C12_O16_to_Si28_modified(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 + C12 --> Si28 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88r + ln_set_rate = -132.213 + -1.46479 * tfactors.T9i + -293.089 * tfactors.T913i + 414.404 * tfactors.T913 + + -28.0562 * tfactors.T9 + 1.61807 * tfactors.T953 + -178.28 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 1.46479 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -293.089 * tfactors.T943i + (1.0/3.0) * 414.404 * tfactors.T923i + + -28.0562 + (5.0/3.0) * 1.61807 * tfactors.T923 + -178.28 * 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_S32_to_Ar36_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // S32 + He4 --> Ar36 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 48.901 + -65.3709 * tfactors.T913i + 5.68294 * tfactors.T913 + + -5.00388 * tfactors.T9 + 0.571407 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -65.3709 * tfactors.T943i + (1.0/3.0) * 5.68294 * tfactors.T923i + + -5.00388 + (5.0/3.0) * 0.571407 * 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_Cl35_to_Ar36_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Cl35 + p --> Ar36 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10r + ln_set_rate = -9.03294 + -2.00996 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 2.00996 * 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 = -42.5249 + -0.564651 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.564651 * 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 = 35.6868 + -27.8971 * tfactors.T913i + -16.2304 * tfactors.T913 + + 35.255 * tfactors.T9 + -25.8411 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -27.8971 * tfactors.T943i + (1.0/3.0) * -16.2304 * tfactors.T923i + + 35.255 + (5.0/3.0) * -25.8411 * 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 = -7.84699 + -3.65092 * tfactors.T9i + 18.0179 * tfactors.T913 + + -2.86304 * tfactors.T9 + 0.250854 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 3.65092 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 18.0179 * tfactors.T923i + + -2.86304 + (5.0/3.0) * 0.250854 * 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_Cl35_to_He4_S32_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Cl35 + p --> He4 + S32 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10r + ln_set_rate = 2.29121 + -6.00976 * tfactors.T9i + 5.33756 * tfactors.T913 + + 1.64418 * tfactors.T9 + -0.246167 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 6.00976 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 5.33756 * tfactors.T923i + + 1.64418 + (5.0/3.0) * -0.246167 * 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 = -1.01202 + -3.93495 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 3.93495 * 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 = -57.5294 + -0.532931 * tfactors.T9i + 25.5338 * tfactors.T913 + + 6.45824 * tfactors.T9 + -0.950294 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.532931 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 25.5338 * tfactors.T923i + + 6.45824 + (5.0/3.0) * -0.950294 * 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; + } + + // il10n + ln_set_rate = 32.12 + -30.9147 * tfactors.T913i + -1.2345 * tfactors.T913 + + 22.5118 * tfactors.T9 + -33.0589 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -30.9147 * tfactors.T943i + (1.0/3.0) * -1.2345 * tfactors.T923i + + 22.5118 + (5.0/3.0) * -33.0589 * 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_Ar36_to_Ca40_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ar36 + He4 --> Ca40 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 52.3486 + -71.0046 * tfactors.T913i + 4.0656 * tfactors.T913 + + -5.26509 * tfactors.T9 + 0.683546 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -71.0046 * tfactors.T943i + (1.0/3.0) * 4.0656 * tfactors.T923i + + -5.26509 + (5.0/3.0) * 0.683546 * 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_K39_to_Ca40_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // K39 + p --> Ca40 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // lo18r + ln_set_rate = 2761.38 + -5.22234 * tfactors.T9i + 802.18 * tfactors.T913i + -4010.27 * tfactors.T913 + + 1136.19 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 5.22234 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 802.18 * tfactors.T943i + (1.0/3.0) * -4010.27 * tfactors.T923i + + 1136.19 * 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; + } + + // lo18r + ln_set_rate = 588.099 + -12.5647 * tfactors.T9i + 641.844 * tfactors.T913i + -1248.49 * tfactors.T913 + + 564.926 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 12.5647 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 641.844 * tfactors.T943i + (1.0/3.0) * -1248.49 * tfactors.T923i + + 564.926 * 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; + } + + // lo18r + ln_set_rate = 102.252 + -1.66508 * tfactors.T9i + 41.1723 * tfactors.T913i + -149.299 * tfactors.T913 + + 10.5229 * tfactors.T9 + -0.68208 * tfactors.T953 + 59.2367 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 1.66508 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 41.1723 * tfactors.T943i + (1.0/3.0) * -149.299 * tfactors.T923i + + 10.5229 + (5.0/3.0) * -0.68208 * tfactors.T923 + 59.2367 * 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_K39_to_He4_Ar36_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // K39 + p --> He4 + Ar36 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 20.5166 + -30.0732 * tfactors.T913i + 7.03263 * tfactors.T913 + + -1.10085 * tfactors.T9 + 0.133768 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -30.0732 * tfactors.T943i + (1.0/3.0) * 7.03263 * tfactors.T923i + + -1.10085 + (5.0/3.0) * 0.133768 * 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_Ca40_to_Ti44_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ca40 + He4 --> Ti44 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // chw0 + ln_set_rate = 53.75 + -76.4273 * tfactors.T913i + 3.87451 * tfactors.T913 + + -3.61477 * tfactors.T9 + 0.367451 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -76.4273 * tfactors.T943i + (1.0/3.0) * 3.87451 * tfactors.T923i + + -3.61477 + (5.0/3.0) * 0.367451 * 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_Sc43_to_Ti44_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Sc43 + p --> Ti44 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 36.8432 + -32.1734 * tfactors.T913i + -1.77078 * tfactors.T913 + + -2.21706 * tfactors.T9 + 0.298499 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -32.1734 * tfactors.T943i + (1.0/3.0) * -1.77078 * tfactors.T923i + + -2.21706 + (5.0/3.0) * 0.298499 * 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_Sc43_to_He4_Ca40_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Sc43 + p --> He4 + Ca40 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 34.8559 + -32.1734 * tfactors.T913i + 0.0296879 * tfactors.T913 + + -0.95232 * tfactors.T9 + 0.129022 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -32.1734 * tfactors.T943i + (1.0/3.0) * 0.0296879 * tfactors.T923i + + -0.95232 + (5.0/3.0) * 0.129022 * 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_Ti44_to_Cr48_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ti44 + He4 --> Cr48 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 64.7958 + -81.667 * tfactors.T913i + -10.6333 * tfactors.T913 + + -0.672613 * tfactors.T9 + 0.161209 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -81.667 * tfactors.T943i + (1.0/3.0) * -10.6333 * tfactors.T923i + + -0.672613 + (5.0/3.0) * 0.161209 * 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_Ti44_to_p_V47_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ti44 + He4 --> p + V47 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // chw0r + ln_set_rate = -76.5154 + -10.7931 * tfactors.T9i + 70.2835 * tfactors.T913 + + -7.99061 * tfactors.T9 + 0.486213 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 10.7931 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 70.2835 * tfactors.T923i + + -7.99061 + (5.0/3.0) * 0.486213 * 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_V47_to_Cr48_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // V47 + p --> Cr48 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // nfisn + ln_set_rate = 42.6798 + -6.0593 * tfactors.T9i + -34.0548 * tfactors.T913i + -3.41973 * tfactors.T913 + + 1.16501 * tfactors.T9 + -0.105543 * tfactors.T953 + -7.70886 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 6.0593 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -34.0548 * tfactors.T943i + (1.0/3.0) * -3.41973 * tfactors.T923i + + 1.16501 + (5.0/3.0) * -0.105543 * tfactors.T923 + -7.70886 * 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; + } + + // nfisn + ln_set_rate = 511.463 + -5.29491 * tfactors.T9i + 317.171 * tfactors.T913i + -911.679 * tfactors.T913 + + 94.4245 * tfactors.T9 + -10.1973 * tfactors.T953 + 330.727 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 5.29491 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 317.171 * tfactors.T943i + (1.0/3.0) * -911.679 * tfactors.T923i + + 94.4245 + (5.0/3.0) * -10.1973 * tfactors.T923 + 330.727 * 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; + } + + // nfisn + ln_set_rate = 23.8315 + 0.246665 * tfactors.T9i + -45.9868 * tfactors.T913i + 13.6822 * tfactors.T913 + + -0.376902 * tfactors.T9 + -0.0194875 * tfactors.T953 + -8.42325 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = -0.246665 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -45.9868 * tfactors.T943i + (1.0/3.0) * 13.6822 * tfactors.T923i + + -0.376902 + (5.0/3.0) * -0.0194875 * tfactors.T923 + -8.42325 * 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; + } + + // nfisn + ln_set_rate = 40.5626 + -0.514414 * tfactors.T9i + -110.655 * tfactors.T913i + 83.0232 * tfactors.T913 + + -19.7762 * tfactors.T9 + 3.03961 * tfactors.T953 + -49.4742 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 0.514414 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -110.655 * tfactors.T943i + (1.0/3.0) * 83.0232 * tfactors.T923i + + -19.7762 + (5.0/3.0) * 3.03961 * tfactors.T923 + -49.4742 * 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_Cr48_to_Fe52_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Cr48 + He4 --> Fe52 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 65.1754 + -86.7459 * tfactors.T913i + -9.79373 * tfactors.T913 + + -0.772169 * tfactors.T9 + 0.155883 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -86.7459 * tfactors.T943i + (1.0/3.0) * -9.79373 * tfactors.T923i + + -0.772169 + (5.0/3.0) * 0.155883 * 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_Cr48_to_p_Mn51_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Cr48 + He4 --> p + Mn51 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 59.2276 + -86.7459 * tfactors.T913i + 1.05653 * tfactors.T913 + + -1.15757 * tfactors.T9 + 0.0877546 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -86.7459 * tfactors.T943i + (1.0/3.0) * 1.05653 * tfactors.T923i + + -1.15757 + (5.0/3.0) * 0.0877546 * 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_Mn51_to_Fe52_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Mn51 + p --> Fe52 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 36.2596 + -36.1825 * tfactors.T913i + 0.873042 * tfactors.T913 + + -2.89731 * tfactors.T9 + 0.364394 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -36.1825 * tfactors.T943i + (1.0/3.0) * 0.873042 * tfactors.T923i + + -2.89731 + (5.0/3.0) * 0.364394 * 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_Fe52_to_Ni56_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Fe52 + He4 --> Ni56 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 66.6417 + -91.6819 * tfactors.T913i + -9.51885 * tfactors.T913 + + -0.533014 * tfactors.T9 + 0.0892607 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -91.6819 * tfactors.T943i + (1.0/3.0) * -9.51885 * tfactors.T923i + + -0.533014 + (5.0/3.0) * 0.0892607 * 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_Fe52_to_p_Co55_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Fe52 + He4 --> p + Co55 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 62.2207 + -91.6819 * tfactors.T913i + -0.329235 * tfactors.T913 + + -0.780924 * tfactors.T9 + 0.0425179 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -91.6819 * tfactors.T943i + (1.0/3.0) * -0.329235 * tfactors.T923i + + -0.780924 + (5.0/3.0) * 0.0425179 * 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_Co55_to_Ni56_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Co55 + p --> Ni56 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 37.3736 + -38.1053 * tfactors.T913i + -0.210947 * tfactors.T913 + + -2.68377 * tfactors.T9 + 0.355814 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = + -(1.0/3.0) * -38.1053 * tfactors.T943i + (1.0/3.0) * -0.210947 * tfactors.T923i + + -2.68377 + (5.0/3.0) * 0.355814 * 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_N13_to_p_C12_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // N13 --> p + C12 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ls09c + ln_set_rate = 40.04074558314484 + -22.547578710551672 * tfactors.T9i + -13.692 * tfactors.T913i + -0.230881 * tfactors.T913 + + 4.44362 * tfactors.T9 + -3.15898 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 22.547578710551672 * tfactors.T9i * tfactors.T9i + -(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.833333 * 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; + } + + // ls09c + ln_set_rate = 40.43534558314484 + -26.326068710551674 * tfactors.T9i + -5.10735 * tfactors.T913i + -2.24111 * tfactors.T913 + + 0.148883 * tfactors.T9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 26.326068710551674 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -5.10735 * tfactors.T943i + (1.0/3.0) * -2.24111 * tfactors.T923i + + 0.148883; + } + + // 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; + } + + + Real C12_pf, dC12_pf_dT; + // setting C12 partition function to 1.0 by default, independent of T + C12_pf = 1.0_rt; + dC12_pf_dT = 0.0_rt; + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real N13_pf, dN13_pf_dT; + // setting N13 partition function to 1.0 by default, independent of T + N13_pf = 1.0_rt; + dN13_pf_dT = 0.0_rt; + + Real z_r = p_pf * C12_pf; + Real z_p = N13_pf; + + Real dz_r_dT = C12_pf * dp_pf_dT + p_pf * dC12_pf_dT; + Real dz_p_dT = dN13_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_O16_to_He4_C12_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 --> He4 + C12 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // nac2 + ln_set_rate = 279.2945280776573 + -84.95160042649215 * tfactors.T9i + 103.411 * tfactors.T913i + -420.567 * tfactors.T913 + + 64.0874 * tfactors.T9 + -12.4624 * tfactors.T953 + 138.803 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 84.95160042649215 * 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 + 138.803 * 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 = 94.31312807765731 + -84.50317042649215 * tfactors.T9i + 58.9128 * tfactors.T913i + -148.273 * tfactors.T913 + + 9.08324 * tfactors.T9 + -0.541041 * tfactors.T953 + 71.8554 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 84.50317042649215 * 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 + 71.8554 * 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; + } + + + Real C12_pf, dC12_pf_dT; + // setting C12 partition function to 1.0 by default, independent of T + C12_pf = 1.0_rt; + dC12_pf_dT = 0.0_rt; + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real O16_pf, dO16_pf_dT; + // interpolating O16 partition function + get_partition_function(O16, tfactors, O16_pf, dO16_pf_dT); + + Real z_r = He4_pf * C12_pf; + Real z_p = O16_pf; + + Real dz_r_dT = C12_pf * dHe4_pf_dT + He4_pf * dC12_pf_dT; + Real dz_p_dT = dO16_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ne20_to_He4_O16_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ne20 --> He4 + O16 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // co10c + ln_set_rate = 34.26581585936365 + -67.65193003813836 * tfactors.T9i + -3.65925 * tfactors.T913 + + 0.714224 * tfactors.T9 + -0.00107508 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 67.65193003813836 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * -3.65925 * tfactors.T923i + + 0.714224 + (5.0/3.0) * -0.00107508 * tfactors.T923; + } + + // 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; + } + + // co10c + ln_set_rate = 28.64304585936365 + -65.24613003813835 * tfactors.T9i; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 65.24613003813835 * tfactors.T9i * 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; + } + + // co10c + ln_set_rate = 48.66033585936365 + -54.887630038138354 * tfactors.T9i + -39.7262 * tfactors.T913i + -0.210799 * tfactors.T913 + + 0.442879 * tfactors.T9 + -0.0797753 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 54.887630038138354 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -39.7262 * tfactors.T943i + (1.0/3.0) * -0.210799 * tfactors.T923i + + 0.442879 + (5.0/3.0) * -0.0797753 * tfactors.T923 + 0.833333 * 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; + } + + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real O16_pf, dO16_pf_dT; + // interpolating O16 partition function + get_partition_function(O16, tfactors, O16_pf, dO16_pf_dT); + + Real Ne20_pf, dNe20_pf_dT; + // interpolating Ne20 partition function + get_partition_function(Ne20, tfactors, Ne20_pf, dNe20_pf_dT); + + Real z_r = He4_pf * O16_pf; + Real z_p = Ne20_pf; + + Real dz_r_dT = O16_pf * dHe4_pf_dT + He4_pf * dO16_pf_dT; + Real dz_p_dT = dNe20_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Mg24_to_p_Na23_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Mg24 --> p + Na23 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = 43.93571176470678 + -135.6881490421346 * tfactors.T9i + -20.6428 * tfactors.T913i + 1.52954 * tfactors.T913 + + 2.7487 * tfactors.T9 + -1.0 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 135.6881490421346 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -20.6428 * tfactors.T943i + (1.0/3.0) * 1.52954 * tfactors.T923i + + 2.7487 + (5.0/3.0) * -1.0 * tfactors.T923 + 0.833333 * 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; + } + + // il10c + ln_set_rate = 34.08761176470678 + -138.9684390421346 * tfactors.T9i + -0.360588 * tfactors.T913 + + 1.4187 * tfactors.T9 + -0.184061 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 138.9684390421346 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * -0.360588 * tfactors.T923i + + 1.4187 + (5.0/3.0) * -0.184061 * tfactors.T923; + } + + // 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; + } + + // il10c + ln_set_rate = 20.002361764706784 + -137.3003390421346 * tfactors.T9i; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 137.3003390421346 * tfactors.T9i * 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; + } + + + Real Na23_pf, dNa23_pf_dT; + // interpolating Na23 partition function + get_partition_function(Na23, tfactors, Na23_pf, dNa23_pf_dT); + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Mg24_pf, dMg24_pf_dT; + // interpolating Mg24 partition function + get_partition_function(Mg24, tfactors, Mg24_pf, dMg24_pf_dT); + + Real z_r = p_pf * Na23_pf; + Real z_p = Mg24_pf; + + Real dz_r_dT = Na23_pf * dp_pf_dT + p_pf * dNa23_pf_dT; + Real dz_p_dT = dMg24_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Mg24_to_He4_Ne20_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Mg24 --> He4 + Ne20 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = -13.886931148855957 + -110.62012330714883 * tfactors.T9i; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 110.62012330714883 * tfactors.T9i * 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; + } + + // il10c + ln_set_rate = 49.324368851144044 + -108.11407330714883 * tfactors.T9i + -46.2525 * tfactors.T913i + 5.58901 * tfactors.T913 + + 7.61843 * tfactors.T9 + -3.683 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 108.11407330714883 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -46.2525 * tfactors.T943i + (1.0/3.0) * 5.58901 * tfactors.T923i + + 7.61843 + (5.0/3.0) * -3.683 * tfactors.T923 + 0.833333 * 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; + } + + // il10c + ln_set_rate = 16.02029885114404 + -120.89497330714883 * tfactors.T9i + 16.9229 * tfactors.T913 + + -2.57325 * tfactors.T9 + 0.208997 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 120.89497330714883 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 16.9229 * tfactors.T923i + + -2.57325 + (5.0/3.0) * 0.208997 * tfactors.T923; + } + + // 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; + } + + // il10c + ln_set_rate = 26.801638851144045 + -117.33433330714882 * tfactors.T9i; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 117.33433330714882 * tfactors.T9i * 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; + } + + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Mg24_pf, dMg24_pf_dT; + // interpolating Mg24 partition function + get_partition_function(Mg24, tfactors, Mg24_pf, dMg24_pf_dT); + + Real Ne20_pf, dNe20_pf_dT; + // interpolating Ne20 partition function + get_partition_function(Ne20, tfactors, Ne20_pf, dNe20_pf_dT); + + Real z_r = He4_pf * Ne20_pf; + Real z_p = Mg24_pf; + + Real dz_r_dT = Ne20_pf * dHe4_pf_dT + He4_pf * dNe20_pf_dT; + Real dz_p_dT = dMg24_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Si28_to_p_Al27_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Si28 --> p + Al27 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = 11.776564828186824 + -136.3434628922348 * tfactors.T9i + 23.8634 * tfactors.T913 + + -3.70135 * tfactors.T9 + 0.28964 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 136.3434628922348 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 23.8634 * tfactors.T923i + + -3.70135 + (5.0/3.0) * 0.28964 * tfactors.T923; + } + + // 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; + } + + // il10c + ln_set_rate = 111.46636482818681 + -134.8268158922348 * tfactors.T9i + -26.8327 * tfactors.T913i + -116.137 * tfactors.T913 + + 0.00950567 * tfactors.T9 + 0.00999755 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 134.8268158922348 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -26.8327 * tfactors.T943i + (1.0/3.0) * -116.137 * tfactors.T923i + + 0.00950567 + (5.0/3.0) * 0.00999755 * tfactors.T923; + } + + // 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; + } + + // il10c + ln_set_rate = 46.54946482818683 + -134.4395028922348 * tfactors.T9i + -23.2205 * tfactors.T913i + + -2.0 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 134.4395028922348 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -23.2205 * tfactors.T943i + + (5.0/3.0) * -2.0 * tfactors.T923 + 0.833333 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Al27_pf, dAl27_pf_dT; + // interpolating Al27 partition function + get_partition_function(Al27, tfactors, Al27_pf, dAl27_pf_dT); + + Real Si28_pf, dSi28_pf_dT; + // interpolating Si28 partition function + get_partition_function(Si28, tfactors, Si28_pf, dSi28_pf_dT); + + Real z_r = p_pf * Al27_pf; + Real z_p = Si28_pf; + + Real dz_r_dT = Al27_pf * dp_pf_dT + p_pf * dAl27_pf_dT; + Real dz_p_dT = dSi28_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Si28_to_He4_Mg24_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Si28 --> He4 + Mg24 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // st08r + ln_set_rate = -25.688574833405916 + -128.69270892750794 * tfactors.T9i + 21.3721 * tfactors.T913i + 37.7649 * tfactors.T913 + + -4.10635 * tfactors.T9 + 0.249618 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 128.69270892750794 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 21.3721 * tfactors.T943i + (1.0/3.0) * 37.7649 * tfactors.T923i + + -4.10635 + (5.0/3.0) * 0.249618 * tfactors.T923; + } + + // 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; + } + + // st08r + ln_set_rate = 32.90059516659409 + -131.48850892750792 * tfactors.T9i; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 131.48850892750792 * tfactors.T9i * 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; + } + + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Mg24_pf, dMg24_pf_dT; + // interpolating Mg24 partition function + get_partition_function(Mg24, tfactors, Mg24_pf, dMg24_pf_dT); + + Real Si28_pf, dSi28_pf_dT; + // interpolating Si28 partition function + get_partition_function(Si28, tfactors, Si28_pf, dSi28_pf_dT); + + Real z_r = He4_pf * Mg24_pf; + Real z_p = Si28_pf; + + Real dz_r_dT = Mg24_pf * dHe4_pf_dT + He4_pf * dMg24_pf_dT; + Real dz_p_dT = dSi28_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_S32_to_p_P31_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // S32 --> p + P31 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = 25.172836958303158 + -106.63693563716609 * tfactors.T9i + 8.09341 * tfactors.T913 + + -0.615971 * tfactors.T9 + 0.031159 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 106.63693563716609 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 8.09341 * tfactors.T923i + + -0.615971 + (5.0/3.0) * 0.031159 * tfactors.T923; + } + + // 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; + } + + // il10c + ln_set_rate = 21.682890958303158 + -105.11947563716609 * tfactors.T9i; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 105.11947563716609 * tfactors.T9i * 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; + } + + // il10c + ln_set_rate = 43.610880958303156 + -102.85989563716609 * tfactors.T9i + -25.3278 * tfactors.T913i + 6.4931 * tfactors.T913 + + -9.27513 * tfactors.T9 + -0.610439 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 102.85989563716609 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -25.3278 * tfactors.T943i + (1.0/3.0) * 6.4931 * tfactors.T923i + + -9.27513 + (5.0/3.0) * -0.610439 * tfactors.T923 + 0.833333 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real S32_pf, dS32_pf_dT; + // interpolating S32 partition function + get_partition_function(S32, tfactors, S32_pf, dS32_pf_dT); + + Real P31_pf, dP31_pf_dT; + // interpolating P31 partition function + get_partition_function(P31, tfactors, P31_pf, dP31_pf_dT); + + Real z_r = p_pf * P31_pf; + Real z_p = S32_pf; + + Real dz_r_dT = P31_pf * dp_pf_dT + p_pf * dP31_pf_dT; + Real dz_p_dT = dS32_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_S32_to_He4_Si28_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // S32 --> He4 + Si28 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 72.81295409739818 + -80.62610309662641 * tfactors.T9i + -59.4896 * tfactors.T913i + 4.47205 * tfactors.T913 + + -4.78989 * tfactors.T9 + 0.557201 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 80.62610309662641 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -59.4896 * tfactors.T943i + (1.0/3.0) * 4.47205 * tfactors.T923i + + -4.78989 + (5.0/3.0) * 0.557201 * tfactors.T923 + 0.833333 * 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; + } + + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real S32_pf, dS32_pf_dT; + // interpolating S32 partition function + get_partition_function(S32, tfactors, S32_pf, dS32_pf_dT); + + Real Si28_pf, dSi28_pf_dT; + // interpolating Si28 partition function + get_partition_function(Si28, tfactors, Si28_pf, dSi28_pf_dT); + + Real z_r = He4_pf * Si28_pf; + Real z_p = S32_pf; + + Real dz_r_dT = Si28_pf * dHe4_pf_dT + He4_pf * dSi28_pf_dT; + Real dz_p_dT = dS32_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_C12_to_He4_He4_He4_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // C12 --> He4 + He4 + He4 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // fy05c + ln_set_rate = 22.39392447043974 + -88.54942933569913 * tfactors.T9i + -13.49 * tfactors.T913i + 21.4259 * tfactors.T913 + + -1.34769 * tfactors.T9 + 0.0879816 * tfactors.T953 + -10.1653 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 88.54942933569913 * 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 + -10.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; + } + + // fy05c + ln_set_rate = 34.95602447043974 + -85.44732933569914 * tfactors.T9i + -23.57 * tfactors.T913i + 20.4886 * tfactors.T913 + + -12.9882 * tfactors.T9 + -20.0 * tfactors.T953 + 0.8333300000000001 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 85.44732933569914 * 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 + 0.8333300000000001 * 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; + } + + // fy05c + ln_set_rate = 45.77337247043974 + -84.42286933569913 * tfactors.T9i + -37.06 * tfactors.T913i + 29.3493 * tfactors.T913 + + -115.507 * tfactors.T9 + -10.0 * tfactors.T953 + 1.66667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 84.42286933569913 * tfactors.T9i * tfactors.T9i + -(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.66667 * 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; + } + + + Real C12_pf, dC12_pf_dT; + // setting C12 partition function to 1.0 by default, independent of T + C12_pf = 1.0_rt; + dC12_pf_dT = 0.0_rt; + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real z_r = He4_pf * He4_pf * He4_pf; + Real z_p = C12_pf; + + Real dz_r_dT = dHe4_pf_dT + dHe4_pf_dT + dHe4_pf_dT; + Real dz_p_dT = dC12_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_O16_to_He4_N13_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // O16 + p --> He4 + N13 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // cf88n + ln_set_rate = 42.232382494512464 + -60.55237555926846 * tfactors.T9i + -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 = 60.55237555926846 * tfactors.T9i * tfactors.T9i + -(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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real O16_pf, dO16_pf_dT; + // interpolating O16 partition function + get_partition_function(O16, tfactors, O16_pf, dO16_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real N13_pf, dN13_pf_dT; + // setting N13 partition function to 1.0 by default, independent of T + N13_pf = 1.0_rt; + dN13_pf_dT = 0.0_rt; + + Real z_r = He4_pf * N13_pf; + Real z_p = p_pf * O16_pf; + + Real dz_r_dT = N13_pf * dHe4_pf_dT + He4_pf * dN13_pf_dT; + Real dz_p_dT = O16_pf * dp_pf_dT + p_pf * dO16_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He4_Ne20_to_p_Na23_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ne20 + He4 --> p + Na23 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = -6.377717086437262 + -29.88961364462334 * tfactors.T9i + 19.7297 * tfactors.T913 + + -2.20987 * tfactors.T9 + 0.153374 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 29.88961364462334 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 19.7297 * tfactors.T923i + + -2.20987 + (5.0/3.0) * 0.153374 * 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; + } + + // il10c + ln_set_rate = 0.227472413562738 + -29.434873644623337 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 29.434873644623337 * 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; + } + + // il10c + ln_set_rate = 19.18524291356274 + -27.573843644623338 * tfactors.T9i + -20.0024 * tfactors.T913i + 11.5988 * tfactors.T913 + + -1.37398 * tfactors.T9 + -1.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 27.573843644623338 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -20.0024 * tfactors.T943i + (1.0/3.0) * 11.5988 * tfactors.T923i + + -1.37398 + (5.0/3.0) * -1.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; + } + + + Real Na23_pf, dNa23_pf_dT; + // interpolating Na23 partition function + get_partition_function(Na23, tfactors, Na23_pf, dNa23_pf_dT); + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Ne20_pf, dNe20_pf_dT; + // interpolating Ne20 partition function + get_partition_function(Ne20, tfactors, Ne20_pf, dNe20_pf_dT); + + Real z_r = p_pf * Na23_pf; + Real z_p = He4_pf * Ne20_pf; + + Real dz_r_dT = Na23_pf * dp_pf_dT + p_pf * dNa23_pf_dT; + Real dz_p_dT = Ne20_pf * dHe4_pf_dT + He4_pf * dNe20_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He4_Mg24_to_p_Al27_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Mg24 + He4 --> p + Al27 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = -6.445750338407262 + -22.82086933218981 * tfactors.T9i + 18.0416 * tfactors.T913 + + -1.54137 * tfactors.T9 + 0.0847506 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 22.82086933218981 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 18.0416 * tfactors.T923i + + -1.54137 + (5.0/3.0) * 0.0847506 * 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; + } + + // il10c + ln_set_rate = -26.286160338407264 + -19.54138133218981 * tfactors.T9i + 5.18642 * tfactors.T913i + -34.7936 * tfactors.T913 + + 168.225 * tfactors.T9 + -115.825 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 19.54138133218981 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 5.18642 * tfactors.T943i + (1.0/3.0) * -34.7936 * tfactors.T923i + + 168.225 + (5.0/3.0) * -115.825 * 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; + } + + // il10c + ln_set_rate = 30.039739661592737 + -18.578369332189812 * tfactors.T9i + -26.4162 * tfactors.T913i + + -2.0 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 18.578369332189812 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -26.4162 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Al27_pf, dAl27_pf_dT; + // interpolating Al27 partition function + get_partition_function(Al27, tfactors, Al27_pf, dAl27_pf_dT); + + Real Mg24_pf, dMg24_pf_dT; + // interpolating Mg24 partition function + get_partition_function(Mg24, tfactors, Mg24_pf, dMg24_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real z_r = p_pf * Al27_pf; + Real z_p = He4_pf * Mg24_pf; + + Real dz_r_dT = Al27_pf * dp_pf_dT + p_pf * dAl27_pf_dT; + Real dz_p_dT = Mg24_pf * dHe4_pf_dT + He4_pf * dMg24_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He4_Si28_to_p_P31_derived(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Si28 + He4 --> p + P31 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = -11.433473139095032 + -25.65965858572089 * tfactors.T9i + 21.521 * tfactors.T913 + + -1.90355 * tfactors.T9 + 0.092724 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 25.65965858572089 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 21.521 * tfactors.T923i + + -1.90355 + (5.0/3.0) * 0.092724 * 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; + } + + // il10c + ln_set_rate = -13.459473139095032 + -24.11106858572089 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 24.11106858572089 * 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; + } + + // il10c + ln_set_rate = 60.342426860904965 + -22.23390858572089 * tfactors.T9i + -31.932 * tfactors.T913i + -77.0334 * tfactors.T913 + + -43.6847 * tfactors.T9 + -4.28955 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 22.23390858572089 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -31.932 * tfactors.T943i + (1.0/3.0) * -77.0334 * tfactors.T923i + + -43.6847 + (5.0/3.0) * -4.28955 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real P31_pf, dP31_pf_dT; + // interpolating P31 partition function + get_partition_function(P31, tfactors, P31_pf, dP31_pf_dT); + + Real Si28_pf, dSi28_pf_dT; + // interpolating Si28 partition function + get_partition_function(Si28, tfactors, Si28_pf, dSi28_pf_dT); + + Real z_r = p_pf * P31_pf; + Real z_p = He4_pf * Si28_pf; + + Real dz_r_dT = P31_pf * dp_pf_dT + p_pf * dP31_pf_dT; + Real dz_p_dT = Si28_pf * dHe4_pf_dT + He4_pf * dSi28_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He4_S32_to_p_Cl35_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // S32 + He4 --> p + Cl35 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = 2.425628238034531 + -27.66622776398283 * tfactors.T9i + 5.33756 * tfactors.T913 + + 1.64418 * tfactors.T9 + -0.246167 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 27.66622776398283 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 5.33756 * tfactors.T923i + + 1.64418 + (5.0/3.0) * -0.246167 * 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; + } + + // il10c + ln_set_rate = -0.877601761965469 + -25.59141776398283 * tfactors.T9i + + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 25.59141776398283 * 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; + } + + // il10c + ln_set_rate = -57.39498176196547 + -22.18939876398283 * tfactors.T9i + 25.5338 * tfactors.T913 + + 6.45824 * tfactors.T9 + -0.950294 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 22.18939876398283 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 25.5338 * tfactors.T923i + + 6.45824 + (5.0/3.0) * -0.950294 * 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; + } + + // il10c + ln_set_rate = 32.25441823803453 + -21.65646776398283 * tfactors.T9i + -30.9147 * tfactors.T913i + -1.2345 * tfactors.T913 + + 22.5118 * tfactors.T9 + -33.0589 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 21.65646776398283 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -30.9147 * tfactors.T943i + (1.0/3.0) * -1.2345 * tfactors.T923i + + 22.5118 + (5.0/3.0) * -33.0589 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Cl35_pf, dCl35_pf_dT; + // interpolating Cl35 partition function + get_partition_function(Cl35, tfactors, Cl35_pf, dCl35_pf_dT); + + Real S32_pf, dS32_pf_dT; + // interpolating S32 partition function + get_partition_function(S32, tfactors, S32_pf, dS32_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real z_r = p_pf * Cl35_pf; + Real z_p = He4_pf * S32_pf; + + Real dz_r_dT = Cl35_pf * dp_pf_dT + p_pf * dCl35_pf_dT; + Real dz_p_dT = S32_pf * dHe4_pf_dT + He4_pf * dS32_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ar36_to_He4_S32_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ar36 --> He4 + S32 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 73.81637663285039 + -77.06281976216322 * tfactors.T9i + -65.3709 * tfactors.T913i + 5.68294 * tfactors.T913 + + -5.00388 * tfactors.T9 + 0.571407 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 77.06281976216322 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -65.3709 * tfactors.T943i + (1.0/3.0) * 5.68294 * tfactors.T923i + + -5.00388 + (5.0/3.0) * 0.571407 * tfactors.T923 + 0.833333 * 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; + } + + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real S32_pf, dS32_pf_dT; + // interpolating S32 partition function + get_partition_function(S32, tfactors, S32_pf, dS32_pf_dT); + + Real Ar36_pf, dAr36_pf_dT; + // interpolating Ar36 partition function + get_partition_function(Ar36, tfactors, Ar36_pf, dAr36_pf_dT); + + Real z_r = He4_pf * S32_pf; + Real z_p = Ar36_pf; + + Real dz_r_dT = S32_pf * dHe4_pf_dT + He4_pf * dS32_pf_dT; + Real dz_p_dT = dAr36_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ar36_to_p_Cl35_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ar36 --> p + Cl35 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // il10c + ln_set_rate = 16.01685487088493 + -100.72924752614605 * tfactors.T9i; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 100.72924752614605 * tfactors.T9i * 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; + } + + // il10c + ln_set_rate = -17.47510512911507 + -99.28393852614604 * tfactors.T9i; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 99.28393852614604 * tfactors.T9i * 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; + } + + // il10c + ln_set_rate = 60.73659487088493 + -98.71928752614605 * tfactors.T9i + -27.8971 * tfactors.T913i + -16.2304 * tfactors.T913 + + 35.255 * tfactors.T9 + -25.8411 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 98.71928752614605 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -27.8971 * tfactors.T943i + (1.0/3.0) * -16.2304 * tfactors.T923i + + 35.255 + (5.0/3.0) * -25.8411 * tfactors.T923 + 0.833333 * 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; + } + + // il10c + ln_set_rate = 17.202804870884933 + -102.37020752614605 * tfactors.T9i + 18.0179 * tfactors.T913 + + -2.86304 * tfactors.T9 + 0.250854 * tfactors.T953; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 102.37020752614605 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 18.0179 * tfactors.T923i + + -2.86304 + (5.0/3.0) * 0.250854 * tfactors.T923; + } + + // 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Cl35_pf, dCl35_pf_dT; + // interpolating Cl35 partition function + get_partition_function(Cl35, tfactors, Cl35_pf, dCl35_pf_dT); + + Real Ar36_pf, dAr36_pf_dT; + // interpolating Ar36 partition function + get_partition_function(Ar36, tfactors, Ar36_pf, dAr36_pf_dT); + + Real z_r = p_pf * Cl35_pf; + Real z_p = Ar36_pf; + + Real dz_r_dT = Cl35_pf * dp_pf_dT + p_pf * dCl35_pf_dT; + Real dz_p_dT = dAr36_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He4_Ar36_to_p_K39_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ar36 + He4 --> p + K39 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 20.636664061510302 + -14.953349961318928 * tfactors.T9i + -30.0732 * tfactors.T913i + 7.03263 * tfactors.T913 + + -1.10085 * tfactors.T9 + 0.133768 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 14.953349961318928 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -30.0732 * tfactors.T943i + (1.0/3.0) * 7.03263 * tfactors.T923i + + -1.10085 + (5.0/3.0) * 0.133768 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real K39_pf, dK39_pf_dT; + // interpolating K39 partition function + get_partition_function(K39, tfactors, K39_pf, dK39_pf_dT); + + Real Ar36_pf, dAr36_pf_dT; + // interpolating Ar36 partition function + get_partition_function(Ar36, tfactors, Ar36_pf, dAr36_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real z_r = p_pf * K39_pf; + Real z_p = He4_pf * Ar36_pf; + + Real dz_r_dT = K39_pf * dp_pf_dT + p_pf * dK39_pf_dT; + Real dz_p_dT = Ar36_pf * dHe4_pf_dT + He4_pf * dAr36_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ca40_to_He4_Ar36_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ca40 --> He4 + Ar36 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 77.28261041284823 + -81.69174599574632 * tfactors.T9i + -71.0046 * tfactors.T913i + 4.0656 * tfactors.T913 + + -5.26509 * tfactors.T9 + 0.683546 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 81.69174599574632 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -71.0046 * tfactors.T943i + (1.0/3.0) * 4.0656 * tfactors.T923i + + -5.26509 + (5.0/3.0) * 0.683546 * tfactors.T923 + 0.833333 * 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; + } + + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Ca40_pf, dCa40_pf_dT; + // interpolating Ca40 partition function + get_partition_function(Ca40, tfactors, Ca40_pf, dCa40_pf_dT); + + Real Ar36_pf, dAr36_pf_dT; + // interpolating Ar36 partition function + get_partition_function(Ar36, tfactors, Ar36_pf, dAr36_pf_dT); + + Real z_r = He4_pf * Ar36_pf; + Real z_p = Ca40_pf; + + Real dz_r_dT = Ar36_pf * dHe4_pf_dT + He4_pf * dAr36_pf_dT; + Real dz_p_dT = dCa40_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ca40_to_p_K39_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ca40 --> p + K39 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // lo18r + ln_set_rate = 2786.4340744743586 + -101.86662364079672 * tfactors.T9i + 802.18 * tfactors.T913i + -4010.27 * tfactors.T913 + + 1137.69 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 101.86662364079672 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 802.18 * tfactors.T943i + (1.0/3.0) * -4010.27 * tfactors.T923i + + 1137.69 * 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; + } + + // lo18r + ln_set_rate = 613.1530744743586 + -109.20898364079672 * tfactors.T9i + 641.844 * tfactors.T913i + -1248.49 * tfactors.T913 + + 566.426 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 109.20898364079672 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 641.844 * tfactors.T943i + (1.0/3.0) * -1248.49 * tfactors.T923i + + 566.426 * 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; + } + + // lo18r + ln_set_rate = 127.30607447435852 + -98.30936364079672 * tfactors.T9i + 41.1723 * tfactors.T913i + -149.299 * tfactors.T913 + + 10.5229 * tfactors.T9 + -0.68208 * tfactors.T953 + 60.7367 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 98.30936364079672 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 41.1723 * tfactors.T943i + (1.0/3.0) * -149.299 * tfactors.T923i + + 10.5229 + (5.0/3.0) * -0.68208 * tfactors.T923 + 60.7367 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Ca40_pf, dCa40_pf_dT; + // interpolating Ca40 partition function + get_partition_function(Ca40, tfactors, Ca40_pf, dCa40_pf_dT); + + Real K39_pf, dK39_pf_dT; + // interpolating K39 partition function + get_partition_function(K39, tfactors, K39_pf, dK39_pf_dT); + + Real z_r = p_pf * K39_pf; + Real z_p = Ca40_pf; + + Real dz_r_dT = K39_pf * dp_pf_dT + p_pf * dK39_pf_dT; + Real dz_p_dT = dCa40_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_He4_Ca40_to_p_Sc43_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ca40 + He4 --> p + Sc43 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 35.65752817292938 + -40.87575463203665 * tfactors.T9i + -32.1734 * tfactors.T913i + 0.0296879 * tfactors.T913 + + -0.95232 * tfactors.T9 + 0.129022 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 40.87575463203665 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -32.1734 * tfactors.T943i + (1.0/3.0) * 0.0296879 * tfactors.T923i + + -0.95232 + (5.0/3.0) * 0.129022 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Ca40_pf, dCa40_pf_dT; + // interpolating Ca40 partition function + get_partition_function(Ca40, tfactors, Ca40_pf, dCa40_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Sc43_pf, dSc43_pf_dT; + // interpolating Sc43 partition function + get_partition_function(Sc43, tfactors, Sc43_pf, dSc43_pf_dT); + + Real z_r = p_pf * Sc43_pf; + Real z_p = He4_pf * Ca40_pf; + + Real dz_r_dT = Sc43_pf * dp_pf_dT + p_pf * dSc43_pf_dT; + Real dz_p_dT = Ca40_pf * dHe4_pf_dT + He4_pf * dCa40_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ti44_to_He4_Ca40_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ti44 --> He4 + Ca40 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // chw0 + ln_set_rate = 78.69908591662849 + -59.4975248620018 * tfactors.T9i + -76.4273 * tfactors.T913i + 3.87451 * tfactors.T913 + + -3.61477 * tfactors.T9 + 0.367451 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 59.4975248620018 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -76.4273 * tfactors.T943i + (1.0/3.0) * 3.87451 * tfactors.T923i + + -3.61477 + (5.0/3.0) * 0.367451 * tfactors.T923 + 0.833333 * 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; + } + + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Ca40_pf, dCa40_pf_dT; + // interpolating Ca40 partition function + get_partition_function(Ca40, tfactors, Ca40_pf, dCa40_pf_dT); + + Real Ti44_pf, dTi44_pf_dT; + // interpolating Ti44 partition function + get_partition_function(Ti44, tfactors, Ti44_pf, dTi44_pf_dT); + + Real z_r = He4_pf * Ca40_pf; + Real z_p = Ti44_pf; + + Real dz_r_dT = Ca40_pf * dHe4_pf_dT + He4_pf * dCa40_pf_dT; + Real dz_p_dT = dTi44_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ti44_to_p_Sc43_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ti44 --> p + Sc43 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 62.59391408955788 + -100.37327949403844 * tfactors.T9i + -32.1734 * tfactors.T913i + -1.77078 * tfactors.T913 + + -2.21706 * tfactors.T9 + 0.298499 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 100.37327949403844 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -32.1734 * tfactors.T943i + (1.0/3.0) * -1.77078 * tfactors.T923i + + -2.21706 + (5.0/3.0) * 0.298499 * tfactors.T923 + 0.833333 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Ti44_pf, dTi44_pf_dT; + // interpolating Ti44 partition function + get_partition_function(Ti44, tfactors, Ti44_pf, dTi44_pf_dT); + + Real Sc43_pf, dSc43_pf_dT; + // interpolating Sc43 partition function + get_partition_function(Sc43, tfactors, Sc43_pf, dSc43_pf_dT); + + Real z_r = p_pf * Sc43_pf; + Real z_p = Ti44_pf; + + Real dz_r_dT = Sc43_pf * dp_pf_dT + p_pf * dSc43_pf_dT; + Real dz_p_dT = dTi44_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Cr48_to_He4_Ti44_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Cr48 --> He4 + Ti44 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 89.75733412085052 + -89.3041938384302 * tfactors.T9i + -81.667 * tfactors.T913i + -10.6333 * tfactors.T913 + + -0.672613 * tfactors.T9 + 0.161209 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 89.3041938384302 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -81.667 * tfactors.T943i + (1.0/3.0) * -10.6333 * tfactors.T923i + + -0.672613 + (5.0/3.0) * 0.161209 * tfactors.T923 + 0.833333 * 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; + } + + + Real Cr48_pf, dCr48_pf_dT; + // interpolating Cr48 partition function + get_partition_function(Cr48, tfactors, Cr48_pf, dCr48_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Ti44_pf, dTi44_pf_dT; + // interpolating Ti44 partition function + get_partition_function(Ti44, tfactors, Ti44_pf, dTi44_pf_dT); + + Real z_r = He4_pf * Ti44_pf; + Real z_p = Cr48_pf; + + Real dz_r_dT = Ti44_pf * dHe4_pf_dT + He4_pf * dTi44_pf_dT; + Real dz_p_dT = dCr48_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Cr48_to_p_V47_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Cr48 --> p + V47 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // nfisn + ln_set_rate = 67.74027107253823 + -100.12633621113824 * tfactors.T9i + -34.0548 * tfactors.T913i + -3.41973 * tfactors.T913 + + 1.16501 * tfactors.T9 + -0.105543 * tfactors.T953 + -6.20886 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 100.12633621113824 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -34.0548 * tfactors.T943i + (1.0/3.0) * -3.41973 * tfactors.T923i + + 1.16501 + (5.0/3.0) * -0.105543 * tfactors.T923 + -6.20886 * 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; + } + + // nfisn + ln_set_rate = 536.5234710725382 + -99.36194621113825 * tfactors.T9i + 317.171 * tfactors.T913i + -911.679 * tfactors.T913 + + 94.4245 * tfactors.T9 + -10.1973 * tfactors.T953 + 332.227 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 99.36194621113825 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * 317.171 * tfactors.T943i + (1.0/3.0) * -911.679 * tfactors.T923i + + 94.4245 + (5.0/3.0) * -10.1973 * tfactors.T923 + 332.227 * 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; + } + + // nfisn + ln_set_rate = 48.891971072538226 + -93.82037121113825 * tfactors.T9i + -45.9868 * tfactors.T913i + 13.6822 * tfactors.T913 + + -0.376902 * tfactors.T9 + -0.0194875 * tfactors.T953 + -6.9232499999999995 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 93.82037121113825 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -45.9868 * tfactors.T943i + (1.0/3.0) * 13.6822 * tfactors.T923i + + -0.376902 + (5.0/3.0) * -0.0194875 * tfactors.T923 + -6.9232499999999995 * 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; + } + + // nfisn + ln_set_rate = 65.62307107253824 + -94.58145021113825 * tfactors.T9i + -110.655 * tfactors.T913i + 83.0232 * tfactors.T913 + + -19.7762 * tfactors.T9 + 3.03961 * tfactors.T953 + -47.9742 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 94.58145021113825 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -110.655 * tfactors.T943i + (1.0/3.0) * 83.0232 * tfactors.T923i + + -19.7762 + (5.0/3.0) * 3.03961 * tfactors.T923 + -47.9742 * 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; + } + + + Real Cr48_pf, dCr48_pf_dT; + // interpolating Cr48 partition function + get_partition_function(Cr48, tfactors, Cr48_pf, dCr48_pf_dT); + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real V47_pf, dV47_pf_dT; + // interpolating V47 partition function + get_partition_function(V47, tfactors, V47_pf, dV47_pf_dT); + + Real z_r = p_pf * V47_pf; + Real z_p = Cr48_pf; + + Real dz_r_dT = V47_pf * dp_pf_dT + p_pf * dV47_pf_dT; + Real dz_p_dT = dCr48_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_V47_to_He4_Ti44_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // V47 + p --> He4 + Ti44 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // chw0r + ln_set_rate = -76.61433695168769 + -6.029445311023438 * tfactors.T9i + 70.2835 * tfactors.T913 + + -7.99061 * tfactors.T9 + 0.486213 * tfactors.T953 + -1.5 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 6.029445311023438 * tfactors.T9i * tfactors.T9i + (1.0/3.0) * 70.2835 * tfactors.T923i + + -7.99061 + (5.0/3.0) * 0.486213 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real V47_pf, dV47_pf_dT; + // interpolating V47 partition function + get_partition_function(V47, tfactors, V47_pf, dV47_pf_dT); + + Real Ti44_pf, dTi44_pf_dT; + // interpolating Ti44 partition function + get_partition_function(Ti44, tfactors, Ti44_pf, dTi44_pf_dT); + + Real z_r = He4_pf * Ti44_pf; + Real z_p = p_pf * V47_pf; + + Real dz_r_dT = Ti44_pf * dHe4_pf_dT + He4_pf * dTi44_pf_dT; + Real dz_p_dT = V47_pf * dp_pf_dT + p_pf * dV47_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Fe52_to_He4_Cr48_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Fe52 --> He4 + Cr48 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 90.14738712482466 + -92.10912191363732 * tfactors.T9i + -86.7459 * tfactors.T913i + -9.79373 * tfactors.T913 + + -0.772169 * tfactors.T9 + 0.155883 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 92.10912191363732 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -86.7459 * tfactors.T943i + (1.0/3.0) * -9.79373 * tfactors.T923i + + -0.772169 + (5.0/3.0) * 0.155883 * tfactors.T923 + 0.833333 * 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; + } + + + Real Cr48_pf, dCr48_pf_dT; + // interpolating Cr48 partition function + get_partition_function(Cr48, tfactors, Cr48_pf, dCr48_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Fe52_pf, dFe52_pf_dT; + // interpolating Fe52 partition function + get_partition_function(Fe52, tfactors, Fe52_pf, dFe52_pf_dT); + + Real z_r = He4_pf * Cr48_pf; + Real z_p = Fe52_pf; + + Real dz_r_dT = Cr48_pf * dHe4_pf_dT + He4_pf * dCr48_pf_dT; + Real dz_p_dT = dFe52_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Fe52_to_p_Mn51_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Fe52 --> p + Mn51 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 61.72798916565748 + -85.6326403498911 * tfactors.T9i + -36.1825 * tfactors.T913i + 0.873042 * tfactors.T913 + + -2.89731 * tfactors.T9 + 0.364394 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 85.6326403498911 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -36.1825 * tfactors.T943i + (1.0/3.0) * 0.873042 * tfactors.T923i + + -2.89731 + (5.0/3.0) * 0.364394 * tfactors.T923 + 0.833333 * 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; + } + + + Real Mn51_pf, dMn51_pf_dT; + // interpolating Mn51 partition function + get_partition_function(Mn51, tfactors, Mn51_pf, dMn51_pf_dT); + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Fe52_pf, dFe52_pf_dT; + // interpolating Fe52 partition function + get_partition_function(Fe52, tfactors, Fe52_pf, dFe52_pf_dT); + + Real z_r = p_pf * Mn51_pf; + Real z_p = Fe52_pf; + + Real dz_r_dT = Mn51_pf * dp_pf_dT + p_pf * dMn51_pf_dT; + Real dz_p_dT = dFe52_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_Mn51_to_He4_Cr48_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Mn51 + p --> He4 + Cr48 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 58.73119795916719 + -6.476551190854941 * tfactors.T9i + -86.7459 * tfactors.T913i + 1.05653 * tfactors.T913 + + -1.15757 * tfactors.T9 + 0.0877546 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 6.476551190854941 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -86.7459 * tfactors.T943i + (1.0/3.0) * 1.05653 * tfactors.T923i + + -1.15757 + (5.0/3.0) * 0.0877546 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Cr48_pf, dCr48_pf_dT; + // interpolating Cr48 partition function + get_partition_function(Cr48, tfactors, Cr48_pf, dCr48_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Mn51_pf, dMn51_pf_dT; + // interpolating Mn51 partition function + get_partition_function(Mn51, tfactors, Mn51_pf, dMn51_pf_dT); + + Real z_r = He4_pf * Cr48_pf; + Real z_p = p_pf * Mn51_pf; + + Real dz_r_dT = Cr48_pf * dHe4_pf_dT + He4_pf * dCr48_pf_dT; + Real dz_p_dT = Mn51_pf * dp_pf_dT + p_pf * dMn51_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ni56_to_He4_Fe52_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ni56 --> He4 + Fe52 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 91.62258922810439 + -92.801099329237 * tfactors.T9i + -91.6819 * tfactors.T913i + -9.51885 * tfactors.T913 + + -0.533014 * tfactors.T9 + 0.0892607 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 92.801099329237 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -91.6819 * tfactors.T943i + (1.0/3.0) * -9.51885 * tfactors.T923i + + -0.533014 + (5.0/3.0) * 0.0892607 * tfactors.T923 + 0.833333 * 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; + } + + + Real Ni56_pf, dNi56_pf_dT; + // interpolating Ni56 partition function + get_partition_function(Ni56, tfactors, Ni56_pf, dNi56_pf_dT); + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Fe52_pf, dFe52_pf_dT; + // interpolating Fe52 partition function + get_partition_function(Fe52, tfactors, Fe52_pf, dFe52_pf_dT); + + Real z_r = He4_pf * Fe52_pf; + Real z_p = Ni56_pf; + + Real dz_r_dT = Fe52_pf * dHe4_pf_dT + He4_pf * dFe52_pf_dT; + Real dz_p_dT = dNi56_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ni56_to_p_Co55_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Ni56 --> p + Co55 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 63.131770608640906 + -83.14741674893808 * tfactors.T9i + -38.1053 * tfactors.T913i + -0.210947 * tfactors.T913 + + -2.68377 * tfactors.T9 + 0.355814 * tfactors.T953 + 0.833333 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 83.14741674893808 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -38.1053 * tfactors.T943i + (1.0/3.0) * -0.210947 * tfactors.T923i + + -2.68377 + (5.0/3.0) * 0.355814 * tfactors.T923 + 0.833333 * 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; + } + + + Real Ni56_pf, dNi56_pf_dT; + // interpolating Ni56 partition function + get_partition_function(Ni56, tfactors, Ni56_pf, dNi56_pf_dT); + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real Co55_pf, dCo55_pf_dT; + // interpolating Co55 partition function + get_partition_function(Co55, tfactors, Co55_pf, dCo55_pf_dT); + + Real z_r = p_pf * Co55_pf; + Real z_p = Ni56_pf; + + Real dz_r_dT = Co55_pf * dp_pf_dT + p_pf * dCo55_pf_dT; + Real dz_p_dT = dNi56_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_p_Co55_to_He4_Fe52_derived_removed(const tf_t& tfactors, Real& rate, Real& drate_dT) { + + // Co55 + p --> He4 + Fe52 + + rate = 0.0; + drate_dT = 0.0; + + Real ln_set_rate{0.0}; + Real dln_set_rate_dT9{0.0}; + Real set_rate{0.0}; + + // ths8r + ln_set_rate = 61.443418619463486 + -9.65364776674457 * tfactors.T9i + -91.6819 * tfactors.T913i + -0.329235 * tfactors.T913 + + -0.780924 * tfactors.T9 + 0.0425179 * tfactors.T953 + -0.666667 * tfactors.lnT9; + + if constexpr (do_T_derivatives) { + dln_set_rate_dT9 = 9.65364776674457 * tfactors.T9i * tfactors.T9i + -(1.0/3.0) * -91.6819 * tfactors.T943i + (1.0/3.0) * -0.329235 * tfactors.T923i + + -0.780924 + (5.0/3.0) * 0.0425179 * 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; + } + + + Real p_pf, dp_pf_dT; + // setting p partition function to 1.0 by default, independent of T + p_pf = 1.0_rt; + dp_pf_dT = 0.0_rt; + + Real He4_pf, dHe4_pf_dT; + // setting He4 partition function to 1.0 by default, independent of T + He4_pf = 1.0_rt; + dHe4_pf_dT = 0.0_rt; + + Real Co55_pf, dCo55_pf_dT; + // interpolating Co55 partition function + get_partition_function(Co55, tfactors, Co55_pf, dCo55_pf_dT); + + Real Fe52_pf, dFe52_pf_dT; + // interpolating Fe52 partition function + get_partition_function(Fe52, tfactors, Fe52_pf, dFe52_pf_dT); + + Real z_r = He4_pf * Fe52_pf; + Real z_p = p_pf * Co55_pf; + + Real dz_r_dT = Fe52_pf * dHe4_pf_dT + He4_pf * dFe52_pf_dT; + Real dz_p_dT = Co55_pf * dp_pf_dT + p_pf * dCo55_pf_dT; + + Real dzterm_dT = (z_p * dz_r_dT - z_r * dz_p_dT) / (z_p * z_p); + + drate_dT = dzterm_dT * rate + drate_dT * (z_r / z_p); + rate *= z_r/z_p; + +} + + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_S32_He4_to_Ar36_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ag = rate_eval.screened_rates(k_He4_S32_to_Ar36_removed); + Real r_ap = rate_eval.screened_rates(k_He4_S32_to_p_Cl35_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_Cl35_to_Ar36_removed); + Real r_pa = rate_eval.screened_rates(k_p_Cl35_to_He4_S32_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ag + r_ap * r_pg * dd; + if constexpr (std::is_same::value) { + Real drdT_ag = rate_eval.dscreened_rates_dT(k_He4_S32_to_Ar36_removed); + Real drdT_ap = rate_eval.dscreened_rates_dT(k_He4_S32_to_p_Cl35_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_Cl35_to_Ar36_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_Cl35_to_He4_S32_removed); + drate_dT = drdT_ag + drdT_ap * r_pg * dd + r_ap * drdT_pg * dd - r_ap * r_pg * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ar36_to_S32_He4_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ga = rate_eval.screened_rates(k_Ar36_to_He4_S32_derived_removed); + Real r_pa = rate_eval.screened_rates(k_p_Cl35_to_He4_S32_removed); + Real r_gp = rate_eval.screened_rates(k_Ar36_to_p_Cl35_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_Cl35_to_Ar36_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ga + r_gp * r_pa * dd; + if constexpr (std::is_same::value) { + Real drdT_ga = rate_eval.dscreened_rates_dT(k_Ar36_to_He4_S32_derived_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_Cl35_to_He4_S32_removed); + Real drdT_gp = rate_eval.dscreened_rates_dT(k_Ar36_to_p_Cl35_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_Cl35_to_Ar36_removed); + drate_dT = drdT_ga + drdT_gp * r_pa * dd + r_gp * drdT_pa * dd - r_gp * r_pa * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ar36_He4_to_Ca40_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ag = rate_eval.screened_rates(k_He4_Ar36_to_Ca40_removed); + Real r_ap = rate_eval.screened_rates(k_He4_Ar36_to_p_K39_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_K39_to_Ca40_removed); + Real r_pa = rate_eval.screened_rates(k_p_K39_to_He4_Ar36_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ag + r_ap * r_pg * dd; + if constexpr (std::is_same::value) { + Real drdT_ag = rate_eval.dscreened_rates_dT(k_He4_Ar36_to_Ca40_removed); + Real drdT_ap = rate_eval.dscreened_rates_dT(k_He4_Ar36_to_p_K39_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_K39_to_Ca40_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_K39_to_He4_Ar36_removed); + drate_dT = drdT_ag + drdT_ap * r_pg * dd + r_ap * drdT_pg * dd - r_ap * r_pg * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ca40_to_Ar36_He4_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ga = rate_eval.screened_rates(k_Ca40_to_He4_Ar36_derived_removed); + Real r_pa = rate_eval.screened_rates(k_p_K39_to_He4_Ar36_removed); + Real r_gp = rate_eval.screened_rates(k_Ca40_to_p_K39_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_K39_to_Ca40_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ga + r_gp * r_pa * dd; + if constexpr (std::is_same::value) { + Real drdT_ga = rate_eval.dscreened_rates_dT(k_Ca40_to_He4_Ar36_derived_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_K39_to_He4_Ar36_removed); + Real drdT_gp = rate_eval.dscreened_rates_dT(k_Ca40_to_p_K39_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_K39_to_Ca40_removed); + drate_dT = drdT_ga + drdT_gp * r_pa * dd + r_gp * drdT_pa * dd - r_gp * r_pa * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ca40_He4_to_Ti44_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ag = rate_eval.screened_rates(k_He4_Ca40_to_Ti44_removed); + Real r_ap = rate_eval.screened_rates(k_He4_Ca40_to_p_Sc43_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_Sc43_to_Ti44_removed); + Real r_pa = rate_eval.screened_rates(k_p_Sc43_to_He4_Ca40_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ag + r_ap * r_pg * dd; + if constexpr (std::is_same::value) { + Real drdT_ag = rate_eval.dscreened_rates_dT(k_He4_Ca40_to_Ti44_removed); + Real drdT_ap = rate_eval.dscreened_rates_dT(k_He4_Ca40_to_p_Sc43_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_Sc43_to_Ti44_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_Sc43_to_He4_Ca40_removed); + drate_dT = drdT_ag + drdT_ap * r_pg * dd + r_ap * drdT_pg * dd - r_ap * r_pg * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ti44_to_Ca40_He4_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ga = rate_eval.screened_rates(k_Ti44_to_He4_Ca40_derived_removed); + Real r_pa = rate_eval.screened_rates(k_p_Sc43_to_He4_Ca40_removed); + Real r_gp = rate_eval.screened_rates(k_Ti44_to_p_Sc43_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_Sc43_to_Ti44_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ga + r_gp * r_pa * dd; + if constexpr (std::is_same::value) { + Real drdT_ga = rate_eval.dscreened_rates_dT(k_Ti44_to_He4_Ca40_derived_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_Sc43_to_He4_Ca40_removed); + Real drdT_gp = rate_eval.dscreened_rates_dT(k_Ti44_to_p_Sc43_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_Sc43_to_Ti44_removed); + drate_dT = drdT_ga + drdT_gp * r_pa * dd + r_gp * drdT_pa * dd - r_gp * r_pa * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ti44_He4_to_Cr48_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ag = rate_eval.screened_rates(k_He4_Ti44_to_Cr48_removed); + Real r_ap = rate_eval.screened_rates(k_He4_Ti44_to_p_V47_removed); + Real r_pg = rate_eval.screened_rates(k_p_V47_to_Cr48_removed); + Real r_pa = rate_eval.screened_rates(k_p_V47_to_He4_Ti44_derived_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ag + r_ap * r_pg * dd; + if constexpr (std::is_same::value) { + Real drdT_ag = rate_eval.dscreened_rates_dT(k_He4_Ti44_to_Cr48_removed); + Real drdT_ap = rate_eval.dscreened_rates_dT(k_He4_Ti44_to_p_V47_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_V47_to_Cr48_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_V47_to_He4_Ti44_derived_removed); + drate_dT = drdT_ag + drdT_ap * r_pg * dd + r_ap * drdT_pg * dd - r_ap * r_pg * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Cr48_to_Ti44_He4_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ga = rate_eval.screened_rates(k_Cr48_to_He4_Ti44_derived_removed); + Real r_pa = rate_eval.screened_rates(k_p_V47_to_He4_Ti44_derived_removed); + Real r_gp = rate_eval.screened_rates(k_Cr48_to_p_V47_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_V47_to_Cr48_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ga + r_gp * r_pa * dd; + if constexpr (std::is_same::value) { + Real drdT_ga = rate_eval.dscreened_rates_dT(k_Cr48_to_He4_Ti44_derived_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_V47_to_He4_Ti44_derived_removed); + Real drdT_gp = rate_eval.dscreened_rates_dT(k_Cr48_to_p_V47_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_V47_to_Cr48_removed); + drate_dT = drdT_ga + drdT_gp * r_pa * dd + r_gp * drdT_pa * dd - r_gp * r_pa * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Cr48_He4_to_Fe52_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ag = rate_eval.screened_rates(k_He4_Cr48_to_Fe52_removed); + Real r_ap = rate_eval.screened_rates(k_He4_Cr48_to_p_Mn51_removed); + Real r_pg = rate_eval.screened_rates(k_p_Mn51_to_Fe52_removed); + Real r_pa = rate_eval.screened_rates(k_p_Mn51_to_He4_Cr48_derived_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ag + r_ap * r_pg * dd; + if constexpr (std::is_same::value) { + Real drdT_ag = rate_eval.dscreened_rates_dT(k_He4_Cr48_to_Fe52_removed); + Real drdT_ap = rate_eval.dscreened_rates_dT(k_He4_Cr48_to_p_Mn51_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_Mn51_to_Fe52_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_Mn51_to_He4_Cr48_derived_removed); + drate_dT = drdT_ag + drdT_ap * r_pg * dd + r_ap * drdT_pg * dd - r_ap * r_pg * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Fe52_to_Cr48_He4_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ga = rate_eval.screened_rates(k_Fe52_to_He4_Cr48_derived_removed); + Real r_pa = rate_eval.screened_rates(k_p_Mn51_to_He4_Cr48_derived_removed); + Real r_gp = rate_eval.screened_rates(k_Fe52_to_p_Mn51_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_Mn51_to_Fe52_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ga + r_gp * r_pa * dd; + if constexpr (std::is_same::value) { + Real drdT_ga = rate_eval.dscreened_rates_dT(k_Fe52_to_He4_Cr48_derived_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_Mn51_to_He4_Cr48_derived_removed); + Real drdT_gp = rate_eval.dscreened_rates_dT(k_Fe52_to_p_Mn51_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_Mn51_to_Fe52_removed); + drate_dT = drdT_ga + drdT_gp * r_pa * dd + r_gp * drdT_pa * dd - r_gp * r_pa * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Fe52_He4_to_Ni56_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ag = rate_eval.screened_rates(k_He4_Fe52_to_Ni56_removed); + Real r_ap = rate_eval.screened_rates(k_He4_Fe52_to_p_Co55_removed); + Real r_pg = rate_eval.screened_rates(k_p_Co55_to_Ni56_removed); + Real r_pa = rate_eval.screened_rates(k_p_Co55_to_He4_Fe52_derived_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ag + r_ap * r_pg * dd; + if constexpr (std::is_same::value) { + Real drdT_ag = rate_eval.dscreened_rates_dT(k_He4_Fe52_to_Ni56_removed); + Real drdT_ap = rate_eval.dscreened_rates_dT(k_He4_Fe52_to_p_Co55_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_Co55_to_Ni56_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_Co55_to_He4_Fe52_derived_removed); + drate_dT = drdT_ag + drdT_ap * r_pg * dd + r_ap * drdT_pg * dd - r_ap * r_pg * dd * dd * (drdT_pg + drdT_pa); + } +} + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void rate_Ni56_to_Fe52_He4_approx(const T& rate_eval, Real& rate, Real& drate_dT) { + + Real r_ga = rate_eval.screened_rates(k_Ni56_to_He4_Fe52_derived_removed); + Real r_pa = rate_eval.screened_rates(k_p_Co55_to_He4_Fe52_derived_removed); + Real r_gp = rate_eval.screened_rates(k_Ni56_to_p_Co55_derived_removed); + Real r_pg = rate_eval.screened_rates(k_p_Co55_to_Ni56_removed); + Real dd = 1.0_rt / (r_pg + r_pa); + rate = r_ga + r_gp * r_pa * dd; + if constexpr (std::is_same::value) { + Real drdT_ga = rate_eval.dscreened_rates_dT(k_Ni56_to_He4_Fe52_derived_removed); + Real drdT_pa = rate_eval.dscreened_rates_dT(k_p_Co55_to_He4_Fe52_derived_removed); + Real drdT_gp = rate_eval.dscreened_rates_dT(k_Ni56_to_p_Co55_derived_removed); + Real drdT_pg = rate_eval.dscreened_rates_dT(k_p_Co55_to_Ni56_removed); + drate_dT = drdT_ga + drdT_gp * r_pa * dd + r_gp * drdT_pa * dd - r_gp * r_pa * dd * dd * (drdT_pg + drdT_pa); + } +} + + +template +AMREX_GPU_HOST_DEVICE AMREX_INLINE +void +fill_reaclib_rates(const tf_t& tfactors, T& rate_eval) +{ + + Real rate; + Real 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::value) { + 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::value) { + rate_eval.dscreened_rates_dT(k_He4_C12_to_O16) = drate_dT; + + } + rate_He4_O16_to_Ne20(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_O16_to_Ne20) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_O16_to_Ne20) = drate_dT; + + } + rate_He4_Ne20_to_Mg24(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Ne20_to_Mg24) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Ne20_to_Mg24) = drate_dT; + + } + rate_p_Na23_to_Mg24(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Na23_to_Mg24) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Na23_to_Mg24) = drate_dT; + + } + rate_He4_Mg24_to_Si28(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Mg24_to_Si28) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Mg24_to_Si28) = drate_dT; + + } + rate_p_Al27_to_Si28(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Al27_to_Si28) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Al27_to_Si28) = drate_dT; + + } + rate_He4_Si28_to_S32(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Si28_to_S32) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Si28_to_S32) = drate_dT; + + } + rate_p_P31_to_S32(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_P31_to_S32) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_P31_to_S32) = drate_dT; + + } + rate_C12_C12_to_p_Na23(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_C12_C12_to_p_Na23) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_C12_C12_to_p_Na23) = drate_dT; + + } + rate_C12_C12_to_He4_Ne20(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_C12_C12_to_He4_Ne20) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_C12_C12_to_He4_Ne20) = 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::value) { + rate_eval.dscreened_rates_dT(k_He4_N13_to_p_O16) = drate_dT; + + } + rate_C12_O16_to_p_Al27(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_C12_O16_to_p_Al27) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_C12_O16_to_p_Al27) = drate_dT; + + } + rate_C12_O16_to_He4_Mg24(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_C12_O16_to_He4_Mg24) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_C12_O16_to_He4_Mg24) = drate_dT; + + } + rate_O16_O16_to_p_P31(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_O16_O16_to_p_P31) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_O16_O16_to_p_P31) = drate_dT; + + } + rate_O16_O16_to_He4_Si28(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_O16_O16_to_He4_Si28) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_O16_O16_to_He4_Si28) = drate_dT; + + } + rate_p_Na23_to_He4_Ne20(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Na23_to_He4_Ne20) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Na23_to_He4_Ne20) = drate_dT; + + } + rate_p_Al27_to_He4_Mg24(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Al27_to_He4_Mg24) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Al27_to_He4_Mg24) = drate_dT; + + } + rate_p_P31_to_He4_Si28(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_P31_to_He4_Si28) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_P31_to_He4_Si28) = 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::value) { + rate_eval.dscreened_rates_dT(k_He4_He4_He4_to_C12) = drate_dT; + + } + rate_C12_C12_to_Mg24_modified(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_C12_C12_to_Mg24_modified) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_C12_C12_to_Mg24_modified) = drate_dT; + + } + rate_O16_O16_to_S32_modified(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_O16_O16_to_S32_modified) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_O16_O16_to_S32_modified) = drate_dT; + + } + rate_C12_O16_to_Si28_modified(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_C12_O16_to_Si28_modified) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_C12_O16_to_Si28_modified) = drate_dT; + + } + rate_He4_S32_to_Ar36_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_S32_to_Ar36_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_S32_to_Ar36_removed) = drate_dT; + + } + rate_p_Cl35_to_Ar36_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Cl35_to_Ar36_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Cl35_to_Ar36_removed) = drate_dT; + + } + rate_p_Cl35_to_He4_S32_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Cl35_to_He4_S32_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Cl35_to_He4_S32_removed) = drate_dT; + + } + rate_He4_Ar36_to_Ca40_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Ar36_to_Ca40_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Ar36_to_Ca40_removed) = drate_dT; + + } + rate_p_K39_to_Ca40_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_K39_to_Ca40_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_K39_to_Ca40_removed) = drate_dT; + + } + rate_p_K39_to_He4_Ar36_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_K39_to_He4_Ar36_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_K39_to_He4_Ar36_removed) = drate_dT; + + } + rate_He4_Ca40_to_Ti44_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Ca40_to_Ti44_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Ca40_to_Ti44_removed) = drate_dT; + + } + rate_p_Sc43_to_Ti44_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Sc43_to_Ti44_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Sc43_to_Ti44_removed) = drate_dT; + + } + rate_p_Sc43_to_He4_Ca40_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Sc43_to_He4_Ca40_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Sc43_to_He4_Ca40_removed) = drate_dT; + + } + rate_He4_Ti44_to_Cr48_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Ti44_to_Cr48_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Ti44_to_Cr48_removed) = drate_dT; + + } + rate_He4_Ti44_to_p_V47_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Ti44_to_p_V47_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Ti44_to_p_V47_removed) = drate_dT; + + } + rate_p_V47_to_Cr48_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_V47_to_Cr48_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_V47_to_Cr48_removed) = drate_dT; + + } + rate_He4_Cr48_to_Fe52_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Cr48_to_Fe52_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Cr48_to_Fe52_removed) = drate_dT; + + } + rate_He4_Cr48_to_p_Mn51_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Cr48_to_p_Mn51_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Cr48_to_p_Mn51_removed) = drate_dT; + + } + rate_p_Mn51_to_Fe52_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Mn51_to_Fe52_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Mn51_to_Fe52_removed) = drate_dT; + + } + rate_He4_Fe52_to_Ni56_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Fe52_to_Ni56_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Fe52_to_Ni56_removed) = drate_dT; + + } + rate_He4_Fe52_to_p_Co55_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Fe52_to_p_Co55_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Fe52_to_p_Co55_removed) = drate_dT; + + } + rate_p_Co55_to_Ni56_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Co55_to_Ni56_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Co55_to_Ni56_removed) = drate_dT; + + } + rate_N13_to_p_C12_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_N13_to_p_C12_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_N13_to_p_C12_derived) = drate_dT; + + } + rate_O16_to_He4_C12_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_O16_to_He4_C12_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_O16_to_He4_C12_derived) = drate_dT; + + } + rate_Ne20_to_He4_O16_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ne20_to_He4_O16_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ne20_to_He4_O16_derived) = drate_dT; + + } + rate_Mg24_to_p_Na23_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Mg24_to_p_Na23_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Mg24_to_p_Na23_derived) = drate_dT; + + } + rate_Mg24_to_He4_Ne20_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Mg24_to_He4_Ne20_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Mg24_to_He4_Ne20_derived) = drate_dT; + + } + rate_Si28_to_p_Al27_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Si28_to_p_Al27_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Si28_to_p_Al27_derived) = drate_dT; + + } + rate_Si28_to_He4_Mg24_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Si28_to_He4_Mg24_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Si28_to_He4_Mg24_derived) = drate_dT; + + } + rate_S32_to_p_P31_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_S32_to_p_P31_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_S32_to_p_P31_derived) = drate_dT; + + } + rate_S32_to_He4_Si28_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_S32_to_He4_Si28_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_S32_to_He4_Si28_derived) = drate_dT; + + } + rate_C12_to_He4_He4_He4_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_C12_to_He4_He4_He4_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_C12_to_He4_He4_He4_derived) = drate_dT; + + } + rate_p_O16_to_He4_N13_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_O16_to_He4_N13_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_O16_to_He4_N13_derived) = drate_dT; + + } + rate_He4_Ne20_to_p_Na23_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Ne20_to_p_Na23_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Ne20_to_p_Na23_derived) = drate_dT; + + } + rate_He4_Mg24_to_p_Al27_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Mg24_to_p_Al27_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Mg24_to_p_Al27_derived) = drate_dT; + + } + rate_He4_Si28_to_p_P31_derived(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Si28_to_p_P31_derived) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Si28_to_p_P31_derived) = drate_dT; + + } + rate_He4_S32_to_p_Cl35_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_S32_to_p_Cl35_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_S32_to_p_Cl35_derived_removed) = drate_dT; + + } + rate_Ar36_to_He4_S32_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ar36_to_He4_S32_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ar36_to_He4_S32_derived_removed) = drate_dT; + + } + rate_Ar36_to_p_Cl35_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ar36_to_p_Cl35_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ar36_to_p_Cl35_derived_removed) = drate_dT; + + } + rate_He4_Ar36_to_p_K39_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Ar36_to_p_K39_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Ar36_to_p_K39_derived_removed) = drate_dT; + + } + rate_Ca40_to_He4_Ar36_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ca40_to_He4_Ar36_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ca40_to_He4_Ar36_derived_removed) = drate_dT; + + } + rate_Ca40_to_p_K39_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ca40_to_p_K39_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ca40_to_p_K39_derived_removed) = drate_dT; + + } + rate_He4_Ca40_to_p_Sc43_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_He4_Ca40_to_p_Sc43_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_He4_Ca40_to_p_Sc43_derived_removed) = drate_dT; + + } + rate_Ti44_to_He4_Ca40_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ti44_to_He4_Ca40_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ti44_to_He4_Ca40_derived_removed) = drate_dT; + + } + rate_Ti44_to_p_Sc43_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ti44_to_p_Sc43_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ti44_to_p_Sc43_derived_removed) = drate_dT; + + } + rate_Cr48_to_He4_Ti44_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Cr48_to_He4_Ti44_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Cr48_to_He4_Ti44_derived_removed) = drate_dT; + + } + rate_Cr48_to_p_V47_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Cr48_to_p_V47_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Cr48_to_p_V47_derived_removed) = drate_dT; + + } + rate_p_V47_to_He4_Ti44_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_V47_to_He4_Ti44_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_V47_to_He4_Ti44_derived_removed) = drate_dT; + + } + rate_Fe52_to_He4_Cr48_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Fe52_to_He4_Cr48_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Fe52_to_He4_Cr48_derived_removed) = drate_dT; + + } + rate_Fe52_to_p_Mn51_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Fe52_to_p_Mn51_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Fe52_to_p_Mn51_derived_removed) = drate_dT; + + } + rate_p_Mn51_to_He4_Cr48_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Mn51_to_He4_Cr48_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Mn51_to_He4_Cr48_derived_removed) = drate_dT; + + } + rate_Ni56_to_He4_Fe52_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ni56_to_He4_Fe52_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ni56_to_He4_Fe52_derived_removed) = drate_dT; + + } + rate_Ni56_to_p_Co55_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_Ni56_to_p_Co55_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ni56_to_p_Co55_derived_removed) = drate_dT; + + } + rate_p_Co55_to_He4_Fe52_derived_removed(tfactors, rate, drate_dT); + rate_eval.screened_rates(k_p_Co55_to_He4_Fe52_derived_removed) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_p_Co55_to_He4_Fe52_derived_removed) = 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]] Real rate{}; + [[maybe_unused]] Real drate_dT{}; + + rate_S32_He4_to_Ar36_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_S32_He4_to_Ar36_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_S32_He4_to_Ar36_approx) = drate_dT; + + } + rate_Ar36_to_S32_He4_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Ar36_to_S32_He4_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ar36_to_S32_He4_approx) = drate_dT; + + } + rate_Ar36_He4_to_Ca40_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Ar36_He4_to_Ca40_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ar36_He4_to_Ca40_approx) = drate_dT; + + } + rate_Ca40_to_Ar36_He4_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Ca40_to_Ar36_He4_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ca40_to_Ar36_He4_approx) = drate_dT; + + } + rate_Ca40_He4_to_Ti44_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Ca40_He4_to_Ti44_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ca40_He4_to_Ti44_approx) = drate_dT; + + } + rate_Ti44_to_Ca40_He4_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Ti44_to_Ca40_He4_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ti44_to_Ca40_He4_approx) = drate_dT; + + } + rate_Ti44_He4_to_Cr48_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Ti44_He4_to_Cr48_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ti44_He4_to_Cr48_approx) = drate_dT; + + } + rate_Cr48_to_Ti44_He4_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Cr48_to_Ti44_He4_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Cr48_to_Ti44_He4_approx) = drate_dT; + + } + rate_Cr48_He4_to_Fe52_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Cr48_He4_to_Fe52_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Cr48_He4_to_Fe52_approx) = drate_dT; + + } + rate_Fe52_to_Cr48_He4_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Fe52_to_Cr48_He4_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Fe52_to_Cr48_He4_approx) = drate_dT; + + } + rate_Fe52_He4_to_Ni56_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Fe52_He4_to_Ni56_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Fe52_He4_to_Ni56_approx) = drate_dT; + + } + rate_Ni56_to_Fe52_He4_approx(rate_eval, rate, drate_dT); + rate_eval.screened_rates(k_Ni56_to_Fe52_He4_approx) = rate; + if constexpr (std::is_same::value) { + rate_eval.dscreened_rates_dT(k_Ni56_to_Fe52_He4_approx) = drate_dT; + + } + +} + +#endif diff --git a/networks/subch_base/subch_base.png b/networks/subch_base/subch_base.png new file mode 100644 index 0000000000..28694836cb Binary files /dev/null and b/networks/subch_base/subch_base.png differ diff --git a/networks/subch_base/subch_base.py b/networks/subch_base/subch_base.py new file mode 100644 index 0000000000..b191b33217 --- /dev/null +++ b/networks/subch_base/subch_base.py @@ -0,0 +1,121 @@ +# subch_base network for He/C burning with key rates +# to bypass the C12(a,g)O16 rate. +# This is a further simplification of subch_simple by +# removing N14, F18, Ne21, and Na22. + +import pynucastro as pyna +from pynucastro.networks import AmrexAstroCxxNetwork + +DO_DERIVED_RATES = True + + +def get_library(): + + reaclib_lib = pyna.ReacLibLibrary() + + all_reactants = ["p", + "he4", "c12", "o16", "ne20", "mg24", "si28", "s32", + "ar36", "ca40", "ti44", "cr48", "fe52", "ni56", + "al27", "p31", "cl35", "k39", "sc43", "v47", "mn51", "co55", + "n13", "na23"] + + subch = reaclib_lib.linking_nuclei(all_reactants) + + # in this list, we have the reactants, the actual reactants, + # and modified products that we will use instead + other_rates = [("c12(c12,n)mg23", "mg24"), + ("o16(o16,n)s31", "s32"), + ("o16(c12,n)si27", "si28")] + + for r, mp in other_rates: + _r = reaclib_lib.get_rate_by_name(r) + _r.modify_products(mp) + subch += pyna.Library(rates=[_r]) + + # finally, the aprox nets don't include the reverse rates for + # C12+C12, C12+O16, and O16+O16, so remove those + + for r in subch.get_rates(): + if sorted(r.products) in [[pyna.Nucleus("c12"), pyna.Nucleus("c12")], + [pyna.Nucleus("c12"), pyna.Nucleus("o16")], + [pyna.Nucleus("o16"), pyna.Nucleus("o16")]]: + subch.remove_rate(r) + + # C12+Ne20 and reverse + # (a,g) links between Na23 and Al27 + # (a,g) links between Al27 and P31 + + rates_to_remove = ["p31(p,c12)ne20", + "si28(a,c12)ne20", + "ne20(c12,p)p31", + "ne20(c12,a)si28", + "na23(a,g)al27", + "al27(g,a)na23", + "al27(a,g)p31", + "p31(g,a)al27"] + + for r in rates_to_remove: + print("removing: ", r) + _r = subch.get_rate_by_name(r) + subch.remove_rate(_r) + + if DO_DERIVED_RATES: + rates_to_derive = [] + for r in subch.get_rates(): + if r.reverse: + # this rate was computed using detailed balance, regardless + # of whether Q < 0 or not. We want to remove it and then + # recompute it + rates_to_derive.append(r) + + # now for each of those derived rates, look to see if the pair exists + + for r in rates_to_derive: + fr = subch.get_rate_by_nuclei(r.products, r.reactants) + if fr: + print(f"modifying {r} from {fr}") + subch.remove_rate(r) + d = pyna.DerivedRate(rate=fr, compute_Q=False, use_pf=True) + subch.add_rate(d) + + return subch + + +def doit(): + + subch = get_library() + + # these are the rates that we are going to allow to be optionally + # zeroed + r1 = subch.get_rate_by_name("c12(p,g)n13") + r2 = subch.get_rate_by_name("n13(he4,p)o16") + + net = AmrexAstroCxxNetwork(libraries=[subch], symmetric_screening=False, disable_rate_params=[r1, r2]) + net.make_ap_pg_approx(intermediate_nuclei=["cl35", "k39", "sc43", "v47", "mn51", "co55"]) + net.remove_nuclei(["cl35", "k39", "sc43", "v47", "mn51", "co55"]) + + # finally, the aprox nets don't include the reverse rates for + # C12+C12, C12+O16, and O16+O16, so remove those + + print(f"number of nuclei: {len(net.unique_nuclei)}") + print(f"number of rates: {len(net.rates)}") + + comp = pyna.Composition(net.get_nuclei()) + comp.set_all(0.1) + comp.set_nuc("he4", 0.95) + comp.normalize() + + rho = 1.e6 + T = 1.e9 + + net.plot(rho, T, comp, outfile="subch_base.png", + rotated=True, hide_xalpha=True, curved_edges=True, + size=(1500, 450), + node_size=500, node_font_size=11, node_color="#337dff", node_shape="s", + Z_range=(1, 29)) + + net.write_network() + + +if __name__ == "__main__": + doit() diff --git a/networks/subch_base/table_rates.H b/networks/subch_base/table_rates.H new file mode 100644 index 0000000000..47a0ef399e --- /dev/null +++ b/networks/subch_base/table_rates.H @@ -0,0 +1,399 @@ +#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 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 +Real +evaluate_linear_1d(const Real fhi, const Real flo, const Real xhi, const Real xlo, const 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. + + Real xx = Clamp(x, xlo, xhi); + Real f = flo + (fhi - flo) * (xx - xlo) / (xhi - xlo); + + return f; +} + +AMREX_INLINE AMREX_GPU_HOST_DEVICE +Real +evaluate_linear_2d(const Real fip1jp1, const Real fip1j, const Real fijp1, const Real fij, + const Real xhi, const Real xlo, const Real yhi, const Real ylo, + const Real x, const Real y) +{ + // This is the 2-D linear interpolator, as an extension of evaluate_linear_1d. + + Real f; + Real dx = xhi - xlo; + Real dy = yhi - ylo; + + Real E = fij; + Real C = (fijp1 - fij) / dy; + Real B = (fip1j - fij) / dx; + Real A = (fip1jp1 - B * dx - C * dy - E) / (dx * dy); + + Real xx = Clamp(x, xlo, xhi); + 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 +Real +evaluate_vars(const table_t& table_meta, const R& log_rhoy_table, const T& log_temp_table, const D& data, + const Real log_rhoy, const 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; + + Real rhoy_lo = log_rhoy_table(irhoy_lo); + Real rhoy_hi = log_rhoy_table(irhoy_hi); + + Real t_lo = log_temp_table(jtemp_lo); + Real t_hi = log_temp_table(jtemp_hi); + + Real fij = data(jtemp_lo, irhoy_lo, component); + Real fip1j = data(jtemp_lo, irhoy_hi, component); + Real fijp1 = data(jtemp_hi, irhoy_lo, component); + Real fip1jp1 = data(jtemp_hi, irhoy_hi, component); + + 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 +Real +evaluate_dr_dtemp(const table_t& table_meta, const R& log_rhoy_table, const T& log_temp_table, const D& data, + const Real log_rhoy, const 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; + + 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 + + Real log_rhoy_lo = log_rhoy_table(irhoy_lo); + Real log_rhoy_hi = log_rhoy_table(irhoy_hi); + + Real log_temp_lo = log_temp_table(jtemp_lo); + Real log_temp_hi = log_temp_table(jtemp_hi); + + Real fij = data(jtemp_lo, irhoy_lo, jtab_rate); + Real fip1j = data(jtemp_lo, irhoy_hi, jtab_rate); + Real fijp1 = data(jtemp_hi, irhoy_lo, jtab_rate); + Real fip1jp1 = data(jtemp_hi, irhoy_hi, jtab_rate); + + Real dlogr_dlogt_i = (fijp1 - fij) / (log_temp_hi - log_temp_lo); + 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. + + Real log_temp_jm1 = log_temp_table(jtemp_lo-1); + Real log_temp_j = log_temp_table(jtemp_lo); + Real log_temp_jp1 = log_temp_table(jtemp_hi); + Real log_temp_jp2 = log_temp_table(jtemp_hi+1); + + Real log_rhoy_lo = log_rhoy_table(irhoy_lo); + Real log_rhoy_hi = log_rhoy_table(irhoy_hi); + + Real fijm1 = data(jtemp_lo-1, irhoy_lo, jtab_rate); + Real fij = data(jtemp_lo, irhoy_lo, jtab_rate); + Real fijp1 = data(jtemp_hi, irhoy_lo, jtab_rate); + Real fijp2 = data(jtemp_hi+1, irhoy_lo, jtab_rate); + + Real fip1jm1 = data(jtemp_lo-1, irhoy_hi, jtab_rate); + Real fip1j = data(jtemp_lo, irhoy_hi, jtab_rate); + Real fip1jp1 = data(jtemp_hi, irhoy_hi, jtab_rate); + Real fip1jp2 = data(jtemp_hi+1, irhoy_hi, jtab_rate); + + Real dlogr_dlogt_ij = (fijp1 - fijm1)/(log_temp_jp1 - log_temp_jm1); + Real dlogr_dlogt_ijp1 = (fijp2 - fij)/(log_temp_jp2 - log_temp_j); + Real dlogr_dlogt_ip1j = (fip1jp1 - fip1jm1)/(log_temp_jp1 - log_temp_jm1); + 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 Real log_rhoy, const Real log_temp, 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 Real rhoy, const Real temp, + Real& rate, Real& drate_dt, Real& edot_nu, Real& edot_gamma) +{ + Array1D entries; + + // Get the table entries at this rhoy, temp + + Real log_rhoy = std::log10(rhoy); + 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/subch_base/table_rates_data.cpp b/networks/subch_base/table_rates_data.cpp new file mode 100644 index 0000000000..63b38aff19 --- /dev/null +++ b/networks/subch_base/table_rates_data.cpp @@ -0,0 +1,23 @@ +#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/subch_base/tfactors.H b/networks/subch_base/tfactors.H new file mode 100644 index 0000000000..43a6316db7 --- /dev/null +++ b/networks/subch_base/tfactors.H @@ -0,0 +1,34 @@ +#ifndef TFACTORS_H +#define TFACTORS_H + +struct tf_t { + Real T9; + Real T9i; + Real T943i; + Real T923i; + Real T913i; + Real T913; + Real T923; + Real T953; + Real lnT9; +}; + +AMREX_GPU_HOST_DEVICE AMREX_INLINE +tf_t evaluate_tfactors(const 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 \ No newline at end of file diff --git a/networks/subch_full/README.md b/networks/subch_full/README.md index c01f02165e..5383194588 100644 --- a/networks/subch_full/README.md +++ b/networks/subch_full/README.md @@ -15,8 +15,10 @@ Shen & Bildsten discuss the sequences: * n14(a, g)f18(a, p)ne21 is the one they consider important, since it produces protons that are then available for c12(p, g)n13(a, p)o16. - This leaves ne21 as an endpoint, which we need to connect by - including na22. + Note that, this leaves ne21 as an endpoint, which we need to connect by + including na22. However, adding na22 only makes it as another endpoint, + failing to resolve the issue, resulting in a network with a second + endpoint other than ni56. For the c12+c12, c12+o16, and o16+o16 rates, we also need to include c12(c12,n)mg23(n, g)mg24, o16(o16, n)s31(n, g)s32,