67 mutable std::optional<double>
m_spin = std::nullopt;
90 const std::string_view
name,
91 const std::string_view
el,
99 const double halfLife_s,
102 const double atomicMass,
103 const double atomicMassUnc
147 [[nodiscard]]
double mass()
const {
211 [[nodiscard]] std::string_view
name()
const {
219 [[nodiscard]] std::string_view
el()
const {
227 [[nodiscard]]
int nz()
const {
235 [[nodiscard]]
int n()
const {
243 [[nodiscard]]
int z()
const {
251 [[nodiscard]]
int a()
const {
259 [[nodiscard]]
double spin()
const {
260 if (!
m_spin.has_value()) {
342 std::string s = jpi_string;
345 return std::numeric_limits<double>::quiet_NaN();
348 std::erase_if(s, [](
const char c) {
349 return c ==
'(' || c ==
')' || c ==
'*' || c ==
'#';
352 if (s ==
"+" || s ==
"-") {
356 if (
const size_t comma_pos = s.find(
','); comma_pos != std::string::npos) {
357 s = s.substr(0, comma_pos);
360 if (!s.empty() && (s.back() ==
'+' || s.back() ==
'-')) {
365 return std::numeric_limits<double>::quiet_NaN();
369 if (
size_t slash_pos = s.find(
'/'); slash_pos != std::string::npos) {
370 if (slash_pos == 0) {
374 const std::string numerator_str = s.substr(0, slash_pos);
375 const std::string denominator_str = s.substr(slash_pos + 1);
376 if (denominator_str.empty()) {
377 return std::numeric_limits<double>::quiet_NaN();
379 const double numerator = std::stod(numerator_str);
380 const double denominator = std::stod(denominator_str);
381 if (denominator == 0.0) {
382 return std::numeric_limits<double>::quiet_NaN();
384 return numerator / denominator;
388 }
catch (
const std::invalid_argument&) {
389 return std::numeric_limits<double>::quiet_NaN();
390 }
catch (
const std::out_of_range&) {
391 return std::numeric_limits<double>::quiet_NaN();
429 return std::hash<std::string>()(s.m_name);
Contains canonical information about atomic species and elements used by 4D-STAR.
bool operator==(const Species &lhs, const Species &rhs)
Equality operator for Species. Compares based on name.
bool operator!=(const Species &lhs, const Species &rhs)
Inequality operator for Species. Compares based on name.
static const std::unordered_map< std::string, const Species & > species
Map of species names to their corresponding Species objects.
std::partial_ordering operator<=>(const Species &lhs, const Species &rhs)
double convert_jpi_to_double(const std::string &jpi_string) noexcept
Converts a spin-parity string (JPI string) to a double-precision floating-point number.
Represents an atomic species (isotope) with its fundamental physical properties.
double spin() const
Gets the nuclear spin as a numeric value.
double m_betaDecayEnergy
Beta decay energy in keV.
int z() const
Gets the atomic number (number of protons).
std::string_view name() const
Gets the name of the species.
std::string_view el() const
Gets the element symbol of the species.
double halfLife() const
Gets the half-life of the species.
Species(const std::string_view name, const std::string_view el, const int nz, const int n, const int z, const int a, const double bindingEnergy, const std::string_view betaCode, const double betaDecayEnergy, const double halfLife_s, const std::string_view spinParity, const std::string_view decayModes, const double atomicMass, const double atomicMassUnc)
Constructs a Species object with detailed properties.
double m_atomicMassUnc
Uncertainty in the atomic mass.
std::string m_name
Name of the species (e.g., "Fe56").
int m_nz
NZ identifier, typically 1000*Z + A.
std::string m_decayModes
Decay modes as a string.
std::string_view betaCode() const
Gets the beta decay code.
int m_a
Mass number (N + Z).
std::string m_el
Element symbol (e.g., "Fe").
friend bool operator==(const Species &lhs, const Species &rhs)
Equality operator for Species. Compares based on name.
double betaDecayEnergy() const
Gets the beta decay energy of the species.
Species(const Species &species)
Copy constructor for Species.
std::string m_spinParity
Spin and parity as a string (e.g., "1/2-").
int m_n
Number of neutrons.
int n() const
Gets the number of neutrons.
std::optional< double > m_spin
Nuclear spin as a double, derived from m_spinParity.
int nz() const
Gets the NZ identifier of the species.
std::string_view decayModes() const
Gets the decay modes as a string.
int m_z
Atomic number (number of protons).
double m_atomicMass
Atomic mass in atomic mass units (u).
std::string m_betaCode
Beta decay code.
double bindingEnergy() const
Gets the binding energy of the species.
double massUnc() const
Gets the uncertainty in the atomic mass.
double m_bindingEnergy
Binding energy in keV.
friend std::ostream & operator<<(std::ostream &os, const Species &species)
Overloads the stream insertion operator for easy printing of a Species object.
int a() const
Gets the mass number.
friend bool operator!=(const Species &lhs, const Species &rhs)
Inequality operator for Species. Compares based on name.
double mass() const
Gets the atomic mass of the species.
double m_halfLife_s
Half-life in seconds. A value of -1.0 typically indicates stability.
friend std::partial_ordering operator<=>(const Species &lhs, const Species &rhs)
std::string_view spinParity() const
Gets the spin and parity as a string.
size_t operator()(const fourdst::atomic::Species &s) const noexcept
Computes the hash for a Species object.