fourdst::libcomposition v1.5.2
Robust atomic species information library
|
Manages a collection of chemical species and their abundances. More...
#include <composition.h>
Public Member Functions | |
Composition ()=default | |
Default constructor. | |
~Composition ()=default | |
Default destructor. | |
bool | finalize (bool norm=false) |
Finalizes the composition, making it ready for querying. | |
Composition (const std::vector< std::string > &symbols) | |
Constructs a Composition and registers the given symbols. | |
Composition (const std::set< std::string > &symbols) | |
Constructs a Composition and registers the given symbols from a set. | |
Composition (const std::vector< std::string > &symbols, const std::vector< double > &fractions, bool massFracMode=true) | |
Constructs and finalizes a Composition with the given symbols and fractions. | |
Composition (const Composition &composition) | |
Constructs a Composition from another Composition. | |
Composition & | operator= (Composition const &other) |
Assignment operator. | |
void | registerSymbol (const std::string &symbol, bool massFracMode=true) |
Registers a new symbol for inclusion in the composition. | |
void | registerSymbol (const std::vector< std::string > &symbols, bool massFracMode=true) |
Registers multiple new symbols. | |
void | registerSpecies (const fourdst::atomic::Species &species, bool massFracMode=true) |
Registers a new species by extracting its symbol. | |
void | registerSpecies (const std::vector< fourdst::atomic::Species > &species, bool massFracMode=true) |
Registers a vector of new species. | |
std::set< std::string > | getRegisteredSymbols () const |
Gets the registered symbols. | |
std::set< fourdst::atomic::Species > | getRegisteredSpecies () const |
Get a set of all species that are registered in the composition. | |
double | setMassFraction (const std::string &symbol, const double &mass_fraction) |
Sets the mass fraction for a given symbol. | |
std::vector< double > | setMassFraction (const std::vector< std::string > &symbols, const std::vector< double > &mass_fractions) |
Sets the mass fraction for multiple symbols. | |
double | setMassFraction (const fourdst::atomic::Species &species, const double &mass_fraction) |
Sets the mass fraction for a given species. | |
std::vector< double > | setMassFraction (const std::vector< fourdst::atomic::Species > &species, const std::vector< double > &mass_fractions) |
Sets the mass fraction for multiple species. | |
double | setNumberFraction (const std::string &symbol, const double &number_fraction) |
Sets the number fraction for a given symbol. | |
std::vector< double > | setNumberFraction (const std::vector< std::string > &symbols, const std::vector< double > &number_fractions) |
Sets the number fraction for multiple symbols. | |
double | setNumberFraction (const fourdst::atomic::Species &species, const double &number_fraction) |
Sets the number fraction for a given species. | |
std::vector< double > | setNumberFraction (const std::vector< fourdst::atomic::Species > &species, const std::vector< double > &number_fractions) |
Sets the number fraction for multiple species. | |
Composition | mix (const Composition &other, double fraction) const |
Mixes this composition with another to produce a new composition. | |
std::unordered_map< std::string, double > | getMassFraction () const |
Gets the mass fractions of all species in the composition. | |
double | getMassFraction (const std::string &symbol) const |
Gets the mass fraction for a given symbol. | |
double | getMassFraction (const fourdst::atomic::Species &species) const |
Gets the mass fraction for a given isotope. | |
double | getNumberFraction (const std::string &symbol) const |
Gets the number fraction for a given symbol. | |
double | getNumberFraction (const fourdst::atomic::Species &species) const |
Gets the number fraction for a given isotope. | |
std::unordered_map< std::string, double > | getNumberFraction () const |
Gets the number fractions of all species in the composition. | |
double | getMolarAbundance (const std::string &symbol) const |
Gets the molar abundance (X_i / A_i) for a given symbol. | |
double | getMolarAbundance (const fourdst::atomic::Species &species) const |
Gets the molar abundance for a given isotope. | |
std::pair< CompositionEntry, GlobalComposition > | getComposition (const std::string &symbol) const |
Gets the composition entry and global composition data for a given symbol. | |
std::pair< CompositionEntry, GlobalComposition > | getComposition (const fourdst::atomic::Species &species) const |
Gets the composition entry and global composition data for a given species. | |
std::pair< std::unordered_map< std::string, CompositionEntry >, GlobalComposition > | getComposition () const |
Gets all composition entries and the global composition data. | |
double | getMeanParticleMass () const |
Compute the mean particle mass of the composition. | |
double | getMeanAtomicNumber () const |
Compute the mean atomic number of the composition. | |
Composition | subset (const std::vector< std::string > &symbols, const std::string &method="norm") const |
Creates a new Composition object containing a subset of species from this one. | |
bool | hasSymbol (const std::string &symbol) const |
Checks if a symbol is registered in the composition. | |
bool | contains (const fourdst::atomic::Species &isotope) const |
Checks if a given isotope is present in the composition. | |
void | setCompositionMode (bool massFracMode) |
Sets the composition mode (mass fraction vs. number fraction). | |
CanonicalComposition | getCanonicalComposition (bool harsh=false) const |
Gets the current canonical composition (X, Y, Z). | |
std::vector< double > | getMassFractionVector () const |
Get a uniform vector representation of the mass fraction stored in the composition object sorted such that the lightest species is at index 0 and the heaviest is at the last index. | |
std::vector< double > | getNumberFractionVector () const |
Get a uniform vector representation of the number fractions stored in the composition object sorted such that the lightest species is at index 0 and the heaviest is at the last index. | |
std::vector< double > | getMolarAbundanceVector () const |
Get a uniform vector representation of the molar abundances stored in the composition object sorted such that the lightest species is at index 0 and the heaviest is at the last index. | |
size_t | getSpeciesIndex (const std::string &symbol) const |
get the index in the sorted vector representation for a given symbol | |
size_t | getSpeciesIndex (const atomic::Species &species) const |
get the index in the sorted vector representation for a given symbol | |
atomic::Species | getSpeciesAtIndex (size_t index) const |
Get the species at a given index in the sorted vector representation. | |
Composition | operator+ (const Composition &other) const |
Overloads the + operator to mix two compositions with a 50/50 fraction. | |
auto | begin () |
Returns an iterator to the beginning of the composition map. | |
auto | begin () const |
Returns a const iterator to the beginning of the composition map. | |
auto | end () |
Returns an iterator to the end of the composition map. | |
auto | end () const |
Returns a const iterator to the end of the composition map. | |
Private Member Functions | |
bool | isValidComposition (const std::vector< double > &fractions) const |
Checks if the given fractions are valid (sum to ~1.0). | |
void | validateComposition (const std::vector< double > &fractions) const |
Validates the given fractions, throwing an exception on failure. | |
bool | finalizeMassFracMode (bool norm) |
Finalizes the composition in mass fraction mode. | |
bool | finalizeNumberFracMode (bool norm) |
Finalizes the composition in number fraction mode. | |
Static Private Member Functions | |
static bool | isValidSymbol (const std::string &symbol) |
Checks if the given symbol is valid by checking against the global species database. | |
Private Attributes | |
fourdst::config::Config & | m_config = fourdst::config::Config::getInstance() |
fourdst::logging::LogManager & | m_logManager = fourdst::logging::LogManager::getInstance() |
quill::Logger * | m_logger = m_logManager.getLogger("log") |
bool | m_finalized = false |
True if the composition is finalized. | |
double | m_specificNumberDensity = 0.0 |
The specific number density of the composition (\sum_{i} X_i m_i. Where X_i is the number fraction of the ith species and m_i is the mass of the ith species). | |
double | m_meanParticleMass = 0.0 |
The mean particle mass of the composition (\sum_{i} \frac{n_i}{m_i}. where n_i is the number fraction of the ith species and m_i is the mass of the ith species). | |
bool | m_massFracMode = true |
True if mass fraction mode, false if number fraction mode. | |
std::set< std::string > | m_registeredSymbols |
The registered symbols. | |
std::unordered_map< std::string, CompositionEntry > | m_compositions |
The compositions. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Composition &composition) |
Overloaded output stream operator for Composition. | |
Manages a collection of chemical species and their abundances.
This class is a primary interface for defining and manipulating material compositions. It can operate in two modes: mass fraction or number fraction.
Key Rules and Workflow:
registerSymbol()
or registerSpecies()
. All registered species must conform to the same abundance mode (mass or number fraction).setMassFraction()
or setNumberFraction()
to define the composition.getMassFraction()
, getMeanParticleMass()
), the composition must be finalized by calling finalize()
. This step validates the composition (abundances sum to ~1.0) and computes global properties.finalize()
before data can be retrieved again.This | class throws various exceptions from fourdst::composition::exceptions for invalid operations, such as using unregistered symbols, providing invalid abundances, or accessing data from a non-finalized composition. |
Definition at line 258 of file composition.h.
|
default |
Default constructor.
|
default |
Default destructor.
|
explicit |
Constructs a Composition and registers the given symbols.
symbols | The symbols to register. The composition will be in mass fraction mode by default. |
exceptions::InvalidSymbolError | if any symbol is invalid. |
Definition at line 176 of file composition.cpp.
|
explicit |
Constructs a Composition and registers the given symbols from a set.
symbols | The symbols to register. The composition will be in mass fraction mode by default. |
exceptions::InvalidSymbolError | if any symbol is invalid. |
Definition at line 182 of file composition.cpp.
fourdst::composition::Composition::Composition | ( | const std::vector< std::string > & | symbols, |
const std::vector< double > & | fractions, | ||
bool | massFracMode = true ) |
Constructs and finalizes a Composition with the given symbols and fractions.
This constructor provides a convenient way to create a fully-formed, finalized composition in one step. The provided fractions must be valid and sum to 1.0.
symbols | The symbols to initialize the composition with. |
fractions | The fractions (mass or number) corresponding to the symbols. |
massFracMode | True if fractions are mass fractions, false if they are number fractions. [Default: true] |
exceptions::InvalidCompositionError | if the number of symbols and fractions do not match, or if the fractions do not sum to ~1.0. |
exceptions::InvalidSymbolError | if any symbol is invalid. |
Definition at line 188 of file composition.cpp.
fourdst::composition::Composition::Composition | ( | const Composition & | composition | ) |
Constructs a Composition from another Composition.
composition | The Composition to copy. |
Definition at line 210 of file composition.cpp.
|
inline |
Returns an iterator to the beginning of the composition map.
Definition at line 821 of file composition.h.
|
inlinenodiscard |
Returns a const iterator to the beginning of the composition map.
Definition at line 829 of file composition.h.
|
nodiscard |
Checks if a given isotope is present in the composition.
isotope | The isotope to check for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 906 of file composition.cpp.
|
inline |
Returns an iterator to the end of the composition map.
Definition at line 837 of file composition.h.
|
inlinenodiscard |
Returns a const iterator to the end of the composition map.
Definition at line 845 of file composition.h.
bool fourdst::composition::Composition::finalize | ( | bool | norm = false | ) |
Finalizes the composition, making it ready for querying.
This method checks if the sum of all fractions (mass or number) is approximately 1.0. It also computes global properties like mean particle mass. This must be called before any get...
method can be used.
norm | If true, the composition will be normalized to sum to 1 before validation. [Default: false] |
m_finalized
is true and global properties are computed. Definition at line 414 of file composition.cpp.
|
private |
Finalizes the composition in mass fraction mode.
norm | If true, the composition will be normalized to sum to 1. |
Definition at line 427 of file composition.cpp.
|
private |
Finalizes the composition in number fraction mode.
norm | If true, the composition will be normalized to sum to 1. |
Definition at line 464 of file composition.cpp.
|
nodiscard |
Gets the current canonical composition (X, Y, Z).
Calculates the total mass fractions for H, He, and metals.
harsh | If true, this will throw an error if 1 - (X + Y) is not equal to the directly summed Z (within a tolerance). If false, it will only log a warning. |
CanonicalComposition
struct. exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
std::runtime_error | if harsh is true and the canonical composition is not self-consistent. |
Definition at line 715 of file composition.cpp.
|
nodiscard |
Gets all composition entries and the global composition data.
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 630 of file composition.cpp.
|
nodiscard |
Gets the composition entry and global composition data for a given species.
species | The species to get the composition for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the species is not in the composition. |
Definition at line 625 of file composition.cpp.
|
nodiscard |
Gets the composition entry and global composition data for a given symbol.
symbol | The symbol to get the composition for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the symbol is not in the composition. |
Definition at line 613 of file composition.cpp.
|
nodiscard |
Gets the mass fractions of all species in the composition.
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 559 of file composition.cpp.
|
nodiscard |
Gets the mass fraction for a given isotope.
species | The isotope to get the mass fraction for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the isotope is not registered in the composition. |
Definition at line 555 of file composition.cpp.
|
nodiscard |
Gets the mass fraction for a given symbol.
symbol | The symbol to get the mass fraction for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the symbol is not in the composition. |
Definition at line 528 of file composition.cpp.
|
nodiscard |
Get a uniform vector representation of the mass fraction stored in the composition object sorted such that the lightest species is at index 0 and the heaviest is at the last index.
This is primarily useful for external libraries which need to ensure that vector representation uniformity is maintained
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 762 of file composition.cpp.
|
nodiscard |
Compute the mean atomic number of the composition.
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 646 of file composition.cpp.
|
nodiscard |
Compute the mean particle mass of the composition.
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 638 of file composition.cpp.
|
nodiscard |
Gets the molar abundance for a given isotope.
species | The isotope to get the molar abundance for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the isotope is not registered in the composition. |
Definition at line 609 of file composition.cpp.
|
nodiscard |
Gets the molar abundance (X_i / A_i) for a given symbol.
symbol | The symbol to get the molar abundance for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the symbol is not in the composition. |
Definition at line 596 of file composition.cpp.
|
nodiscard |
Get a uniform vector representation of the molar abundances stored in the composition object sorted such that the lightest species is at index 0 and the heaviest is at the last index.
This is primarily useful for external libraries which need to ensure that vector representation uniformity is maintained
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 803 of file composition.cpp.
|
nodiscard |
Gets the number fractions of all species in the composition.
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 588 of file composition.cpp.
|
nodiscard |
Gets the number fraction for a given isotope.
species | The isotope to get the number fraction for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the isotope is not registered in the composition. |
Definition at line 584 of file composition.cpp.
|
nodiscard |
Gets the number fraction for a given symbol.
symbol | The symbol to get the number fraction for. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the symbol is not in the composition. |
Definition at line 568 of file composition.cpp.
|
nodiscard |
Get a uniform vector representation of the number fractions stored in the composition object sorted such that the lightest species is at index 0 and the heaviest is at the last index.
This is primarily useful for external libraries which need to ensure that vector representation uniformity is maintained
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
Definition at line 783 of file composition.cpp.
|
nodiscard |
Get a set of all species that are registered in the composition.
atomic::Species
objects registered in the composition. Definition at line 280 of file composition.cpp.
|
nodiscard |
Gets the registered symbols.
Definition at line 276 of file composition.cpp.
|
nodiscard |
Get the species at a given index in the sorted vector representation.
This is primarily useful for external libraries which need to ensure that vector representation uniformity is maintained
index | The index in the sorted vector representation for which to return the species. Must be in [0, N-1] where N is the number of registered species. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
std::out_of_range | if the index is out of range. |
Definition at line 873 of file composition.cpp.
|
nodiscard |
get the index in the sorted vector representation for a given symbol
This is primarily useful for external libraries which need to ensure that vector representation uniformity is maintained
species | the species to look up the index for. Note that this is the index species data will be at if you were to call getMolarAbundanceVector(), getMassFractionVector(), or getNumberFractionVector() |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the symbol is not registered in the composition |
Definition at line 848 of file composition.cpp.
|
nodiscard |
get the index in the sorted vector representation for a given symbol
This is primarily useful for external libraries which need to ensure that vector representation uniformity is maintained
symbol | the symbol to look up the index for. Note that this is the index species data will be at if you were to call getMolarAbundanceVector(), getMassFractionVector(), or getNumberFractionVector() |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
exceptions::UnregisteredSymbolError | if the symbol is not registered in the composition |
Definition at line 823 of file composition.cpp.
|
nodiscard |
Checks if a symbol is registered in the composition.
symbol | The symbol to check. |
Definition at line 902 of file composition.cpp.
|
nodiscardprivate |
Checks if the given fractions are valid (sum to ~1.0).
fractions | The fractions to check. |
Definition at line 295 of file composition.cpp.
|
staticprivate |
Checks if the given symbol is valid by checking against the global species database.
symbol | The symbol to check. |
Definition at line 308 of file composition.cpp.
|
nodiscard |
Mixes this composition with another to produce a new composition.
The mixing is performed linearly on the mass fractions. The formula for each species is: new_X_i = fraction * this_X_i + (1 - fraction) * other_X_i
. The resulting composition is automatically finalized.
other | The other composition to mix with. |
fraction | The mixing fraction. A value of 1.0 means the new composition is 100% this , 0.0 means 100% other . |
Composition
object representing the mixture. this
and other
compositions must be finalized. exceptions::CompositionNotFinalizedError | if either composition is not finalized. |
exceptions::InvalidCompositionError | if the fraction is not between 0 and 1. |
Definition at line 498 of file composition.cpp.
Composition fourdst::composition::Composition::operator+ | ( | const Composition & | other | ) | const |
Overloads the + operator to mix two compositions with a 50/50 fraction.
OVERLOADS.
This is a convenience operator that calls mix(other, 0.5)
.
other | The other composition to mix with. |
See | mix() for exceptions. |
Definition at line 921 of file composition.cpp.
Composition & fourdst::composition::Composition::operator= | ( | Composition const & | other | ) |
Assignment operator.
other | The Composition to assign from. |
Definition at line 219 of file composition.cpp.
void fourdst::composition::Composition::registerSpecies | ( | const fourdst::atomic::Species & | species, |
bool | massFracMode = true ) |
Registers a new species by extracting its symbol.
species | The species to register. |
massFracMode | True for mass fraction mode, false for number fraction mode. |
exceptions::InvalidSymbolError | if the species' symbol is invalid. |
exceptions::CompositionModeError | if the mode conflicts. |
Definition at line 266 of file composition.cpp.
void fourdst::composition::Composition::registerSpecies | ( | const std::vector< fourdst::atomic::Species > & | species, |
bool | massFracMode = true ) |
Registers a vector of new species.
species | The vector of species to register. |
massFracMode | True for mass fraction mode, false for number fraction mode. |
exceptions::InvalidSymbolError | if any species' symbol is invalid. |
exceptions::CompositionModeError | if the mode conflicts. |
Definition at line 270 of file composition.cpp.
void fourdst::composition::Composition::registerSymbol | ( | const std::string & | symbol, |
bool | massFracMode = true ) |
Registers a new symbol for inclusion in the composition.
A symbol must be registered before its abundance can be set. The first registration sets the mode (mass/number fraction) for the entire composition.
symbol | The symbol to register (e.g., "Fe-56"). |
massFracMode | True for mass fraction mode, false for number fraction mode. This is only effective for the first symbol registered. |
exceptions::InvalidSymbolError | if the symbol is not in the atomic species database. |
exceptions::CompositionModeError | if attempting to register with a mode that conflicts with the existing mode. |
Definition at line 233 of file composition.cpp.
void fourdst::composition::Composition::registerSymbol | ( | const std::vector< std::string > & | symbols, |
bool | massFracMode = true ) |
Registers multiple new symbols.
symbols | The symbols to register. |
massFracMode | True for mass fraction mode, false for number fraction mode. |
exceptions::InvalidSymbolError | if any symbol is invalid. |
exceptions::CompositionModeError | if the mode conflicts with an already set mode. |
Definition at line 260 of file composition.cpp.
void fourdst::composition::Composition::setCompositionMode | ( | bool | massFracMode | ) |
Sets the composition mode (mass fraction vs. number fraction).
This function converts all entries in the composition to the specified mode.
massFracMode | True to switch to mass fraction mode, false for number fraction mode. |
exceptions::CompositionNotFinalizedError | if the composition is not finalized. |
std::runtime_error | if the conversion fails for an unknown reason. |
Definition at line 694 of file composition.cpp.
double fourdst::composition::Composition::setMassFraction | ( | const fourdst::atomic::Species & | species, |
const double & | mass_fraction ) |
Sets the mass fraction for a given species.
species | The species to set the mass fraction for. |
mass_fraction | The mass fraction to set. |
exceptions::UnregisteredSymbolError | if the species is not registered. |
exceptions::CompositionModeError | if the composition is in number fraction mode. |
exceptions::InvalidCompositionError | if the mass fraction is not between 0 and 1. |
Definition at line 349 of file composition.cpp.
double fourdst::composition::Composition::setMassFraction | ( | const std::string & | symbol, |
const double & | mass_fraction ) |
Sets the mass fraction for a given symbol.
symbol | The symbol to set the mass fraction for. |
mass_fraction | The mass fraction to set (must be in [0, 1]). |
exceptions::UnregisteredSymbolError | if the symbol is not registered. |
exceptions::CompositionModeError | if the composition is in number fraction mode. |
exceptions::InvalidCompositionError | if the mass fraction is not between 0 and 1. |
Definition at line 312 of file composition.cpp.
std::vector< double > fourdst::composition::Composition::setMassFraction | ( | const std::vector< fourdst::atomic::Species > & | species, |
const std::vector< double > & | mass_fractions ) |
Sets the mass fraction for multiple species.
species | The vector of species to set the mass fractions for. |
mass_fractions | The vector of mass fractions corresponding to the species. |
See | setMassFraction(const std::vector<std::string>&, const std::vector<double>&) for exceptions. |
Definition at line 353 of file composition.cpp.
std::vector< double > fourdst::composition::Composition::setMassFraction | ( | const std::vector< std::string > & | symbols, |
const std::vector< double > & | mass_fractions ) |
Sets the mass fraction for multiple symbols.
symbols | The symbols to set the mass fractions for. |
mass_fractions | The mass fractions corresponding to the symbols. |
exceptions::InvalidCompositionError | if symbol and fraction counts differ. |
See | setMassFraction(const std::string&, const double&) for other exceptions. |
Definition at line 335 of file composition.cpp.
double fourdst::composition::Composition::setNumberFraction | ( | const fourdst::atomic::Species & | species, |
const double & | number_fraction ) |
Sets the number fraction for a given species.
species | The species to set the number fraction for. |
number_fraction | The number fraction to set for the species. |
exceptions::UnregisteredSymbolError | if the species is not registered. |
exceptions::CompositionModeError | if the composition is in mass fraction mode. |
exceptions::InvalidCompositionError | if the number fraction is not between 0 and 1. |
Definition at line 400 of file composition.cpp.
double fourdst::composition::Composition::setNumberFraction | ( | const std::string & | symbol, |
const double & | number_fraction ) |
Sets the number fraction for a given symbol.
symbol | The symbol to set the number fraction for. |
number_fraction | The number fraction to set (must be in [0, 1]). |
exceptions::UnregisteredSymbolError | if the symbol is not registered. |
exceptions::CompositionModeError | if the composition is in mass fraction mode. |
exceptions::InvalidCompositionError | if the number fraction is not between 0 and 1. |
Definition at line 363 of file composition.cpp.
std::vector< double > fourdst::composition::Composition::setNumberFraction | ( | const std::vector< fourdst::atomic::Species > & | species, |
const std::vector< double > & | number_fractions ) |
Sets the number fraction for multiple species.
species | The vector of species to set the number fractions for. |
number_fractions | The vector of number fractions corresponding to the species. |
See | setNumberFraction(const std::vector<std::string>&, const std::vector<double>&) for exceptions. |
Definition at line 404 of file composition.cpp.
std::vector< double > fourdst::composition::Composition::setNumberFraction | ( | const std::vector< std::string > & | symbols, |
const std::vector< double > & | number_fractions ) |
Sets the number fraction for multiple symbols.
symbols | The symbols to set the number fractions for. |
number_fractions | The number fractions corresponding to the symbols. |
exceptions::InvalidCompositionError | if symbol and fraction counts differ. |
See | setNumberFraction(const std::string&, const double&) for other exceptions. |
Definition at line 386 of file composition.cpp.
|
nodiscard |
Creates a new Composition object containing a subset of species from this one.
symbols | The symbols to include in the subset. |
method | The method for handling the abundances of the new subset. Can be "norm" (normalize abundances to sum to 1) or "none" (keep original abundances). |
Composition
object containing the subset. exceptions::UnregisteredSymbolError | if any requested symbol is not in the original composition. |
exceptions::InvalidMixingMode | if an invalid method is provided. |
exceptions::FailedToFinalizeCompositionError | if normalization fails. |
Definition at line 665 of file composition.cpp.
|
private |
Validates the given fractions, throwing an exception on failure.
fractions | The fractions to validate. |
exceptions::InvalidCompositionError | if the fractions are invalid. |
Definition at line 288 of file composition.cpp.
|
friend |
Overloaded output stream operator for Composition.
os | The output stream. |
composition | The Composition to output. |
Definition at line 937 of file composition.cpp.
|
private |
The compositions.
Definition at line 270 of file composition.h.
|
private |
Definition at line 260 of file composition.h.
|
private |
True if the composition is finalized.
Definition at line 264 of file composition.h.
|
private |
Definition at line 262 of file composition.h.
|
private |
Definition at line 261 of file composition.h.
|
private |
True if mass fraction mode, false if number fraction mode.
Definition at line 267 of file composition.h.
|
private |
The mean particle mass of the composition (\sum_{i} \frac{n_i}{m_i}. where n_i is the number fraction of the ith species and m_i is the mass of the ith species).
Definition at line 266 of file composition.h.
|
private |
The registered symbols.
Definition at line 269 of file composition.h.
|
private |
The specific number density of the composition (\sum_{i} X_i m_i. Where X_i is the number fraction of the ith species and m_i is the mass of the ith species).
Definition at line 265 of file composition.h.