feat(MultiscalePartitioningEngineView): added *much* more robust qse group identifiction and solving

This commit is contained in:
2025-07-10 09:36:05 -04:00
parent 1ac6b451b8
commit 7012eb819a
23 changed files with 1863 additions and 378 deletions

View File

@@ -136,12 +136,12 @@ namespace gridfire {
}
void AdaptiveEngineView::generateJacobianMatrix(
const std::vector<double> &Y_culled,
const std::vector<double> &Y_dynamic,
const double T9,
const double rho
) {
validateState();
const auto Y_full = mapCulledToFull(Y_culled);
const auto Y_full = mapCulledToFull(Y_dynamic);
m_baseEngine.generateJacobianMatrix(Y_full, T9, rho);
}
@@ -221,6 +221,25 @@ namespace gridfire {
return m_baseEngine.getScreeningModel();
}
std::vector<double> AdaptiveEngineView::mapNetInToMolarAbundanceVector(const NetIn &netIn) const {
std::vector<double> Y(m_activeSpecies.size(), 0.0); // Initialize with zeros
for (const auto& [symbol, entry] : netIn.composition) {
Y[getSpeciesIndex(entry.isotope())] = netIn.composition.getMolarAbundance(symbol); // Map species to their molar abundance
}
return Y; // Return the vector of molar abundances
}
int AdaptiveEngineView::getSpeciesIndex(const fourdst::atomic::Species &species) const {
auto it = std::find(m_activeSpecies.begin(), m_activeSpecies.end(), species);
if (it != m_activeSpecies.end()) {
return static_cast<int>(std::distance(m_activeSpecies.begin(), it));
} else {
LOG_ERROR(m_logger, "Species '{}' not found in active species list.", species.name());
m_logger->flush_log();
throw std::runtime_error("Species not found in active species list: " + std::string(species.name()));
}
}
std::vector<double> AdaptiveEngineView::mapCulledToFull(const std::vector<double>& culled) const {
std::vector<double> full(m_baseEngine.getNetworkSpecies().size(), 0.0);
for (size_t i_culled = 0; i_culled < culled.size(); ++i_culled) {