Program Listing for File IsotopeData.hpp
↰ Return to documentation for file (src/elem/IsotopeData.hpp)
#ifndef ISOTOPEDATA_HPP
#define ISOTOPEDATA_HPP
#include "ElemData.hpp"
#include <array>
#include <stdexcept>
#include <string>
#include <utility>
#include <vector>
namespace elem
{
struct IsotopeDecayData
{
unsigned int Z_; // NOLINT(readability-identifier-naming) -- physics naming convention
unsigned int A_; // NOLINT(readability-identifier-naming) -- physics naming convention
double branchingRatio_;
};
class IsotopeData : public ElemData
{
public:
IsotopeData(std::array<char, 2> symbol, unsigned int z, unsigned int a,
double lifetime = 0.0, std::vector<IsotopeDecayData> daughters = {})
: ElemData(symbol, z), A_(a), lifetime_(lifetime), daughters_(std::move(daughters))
{
if (lifetime_ < 0.0)
{
throw std::runtime_error(
"IsotopeData: lifetime must be non-negative, got " +
std::to_string(lifetime_));
}
}
IsotopeData(const IsotopeData&) = default;
auto operator=(const IsotopeData&) -> IsotopeData& = default;
IsotopeData(IsotopeData&&) = default;
auto operator=(IsotopeData&&) -> IsotopeData& = default;
~IsotopeData() = default;
[[nodiscard]] auto A() const noexcept // NOLINT(readability-identifier-naming)
-> unsigned int { return A_; }
[[nodiscard]] auto label() const -> std::string
{
const auto& sym = symbol();
std::string result(1, sym[0]);
if (sym[1] != '\0') { result += sym[1]; }
result += std::to_string(A_);
return result;
}
[[nodiscard]] auto lifetime() const noexcept -> double { return lifetime_; }
[[nodiscard]] auto daughters() const noexcept
-> const std::vector<IsotopeDecayData>& { return daughters_; }
[[nodiscard]] auto stable() const noexcept -> bool { return lifetime_ == 0.0; }
[[nodiscard]] auto operator==(const IsotopeData& o) const noexcept -> bool
{ return Z_ == o.Z_ && A_ == o.A_; }
[[nodiscard]] auto operator!=(const IsotopeData& o) const noexcept -> bool
{ return !(*this == o); }
[[nodiscard]] auto operator<(const IsotopeData& o) const noexcept -> bool
{ return Z_ != o.Z_ ? Z_ < o.Z_ : A_ < o.A_; }
[[nodiscard]] auto operator>(const IsotopeData& o) const noexcept -> bool
{ return Z_ != o.Z_ ? Z_ > o.Z_ : A_ > o.A_; }
[[nodiscard]] auto operator<=(const IsotopeData& o) const noexcept -> bool
{ return Z_ != o.Z_ ? Z_ < o.Z_ : A_ <= o.A_; }
[[nodiscard]] auto operator>=(const IsotopeData& o) const noexcept -> bool
{ return Z_ != o.Z_ ? Z_ > o.Z_ : A_ >= o.A_; }
protected:
unsigned int A_; // NOLINT(readability-identifier-naming) -- physics naming convention
double lifetime_;
std::vector<IsotopeDecayData> daughters_;
};
} // namespace elem
#endif // ISOTOPEDATA_HPP