feat(neutrino): Updated neutrino output

GridFire now reports neutrino loss for reaclib reactions. Note this
currently is only computed if precomputation is enabled.
This commit is contained in:
2025-11-27 15:00:51 -05:00
parent 05175ae87c
commit 39a689ee5d
16 changed files with 97 additions and 62 deletions

View File

@@ -88,7 +88,7 @@ namespace {
if (has_flag(reaction_types, gridfire::engine::NetworkConstructionFlags::REACLIB_STRONG)) {
const auto& allReaclibReactions = gridfire::reaclib::get_all_reaclib_reactions();
for (const auto& reaction : allReaclibReactions) {
const bool isWeakReaction = gridfire::reaclib::reaction_is_weak(*reaction);
const bool isWeakReaction = gridfire::reaction::reaction_is_weak(*reaction);
const bool okayToUseReaclibWeakReaction = has_flag(reaction_types, gridfire::engine::NetworkConstructionFlags::REACLIB_WEAK);
const bool reaclibWeakOkay = !isWeakReaction || okayToUseReaclibWeakReaction;

View File

@@ -224,22 +224,4 @@ namespace gridfire::reaclib {
return *s_all_reaclib_reactions_ptr;
}
bool reaction_is_weak(const reaction::Reaction& reaction) {
const std::vector<fourdst::atomic::Species>& reactants = reaction.reactants();
const std::vector<fourdst::atomic::Species>& products = reaction.products();
if (reactants.size() != products.size()) {
return false;
}
if (reactants.size() != 1 || products.size() != 1) {
return false;
}
if (std::floor(reactants[0].a()) != std::floor(products[0].a())) {
return false;
}
return true;
}
} // namespace gridfire::reaclib

View File

@@ -231,7 +231,7 @@ namespace gridfire::reaction {
std::unordered_set<bool> reaction_weak_types;
for (const auto& reaction : reactions) {
reaction_weak_types.insert(reaclib::reaction_is_weak(*reaction));
reaction_weak_types.insert(reaction::reaction_is_weak(*reaction));
}
if (reaction_weak_types.size() != 1) {
@@ -611,8 +611,28 @@ namespace gridfire::reaction {
}
}
return finalReactionSet;
}
return finalReactionSet;
}
bool reaction_is_weak(const reaction::Reaction& reaction) {
const std::vector<fourdst::atomic::Species>& reactants = reaction.reactants();
const std::vector<fourdst::atomic::Species>& products = reaction.products();
if (reactants.size() != products.size()) {
return false;
}
if (reactants.size() != 1 || products.size() != 1) {
return false;
}
if (std::floor(reactants[0].a()) != std::floor(products[0].a())) {
return false;
}
return true;
}
}

View File

@@ -190,8 +190,11 @@ namespace gridfire::solver {
sunrealtype* y_data = N_VGetArrayPointer(m_Y);
const double current_energy = y_data[numSpecies]; // Specific energy rate
accumulated_neutrino_energy_loss += user_data.neutrino_energy_loss_rate;
accumulated_total_neutrino_flux += user_data.total_neutrino_flux;
// TODO: Accumulate neutrino loss through the state vector directly which will allow CVODE to properly integrate it
accumulated_neutrino_energy_loss += user_data.neutrino_energy_loss_rate * last_step_size;
accumulated_total_neutrino_flux += user_data.total_neutrino_flux * last_step_size;
size_t iter_diff = (total_nonlinear_iterations + nliters) - prev_nonlinear_iterations;
size_t convFail_diff = (total_convergence_failures + nlcfails) - prev_convergence_failures;
if (m_stdout_logging_enabled) {
@@ -508,8 +511,8 @@ namespace gridfire::solver {
netOut.dEps_dT = dEps_dT;
netOut.dEps_dRho = dEps_dRho;
netOut.neutrino_energy_loss_rate = accumulated_neutrino_energy_loss;
netOut.total_neutrino_flux = accumulated_total_neutrino_flux;
netOut.specific_neutrino_energy_loss = accumulated_neutrino_energy_loss;
netOut.specific_neutrino_flux = accumulated_total_neutrino_flux;
LOG_TRACE_L2(m_logger, "Output data built!");
LOG_TRACE_L2(m_logger, "Solver evaluation complete!.");