fourdst::libcomposition v1.9.0 Robust atomic species information library

Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Friends | List of all members
fourdst::composition::CompositionEntry Struct Reference

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 | number_fraction () const
| Gets the number fraction of the species.
double | number_fraction (double totalMolesPerMass) 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 totalMolesPerMass)
| 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.
double | m_molesPerMass = 0.0
double | m_cachedNumberFraction = 0.0
| Cached number fraction for conversions when in mass fraction mode.
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.

## Detailed Description

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 84 of file composition.h.

## Constructor & Destructor Documentation

## ◆ CompositionEntry() [1/3]

fourdst::composition::CompositionEntry::CompositionEntry | ( |  | ) |

Default constructor. Initializes a default entry (H-1), but in an uninitialized state.

Definition at line 69 of file composition.cpp.

## ◆ CompositionEntry() [2/3]

fourdst::composition::CompositionEntry::CompositionEntry | ( | const std::string & | symbol,
|  | bool | massFracMode = true )
| explicit

Constructs a CompositionEntry for a given symbol and abundance mode.

Parameters

  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

  exceptions::InvalidSpeciesSymbolError | if the symbol does not exist in the atomic species database.
  exceptions::EntryAlreadyInitializedError | if setSpecies is called on an already initialized entry.

Usage Example:
  CompositionEntry entry("H-1", true); // Entry for H-1 in mass fraction mode.
  fourdst::composition::CompositionEntry::CompositionEntry
  CompositionEntry()
  Default constructor. Initializes a default entry (H-1), but in an uninitialized state.
  Definition composition.cpp:69

Definition at line 74 of file composition.cpp.

## ◆ CompositionEntry() [3/3]

fourdst::composition::CompositionEntry::CompositionEntry | ( | const CompositionEntry & | entry | ) |
| default

Copy constructor.

Parameters

  entry | The CompositionEntry to copy.

## Member Function Documentation

## ◆ getMassFracMode()

bool fourdst::composition::CompositionEntry::getMassFracMode | ( |  | ) | const
| nodiscard

Gets the mode of the composition entry.

Returns
  True if in mass fraction mode, false if in number fraction mode.

Definition at line 183 of file composition.cpp.

## ◆ isotope()

atomic::Species fourdst::composition::CompositionEntry::isotope | ( |  | ) | const
| nodiscard

Gets the isotope data for the species.

Returns
  A const reference to the `atomic::Species` object.

Definition at line 130 of file composition.cpp.

## ◆ mass_fraction()

double fourdst::composition::CompositionEntry::mass_fraction | ( |  | ) | const
| nodiscard

Gets the mass fraction of the species.

Precondition
  The entry must be in mass fraction mode.

Returns
  The mass fraction of the species.

Exceptions

  exceptions::CompositionModeError | if the entry is in number fraction mode.

Definition at line 102 of file composition.cpp.

## ◆ number_fraction() [1/2]

double fourdst::composition::CompositionEntry::number_fraction | ( |  | ) | const
| nodiscard

Gets the number fraction of the species.

Precondition
  The entry must be in number fraction mode.

Returns
  The number fraction of the species.

Exceptions

  exceptions::CompositionModeError | if the entry is in mass fraction mode.

Definition at line 110 of file composition.cpp.

## ◆ number_fraction() [2/2]

double fourdst::composition::CompositionEntry::number_fraction | ( | double | totalMolesPerMass | ) | const
| nodiscard

Gets the number fraction, converting from mass fraction if necessary.

Parameters

  totalMolesPerMass | The total moles per unit mass (specific number density) of the entire composition.

Returns
  The number fraction of the species.

Definition at line 118 of file composition.cpp.

## ◆ rel_abundance()

double fourdst::composition::CompositionEntry::rel_abundance | ( |  | ) | const
| nodiscard

Gets the relative abundance of the species.

Returns
  The relative abundance.

Definition at line 126 of file composition.cpp.

## ◆ setMassFracMode()

bool fourdst::composition::CompositionEntry::setMassFracMode | ( | double | meanMolarMass | ) |

