|
fourdst::libcomposition v1.5.2
Robust atomic species information library
|
Represents a single entry (an isotope) within a composition. More...
#include <composition.h>
Public Member Functions | |
| CompositionEntry () | |
| Default constructor. Initializes a default entry (H-1), but in an uninitialized state. | |
| CompositionEntry (const std::string &symbol, bool massFracMode=true) | |
| Constructs a CompositionEntry for a given symbol and abundance mode. | |
| CompositionEntry (const CompositionEntry &entry) | |
| Copy constructor. | |
| void | setSpecies (const std::string &symbol) |
| Sets the species for the composition entry. This can only be done once. | |
| std::string | symbol () const |
| Gets the chemical symbol of the species. | |
| double | mass_fraction () const |
| Gets the mass fraction of the species. | |
| double | mass_fraction (double meanMolarMass) const |
| Gets the mass fraction, converting from number fraction if necessary. | |
| double | number_fraction () const |
| Gets the number fraction of the species. | |
| double | number_fraction (double totalMoles) const |
| Gets the number fraction, converting from mass fraction if necessary. | |
| double | rel_abundance () const |
| Gets the relative abundance of the species. | |
| atomic::Species | isotope () const |
| Gets the isotope data for the species. | |
| bool | getMassFracMode () const |
| Gets the mode of the composition entry. | |
| void | setMassFraction (double mass_fraction) |
| Sets the mass fraction of the species. | |
| void | setNumberFraction (double number_fraction) |
| Sets the number fraction of the species. | |
| bool | setMassFracMode (double meanMolarMass) |
| Switches the mode to mass fraction mode. | |
| bool | setNumberFracMode (double totalMoles) |
| Switches the mode to number fraction mode. | |
Public Attributes | |
| std::string | m_symbol |
| The chemical symbol of the species (e.g., "H-1", "Fe-56"). | |
| atomic::Species | m_isotope |
The atomic::Species object containing detailed isotope data. | |
| bool | m_massFracMode = true |
| The mode of the composition entry. True if mass fraction, false if number fraction. | |
| double | m_massFraction = 0.0 |
The mass fraction of the species. Valid only if m_massFracMode is true. | |
| double | m_numberFraction = 0.0 |
The number fraction (mole fraction) of the species. Valid only if m_massFracMode is false. | |
| double | m_relAbundance = 0.0 |
| The relative abundance, used internally for conversions. For mass fraction mode, this is X_i / A_i; for number fraction mode, it's n_i * A_i. | |
| bool | m_initialized = false |
| True if the composition entry has been initialized with a valid species. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const CompositionEntry &entry) |
| Overloaded output stream operator for CompositionEntry. | |
Represents a single entry (an isotope) within a composition.
This struct holds the properties of one component, including its symbol, the corresponding atomic::Species object, and its abundance (either as a mass fraction or number fraction). It manages the state and conversions for that single entry.
Definition at line 83 of file composition.h.
| fourdst::composition::CompositionEntry::CompositionEntry | ( | ) |
Default constructor. Initializes a default entry (H-1), but in an uninitialized state.
Definition at line 38 of file composition.cpp.
|
explicit |
Constructs a CompositionEntry for a given symbol and abundance mode.
| symbol | The chemical symbol of the species (e.g., "He-4"). |
| massFracMode | True to operate in mass fraction mode, false for number fraction mode. |
| exceptions::InvalidSpeciesSymbolError | if the symbol does not exist in the atomic species database. |
| exceptions::EntryAlreadyInitializedError | if setSpecies is called on an already initialized entry. |
Definition at line 43 of file composition.cpp.
| fourdst::composition::CompositionEntry::CompositionEntry | ( | const CompositionEntry & | entry | ) |
Copy constructor.
| entry | The CompositionEntry to copy. |
Definition at line 47 of file composition.cpp.
|
nodiscard |
Gets the mode of the composition entry.
Definition at line 147 of file composition.cpp.
|
nodiscard |
Gets the isotope data for the species.
atomic::Species object. Definition at line 109 of file composition.cpp.
|
nodiscard |
Gets the mass fraction of the species.
| exceptions::CompositionModeError | if the entry is in number fraction mode. |
Definition at line 72 of file composition.cpp.
|
nodiscard |
Gets the mass fraction, converting from number fraction if necessary.
| meanMolarMass | The mean molar mass of the entire composition, required for conversion. |
Definition at line 79 of file composition.cpp.
|
nodiscard |
Gets the number fraction of the species.
| exceptions::CompositionModeError | if the entry is in mass fraction mode. |
Definition at line 89 of file composition.cpp.
|
nodiscard |
Gets the number fraction, converting from mass fraction if necessary.
| totalMoles | The total moles per unit mass (specific number density) of the entire composition. |
Definition at line 96 of file composition.cpp.
|
nodiscard |
Gets the relative abundance of the species.
Definition at line 105 of file composition.cpp.
| bool fourdst::composition::CompositionEntry::setMassFracMode | ( | double | meanMolarMass | ) |
Switches the mode to mass fraction mode.
| meanMolarMass | The mean molar mass of the composition, required for conversion. |
Definition at line 129 of file composition.cpp.
| void fourdst::composition::CompositionEntry::setMassFraction | ( | double | mass_fraction | ) |
Sets the mass fraction of the species.
| mass_fraction | The mass fraction to set. Must be in [0, 1]. |
| exceptions::CompositionModeError | if the entry is in number fraction mode. |
Definition at line 113 of file composition.cpp.
| bool fourdst::composition::CompositionEntry::setNumberFracMode | ( | double | totalMoles | ) |
Switches the mode to number fraction mode.
| totalMoles | The total moles per unit mass (specific number density) of the composition. |
Definition at line 138 of file composition.cpp.
| void fourdst::composition::CompositionEntry::setNumberFraction | ( | double | number_fraction | ) |
Sets the number fraction of the species.
| number_fraction | The number fraction to set. Must be in [0, 1]. |
| exceptions::CompositionModeError | if the entry is in mass fraction mode. |
Definition at line 121 of file composition.cpp.
| void fourdst::composition::CompositionEntry::setSpecies | ( | const std::string & | symbol | ) |
Sets the species for the composition entry. This can only be done once.
| symbol | The chemical symbol of the species. |
| exceptions::EntryAlreadyInitializedError | if the entry has already been initialized. |
| exceptions::InvalidSpeciesSymbolError | if the symbol is not found in the atomic species database. |
Definition at line 56 of file composition.cpp.
|
nodiscard |
Gets the chemical symbol of the species.
Definition at line 68 of file composition.cpp.
|
friend |
Overloaded output stream operator for CompositionEntry.
| os | The output stream. |
| entry | The CompositionEntry to output. |
Definition at line 767 of file composition.cpp.
| bool fourdst::composition::CompositionEntry::m_initialized = false |
True if the composition entry has been initialized with a valid species.
Definition at line 92 of file composition.h.
| atomic::Species fourdst::composition::CompositionEntry::m_isotope |
The atomic::Species object containing detailed isotope data.
Definition at line 85 of file composition.h.
| bool fourdst::composition::CompositionEntry::m_massFracMode = true |
The mode of the composition entry. True if mass fraction, false if number fraction.
Definition at line 86 of file composition.h.
| double fourdst::composition::CompositionEntry::m_massFraction = 0.0 |
The mass fraction of the species. Valid only if m_massFracMode is true.
Definition at line 88 of file composition.h.
| double fourdst::composition::CompositionEntry::m_numberFraction = 0.0 |
The number fraction (mole fraction) of the species. Valid only if m_massFracMode is false.
Definition at line 89 of file composition.h.
| double fourdst::composition::CompositionEntry::m_relAbundance = 0.0 |
The relative abundance, used internally for conversions. For mass fraction mode, this is X_i / A_i; for number fraction mode, it's n_i * A_i.
Definition at line 90 of file composition.h.
| std::string fourdst::composition::CompositionEntry::m_symbol |
The chemical symbol of the species (e.g., "H-1", "Fe-56").
Definition at line 84 of file composition.h.