2025-07-24 09:35:52 -04:00
\chapter { libcomposition\+ : A Modern C++ Library for Chemical Compositions}
\hypertarget { index} { } \label { index} \index { libcomposition: A Modern C++ Library for Chemical Compositions@{ libcomposition: A Modern C++ Library for Chemical Compositions} }
\hypertarget { index_ intro_ sec} { } \doxysection { \texorpdfstring { Introduction} { Introduction} } \label { index_ intro_ sec}
2025-11-08 06:42:51 -05:00
{ \ttfamily libcomposition} is a modern C++23 library designed for the creation, manipulation, and analysis of chemical compositions, with a focus on astrophysical applications. It provides a robust and user-\/ friendly interface for handling material compositions defined by mass or number fractions.\hypertarget { index_ autotoc_ md10} { } \doxysubsubsection { \texorpdfstring { Key Features} { Key Features} } \label { index_ autotoc_ md10}
2025-07-24 09:35:52 -04:00
\begin { DoxyItemize}
\item { \bfseries { Dual-\/ \+ Mode Operation} } \+ : Natively supports compositions defined by { \bfseries { mass fraction} } or { \bfseries { number fraction} } .
\item { \bfseries { Rich Atomic Database} } \+ : Includes a comprehensive, header-\/ only database of isotopic properties (mass, half-\/ life, spin, etc.) generated from the AME2020 and NUBASE2020 evaluations.
\item { \bfseries { Type Safety and Error Handling} } \+ : Utilizes a clear exception hierarchy to report errors, such as using an unregistered isotope or accessing data from a non-\/ validated composition.
\item { \bfseries { Powerful Functionality} } \+ : Core features include mixing, subsetting, and on-\/ the-\/ fly conversion between mass and number fractions.
\item { \bfseries { Easy Integration} } \+ : Designed for seamless integration with other projects using the Meson build system and { \ttfamily pkg-\/ config} .
\end { DoxyItemize}
\DoxyHorRuler { 0}
\hypertarget { index_ install_ sec} { } \doxysection { \texorpdfstring { Installation} { Installation} } \label { index_ install_ sec}
2025-11-08 06:42:51 -05:00
{ \ttfamily libcomposition} uses the Meson build system. A C++23 compatible compiler is required.\hypertarget { index_ autotoc_ md12} { } \doxysubsubsection { \texorpdfstring { Build Steps} { Build Steps} } \label { index_ autotoc_ md12}
2025-07-24 09:35:52 -04:00
{ \bfseries { Setup the build directory\+ :} }
The first step is to use meson to set up an out of source build. Note that this means that you can have multiple builds configured and cleanly seperated!
\begin { DoxyCode} { 0}
\DoxyCodeLine { meson\ setup\ builddir}
\end { DoxyCode}
{ \bfseries { Compile the library\+ :} }
meson by default uses ninja to compile so it should be very fast; however, gcc is very slow when compiling the species database so that migth take some time (clang tends to be very fast for this).
\begin { DoxyCode} { 0}
\DoxyCodeLine { meson\ compile\ -\/ C\ builddir}
\end { DoxyCode}
{ \bfseries { Install the library\+ :} }
This will also install a pkg-\/ config file!
\begin { DoxyCode} { 0}
\DoxyCodeLine { sudo\ meson\ install\ -\/ C\ builddir}
\end { DoxyCode}
2025-11-08 06:42:51 -05:00
\hypertarget { index_ autotoc_ md13} { } \doxysubsubsection { \texorpdfstring { Build Options} { Build Options} } \label { index_ autotoc_ md13}
2025-07-24 09:35:52 -04:00
You can enable the generation of a { \ttfamily pkg-\/ config} file during the setup step, which simplifies linking the library in other projects. by default this is true; it can be useful to disable this when using some build system orgestrator (such as meson-\/ python).
\begin { DoxyCode} { 0}
\DoxyCodeLine { \# \ Enable\ pkg-\/ config\ file\ generation}
\DoxyCodeLine { meson\ setup\ builddir\ -\/ Dpkg-\/ config=true}
\end { DoxyCode}
\DoxyHorRuler { 0}
\hypertarget { index_ usage_ sec} { } \doxysection { \texorpdfstring { Usage} { Usage} } \label { index_ usage_ sec}
2025-11-08 06:42:51 -05:00
\hypertarget { index_ autotoc_ md15} { } \doxysubsubsection { \texorpdfstring { Linking with pkg-\/ config} { Linking with pkg-\/ config} } \label { index_ autotoc_ md15}
2025-07-24 09:35:52 -04:00
If you installed { \ttfamily libcomposition} with the { \ttfamily pkg-\/ config} option enabled, you can get the necessary compiler and linker flags easily\+ :
\begin { DoxyCode} { 0}
\DoxyCodeLine { \# \ Get\ compiler\ flags\ (include\ paths)}
\DoxyCodeLine { pkg-\/ config\ -\/ -\/ cflags\ fourdst\_ composition}
\DoxyCodeLine { }
\DoxyCodeLine { \# \ Get\ linker\ flags\ (library\ paths\ and\ names)}
\DoxyCodeLine { pkg-\/ config\ -\/ -\/ libs\ fourdst\_ composition}
\end { DoxyCode}
{ \bfseries { Example compilation command\+ :} }
\begin { DoxyCode} { 0}
\DoxyCodeLine { g++\ my\_ app.cpp\ \$ (pkg-\/ config\ -\/ -\/ cflags\ -\/ -\/ libs\ fourdst\_ composition)\ -\/ o\ my\_ app}
\end { DoxyCode}
2025-11-08 06:42:51 -05:00
\hypertarget { index_ autotoc_ md16} { } \doxysubsubsection { \texorpdfstring { C++ Usage Examples} { C++ Usage Examples} } \label { index_ autotoc_ md16}
\hypertarget { index_ autotoc_ md17} { } \doxysubsubsubsection { \texorpdfstring { 1. Basic Mass Fraction Composition} { 1. Basic Mass Fraction Composition} } \label { index_ autotoc_ md17}
2025-07-24 09:35:52 -04:00
The most common use case is defining a composition by mass fractions (X, Y, Z).
\begin { DoxyCode} { 0}
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ <iostream>} }
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ "{ } \mbox { \hyperlink { composition_ 8h} { fourdst/composition/composition.h} } "{ } } }
\DoxyCodeLine { }
\DoxyCodeLine { \textcolor { keywordtype} { int} \ main()\ \{ }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ 1.\ Create\ a\ composition\ object} }
\DoxyCodeLine { \ \ \ \ \mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition} { fourdst::composition::Composition} } \ comp;}
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ 2.\ Register\ the\ symbols\ you\ want\ to\ use} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a3ab4dcda0bfd1a35b169bcc57fe66725} { registerSymbol} } (\textcolor { stringliteral} { "{ } H-\/ 1"{ } } );}
\DoxyCodeLine { \ \ \ \ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a3ab4dcda0bfd1a35b169bcc57fe66725} { registerSymbol} } (\textcolor { stringliteral} { "{ } He-\/ 4"{ } } );}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ 3.\ Set\ their\ mass\ fractions} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ comp.setMassFraction(\textcolor { stringliteral} { "{ } H-\/ 1"{ } } ,\ 0.75);}
\DoxyCodeLine { \ \ \ \ comp.setMassFraction(\textcolor { stringliteral} { "{ } He-\/ 4"{ } } ,\ 0.25);}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ 4.\ Finalize\ the\ composition\ to\ validate\ it\ and\ compute\ global\ properties} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \textcolor { keywordflow} { if} \ (comp.finalize())\ \{ }
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } Composition\ finalized\ successfully!"{ } } \ <<\ std::endl;}
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } H-\/ 1\ Mass\ Fraction:\ "{ } } \ <<\ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a9ea2b673341fdc67afeb0f0517a54c8c} { getMassFraction} } (\textcolor { stringliteral} { "{ } H-\/ 1"{ } } )\ <<\ std::endl;}
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } Mean\ Particle\ Mass:\ "{ } } \ <<\ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ afbbb5e51ad5ae5c0fa6bc0094195aecd} { getMeanParticleMass} } ()\ <<\ \textcolor { stringliteral} { "{ } \ g/mol"{ } } \ <<\ std::endl;}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { \ \ \ \ \} \ \textcolor { keywordflow} { else} \ \{ }
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cerr\ <<\ \textcolor { stringliteral} { "{ } Failed\ to\ finalize\ composition."{ } } \ <<\ std::endl;}
\DoxyCodeLine { \ \ \ \ \} }
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { keywordflow} { return} \ 0;}
\DoxyCodeLine { \} }
\end { DoxyCode}
2025-11-08 06:42:51 -05:00
\hypertarget { index_ autotoc_ md18} { } \doxysubsubsubsection { \texorpdfstring { 2. Number Fraction Composition and Mode Switching} { 2. Number Fraction Composition and Mode Switching} } \label { index_ autotoc_ md18}
2025-07-24 09:35:52 -04:00
The library can also work with number (mole) fractions and switch between modes.
\begin { DoxyCode} { 0}
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ "{ } \mbox { \hyperlink { composition_ 8h} { fourdst/composition/composition.h} } "{ } } }
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ "{ } \mbox { \hyperlink { exceptions_ _ composition_ 8h} { fourdst/composition/exceptions/exceptions\_ composition.h} } "{ } } }
\DoxyCodeLine { }
\DoxyCodeLine { \textcolor { keywordtype} { void} \ number\_ fraction\_ example()\ \{ }
\DoxyCodeLine { \ \ \ \ \mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition} { fourdst::composition::Composition} } \ comp;}
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ Register\ symbols\ in\ number\ fraction\ mode} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a3ab4dcda0bfd1a35b169bcc57fe66725} { registerSymbol} } (\textcolor { stringliteral} { "{ } H-\/ 1"{ } } ,\ \textcolor { keyword} { false} );\ \textcolor { comment} { //\ massFracMode\ =\ false} }
\DoxyCodeLine { \ \ \ \ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a3ab4dcda0bfd1a35b169bcc57fe66725} { registerSymbol} } (\textcolor { stringliteral} { "{ } He-\/ 4"{ } } ,\ \textcolor { keyword} { false} );}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ comp.setNumberFraction(\textcolor { stringliteral} { "{ } H-\/ 1"{ } } ,\ 0.9);}
\DoxyCodeLine { \ \ \ \ comp.setNumberFraction(\textcolor { stringliteral} { "{ } He-\/ 4"{ } } ,\ 0.1);}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \textcolor { keywordflow} { if} \ (comp.finalize())\ \{ }
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ \textcolor { comment} { //\ We\ can\ get\ number\ fractions\ directly} }
2025-10-12 10:22:43 -04:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } He-\/ 4\ Number\ Fraction:\ "{ } } \ <<\ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a34f71d4d8f0297c576fd62fabd490305} { getNumberFraction} } (\textcolor { stringliteral} { "{ } He-\/ 4"{ } } )\ <<\ std::endl;}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \ \ \ \ \textcolor { comment} { //\ Or\ get\ the\ equivalent\ mass\ fraction} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } He-\/ 4\ Mass\ Fraction:\ "{ } } \ <<\ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a9ea2b673341fdc67afeb0f0517a54c8c} { getMassFraction} } (\textcolor { stringliteral} { "{ } He-\/ 4"{ } } )\ <<\ std::endl;}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \ \ \ \ \textcolor { comment} { //\ Switch\ the\ entire\ composition\ to\ mass\ fraction\ mode} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ comp.setCompositionMode(\textcolor { keyword} { true} );\ \textcolor { comment} { //\ true\ for\ mass\ fraction\ mode} }
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \ \ \ \ \textcolor { comment} { //\ Now,\ getting\ the\ mass\ fraction\ is\ a\ direct\ lookup} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } He-\/ 4\ Mass\ Fraction\ (after\ mode\ switch):\ "{ } } \ <<\ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a9ea2b673341fdc67afeb0f0517a54c8c} { getMassFraction} } (\textcolor { stringliteral} { "{ } He-\/ 4"{ } } )\ <<\ std::endl;}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { \ \ \ \ \} }
\DoxyCodeLine { \} }
\end { DoxyCode}
2025-11-08 06:42:51 -05:00
\hypertarget { index_ autotoc_ md19} { } \doxysubsubsubsection { \texorpdfstring { 3. Mixing Two Compositions} { 3. Mixing Two Compositions} } \label { index_ autotoc_ md19}
2025-07-24 09:35:52 -04:00
You can easily mix two compositions. The library handles the union of all species.
\begin { DoxyCode} { 0}
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ "{ } \mbox { \hyperlink { composition_ 8h} { fourdst/composition/composition.h} } "{ } } }
\DoxyCodeLine { }
\DoxyCodeLine { \textcolor { keywordtype} { void} \ mixing\_ example()\ \{ }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ Composition\ 1:\ Pure\ Hydrogen} }
\DoxyCodeLine { \ \ \ \ \mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition} { fourdst::composition::Composition} } \ comp1(\{ \textcolor { stringliteral} { "{ } H-\/ 1"{ } } \} ,\ \{ 1.0\} );}
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ Composition\ 2:\ Pure\ Helium} }
\DoxyCodeLine { \ \ \ \ \mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition} { fourdst::composition::Composition} } \ comp2(\{ \textcolor { stringliteral} { "{ } He-\/ 4"{ } } \} ,\ \{ 1.0\} );}
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ Mix\ them\ with\ a\ 50/50\ ratio\ using\ the\ '+'\ operator} }
\DoxyCodeLine { \ \ \ \ \mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition} { fourdst::composition::Composition} } \ mixed\ =\ comp1\ +\ comp2;}
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ Mix\ them\ with\ a\ 75/25\ ratio\ using\ the\ mix()\ method} }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ 0.75\ of\ comp1,\ 0.25\ of\ comp2} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition} { fourdst::composition::Composition} } \ mixed2\ =\ comp1.mix(comp2,\ 0.75);}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } 50/50\ Mix\ H-\/ 1:\ "{ } } \ <<\ mixed.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a9ea2b673341fdc67afeb0f0517a54c8c} { getMassFraction} } (\textcolor { stringliteral} { "{ } H-\/ 1"{ } } )\ <<\ std::endl;\ \ \ \textcolor { comment} { //\ -\/ >\ 0.5} }
\DoxyCodeLine { \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } 75/25\ Mix\ H-\/ 1:\ "{ } } \ <<\ mixed2.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a9ea2b673341fdc67afeb0f0517a54c8c} { getMassFraction} } (\textcolor { stringliteral} { "{ } H-\/ 1"{ } } )\ <<\ std::endl;\ \ \textcolor { comment} { //\ -\/ >\ 0.75} }
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { \} }
\end { DoxyCode}
2025-11-08 06:42:51 -05:00
\hypertarget { index_ autotoc_ md20} { } \doxysubsubsubsection { \texorpdfstring { 4. Error Handling} { 4. Error Handling} } \label { index_ autotoc_ md20}
2025-07-24 09:35:52 -04:00
The library uses exceptions to report errors. Always wrap calls in a { \ttfamily try-\/ catch} block for robust code.
\begin { DoxyCode} { 0}
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ "{ } \mbox { \hyperlink { composition_ 8h} { fourdst/composition/composition.h} } "{ } } }
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ "{ } \mbox { \hyperlink { exceptions_ _ composition_ 8h} { fourdst/composition/exceptions/exceptions\_ composition.h} } "{ } } }
\DoxyCodeLine { }
\DoxyCodeLine { \textcolor { keywordtype} { void} \ error\_ example()\ \{ }
\DoxyCodeLine { \ \ \ \ \mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition} { fourdst::composition::Composition} } \ comp;}
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a3ab4dcda0bfd1a35b169bcc57fe66725} { registerSymbol} } (\textcolor { stringliteral} { "{ } H-\/ 1"{ } } );}
\DoxyCodeLine { \ \ \ \ comp.setMassFraction(\textcolor { stringliteral} { "{ } H-\/ 1"{ } } ,\ 1.0);}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { keywordflow} { try} \ \{ }
\DoxyCodeLine { \ \ \ \ \ \ \ \ \textcolor { comment} { //\ This\ will\ throw,\ because\ the\ composition\ is\ not\ finalized\ yet.} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ \textcolor { keywordtype} { double} \ mass\ =\ comp.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1_ composition_ a9ea2b673341fdc67afeb0f0517a54c8c} { getMassFraction} } (\textcolor { stringliteral} { "{ } H-\/ 1"{ } } );}
\DoxyCodeLine { \ \ \ \ \} \ \textcolor { keywordflow} { catch} \ (\textcolor { keyword} { const} \ fourdst::composition::exceptions::CompositionNotFinalizedError\& \ e)\ \{ }
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cerr\ <<\ \textcolor { stringliteral} { "{ } Caught\ expected\ error:\ "{ } } \ <<\ e.what()\ <<\ std::endl;}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { \ \ \ \ \} }
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { keywordflow} { try} \ \{ }
\DoxyCodeLine { \ \ \ \ \ \ \ \ \textcolor { comment} { //\ This\ will\ throw,\ because\ "{ } Li-\/ 6"{ } \ was\ never\ registered.} }
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \ \ \ \ \ \ \ \ comp.setMassFraction(\textcolor { stringliteral} { "{ } Li-\/ 6"{ } } ,\ 0.1);}
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { \ \ \ \ \} \ \textcolor { keywordflow} { catch} \ (\textcolor { keyword} { const} \ \mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1exceptions_ 1_ 1_ unregistered_ symbol_ error} { fourdst::composition::exceptions::UnregisteredSymbolError} } \& \ e)\ \{ }
\DoxyCodeLine { \ \ \ \ \ \ \ \ std::cerr\ <<\ \textcolor { stringliteral} { "{ } Caught\ expected\ error:\ "{ } } \ <<\ e.\mbox { \hyperlink { classfourdst_ 1_ 1composition_ 1_ 1exceptions_ 1_ 1_ composition_ error_ ae44ceddb19da8a8cda7ee150b6826d08} { what} } ()\ <<\ std::endl;}
\DoxyCodeLine { \ \ \ \ \} }
\DoxyCodeLine { \} }
\end { DoxyCode}
2025-11-08 06:42:51 -05:00
\hypertarget { index_ autotoc_ md21} { } \doxysubsubsubsection { \texorpdfstring { 5. Accessing Atomic Data} { 5. Accessing Atomic Data} } \label { index_ autotoc_ md21}
2025-07-24 09:35:52 -04:00
You can directly access the static database of all known species.
\begin { DoxyCode} { 0}
2025-11-08 06:42:51 -05:00
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ "{ } fourdst/composition/species.h"{ } } \ \textcolor { comment} { //\ Provides\ static\ instances\ like\ H\_ 1} }
\DoxyCodeLine { \textcolor { preprocessor} { \# include\ "{ } fourdst/composition/atomicSpecies.h"{ } } \ \textcolor { comment} { //\ Provides\ the\ main\ 'species'\ map} }
2025-07-24 09:35:52 -04:00
\DoxyCodeLine { }
\DoxyCodeLine { \textcolor { keywordtype} { void} \ data\_ example()\ \{ }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ Access\ via\ the\ map} }
\DoxyCodeLine { \ \ \ \ \textcolor { keyword} { const} \ \textcolor { keyword} { auto} \& \ fe56\ =\ \mbox { \hyperlink { namespacefourdst_ 1_ 1atomic_ a3f619cc8f8b2cd718a4082c6adb0de90} { fourdst::atomic::species} } .at(\textcolor { stringliteral} { "{ } Fe-\/ 56"{ } } );}
\DoxyCodeLine { \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } Fe-\/ 56\ mass:\ "{ } } \ <<\ fe56-\/ >mass()\ <<\ std::endl;}
\DoxyCodeLine { }
\DoxyCodeLine { \ \ \ \ \textcolor { comment} { //\ Access\ via\ the\ static\ instance} }
\DoxyCodeLine { \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } H-\/ 1\ spin:\ "{ } } \ <<\ \mbox { \hyperlink { namespacefourdst_ 1_ 1atomic_ a6766bc834fd656df51bdcf22f7d97877} { fourdst::atomic::H\_ 1} } .spin()\ <<\ std::endl;}
\DoxyCodeLine { \ \ \ \ std::cout\ <<\ \textcolor { stringliteral} { "{ } F-\/ 18\ half-\/ life:\ "{ } } \ <<\ \mbox { \hyperlink { namespacefourdst_ 1_ 1atomic_ a3c09ded079905f8c355f9ea87b6b191f} { fourdst::atomic::F\_ 18} } .halfLife()\ <<\ \textcolor { stringliteral} { "{ } \ s"{ } } \ <<\ std::endl;}
\DoxyCodeLine { \} }
\end { DoxyCode}
\DoxyHorRuler { 0}
\hypertarget { index_ test_ sec} { } \doxysection { \texorpdfstring { Testing} { Testing} } \label { index_ test_ sec}
2025-11-08 06:42:51 -05:00
{ \ttfamily libcomposition} is tested using the Google\+ Test framework. The test suite provides high coverage of the library\textquotesingle { } s functionality.\hypertarget { index_ autotoc_ md23} { } \doxysubsubsection { \texorpdfstring { Test Coverage Includes\+ :} { Test Coverage Includes\+ :} } \label { index_ autotoc_ md23}
2025-07-24 09:35:52 -04:00
\begin { DoxyItemize}
\item { \bfseries { Atomic Data Validation} } \+ : Spot checks on isotopic properties (mass, half-\/ life, spin) for a wide range of elements to ensure the underlying data files are parsed and represented correctly.
\item { \bfseries { Core { \ttfamily Composition} Workflow} } \+ : Verification of object construction, symbol registration (for both valid and invalid symbols), and the complete workflow of setting and getting both mass and number fractions.
\item { \bfseries { Finalization Logic} } \+ : Ensures that { \ttfamily finalize()} is a required step before querying data. Tests the validation logic for compositions that sum to 1.\+ 0 and the auto-\/ normalization feature ({ \ttfamily finalize(true)} ).
\item { \bfseries { Advanced Features} } \+ : Dedicated tests for { \ttfamily mix()} , { \ttfamily subset()} , { \ttfamily set\+ Composition\+ Mode()} , and the calculation of derived quantities like { \ttfamily get\+ Molar\+ Abundance()} and { \ttfamily get\+ Mean\+ Atomic\+ Number()} .
\item { \bfseries { Exception Handling} } \+ : Confirms that invalid operations (e.\+ g., using an unregistered symbol, mixing un-\/ finalized compositions) correctly throw exceptions from the { \ttfamily \doxylink { namespacefourdst_ 1_ 1composition_ 1_ 1exceptions} { fourdst\+ ::composition\+ ::exceptions} } hierarchy.
\end { DoxyItemize}
\DoxyHorRuler { 0}
\hypertarget { index_ api_ sec} { } \doxysection { \texorpdfstring { API Reference} { API Reference} } \label { index_ api_ sec}
For a complete list of all classes, methods, and functions, please see the \texorpdfstring { $ \ast $ } { *} \texorpdfstring { $ \ast $ } { *} \href { namespaces.html} { \texttt { Namespaces} } \texorpdfstring { $ \ast $ } { *} \texorpdfstring { $ \ast $ } { *} and \texorpdfstring { $ \ast $ } { *} \texorpdfstring { $ \ast $ } { *} \href { annotated.html} { \texttt { Classes} } \texorpdfstring { $ \ast $ } { *} \texorpdfstring { $ \ast $ } { *} sections of this documentation.