Switches the mode to mass fraction mode.

Parameters

  meanMolarMass | The mean molar mass of the composition, required for conversion.

Returns
  True if the mode was successfully set, false otherwise.

Definition at line 159 of file composition.cpp.

## ◆ setMassFraction()

void fourdst::composition::CompositionEntry::setMassFraction | ( | double | mass_fraction | ) |

Sets the mass fraction of the species.

Parameters

  mass_fraction | The mass fraction to set. Must be in [0, 1].

Precondition
  The entry must be in mass fraction mode.

Exceptions

  exceptions::CompositionModeError | if the entry is in number fraction mode.

Definition at line 134 of file composition.cpp.

## ◆ setNumberFracMode()

bool fourdst::composition::CompositionEntry::setNumberFracMode | ( | double | totalMolesPerMass | ) |

Switches the mode to number fraction mode.

Parameters

  totalMolesPerMass | The total moles per unit mass (specific number density) of the composition.

Returns
  True if the mode was successfully set, false otherwise.

Definition at line 171 of file composition.cpp.

## ◆ setNumberFraction()

void fourdst::composition::CompositionEntry::setNumberFraction | ( | double | number_fraction | ) |

Sets the number fraction of the species.

Parameters

  number_fraction | The number fraction to set. Must be in [0, 1].

Precondition
  The entry must be in number fraction mode.

Exceptions

  exceptions::CompositionModeError | if the entry is in mass fraction mode.

Definition at line 148 of file composition.cpp.

## ◆ setSpecies()

void fourdst::composition::CompositionEntry::setSpecies | ( | const std::string & | symbol | ) |

Sets the species for the composition entry. This can only be done once.

Parameters

  symbol | The chemical symbol of the species.

Exceptions

  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 86 of file composition.cpp.

## ◆ symbol()

std::string fourdst::composition::CompositionEntry::symbol | ( |  | ) | const
| nodiscard

Gets the chemical symbol of the species.

Returns
  The chemical symbol.

Definition at line 98 of file composition.cpp.

## Friends And Related Symbol Documentation

## ◆ operator<<

std::ostream & operator<< | ( | std::ostream & | os,
|  | const CompositionEntry & | entry )
| friend

Overloaded output stream operator for CompositionEntry.

Parameters

  os | The output stream.
  entry | The CompositionEntry to output.

Returns
  The output stream.

Definition at line 1070 of file composition.cpp.

## Member Data Documentation

## ◆ m_cachedNumberFraction

double fourdst::composition::CompositionEntry::m_cachedNumberFraction = 0.0

Cached number fraction for conversions when in mass fraction mode.

Definition at line 93 of file composition.h.

## ◆ m_initialized

bool fourdst::composition::CompositionEntry::m_initialized = false

True if the composition entry has been initialized with a valid species.

Definition at line 96 of file composition.h.

## ◆ m_isotope

atomic::Species fourdst::composition::CompositionEntry::m_isotope

The `atomic::Species` object containing detailed isotope data.

Definition at line 86 of file composition.h.

## ◆ m_massFracMode

bool fourdst::composition::CompositionEntry::m_massFracMode = true

The mode of the composition entry. True if mass fraction, false if number fraction.

Definition at line 87 of file composition.h.

## ◆ m_massFraction

double fourdst::composition::CompositionEntry::m_massFraction = 0.0

The mass fraction of the species. Valid only if `m_massFracMode` is true.

Definition at line 89 of file composition.h.

## ◆ m_molesPerMass

double fourdst::composition::CompositionEntry::m_molesPerMass = 0.0

Definition at line 92 of file composition.h.

## ◆ m_numberFraction

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 90 of file composition.h.

## ◆ m_relAbundance

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 91 of file composition.h.

## ◆ m_symbol

std::string fourdst::composition::CompositionEntry::m_symbol

The chemical symbol of the species (e.g., "H-1", "Fe-56").

Definition at line 85 of file composition.h.

The documentation for this struct was generated from the following files:

- src/composition/include/fourdst/composition/composition.h
- src/composition/lib/composition.cpp