52 const std::vector<fourdst::atomic::Species>& species,
53 const std::vector<double>& Y,
74 const std::vector<fourdst::atomic::Species>& species,
75 const std::vector<CppAD::AD<double>>& Y,
76 const CppAD::AD<double> T9,
77 const CppAD::AD<double> rho
81 quill::Logger*
m_logger = fourdst::logging::LogManager::getInstance().getLogger(
"log");
102 const std::vector<fourdst::atomic::Species>& species,
103 const std::vector<T>& Y,
143 const std::vector<fourdst::atomic::Species>& species,
144 const std::vector<T>& Y,
150 "Calculating weak screening factors for {} reactions...",
156 const T low_temp_threshold(1e-9);
158 const T low_T_flag = CppAD::CondExpLt(T9, low_temp_threshold, zero, one);
165 for (
size_t i = 0; i < species.size(); ++i) {
166 const T Z = species[i].m_z;
167 zeta += (Z * Z + Z) * Y[i];
171 const T T7 = T9 *
static_cast<T
>(100.00);
172 const T T7_safe = CppAD::CondExpLe(T7, low_temp_threshold, low_temp_threshold, T7);
173 const T prefactor =
static_cast<T
>(0.188) * CppAD::sqrt(rho / (T7_safe * T7_safe * T7_safe)) * CppAD::sqrt(zeta);
176 std::vector<T> factors;
177 factors.reserve(reactions.
size());
178 for (
const auto&
reaction : reactions) {
180 const auto& reactants =
reaction.reactants();
181 const bool isTripleAlpha = (
182 reactants.size() == 3 &&
183 reactants[0].m_z == 2 &&
184 reactants[1].m_z == 2 &&
185 reactants[2].m_z == 2 &&
186 reactants[0] == reactants[1] &&
187 reactants[1] == reactants[2]
189 if (reactants.size() == 2) {
190 LOG_TRACE_L3(
m_logger,
"Calculating screening factor for reaction: {}",
reaction.peName());
191 const T Z1 =
static_cast<T
>(reactants[0].m_z);
192 const T Z2 =
static_cast<T
>(reactants[1].m_z);
193 H_12 = prefactor * Z1 * Z2;
195 else if (isTripleAlpha) {
196 LOG_TRACE_L3(
m_logger,
"Special case for triple alpha process in reaction: {}",
reaction.peName());
198 const T Z_alpha =
static_cast<T
>(2.0);
199 const T H_alpha_alpha = prefactor * Z_alpha * Z_alpha;
200 H_12 =
static_cast<T
>(3.0) * H_alpha_alpha;
206 H_12 = CppAD::CondExpGe(H_12,
static_cast<T
>(2.0),
static_cast<T
>(2.0), H_12);
207 factors.push_back(CppAD::exp(H_12));
std::vector< T > calculateFactors_impl(const reaction::LogicalReactionSet &reactions, const std::vector< fourdst::atomic::Species > &species, const std::vector< T > &Y, const T T9, const T rho) const
Template implementation for calculating weak screening factors.
std::vector< double > calculateScreeningFactors(const reaction::LogicalReactionSet &reactions, const std::vector< fourdst::atomic::Species > &species, const std::vector< double > &Y, const double T9, const double rho) const override
Calculates weak screening factors for a set of reactions.