Elements and materials
Elements, substances, materials, matter calculations, and typed composition records.
-
enum class snt::mat::IsotopeSelection : std::uint8_t
Method used to select the isotope of an element.
Values:
-
enumerator EXPLICIT
An isotope was requested explicitly.
-
enumerator NATURAL
Natural-abundance weighted isotope distribution.
-
enumerator DEFAULT
Most abundant isotope, NIST representative isotope, or first table isotope.
-
enumerator PARTICLE
Proton, neutron, or electron.
-
enumerator EXPLICIT
-
std::array<RepresentativeIsotope, 10> snt::mat::PT_REPRESENTATIVE
-
struct ComponentData
A component of a chemical formula or material mixture.
Dimensional fields describe one unit of the component.
number_fractionandmass_fractiondescribe its contribution to the whole composite.Public Members
-
std::string expression
Component expression.
-
double proportion
Amount supplied by the caller.
-
double count
Number contribution in one reference batch.
-
double protons
Protons per component unit.
-
double neutrons
Neutrons per component unit.
-
double electrons
Electrons per component unit.
-
double number_fraction
Normalized number fraction.
-
double mass_fraction
Normalized mass fraction.
-
bool ion_mass_approximation
Ion binding-energy corrections are omitted.
-
bool ion_mass_correction
A component uses NIST reference ionization corrections.
-
std::string expression
-
struct CompositeData
Composition of a formula or mixture.
sumdescribes one reference batch.avgis a descriptive arithmetic mean of the component rows and is not a physical mixture mean.Public Members
-
std::vector<CompositeRow> components
Component contributions.
-
CompositeRow sum
Aggregate contribution.
-
CompositeRow avg
Descriptive arithmetic mean.
-
std::vector<CompositeRow> components
-
struct CompositeRow
One row of a composite composition. Contributions are multiplied by the component count.
Public Members
-
std::string expression
Component,
sum, oravg.
-
double count
Number contribution in one reference batch.
-
double protons
Proton contribution.
-
double neutrons
Neutron contribution.
-
double electrons
Electron contribution.
-
double number_fraction
Normalized number fraction.
-
double mass_fraction
Normalized mass fraction.
-
bool ion_mass_approximation
A contributing ion omits its binding-energy correction.
-
bool ion_mass_correction
A contributing ion uses NIST reference ionization corrections.
-
std::string expression
-
class Element : private snt::mat::Part<int>, private snt::mat::Matter
An element is a pure substance that consists entirely of one type of atom.
The signed value in braces is the conventional electric charge in units of the elementary charge:
H{1+1}is a proton andH{1-1}is a hydride anion. Positive charge removes electrons from the neutral atom; negative charge adds them.Public Functions
-
inline const std::string &get_symbol() const
-
inline unsigned int get_isotope() const
-
inline int get_charge() const
-
inline bool get_natural() const
-
inline IsotopeSelection get_selection() const
-
inline double get_effective_isotope_number() const
-
inline double get_natural_abundance_sum() const
-
inline MatterData data_matter() const
Return matter rows for this atom or free particle.
-
Element(const std::string &expr, int prop = 1, bool nat = true, const MatterSpec &matter = {})
Construct an element.
- Parameters:
expr – Element string representation
prop – Component proportion in a composite
nat – Indicate if the element uses the natural isotope distribution
matter – Optional matter inputs
-
inline double protons() const
Return the number of protons per atom.
-
inline double neutrons() const
Return the abundance-weighted number of neutrons per atom.
-
inline double electrons() const
Return the number of electrons per atom or ion.
-
inline bool uses_ion_mass_approximation() const
Whether the atomic ion mass omits a required binding-energy correction.
-
inline bool uses_ion_mass_correction() const
Whether a complete NIST reference-element ionization correction was applied.
-
ElementData data() const
Return a typed view of the element’s physical facts.
-
std::string to_string() const
Return a string representation of an element instance.
-
void set_matter(const MatterSpec &spec)
Replace matter constraints, derive values, and commit only when consistent.
-
inline MatterSpec get_matter_spec() const
Return the original constraints, without derived values.
-
inline const std::string &get_symbol() const
-
struct ElementData
Physical facts about an element expression.
Public Members
-
std::string expression
Source expression.
-
unsigned int declared_isotope
Explicitly requested mass number, or zero.
-
double effective_isotope_number
Mass number or abundance-weighted mean mass number.
-
int charge
Conventional electric charge.
-
double protons
Number of protons.
-
double neutrons
Number of neutrons.
-
double electrons
Number of electrons.
-
IsotopeSelection selection
Isotope selection method.
-
bool natural
True for natural-abundance selection.
-
bool ion_mass_approximation
Ion binding-energy correction is omitted.
-
bool ion_mass_correction
NIST reference ionization energies were applied.
-
std::optional<double> applied_ionization_energy_eV
Sum of all required ionization stages.
-
std::string expression
-
struct Isotope
-
class Material : private snt::mat::Set<Substance, double>, private snt::mat::Matter
A material represented as a mixture of substances.
Number modes treat amounts as species counts. Mass-fraction mode treats amounts as mass weights and derives the mean species mass from
sum(w_i) / sum(w_i / m_i).Public Functions
-
Material()
Construct an empty material.
-
Material(const SubstanceMap &comp, Norm norm = Norm::NUMBER_FRACTION, bool natural = true, const MatterSpec &matter = {})
Construct a material from a map of substances and amounts.
-
Material(std::initializer_list<SubstanceMap::value_type> comp, Norm norm = Norm::NUMBER_FRACTION, bool natural = true, const MatterSpec &matter = {})
Construct a material from braced substance amounts.
This disambiguates single-entry construction such as
Material({{"H2O", 1.0}})from copy construction.
-
Material(const SubstanceMap &comp, Norm norm, const MatterSpec &matter, bool natural = true)
Construct a material from a map with optional matter and natural selection.
-
Material(const std::string &expr, Norm norm = Norm::NUMBER_FRACTION, bool natural = true, const MatterSpec &matter = {})
Construct a material from an expression such as
0.2 <H2O> 0.8 <NaCl>.
-
Material(const std::string &expr, Norm norm, const MatterSpec &matter, bool natural = true)
Construct a material from an expression with matter and natural selection.
-
Material(const std::string &expr, bool natural, Norm norm, const MatterSpec &matter = {})
Construct a material with Python-style natural-before-norm argument order.
-
void add(const std::string &expr, double prop = 1.0)
Add a substance and recompute composition and matter from the supplied inputs.
-
inline std::vector<ComponentData> data_components() const
Return substance rows with normalized composition fractions.
-
inline CompositeData data_composite() const
Return mixture composition contributions and summaries.
-
inline MatterData data_matter() const
Return species and aggregate matter values.
-
double protons() const
Return the number of protons in one reference mixture batch.
-
double neutrons() const
Return the abundance-weighted number of neutrons in one reference mixture batch.
-
double electrons() const
Return the number of electrons in one reference mixture batch.
-
std::string to_string() const
Return a compact description of the mixture amounts.
-
Material operator*(double factor) const
Return a material with all input amounts scaled by a factor.
-
Material operator+(const Material &other) const
Return a material with merged amounts from both materials.
-
void set_matter(const MatterSpec &spec)
Replace matter constraints, derive values, and commit only when consistent.
-
inline MatterSpec get_matter_spec() const
Return the original constraints, without derived values.
-
Material()
-
class Matter
Matter is anything that has mass and occupies space.
Optional fields distinguish omitted values from supplied zeros.
number_densityis the density of reference units (atoms, formula units, or mixture reference batches).total_number_densityis the sum of species number densities.Subclassed by snt::mat::Element, snt::mat::Material, snt::mat::Substance
Public Functions
-
inline std::optional<puq::Quantity> get_volume() const
Return independent snapshots of derived matter values.
-
inline MatterSpec get_matter_spec() const
Return the original constraints, without derived values.
-
inline std::optional<puq::Quantity> get_volume() const
-
struct MatterData
Composite matter values and component rows.
Public Members
-
struct MatterRow
One row of component matter values. A value is absent when its input is unknown.
Public Members
-
std::string expression
Component,
sum, oravg.
-
std::string expression
-
struct MatterSpec
Optional physical inputs for a matter calculation.
-
struct MatterSpecies
A species used to derive component matter values.
-
template<typename PROPORTION>
class Part A part is an individual substance or part that combines with others to form a larger whole
- Template Parameters:
PROPORTION – proportion coefficient type (double or integer)
Public Functions
-
inline PROPORTION get_proportion() const
Return the component amount used by the containing composite.
-
inline const std::string &get_expression() const
Return the source expression of this part.
-
inline bool has_component_mass() const
Return whether a component mass has been assigned.
-
struct RepresentativeIsotope
-
template<typename MEMBER, typename PROPORTION>
class Set A collection of physical members and their proportions.
Number modes interpret proportions as counts. Mass-fraction mode interprets them as mass weights. In both cases normalized number and mass fractions are available and the reference-batch mass is computed dimensionally.
- Template Parameters:
MEMBER – Type of set members
PROPORTION – Proportion data type
Public Types
-
using PartMap = std::map<std::string, PROPORTION>
Map of parts and their proportions.
Public Functions
-
inline const std::string &get_expression() const
Return the source composition expression.
-
inline bool get_natural() const
Return the isotope-selection policy for unspecified isotopes.
-
inline double get_reference_count() const
Return the species count in one reference batch.
-
inline puq::Quantity get_composite_mass() const
Return an independent copy of the reference-batch mass.
-
inline bool empty() const
Return whether this set has no members.
-
inline const MemberMap &components() const
Return the stored members in deterministic expression order.
-
inline bool uses_ion_mass_approximation() const
Whether a nonzero component uses an approximate atomic ion mass.
-
inline bool uses_ion_mass_correction() const
Whether a nonzero component uses NIST reference ionization corrections.
-
inline double reference_count_of(const MEMBER &member) const
Number contribution of a member to one reference batch.
-
inline std::vector<ComponentData> data_components() const
Return component rows with normalized fractions.
-
inline CompositeData data_composite() const
Return component contributions plus aggregate and descriptive average rows.
-
inline std::vector<MatterSpecies> matter_species() const
Return species fractions and masses used for matter calculations.
-
class Substance : private snt::mat::Set<Element, int>, private snt::mat::Part<double>, private snt::mat::Matter
A form of matter with uniform and definite composition and distinct physical and chemical properties.
Public Functions
-
Substance()
Construct an empty substance.
-
explicit Substance(double num)
Substance class constructor from a scalar number
- Parameters:
num – Number
-
Substance(const ElementMap &comp, double prop = 1, bool nat = true, const MatterSpec &matter = {})
Substance class constructor from a map of components and their proportions
- Parameters:
comp – Map of components and their proportions
prop – Component proportion in a Composite
nat – Indicate if substance atoms should use natural abundance
-
Substance(std::initializer_list<ElementMap::value_type> comp, double prop = 1, bool nat = true, const MatterSpec &matter = {})
Construct a substance from braced element counts.
This disambiguates single-entry construction such as
Substance({{"H", 2}})from copy construction.
-
Substance(const std::string &expr, double prop = 1, bool nat = true, const MatterSpec &matter = {})
Substance class constructor from an expression
- Parameters:
expr – Element string representation
prop – Component proportion in a Composite
nat – Indicate if substance atoms should use natural abundance
-
std::string to_string() const
Convert element to a string
- Returns:
String representation of a substance
-
void add(const std::string &expr, int prop = 1)
Add an element, regenerate the formula, and recompute matter from supplied inputs.
-
inline std::string formula() const
Return the formula expression of this substance.
-
double protons() const
Return the number of protons in one formula unit.
-
double neutrons() const
Return the abundance-weighted number of neutrons in one formula unit.
-
double electrons() const
Return the number of electrons in one formula unit.
-
inline std::vector<ComponentData> data_components() const
Return element rows with normalized composition fractions.
-
inline CompositeData data_composite() const
Return formula composition contributions and summaries.
-
inline MatterData data_matter() const
Return component and aggregate matter values.
-
Substance operator+(const Substance &other) const
Return merged element compositions; requires matching natural-abundance settings.
-
void set_matter(const MatterSpec &spec)
Replace matter constraints, derive values, and commit only when consistent.
-
inline MatterSpec get_matter_spec() const
Return the original constraints, without derived values.
-
Substance()