17 const std::vector<fourdst::atomic::Species>& species,
18 const std::vector<double>& Y,
25 const std::vector<fourdst::atomic::Species>& species,
26 const std::vector<CppAD::AD<double>>& Y,
27 const CppAD::AD<double> T9,
28 const CppAD::AD<double> rho
31 quill::Logger*
m_logger = fourdst::logging::LogManager::getInstance().getLogger(
"log");
37 const std::vector<fourdst::atomic::Species>& species,
38 const std::vector<T>& Y,
47 const std::vector<fourdst::atomic::Species>& species,
48 const std::vector<T>& Y,
54 "Calculating weak screening factors for {} reactions...",
60 const T low_temp_threshold(1e-9);
62 const T low_T_flag = CppAD::CondExpLt(T9, low_temp_threshold, zero, one);
69 for (
size_t i = 0; i < species.size(); ++i) {
70 const T Z = species[i].m_z;
71 zeta += (Z * Z + Z) * Y[i];
75 const T T7 = T9 *
static_cast<T
>(100.00);
76 const T T7_safe = CppAD::CondExpLe(T7, low_temp_threshold, low_temp_threshold, T7);
77 const T prefactor =
static_cast<T
>(0.188) * CppAD::sqrt(rho / (T7_safe * T7_safe * T7_safe)) * CppAD::sqrt(zeta);
80 std::vector<T> factors;
81 factors.reserve(reactions.
size());
82 for (
const auto&
reaction : reactions) {
84 const auto& reactants =
reaction.reactants();
85 const bool isTripleAlpha = (
86 reactants.size() == 3 &&
87 reactants[0].m_z == 2 &&
88 reactants[1].m_z == 2 &&
89 reactants[2].m_z == 2 &&
90 reactants[0] == reactants[1] &&
91 reactants[1] == reactants[2]
93 if (reactants.size() == 2) {
94 LOG_TRACE_L3(
m_logger,
"Calculating screening factor for reaction: {}",
reaction.peName());
95 const T Z1 =
static_cast<T
>(reactants[0].m_z);
96 const T Z2 =
static_cast<T
>(reactants[1].m_z);
97 H_12 = prefactor * Z1 * Z2;
99 else if (isTripleAlpha) {
100 LOG_TRACE_L3(
m_logger,
"Special case for triple alpha process in reaction: {}",
reaction.peName());
102 const T Z_alpha =
static_cast<T
>(2.0);
103 const T H_alpha_alpha = prefactor * Z_alpha * Z_alpha;
104 H_12 =
static_cast<T
>(3.0) * H_alpha_alpha;
110 H_12 = CppAD::CondExpGe(H_12,
static_cast<T
>(2.0),
static_cast<T
>(2.0), H_12);
111 factors.push_back(CppAD::exp(H_12));