\begin{DoxyCompactList}\small\item\em Constructs a stellar {\ttfamily\doxylink{classfourdst_1_1composition_1_1_composition}{Composition}} from a named solar metal-\/fraction scheme and isotopic-\/percentage table, scaled to the supplied bulk hydrogen and helium mass fractions. \end{DoxyCompactList}\item
\begin{DoxyCompactList}\small\item\em Build a \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} object from symbols and their corresponding mass fractions. \end{DoxyCompactList}\item
\begin{DoxyCompactList}\small\item\em Build a \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} object from species and their corresponding mass fractions. \end{DoxyCompactList}\item
\begin{DoxyCompactList}\small\item\em Build a \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} object from species in a set and their corresponding mass fractions. \end{DoxyCompactList}\item
\begin{DoxyCompactList}\small\item\em Build a \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} object from a map of species to mass fractions. \end{DoxyCompactList}\item
\begin{DoxyCompactList}\small\item\em Build a \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} object from a map of species to mass fractions. \end{DoxyCompactList}\item
\begin{DoxyCompactList}\small\item\em Build a \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} object from a map of species to mass fractions. \end{DoxyCompactList}\item
\begin{DoxyCompactList}\small\item\em Build a \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} object from a map of species to mass fractions. \end{DoxyCompactList}\item
The composition module provides a small, but expressive, API for constructing and querying material compositions used throughout the 4D-\/\+STAR codebase. A \doxylink{classfourdst_1_1composition_1_1_composition}{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).
\item Species and Symbols\+: Atomic isotopes are represented by the strongly-\/typed \doxylink{structfourdst_1_1atomic_1_1_species}{fourdst\+::atomic\+::\+Species} values (see {\ttfamily\doxylink{species_8h}{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.
\item Molar abundances\+: The \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} API accepts and stores molar abundances (absolute mole counts). Many derived quantities (mass fraction, number fraction, mean particle mass) are computed from these molar abundances.
\item Canonical composition\+: A \doxylink{structfourdst_1_1composition_1_1_canonical_composition}{Canonical\+Composition} (X, Y, Z) is provided which groups mass fractions into hydrogen (X), helium (Y), and metals (Z). A lightweight struct {\ttfamily\doxylink{structfourdst_1_1composition_1_1_canonical_composition}{Canonical\+Composition}} holds these values and provides an ostream operator for easy logging and testing.
\item Caching\+: The concrete \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} implementation caches computed vectors and scalars to avoid repeated work. The cache is invalidated automatically when molar abundances or registered species are changed.
\end{DoxyItemize}\hypertarget{namespacefourdst_1_1composition_autotoc_md6}{}\doxysubsubsection{\texorpdfstring{Main types and functions}{Main types and functions}}\label{namespacefourdst_1_1composition_autotoc_md6}
\item\doxylink{classfourdst_1_1composition_1_1_composition}{Composition}\+: The primary concrete class for building and interrogating compositions. It implements the \doxylink{classfourdst_1_1composition_1_1_composition_abstract}{Composition\+Abstract} 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).
\item\doxylink{classfourdst_1_1composition_1_1_composition_abstract}{Composition\+Abstract}\+: A compact abstract interface implemented by \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} which guarantees the presence of all getter/query methods. This allows other components to accept composition-\/like objects without depending on the concrete implementation.
\item Utilities (\doxylink{namespacefourdst_1_1composition_aa90b1ef07d607c0c829bedccf381cf54}{fourdst\+::composition\+::build\+Composition\+From\+Mass\+Fractions})\+: Convenience helpers exist to construct a \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} from mass fractions (instead of molar abundances). Those helpers validate that the provided mass fractions sum to unity within a tight tolerance and convert them into the corresponding molar abundances before returning a populated \doxylink{classfourdst_1_1composition_1_1_composition}{Composition}.
\item Exceptions (namespace \doxylink{namespacefourdst_1_1composition_1_1exceptions}{fourdst\+::composition\+::exceptions})\+: The module defines a small hierarchy of exceptions for error handling\+:
\begin{DoxyItemize}
\item Composition\+Error\+: Base class for composition-\/related errors.
\item Invalid\+Composition\+Error\+: Thrown when the composition is inconsistent or when mass fractions fail validation.
\item Unregistered\+Symbol\+Error\+: Thrown when an operation requires a symbol that hasn\textquotesingle{}t been registered on the \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} object.
\hypertarget{namespacefourdst_1_1composition_autotoc_md8}{}\doxysubsubsection{\texorpdfstring{Notes and remarks}{Notes and remarks}}\label{namespacefourdst_1_1composition_autotoc_md8}
\item Molar abundances are the canonical input for the \doxylink{classfourdst_1_1composition_1_1_composition}{Composition} class. When passing mass fractions, use the {\ttfamily build\+Composition\+From\+Mass\+Fractions} helper which performs the safe conversion and validation.
\item Many methods throw exceptions from the {\ttfamily\doxylink{namespacefourdst_1_1composition_1_1exceptions}{fourdst\+::composition\+::exceptions}} namespace on invalid usage (unknown symbols, unregistered species, or invalid abundance values). Callers should catch and handle these where appropriate.
\item Floating point results (mass/number fractions, mean particle mass, Y\+\_\+e) are computed as doubles and may have small numerical round-\/off. Callers comparing values in tests should use an appropriate tolerance.
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the provided mass fractions do not sum to within one part in 10\texorpdfstring{$^\wedge$}{\string^}10 of 1.\+0. \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the number of species does not match the number of mass fractions.\\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the provided mass fractions do not sum to within one part in 10\texorpdfstring{$^\wedge$}{\string^}10 of 1.\+0. \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the provided mass fractions do not sum to within one part in 10\texorpdfstring{$^\wedge$}{\string^}10 of 1.\+0. \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the provided mass fractions do not sum to within one part in 10\texorpdfstring{$^\wedge$}{\string^}10 of 1.\+0. \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the number of species does not match the number of mass fractions. \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_unknown_symbol_error}{exceptions\+::\+Unknown\+Symbol\+Error}}& if any symbol is invalid. Symbols are invalid if they are not registered at compile time in the atomic species database ({\ttfamily\doxylink{species_8h}{fourdst/atomic/species.\+h}}). \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the provided mass fractions do not sum to within one part in 10\texorpdfstring{$^\wedge$}{\string^}10 of 1.\+0. \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the number of symbols does not match the number of mass fractions. \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the provided mass fractions do not sum to within one part in 10\texorpdfstring{$^\wedge$}{\string^}10 of 1.\+0. \\
{\em\doxylink{classfourdst_1_1composition_1_1exceptions_1_1_invalid_composition_error}{exceptions\+::\+Invalid\+Composition\+Error}}& if the provided mass fractions do not sum to within one part in 10\texorpdfstring{$^\wedge$}{\string^}10 of 1.\+0. \\
Constructs a stellar {\ttfamily\doxylink{classfourdst_1_1composition_1_1_composition}{Composition}} from a named solar metal-\/fraction scheme and isotopic-\/percentage table, scaled to the supplied bulk hydrogen and helium mass fractions.
Available metal fraction schemes (extracted from MESA {\ttfamily chem\+\_\+def.\+f90})\+:
\item{\bfseries{Data loading}} — The embedded binary {\ttfamily Standard\+Metal\+Fractions} is copied into a {\ttfamily std\+::vector\texorpdfstring{$<$}{<}char\texorpdfstring{$>$}{>}} and parsed twice\+: once for {\ttfamily metal\+\_\+fraction\+\_\+scheme} and once for {\ttfamily isotopic\+\_\+percentage\+\_\+scheme}.
\item{\bfseries{Species list}} — The isotope table is iterated; any isotope whose element appears in the metals list or is {\ttfamily "{}\+H"{}} / {\ttfamily "{}\+He"{}} is looked up in the global {\ttfamily\doxylink{namespacefourdst_1_1atomic_a3f619cc8f8b2cd718a4082c6adb0de90}{atomic\+::species}} registry by {\ttfamily "{}$<$\+Element$>$-\/$<$\+A$>$"{}} and added to the list.
\item{\bfseries{H and He mass fractions}} — Four entries are prepended (H-\/1, H-\/2, He-\/3, He-\/4) using Anders \& Grevesse (1989) solar He3/\+He4 ratio\+:
\begin{DoxyItemize}
\item X(H-\/1) = clamp(1 -\/ Z -\/ Y, 0, 1)
\item X(H-\/2) = 0
\item X(He-\/3) = Y \texorpdfstring{$\ast$}{*} xsol\+\_\+\+He3 / (xsol\+\_\+\+He3 + xsol\+\_\+\+He4)
\item X(He-\/4) = Y \texorpdfstring{$\ast$}{*} xsol\+\_\+\+He4 / (xsol\+\_\+\+He3 + xsol\+\_\+\+He4) where xsol\+\_\+\+He3 = 2.\+9291e-\/5 and xsol\+\_\+\+He4 = 2.\+7521e-\/1.
\end{DoxyItemize}
\item{\bfseries{Atomic-\/weight weighting}} — When {\ttfamily Composition\+Data\+::requires\+\_\+atomic\+\_\+weight} is {\ttfamily true}, each metal\textquotesingle{}s number-\/fraction abundance is multiplied by the atomic mass of its most-\/abundant isotope (determined from the isotopic table).
\item{\bfseries{Normalisation}} — Metal fractions are summed and normalised to unity.
\item{\bfseries{Isotope distribution}} — Per-\/isotope mass fractions are computed as\+: X\+\_\+i = Z\+\_\+total \texorpdfstring{$\ast$}{*} f\+\_\+E \texorpdfstring{$\ast$}{*} (p\+\_\+i \texorpdfstring{$\ast$}{*} m\+\_\+i) / sum\+\_\+j(p\+\_\+j \texorpdfstring{$\ast$}{*} m\+\_\+j) where f\+\_\+E is the normalised metal fraction, p\+\_\+i the isotopic percentage (0-\/100 scale), and m\+\_\+i the isotope\textquotesingle{}s atomic mass.
\item{\bfseries{Renormalisation}} — Metal mass fractions are rescaled so their sum equals Z\+\_\+total exactly.
\item{\bfseries{Assembly}} — {\ttfamily build\+Composition\+From\+Mass\+Fractions(species, mass\+Fracs)} builds the final {\ttfamily\doxylink{classfourdst_1_1composition_1_1_composition}{Composition}} object.
\end{DoxyEnumerate}
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}&{\em metal\+\_\+fraction\+\_\+scheme}& Block tag of the desired solar metal composition (e.\+g., {\ttfamily "{}\+GS98"{}}, {\ttfamily "{}\+AGSS09"{}}). Case-\/sensitive; must match a {\ttfamily BEGIN}/{\ttfamily END} tag in the embedded data exactly. \\
\hline
\mbox{\texttt{ in}}&{\em isotopic\+\_\+percentage\+\_\+scheme}& Block tag of the isotopic percentage table (e.\+g., {\ttfamily "{}\+L03\+\_\+data"{}}, {\ttfamily "{}\+L09\+\_\+data"{}}). \\
\hline
\mbox{\texttt{ in}}&{\em initial\+\_\+z}& Total metal mass fraction Z (0 \texorpdfstring{$<$}{<}= Z \texorpdfstring{$<$}{<} 1). \\
\hline
\mbox{\texttt{ in}}&{\em initial\+\_\+y}& Total helium mass fraction Y (0 \texorpdfstring{$<$}{<}= Y \texorpdfstring{$<$}{<} 1, with X + Y + Z \texorpdfstring{$<$}{<}= 1 recommended). X(H-\/1) is clamped to \mbox{[}0, 1\mbox{]} if the constraint is violated.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily\doxylink{classfourdst_1_1composition_1_1_composition}{Composition}} Fully populated composition object with per-\/isotope mass fractions normalised to {\ttfamily initial\+\_\+z} and {\ttfamily initial\+\_\+y}.
\end{DoxyReturn}
\begin{DoxyExceptions}{Exceptions}
{\em std\+::out\+\_\+of\+\_\+range}& If a species name derived from the isotopic table is absent from {\ttfamily\doxylink{namespacefourdst_1_1atomic_a3f619cc8f8b2cd718a4082c6adb0de90}{atomic\+::species}}, or if either scheme tag is not present in the embedded data. \\
\hline
{\em std\+::invalid\+\_\+argument}& If numeric fields in the embedded data are malformed (propagated from {\ttfamily std\+::stod} / {\ttfamily std\+::stoi}).\\
Definition at line \mbox{\hyperlink{standard__compositions_8cpp_source_l00252}{252}} of file \mbox{\hyperlink{standard__compositions_8cpp_source}{standard\+\_\+compositions.\+cpp}}.
Enum-\/based overload of {\ttfamily\doxylink{namespacefourdst_1_1composition_a708d71303db2fa22c8871f3bfc3d11d4}{get\+\_\+composition\+\_\+record()}}.
Translates strongly-\/typed enum values to their canonical string representations via {\ttfamily Solar\+Compositions\+\_\+to\+\_\+string\+\_\+map} and {\ttfamily Isotopic\+Percentages\+\_\+to\+\_\+string\+\_\+map}, then delegates to the string-\/based overload. This overload is preferred as it prevents scheme name typos.
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}&{\em metal\+\_\+fraction\+\_\+scheme}& Enum identifying the desired solar metal composition (e.\+g., {\ttfamily Solar\+Compositions\+::\+GS98}). \\
\mbox{\texttt{ in}}&{\em initial\+\_\+z}& Total metal mass fraction Z (0 \texorpdfstring{$<$}{<}= Z \texorpdfstring{$<$}{<} 1). \\
\hline
\mbox{\texttt{ in}}&{\em initial\+\_\+y}& Total helium mass fraction Y (0 \texorpdfstring{$<$}{<}= Y \texorpdfstring{$<$}{<} 1).\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily\doxylink{classfourdst_1_1composition_1_1_composition}{Composition}} Fully populated composition; see the string-\/based overload for the complete algorithm description.
\end{DoxyReturn}
\begin{DoxyExceptions}{Exceptions}
{\em std\+::out\+\_\+of\+\_\+range}& If the enum value is absent from its lookup map (should not occur with valid named enum members).\\
Definition at line \mbox{\hyperlink{standard__compositions_8cpp_source_l00390}{390}} of file \mbox{\hyperlink{standard__compositions_8cpp_source}{standard\+\_\+compositions.\+cpp}}.