|
fourdst::libcomposition v2.0.1
Robust atomic species information library
|
Utilities and types for representing and manipulating chemical compositions. More...
Namespaces | |
| namespace | exceptions |
Classes | |
| struct | CanonicalComposition |
| Represents the canonical (X, Y, Z) composition of stellar material. More... | |
| class | Composition |
| Manages a collection of chemical species and their abundances. More... | |
Functions | |
| Composition | buildCompositionFromMassFractions (const std::vector< std::string > &symbols, const std::vector< double > &massFractions) |
| Build a Composition object from symbols and their corresponding mass fractions. | |
| Composition | buildCompositionFromMassFractions (const std::vector< atomic::Species > &species, const std::vector< double > &massFractions) |
| Build a Composition object from species and their corresponding mass fractions. | |
| Composition | buildCompositionFromMassFractions (const std::set< atomic::Species > &species, const std::vector< double > &massFractions) |
| Build a Composition object from species in a set and their corresponding mass fractions. | |
| std::ostream & | operator<< (std::ostream &os, const Composition &composition) |
| OVERLOADS. | |
Utilities and types for representing and manipulating chemical compositions.
The composition module provides a small, but expressive, API for constructing and querying material compositions used throughout the 4D-STAR codebase. A Composition represents a collection of atomic species together with their molar abundances. From these molar abundances the module can compute derived quantities such as mass fractions, number fractions, canonical (X, Y, Z) composition, mean particle mass, and the electron abundance (Y_e).
Key concepts:
fourdst/atomic/species.h). Each species also has a human-readable string symbol (e.g. "H-1", "He-4") used by some constructors and convenience overloads.CanonicalComposition holds these values and provides an ostream operator for easy logging and testing.Composition: The primary concrete class for building and interrogating compositions. It implements the CompositionAbstract interface and exposes methods to register symbols/species, set molar abundances, and query all commonly-needed derived quantities. Multiple constructors are provided for convenience (from vectors/sets of symbols or species, with optional molar-abundance initialization).
Important member functions include:
Example 1 – basic construction and queries:
Example 2 – constructing from mass fractions:
buildCompositionFromMassFractions helper which performs the safe conversion and validation.fourdst::composition::exceptions namespace on invalid usage (unknown symbols, unregistered species, or invalid abundance values). Callers should catch and handle these where appropriate.| Composition fourdst::composition::buildCompositionFromMassFractions | ( | const std::set< atomic::Species > & | species, |
| const std::vector< double > & | massFractions ) |
Build a Composition object from species in a set and their corresponding mass fractions.
| species | The species to register. |
| massFractions | The corresponding mass fractions for each species. |
| exceptions::InvalidCompositionError | if the provided mass fractions do not sum to within one part in 10^10 of 1.0. |
| exceptions::InvalidCompositionError | if the number of species does not match the number of mass fractions. |
| Composition fourdst::composition::buildCompositionFromMassFractions | ( | const std::vector< atomic::Species > & | species, |
| const std::vector< double > & | massFractions ) |
Build a Composition object from species and their corresponding mass fractions.
| species | The species to register. |
| massFractions | The corresponding mass fractions for each species. |
| exceptions::InvalidCompositionError | if the provided mass fractions do not sum to within one part in 10^10 of 1.0. |
| exceptions::InvalidCompositionError | if the number of species does not match the number of mass fractions. |
| Composition fourdst::composition::buildCompositionFromMassFractions | ( | const std::vector< std::string > & | symbols, |
| const std::vector< double > & | massFractions ) |
Build a Composition object from symbols and their corresponding mass fractions.
| symbols | The symbols to register. |
| massFractions | The corresponding mass fractions for each symbol. |
| exceptions::UnknownSymbolError | if any symbol is invalid. Symbols are invalid if they are not registered at compile time in the atomic species database (fourdst/atomic/species.h). |
| exceptions::InvalidCompositionError | if the provided mass fractions do not sum to within one part in 10^10 of 1.0. |
| exceptions::InvalidCompositionError | if the number of symbols does not match the number of mass fractions. |
| std::ostream & fourdst::composition::operator<< | ( | std::ostream & | os, |
| const Composition & | composition ) |
OVERLOADS.
Overloaded output stream operator for Composition.
| os | The output stream. |
| composition | The Composition to output. |
Definition at line 593 of file composition.cpp.