#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, strum :: EnumIter)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
pub enum TelluriumIsotope {
Te104,
Te105,
Te106,
Te107,
Te108,
Te109,
Te110,
Te111,
Te112,
Te113,
Te114,
Te115,
Te116,
Te117,
Te118,
Te119,
Te120,
Te121,
Te122,
Te123,
Te124,
Te125,
Te126,
Te127,
Te128,
Te129,
Te130,
Te131,
Te132,
Te133,
Te134,
Te135,
Te136,
Te137,
Te138,
Te139,
Te140,
Te141,
Te142,
Te143,
Te144,
Te145,
}
impl super::RelativeAtomicMass for TelluriumIsotope {
#[inline]
fn relative_atomic_mass(&self) -> f64 {
match self {
Self::Te104 => 103.946723408f64,
Self::Te105 => 104.9433f64,
Self::Te106 => 105.9375f64,
Self::Te107 => 106.935012f64,
Self::Te108 => 107.9293805f64,
Self::Te109 => 108.9273045f64,
Self::Te110 => 109.9224581f64,
Self::Te111 => 110.9210006f64,
Self::Te112 => 111.9167279f64,
Self::Te113 => 112.915891f64,
Self::Te114 => 113.912089f64,
Self::Te115 => 114.911902f64,
Self::Te116 => 115.90846f64,
Self::Te117 => 116.908646f64,
Self::Te118 => 117.905854f64,
Self::Te119 => 118.9064071f64,
Self::Te120 => 119.9040593f64,
Self::Te121 => 120.904944f64,
Self::Te122 => 121.9030435f64,
Self::Te123 => 122.9042698f64,
Self::Te124 => 123.9028171f64,
Self::Te125 => 124.9044299f64,
Self::Te126 => 125.9033109f64,
Self::Te127 => 126.9052257f64,
Self::Te128 => 127.90446128f64,
Self::Te129 => 128.90659646f64,
Self::Te130 => 129.906222748f64,
Self::Te131 => 130.908522213f64,
Self::Te132 => 131.9085467f64,
Self::Te133 => 132.9109688f64,
Self::Te134 => 133.911394f64,
Self::Te135 => 134.9165557f64,
Self::Te136 => 135.9201006f64,
Self::Te137 => 136.9255989f64,
Self::Te138 => 137.9294722f64,
Self::Te139 => 138.9353672f64,
Self::Te140 => 139.939499f64,
Self::Te141 => 140.9458f64,
Self::Te142 => 141.95022f64,
Self::Te143 => 142.95676f64,
Self::Te144 => 143.961116f64,
Self::Te145 => 144.967783f64,
}
}
}
impl super::ElementVariant for TelluriumIsotope {
#[inline]
fn element(&self) -> crate::Element {
crate::Element::Te
}
}
impl super::MassNumber for TelluriumIsotope {
#[inline]
fn mass_number(&self) -> u16 {
match self {
Self::Te104 => 104u16,
Self::Te105 => 105u16,
Self::Te106 => 106u16,
Self::Te107 => 107u16,
Self::Te108 => 108u16,
Self::Te109 => 109u16,
Self::Te110 => 110u16,
Self::Te111 => 111u16,
Self::Te112 => 112u16,
Self::Te113 => 113u16,
Self::Te114 => 114u16,
Self::Te115 => 115u16,
Self::Te116 => 116u16,
Self::Te117 => 117u16,
Self::Te118 => 118u16,
Self::Te119 => 119u16,
Self::Te120 => 120u16,
Self::Te121 => 121u16,
Self::Te122 => 122u16,
Self::Te123 => 123u16,
Self::Te124 => 124u16,
Self::Te125 => 125u16,
Self::Te126 => 126u16,
Self::Te127 => 127u16,
Self::Te128 => 128u16,
Self::Te129 => 129u16,
Self::Te130 => 130u16,
Self::Te131 => 131u16,
Self::Te132 => 132u16,
Self::Te133 => 133u16,
Self::Te134 => 134u16,
Self::Te135 => 135u16,
Self::Te136 => 136u16,
Self::Te137 => 137u16,
Self::Te138 => 138u16,
Self::Te139 => 139u16,
Self::Te140 => 140u16,
Self::Te141 => 141u16,
Self::Te142 => 142u16,
Self::Te143 => 143u16,
Self::Te144 => 144u16,
Self::Te145 => 145u16,
}
}
}
impl super::IsotopicComposition for TelluriumIsotope {
#[inline]
fn isotopic_composition(&self) -> Option<f64> {
match self {
Self::Te120 => Some(0.0009f64),
Self::Te122 => Some(0.0255f64),
Self::Te123 => Some(0.0089f64),
Self::Te124 => Some(0.0474f64),
Self::Te125 => Some(0.0707f64),
Self::Te126 => Some(0.1884f64),
Self::Te128 => Some(0.3174f64),
Self::Te130 => Some(0.3408f64),
_ => None,
}
}
}
impl super::MostAbundantIsotope for TelluriumIsotope {
fn most_abundant_isotope() -> Self {
Self::Te130
}
}
impl From<TelluriumIsotope> for crate::Isotope {
fn from(isotope: TelluriumIsotope) -> Self {
crate::Isotope::Te(isotope)
}
}
impl From<TelluriumIsotope> for crate::Element {
fn from(_isotope: TelluriumIsotope) -> Self {
crate::Element::Te
}
}
impl TryFrom<u64> for TelluriumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u64) -> Result<Self, Self::Error> {
match value {
104u64 => Ok(Self::Te104),
105u64 => Ok(Self::Te105),
106u64 => Ok(Self::Te106),
107u64 => Ok(Self::Te107),
108u64 => Ok(Self::Te108),
109u64 => Ok(Self::Te109),
110u64 => Ok(Self::Te110),
111u64 => Ok(Self::Te111),
112u64 => Ok(Self::Te112),
113u64 => Ok(Self::Te113),
114u64 => Ok(Self::Te114),
115u64 => Ok(Self::Te115),
116u64 => Ok(Self::Te116),
117u64 => Ok(Self::Te117),
118u64 => Ok(Self::Te118),
119u64 => Ok(Self::Te119),
120u64 => Ok(Self::Te120),
121u64 => Ok(Self::Te121),
122u64 => Ok(Self::Te122),
123u64 => Ok(Self::Te123),
124u64 => Ok(Self::Te124),
125u64 => Ok(Self::Te125),
126u64 => Ok(Self::Te126),
127u64 => Ok(Self::Te127),
128u64 => Ok(Self::Te128),
129u64 => Ok(Self::Te129),
130u64 => Ok(Self::Te130),
131u64 => Ok(Self::Te131),
132u64 => Ok(Self::Te132),
133u64 => Ok(Self::Te133),
134u64 => Ok(Self::Te134),
135u64 => Ok(Self::Te135),
136u64 => Ok(Self::Te136),
137u64 => Ok(Self::Te137),
138u64 => Ok(Self::Te138),
139u64 => Ok(Self::Te139),
140u64 => Ok(Self::Te140),
141u64 => Ok(Self::Te141),
142u64 => Ok(Self::Te142),
143u64 => Ok(Self::Te143),
144u64 => Ok(Self::Te144),
145u64 => Ok(Self::Te145),
_ => Err(crate::errors::Error::Isotope(crate::Element::Te, value)),
}
}
}
impl TryFrom<u8> for TelluriumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u8) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u16> for TelluriumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u16) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl TryFrom<u32> for TelluriumIsotope {
type Error = crate::errors::Error;
fn try_from(value: u32) -> Result<Self, Self::Error> {
Self::try_from(u64::from(value))
}
}
impl core::fmt::Display for TelluriumIsotope {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::Te104 => write!(f, "Te104"),
Self::Te105 => write!(f, "Te105"),
Self::Te106 => write!(f, "Te106"),
Self::Te107 => write!(f, "Te107"),
Self::Te108 => write!(f, "Te108"),
Self::Te109 => write!(f, "Te109"),
Self::Te110 => write!(f, "Te110"),
Self::Te111 => write!(f, "Te111"),
Self::Te112 => write!(f, "Te112"),
Self::Te113 => write!(f, "Te113"),
Self::Te114 => write!(f, "Te114"),
Self::Te115 => write!(f, "Te115"),
Self::Te116 => write!(f, "Te116"),
Self::Te117 => write!(f, "Te117"),
Self::Te118 => write!(f, "Te118"),
Self::Te119 => write!(f, "Te119"),
Self::Te120 => write!(f, "Te120"),
Self::Te121 => write!(f, "Te121"),
Self::Te122 => write!(f, "Te122"),
Self::Te123 => write!(f, "Te123"),
Self::Te124 => write!(f, "Te124"),
Self::Te125 => write!(f, "Te125"),
Self::Te126 => write!(f, "Te126"),
Self::Te127 => write!(f, "Te127"),
Self::Te128 => write!(f, "Te128"),
Self::Te129 => write!(f, "Te129"),
Self::Te130 => write!(f, "Te130"),
Self::Te131 => write!(f, "Te131"),
Self::Te132 => write!(f, "Te132"),
Self::Te133 => write!(f, "Te133"),
Self::Te134 => write!(f, "Te134"),
Self::Te135 => write!(f, "Te135"),
Self::Te136 => write!(f, "Te136"),
Self::Te137 => write!(f, "Te137"),
Self::Te138 => write!(f, "Te138"),
Self::Te139 => write!(f, "Te139"),
Self::Te140 => write!(f, "Te140"),
Self::Te141 => write!(f, "Te141"),
Self::Te142 => write!(f, "Te142"),
Self::Te143 => write!(f, "Te143"),
Self::Te144 => write!(f, "Te144"),
Self::Te145 => write!(f, "Te145"),
}
}
}
#[cfg(test)]
mod tests {
use strum::IntoEnumIterator;
use super::*;
use crate::isotopes::{
ElementVariant, IsotopicComposition, MassNumber, MostAbundantIsotope, RelativeAtomicMass,
};
#[test]
fn test_relative_atomic_mass() {
for isotope in TelluriumIsotope::iter() {
let mass = isotope.relative_atomic_mass();
assert!(mass > 0.0, "Mass should be positive for {isotope:?}");
}
}
#[test]
fn test_element() {
for isotope in TelluriumIsotope::iter() {
let element = isotope.element();
assert_eq!(element, crate::Element::Te, "Element should be correct for {isotope:?}");
}
}
#[test]
fn test_mass_number() {
for isotope in TelluriumIsotope::iter() {
let mass_number = isotope.mass_number();
assert!(
mass_number > 0 && mass_number < 300,
"Mass number should be reasonable for {isotope:?}"
);
}
}
#[test]
fn test_isotopic_composition() {
for isotope in TelluriumIsotope::iter() {
let comp = isotope.isotopic_composition();
if let Some(c) = comp {
assert!(
(0.0..=1.0).contains(&c),
"Composition should be between 0 and 1 for {isotope:?}"
);
}
}
}
#[test]
fn test_most_abundant() {
let most_abundant = TelluriumIsotope::most_abundant_isotope();
let _ = most_abundant.relative_atomic_mass();
}
#[test]
fn test_from_isotope() {
for isotope in TelluriumIsotope::iter() {
let iso: crate::Isotope = isotope.into();
match iso {
crate::Isotope::Te(i) => assert_eq!(i, isotope),
_ => panic!("Wrong isotope type"),
}
}
}
#[test]
fn test_from_element() {
for isotope in TelluriumIsotope::iter() {
let elem: crate::Element = isotope.into();
assert_eq!(elem, crate::Element::Te);
}
}
#[test]
fn test_try_from_mass_number() {
for isotope in TelluriumIsotope::iter() {
let mass = isotope.mass_number();
let iso = TelluriumIsotope::try_from(mass).unwrap();
assert_eq!(iso, isotope);
let iso_u32 = TelluriumIsotope::try_from(u32::from(mass)).unwrap();
assert_eq!(iso_u32, isotope);
if let Ok(mass_u8) = u8::try_from(mass) {
let iso_u8 = TelluriumIsotope::try_from(mass_u8).unwrap();
assert_eq!(iso_u8, isotope);
}
}
assert!(TelluriumIsotope::try_from(0_u16).is_err());
assert!(TelluriumIsotope::try_from(1000_u16).is_err());
assert!(TelluriumIsotope::try_from(0_u32).is_err());
assert!(TelluriumIsotope::try_from(1000_u32).is_err());
assert!(TelluriumIsotope::try_from(0_u8).is_err());
}
#[test]
fn test_display() {
for isotope in TelluriumIsotope::iter() {
let s = alloc::format!("{isotope}");
assert!(!s.is_empty(), "Display should not be empty for {isotope:?}");
}
}
}