Skip to main content

elements_rs/isotopes/
ruthenium.rs

1//! Isotopes of the element Ruthenium
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, strum :: EnumIter)]
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
5/// Isotopes of the element Ruthenium
6pub enum RutheniumIsotope {
7    /// Isotope Ru87 of Ruthenium
8    Ru87,
9    /// Isotope Ru88 of Ruthenium
10    Ru88,
11    /// Isotope Ru89 of Ruthenium
12    Ru89,
13    /// Isotope Ru90 of Ruthenium
14    Ru90,
15    /// Isotope Ru91 of Ruthenium
16    Ru91,
17    /// Isotope Ru92 of Ruthenium
18    Ru92,
19    /// Isotope Ru93 of Ruthenium
20    Ru93,
21    /// Isotope Ru94 of Ruthenium
22    Ru94,
23    /// Isotope Ru95 of Ruthenium
24    Ru95,
25    /// Isotope Ru96 of Ruthenium
26    Ru96,
27    /// Isotope Ru97 of Ruthenium
28    Ru97,
29    /// Isotope Ru98 of Ruthenium
30    Ru98,
31    /// Isotope Ru99 of Ruthenium
32    Ru99,
33    /// Isotope Ru100 of Ruthenium
34    Ru100,
35    /// Isotope Ru101 of Ruthenium
36    Ru101,
37    /// Isotope Ru102 of Ruthenium
38    Ru102,
39    /// Isotope Ru103 of Ruthenium
40    Ru103,
41    /// Isotope Ru104 of Ruthenium
42    Ru104,
43    /// Isotope Ru105 of Ruthenium
44    Ru105,
45    /// Isotope Ru106 of Ruthenium
46    Ru106,
47    /// Isotope Ru107 of Ruthenium
48    Ru107,
49    /// Isotope Ru108 of Ruthenium
50    Ru108,
51    /// Isotope Ru109 of Ruthenium
52    Ru109,
53    /// Isotope Ru110 of Ruthenium
54    Ru110,
55    /// Isotope Ru111 of Ruthenium
56    Ru111,
57    /// Isotope Ru112 of Ruthenium
58    Ru112,
59    /// Isotope Ru113 of Ruthenium
60    Ru113,
61    /// Isotope Ru114 of Ruthenium
62    Ru114,
63    /// Isotope Ru115 of Ruthenium
64    Ru115,
65    /// Isotope Ru116 of Ruthenium
66    Ru116,
67    /// Isotope Ru117 of Ruthenium
68    Ru117,
69    /// Isotope Ru118 of Ruthenium
70    Ru118,
71    /// Isotope Ru119 of Ruthenium
72    Ru119,
73    /// Isotope Ru120 of Ruthenium
74    Ru120,
75    /// Isotope Ru121 of Ruthenium
76    Ru121,
77    /// Isotope Ru122 of Ruthenium
78    Ru122,
79    /// Isotope Ru123 of Ruthenium
80    Ru123,
81    /// Isotope Ru124 of Ruthenium
82    Ru124,
83}
84impl super::RelativeAtomicMass for RutheniumIsotope {
85    #[inline]
86    fn relative_atomic_mass(&self) -> f64 {
87        match self {
88            Self::Ru87 => 86.95069f64,
89            Self::Ru88 => 87.9416f64,
90            Self::Ru89 => 88.93762f64,
91            Self::Ru90 => 89.9303444f64,
92            Self::Ru91 => 90.9267419f64,
93            Self::Ru92 => 91.9202344f64,
94            Self::Ru93 => 92.9171044f64,
95            Self::Ru94 => 93.9113429f64,
96            Self::Ru95 => 94.910406f64,
97            Self::Ru96 => 95.90759025f64,
98            Self::Ru97 => 96.9075471f64,
99            Self::Ru98 => 97.9052868f64,
100            Self::Ru99 => 98.9059341f64,
101            Self::Ru100 => 99.9042143f64,
102            Self::Ru101 => 100.9055769f64,
103            Self::Ru102 => 101.9043441f64,
104            Self::Ru103 => 102.9063186f64,
105            Self::Ru104 => 103.9054275f64,
106            Self::Ru105 => 104.9077476f64,
107            Self::Ru106 => 105.9073291f64,
108            Self::Ru107 => 106.909972f64,
109            Self::Ru108 => 107.910188f64,
110            Self::Ru109 => 108.913326f64,
111            Self::Ru110 => 109.9140407f64,
112            Self::Ru111 => 110.91757f64,
113            Self::Ru112 => 111.918809f64,
114            Self::Ru113 => 112.922844f64,
115            Self::Ru114 => 113.9246136f64,
116            Self::Ru115 => 114.92882f64,
117            Self::Ru116 => 115.9312192f64,
118            Self::Ru117 => 116.9361f64,
119            Self::Ru118 => 117.93853f64,
120            Self::Ru119 => 118.94357f64,
121            Self::Ru120 => 119.94631f64,
122            Self::Ru121 => 120.95164f64,
123            Self::Ru122 => 121.95447f64,
124            Self::Ru123 => 122.95989f64,
125            Self::Ru124 => 123.96305f64,
126        }
127    }
128}
129impl super::ElementVariant for RutheniumIsotope {
130    #[inline]
131    fn element(&self) -> crate::Element {
132        crate::Element::Ru
133    }
134}
135impl super::MassNumber for RutheniumIsotope {
136    #[inline]
137    fn mass_number(&self) -> u16 {
138        match self {
139            Self::Ru87 => 87u16,
140            Self::Ru88 => 88u16,
141            Self::Ru89 => 89u16,
142            Self::Ru90 => 90u16,
143            Self::Ru91 => 91u16,
144            Self::Ru92 => 92u16,
145            Self::Ru93 => 93u16,
146            Self::Ru94 => 94u16,
147            Self::Ru95 => 95u16,
148            Self::Ru96 => 96u16,
149            Self::Ru97 => 97u16,
150            Self::Ru98 => 98u16,
151            Self::Ru99 => 99u16,
152            Self::Ru100 => 100u16,
153            Self::Ru101 => 101u16,
154            Self::Ru102 => 102u16,
155            Self::Ru103 => 103u16,
156            Self::Ru104 => 104u16,
157            Self::Ru105 => 105u16,
158            Self::Ru106 => 106u16,
159            Self::Ru107 => 107u16,
160            Self::Ru108 => 108u16,
161            Self::Ru109 => 109u16,
162            Self::Ru110 => 110u16,
163            Self::Ru111 => 111u16,
164            Self::Ru112 => 112u16,
165            Self::Ru113 => 113u16,
166            Self::Ru114 => 114u16,
167            Self::Ru115 => 115u16,
168            Self::Ru116 => 116u16,
169            Self::Ru117 => 117u16,
170            Self::Ru118 => 118u16,
171            Self::Ru119 => 119u16,
172            Self::Ru120 => 120u16,
173            Self::Ru121 => 121u16,
174            Self::Ru122 => 122u16,
175            Self::Ru123 => 123u16,
176            Self::Ru124 => 124u16,
177        }
178    }
179}
180impl super::IsotopicComposition for RutheniumIsotope {
181    #[inline]
182    fn isotopic_composition(&self) -> Option<f64> {
183        match self {
184            Self::Ru96 => Some(0.0554f64),
185            Self::Ru98 => Some(0.0187f64),
186            Self::Ru99 => Some(0.1276f64),
187            Self::Ru100 => Some(0.126f64),
188            Self::Ru101 => Some(0.1706f64),
189            Self::Ru102 => Some(0.3155f64),
190            Self::Ru104 => Some(0.1862f64),
191            _ => None,
192        }
193    }
194}
195impl super::MostAbundantIsotope for RutheniumIsotope {
196    fn most_abundant_isotope() -> Self {
197        Self::Ru102
198    }
199}
200impl From<RutheniumIsotope> for crate::Isotope {
201    fn from(isotope: RutheniumIsotope) -> Self {
202        crate::Isotope::Ru(isotope)
203    }
204}
205impl From<RutheniumIsotope> for crate::Element {
206    fn from(_isotope: RutheniumIsotope) -> Self {
207        crate::Element::Ru
208    }
209}
210impl TryFrom<u64> for RutheniumIsotope {
211    type Error = crate::errors::Error;
212    fn try_from(value: u64) -> Result<Self, Self::Error> {
213        match value {
214            87u64 => Ok(Self::Ru87),
215            88u64 => Ok(Self::Ru88),
216            89u64 => Ok(Self::Ru89),
217            90u64 => Ok(Self::Ru90),
218            91u64 => Ok(Self::Ru91),
219            92u64 => Ok(Self::Ru92),
220            93u64 => Ok(Self::Ru93),
221            94u64 => Ok(Self::Ru94),
222            95u64 => Ok(Self::Ru95),
223            96u64 => Ok(Self::Ru96),
224            97u64 => Ok(Self::Ru97),
225            98u64 => Ok(Self::Ru98),
226            99u64 => Ok(Self::Ru99),
227            100u64 => Ok(Self::Ru100),
228            101u64 => Ok(Self::Ru101),
229            102u64 => Ok(Self::Ru102),
230            103u64 => Ok(Self::Ru103),
231            104u64 => Ok(Self::Ru104),
232            105u64 => Ok(Self::Ru105),
233            106u64 => Ok(Self::Ru106),
234            107u64 => Ok(Self::Ru107),
235            108u64 => Ok(Self::Ru108),
236            109u64 => Ok(Self::Ru109),
237            110u64 => Ok(Self::Ru110),
238            111u64 => Ok(Self::Ru111),
239            112u64 => Ok(Self::Ru112),
240            113u64 => Ok(Self::Ru113),
241            114u64 => Ok(Self::Ru114),
242            115u64 => Ok(Self::Ru115),
243            116u64 => Ok(Self::Ru116),
244            117u64 => Ok(Self::Ru117),
245            118u64 => Ok(Self::Ru118),
246            119u64 => Ok(Self::Ru119),
247            120u64 => Ok(Self::Ru120),
248            121u64 => Ok(Self::Ru121),
249            122u64 => Ok(Self::Ru122),
250            123u64 => Ok(Self::Ru123),
251            124u64 => Ok(Self::Ru124),
252            _ => Err(crate::errors::Error::Isotope(crate::Element::Ru, value)),
253        }
254    }
255}
256impl TryFrom<u8> for RutheniumIsotope {
257    type Error = crate::errors::Error;
258    fn try_from(value: u8) -> Result<Self, Self::Error> {
259        Self::try_from(u64::from(value))
260    }
261}
262impl TryFrom<u16> for RutheniumIsotope {
263    type Error = crate::errors::Error;
264    fn try_from(value: u16) -> Result<Self, Self::Error> {
265        Self::try_from(u64::from(value))
266    }
267}
268impl TryFrom<u32> for RutheniumIsotope {
269    type Error = crate::errors::Error;
270    fn try_from(value: u32) -> Result<Self, Self::Error> {
271        Self::try_from(u64::from(value))
272    }
273}
274impl core::fmt::Display for RutheniumIsotope {
275    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
276        match self {
277            Self::Ru87 => write!(f, "Ru87"),
278            Self::Ru88 => write!(f, "Ru88"),
279            Self::Ru89 => write!(f, "Ru89"),
280            Self::Ru90 => write!(f, "Ru90"),
281            Self::Ru91 => write!(f, "Ru91"),
282            Self::Ru92 => write!(f, "Ru92"),
283            Self::Ru93 => write!(f, "Ru93"),
284            Self::Ru94 => write!(f, "Ru94"),
285            Self::Ru95 => write!(f, "Ru95"),
286            Self::Ru96 => write!(f, "Ru96"),
287            Self::Ru97 => write!(f, "Ru97"),
288            Self::Ru98 => write!(f, "Ru98"),
289            Self::Ru99 => write!(f, "Ru99"),
290            Self::Ru100 => write!(f, "Ru100"),
291            Self::Ru101 => write!(f, "Ru101"),
292            Self::Ru102 => write!(f, "Ru102"),
293            Self::Ru103 => write!(f, "Ru103"),
294            Self::Ru104 => write!(f, "Ru104"),
295            Self::Ru105 => write!(f, "Ru105"),
296            Self::Ru106 => write!(f, "Ru106"),
297            Self::Ru107 => write!(f, "Ru107"),
298            Self::Ru108 => write!(f, "Ru108"),
299            Self::Ru109 => write!(f, "Ru109"),
300            Self::Ru110 => write!(f, "Ru110"),
301            Self::Ru111 => write!(f, "Ru111"),
302            Self::Ru112 => write!(f, "Ru112"),
303            Self::Ru113 => write!(f, "Ru113"),
304            Self::Ru114 => write!(f, "Ru114"),
305            Self::Ru115 => write!(f, "Ru115"),
306            Self::Ru116 => write!(f, "Ru116"),
307            Self::Ru117 => write!(f, "Ru117"),
308            Self::Ru118 => write!(f, "Ru118"),
309            Self::Ru119 => write!(f, "Ru119"),
310            Self::Ru120 => write!(f, "Ru120"),
311            Self::Ru121 => write!(f, "Ru121"),
312            Self::Ru122 => write!(f, "Ru122"),
313            Self::Ru123 => write!(f, "Ru123"),
314            Self::Ru124 => write!(f, "Ru124"),
315        }
316    }
317}
318#[cfg(test)]
319mod tests {
320    use strum::IntoEnumIterator;
321
322    use super::*;
323    use crate::isotopes::{
324        ElementVariant, IsotopicComposition, MassNumber, MostAbundantIsotope, RelativeAtomicMass,
325    };
326    #[test]
327    fn test_relative_atomic_mass() {
328        for isotope in RutheniumIsotope::iter() {
329            let mass = isotope.relative_atomic_mass();
330            assert!(mass > 0.0, "Mass should be positive for {isotope:?}");
331        }
332    }
333    #[test]
334    fn test_element() {
335        for isotope in RutheniumIsotope::iter() {
336            let element = isotope.element();
337            assert_eq!(element, crate::Element::Ru, "Element should be correct for {isotope:?}");
338        }
339    }
340    #[test]
341    fn test_mass_number() {
342        for isotope in RutheniumIsotope::iter() {
343            let mass_number = isotope.mass_number();
344            assert!(
345                mass_number > 0 && mass_number < 300,
346                "Mass number should be reasonable for {isotope:?}"
347            );
348        }
349    }
350    #[test]
351    fn test_isotopic_composition() {
352        for isotope in RutheniumIsotope::iter() {
353            let comp = isotope.isotopic_composition();
354            if let Some(c) = comp {
355                assert!(
356                    (0.0..=1.0).contains(&c),
357                    "Composition should be between 0 and 1 for {isotope:?}"
358                );
359            }
360        }
361    }
362    #[test]
363    fn test_most_abundant() {
364        let most_abundant = RutheniumIsotope::most_abundant_isotope();
365        let _ = most_abundant.relative_atomic_mass();
366    }
367    #[test]
368    fn test_from_isotope() {
369        for isotope in RutheniumIsotope::iter() {
370            let iso: crate::Isotope = isotope.into();
371            match iso {
372                crate::Isotope::Ru(i) => assert_eq!(i, isotope),
373                _ => panic!("Wrong isotope type"),
374            }
375        }
376    }
377    #[test]
378    fn test_from_element() {
379        for isotope in RutheniumIsotope::iter() {
380            let elem: crate::Element = isotope.into();
381            assert_eq!(elem, crate::Element::Ru);
382        }
383    }
384    #[test]
385    fn test_try_from_mass_number() {
386        for isotope in RutheniumIsotope::iter() {
387            let mass = isotope.mass_number();
388            let iso = RutheniumIsotope::try_from(mass).unwrap();
389            assert_eq!(iso, isotope);
390            let iso_u32 = RutheniumIsotope::try_from(u32::from(mass)).unwrap();
391            assert_eq!(iso_u32, isotope);
392            if let Ok(mass_u8) = u8::try_from(mass) {
393                let iso_u8 = RutheniumIsotope::try_from(mass_u8).unwrap();
394                assert_eq!(iso_u8, isotope);
395            }
396        }
397        assert!(RutheniumIsotope::try_from(0_u16).is_err());
398        assert!(RutheniumIsotope::try_from(1000_u16).is_err());
399        assert!(RutheniumIsotope::try_from(0_u32).is_err());
400        assert!(RutheniumIsotope::try_from(1000_u32).is_err());
401        assert!(RutheniumIsotope::try_from(0_u8).is_err());
402    }
403    #[test]
404    fn test_display() {
405        for isotope in RutheniumIsotope::iter() {
406            let s = alloc::format!("{isotope}");
407            assert!(!s.is_empty(), "Display should not be empty for {isotope:?}");
408        }
409    }
410}