10#include <unordered_map>
17 const std::vector<atomic::Species>& activeSpecies
54 std::set<std::string> symbols;
56 symbols.insert(std::string(species.name()));
66 std::unordered_map<atomic::Species, double> massFractions;
71 massFractions[species] = 0.0;
78 std::unordered_map<atomic::Species, double> numberFractions;
83 numberFractions[species] = 0.0;
86 return numberFractions;
138 double meanParticleMass = 0.0;
142 const double atomicMass = species.mass();
143 meanParticleMass += numberFraction * atomicMass;
146 return meanParticleMass;
160 std::vector<double> massFractions;
165 return massFractions;
169 std::vector<double> numberFractions;
174 return numberFractions;
178 std::vector<double> molarAbundances;
183 return molarAbundances;
190 return std::distance(
194 return std::string(sp.name()) == symbol;
199 return std::distance(
207 throw std::out_of_range(
"Index " + std::to_string(index) +
" is out of bounds for active species of size " + std::to_string(
m_activeSpecies.size()) +
".");
210 std::advance(it, index);
Abstract base class for chemical composition representations.
double getMolarAbundance(const std::string &symbol) const override
Get the molar abundance for a given symbol.
CompositionDecorator(std::unique_ptr< CompositionAbstract > decorator)
std::unordered_map< atomic::Species, double > getNumberFraction() const noexcept override
Get the number fraction for all registered symbols.
std::unique_ptr< CompositionAbstract > m_base_composition
bool contains(const atomic::Species &species) const noexcept override
Check if the composition contains the given species.
std::unordered_map< atomic::Species, double > getMassFraction() const noexcept override
Get the mass fraction for all registered symbols.
bool contains(const atomic::Species &species) const noexcept override
Check if the composition contains the given species.
size_t hash() const override
std::vector< atomic::Species > m_activeSpecies
std::unordered_map< atomic::Species, double > getMassFraction() const noexcept override
Get the mass fraction for all registered symbols.
std::unordered_map< atomic::Species, double > getNumberFraction() const noexcept override
Get the number fraction for all registered symbols.
double getMolarAbundance(const std::string &symbol) const override
Get the molar abundance for a given symbol.
std::unique_ptr< CompositionAbstract > clone() const override
double getElectronAbundance() const noexcept override
Get the electron abundance of the composition.
double getMeanParticleMass() const noexcept override
Get the mean particle mass of the composition.
const std::vector< atomic::Species > & getRegisteredSpecies() const noexcept override
Get all registered atomic species in the composition.
size_t size() const noexcept override
size_t getSpeciesIndex(const std::string &symbol) const override
Get the index of a species by symbol.
std::vector< double > getMassFractionVector() const noexcept override
Get the mass fraction as a vector.
MaskedComposition(const CompositionAbstract &baseComposition, const std::vector< atomic::Species > &activeSpecies)
std::set< std::string > getRegisteredSymbols() const noexcept override
Get all registered chemical symbols in the composition.
iterator begin() override
std::vector< double > m_molarAbundances
std::vector< double > getMolarAbundanceVector() const noexcept override
Get the molar abundance as a vector.
atomic::Species getSpeciesAtIndex(size_t index) const override
Get the species at a given index.
detail::CompositionIterator< true > const_iterator
std::vector< double > getNumberFractionVector() const noexcept override
Get the number fraction as a vector.
detail::CompositionIterator< false > iterator
Exception thrown when an unknown symbol is encountered.
Exception thrown when a symbol is used that has not been registered.
static const std::unordered_map< std::string, const Species & > species
Map of species names to their corresponding Species objects.
Utilities and types for representing and manipulating chemical compositions.
Represents an atomic species (isotope) with its fundamental physical properties.
std::string_view name() const
Gets the name of the species.
static uint64_t hash_exact(const CompositionT &comp)