feat(composition): added ability to change composition modes

This commit is contained in:
2025-03-25 13:01:22 -04:00
parent 941af6331b
commit 0e9a7df381
3 changed files with 50 additions and 0 deletions

View File

@@ -459,4 +459,25 @@ Composition Composition::subset(const std::vector<std::string>& symbols, std::st
}
}
return subsetComposition;
}
void Composition::setCompositionMode(bool massFracMode) {
if (!m_finalized) {
LOG_ERROR(m_logger, "Composition has not been finalized. Mode cannot be set unless composition is finalized.");
throw std::runtime_error("Composition has not been finalized (Consider running .finalize()). The mode cannot be set unless the composition is finalized.");
}
bool okay = true;
for (auto& [_, entry] : m_compositions) {
if (massFracMode) {
okay = entry.setMassFracMode(m_meanParticleMass);
} else {
okay = entry.setNumberFracMode(m_specificNumberDensity);
}
if (!okay) {
LOG_ERROR(m_logger, "Composition mode could not be set.");
throw std::runtime_error("Composition mode could not be set.");
}
}
m_massFracMode = massFracMode;
}