Loading...
Searching...
No Matches
composition_abstract.h
Go to the documentation of this file.
#pragma once
#include "fourdst/atomic/atomicSpecies.h"
#include "fourdst/composition/iterators/composition_abstract_iterator.h"
#include <string>
#include <unordered_map>
#include <set>
#include <vector>
#include <memory>
namespace fourdst::composition {
class CompositionAbstract {
public:
using iterator = detail::CompositionIterator<false>;
using const_iterator = detail::CompositionIterator<true>;
virtual ~CompositionAbstract() = default;
[[nodiscard]] virtual bool contains(const fourdst::atomic::Species& species) const noexcept = 0;
[[nodiscard]] virtual bool contains(const std::string& symbol) const = 0;
[[nodiscard]] virtual size_t size() const noexcept = 0;
[[nodiscard]] virtual std::set<std::string> getRegisteredSymbols() const noexcept = 0;
[[nodiscard]] virtual const std::vector<atomic::Species> &getRegisteredSpecies() const noexcept = 0;
[[nodiscard]] virtual std::unordered_map<fourdst::atomic::Species, double> getMassFraction() const noexcept = 0;
[[nodiscard]] virtual std::unordered_map<fourdst::atomic::Species, double> getNumberFraction() const noexcept = 0;
[[nodiscard]] virtual double getMassFraction(const std::string& symbol) const = 0;
[[nodiscard]] virtual double getMassFraction(const fourdst::atomic::Species& species) const = 0;
[[nodiscard]] virtual double getNumberFraction(const std::string& symbol) const = 0;
[[nodiscard]] virtual double getNumberFraction(const fourdst::atomic::Species& species) const = 0;
[[nodiscard]] virtual double getMolarAbundance(const std::string& symbol) const = 0;
[[nodiscard]] virtual double getMolarAbundance(const fourdst::atomic::Species& species) const = 0;
[[nodiscard]] virtual double getMeanParticleMass() const noexcept = 0;
[[nodiscard]] virtual double getElectronAbundance() const noexcept = 0;
[[nodiscard]] virtual std::vector<double> getMassFractionVector() const noexcept = 0;
[[nodiscard]] virtual std::vector<double> getNumberFractionVector() const noexcept = 0;
[[nodiscard]] virtual std::vector<double> getMolarAbundanceVector() const noexcept = 0;
[[nodiscard]] virtual size_t getSpeciesIndex(const std::string& symbol) const = 0;
[[nodiscard]] virtual size_t getSpeciesIndex(const fourdst::atomic::Species& species) const = 0;
[[nodiscard]] virtual atomic::Species getSpeciesAtIndex(size_t index) const = 0;
[[nodiscard]] virtual std::unique_ptr<CompositionAbstract> clone() const = 0;
[[nodiscard]] virtual iterator begin() = 0;
[[nodiscard]] virtual iterator end() = 0;
[[nodiscard]] virtual const_iterator begin() const = 0;
[[nodiscard]] virtual const_iterator end() const = 0;
[[nodiscard]] virtual std::size_t hash() const = 0;
};
// ReSharper disable once CppClassCanBeFinal
}
atomicSpecies.h
fourdst::composition::CompositionAbstract
Abstract base class for chemical composition representations.
Definition composition_abstract.h:36
fourdst::composition::CompositionAbstract::const_iterator
detail::CompositionIterator< true > const_iterator
Definition composition_abstract.h:39
fourdst::composition::CompositionAbstract::getMolarAbundance
virtual double getMolarAbundance(const std::string &symbol) const =0
Get the molar abundance for a given symbol.
fourdst::composition::CompositionAbstract::hash
virtual std::size_t hash() const =0
fourdst::composition::CompositionAbstract::contains
virtual bool contains(const fourdst::atomic::Species &species) const noexcept=0
Check if the composition contains the given species.
fourdst::composition::CompositionAbstract::getMassFraction
virtual std::unordered_map< fourdst::atomic::Species, double > getMassFraction() const noexcept=0
Get the mass fraction for all registered symbols.
fourdst::composition::CompositionAbstract::getSpeciesAtIndex
virtual atomic::Species getSpeciesAtIndex(size_t index) const =0
Get the species at a given index.
fourdst::composition::CompositionAbstract::begin
virtual iterator begin()=0
fourdst::composition::CompositionAbstract::getMolarAbundanceVector
virtual std::vector< double > getMolarAbundanceVector() const noexcept=0
Get the molar abundance as a vector.
fourdst::composition::CompositionAbstract::getNumberFraction
virtual std::unordered_map< fourdst::atomic::Species, double > getNumberFraction() const noexcept=0
Get the number fraction for all registered symbols.
fourdst::composition::CompositionAbstract::contains
virtual bool contains(const std::string &symbol) const =0
Check if the composition contains the given species.
fourdst::composition::CompositionAbstract::getMassFractionVector
virtual std::vector< double > getMassFractionVector() const noexcept=0
Get the mass fraction as a vector.
fourdst::composition::CompositionAbstract::clone
virtual std::unique_ptr< CompositionAbstract > clone() const =0
fourdst::composition::CompositionAbstract::getNumberFractionVector
virtual std::vector< double > getNumberFractionVector() const noexcept=0
Get the number fraction as a vector.
fourdst::composition::CompositionAbstract::~CompositionAbstract
virtual ~CompositionAbstract()=default
Virtual destructor.
fourdst::composition::CompositionAbstract::getRegisteredSymbols
virtual std::set< std::string > getRegisteredSymbols() const noexcept=0
Get all registered chemical symbols in the composition.
fourdst::composition::CompositionAbstract::end
virtual iterator end()=0
fourdst::composition::CompositionAbstract::iterator
detail::CompositionIterator< false > iterator
Definition composition_abstract.h:38
fourdst::composition::CompositionAbstract::getElectronAbundance
virtual double getElectronAbundance() const noexcept=0
Get the electron abundance of the composition.
fourdst::composition::CompositionAbstract::getRegisteredSpecies
virtual const std::vector< atomic::Species > & getRegisteredSpecies() const noexcept=0
Get all registered atomic species in the composition.
fourdst::composition::CompositionAbstract::getSpeciesIndex
virtual size_t getSpeciesIndex(const std::string &symbol) const =0
Get the index of a species by symbol.
fourdst::composition::CompositionAbstract::size
virtual size_t size() const noexcept=0
fourdst::composition::CompositionAbstract::getMeanParticleMass
virtual double getMeanParticleMass() const noexcept=0
Get the mean particle mass of the composition.
fourdst::composition::detail::CompositionIterator
Definition composition_abstract_iterator.h:13
composition_abstract_iterator.h
fourdst::atomic
Contains canonical information about atomic species and elements used by 4D-STAR.
fourdst::composition
Utilities and types for representing and manipulating chemical compositions.
fourdst
fourdst::atomic::Species
Represents an atomic species (isotope) with its fundamental physical properties.
Definition atomicSpecies.h:52