Skip to main content

elements_rs/isotopes/
thallium.rs

1//! Isotopes of the element Thallium
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 Thallium
6pub enum ThalliumIsotope {
7    /// Isotope Tl176 of Thallium
8    Tl176,
9    /// Isotope Tl177 of Thallium
10    Tl177,
11    /// Isotope Tl178 of Thallium
12    Tl178,
13    /// Isotope Tl179 of Thallium
14    Tl179,
15    /// Isotope Tl180 of Thallium
16    Tl180,
17    /// Isotope Tl181 of Thallium
18    Tl181,
19    /// Isotope Tl182 of Thallium
20    Tl182,
21    /// Isotope Tl183 of Thallium
22    Tl183,
23    /// Isotope Tl184 of Thallium
24    Tl184,
25    /// Isotope Tl185 of Thallium
26    Tl185,
27    /// Isotope Tl186 of Thallium
28    Tl186,
29    /// Isotope Tl187 of Thallium
30    Tl187,
31    /// Isotope Tl188 of Thallium
32    Tl188,
33    /// Isotope Tl189 of Thallium
34    Tl189,
35    /// Isotope Tl190 of Thallium
36    Tl190,
37    /// Isotope Tl191 of Thallium
38    Tl191,
39    /// Isotope Tl192 of Thallium
40    Tl192,
41    /// Isotope Tl193 of Thallium
42    Tl193,
43    /// Isotope Tl194 of Thallium
44    Tl194,
45    /// Isotope Tl195 of Thallium
46    Tl195,
47    /// Isotope Tl196 of Thallium
48    Tl196,
49    /// Isotope Tl197 of Thallium
50    Tl197,
51    /// Isotope Tl198 of Thallium
52    Tl198,
53    /// Isotope Tl199 of Thallium
54    Tl199,
55    /// Isotope Tl200 of Thallium
56    Tl200,
57    /// Isotope Tl201 of Thallium
58    Tl201,
59    /// Isotope Tl202 of Thallium
60    Tl202,
61    /// Isotope Tl203 of Thallium
62    Tl203,
63    /// Isotope Tl204 of Thallium
64    Tl204,
65    /// Isotope Tl205 of Thallium
66    Tl205,
67    /// Isotope Tl206 of Thallium
68    Tl206,
69    /// Isotope Tl207 of Thallium
70    Tl207,
71    /// Isotope Tl208 of Thallium
72    Tl208,
73    /// Isotope Tl209 of Thallium
74    Tl209,
75    /// Isotope Tl210 of Thallium
76    Tl210,
77    /// Isotope Tl211 of Thallium
78    Tl211,
79    /// Isotope Tl212 of Thallium
80    Tl212,
81    /// Isotope Tl213 of Thallium
82    Tl213,
83    /// Isotope Tl214 of Thallium
84    Tl214,
85    /// Isotope Tl215 of Thallium
86    Tl215,
87    /// Isotope Tl216 of Thallium
88    Tl216,
89    /// Isotope Tl217 of Thallium
90    Tl217,
91    /// Isotope Tl218 of Thallium
92    Tl218,
93}
94impl super::RelativeAtomicMass for ThalliumIsotope {
95    #[inline]
96    fn relative_atomic_mass(&self) -> f64 {
97        match self {
98            Self::Tl176 => 176.000624f64,
99            Self::Tl177 => 176.996431f64,
100            Self::Tl178 => 177.99485f64,
101            Self::Tl179 => 178.991111f64,
102            Self::Tl180 => 179.990057f64,
103            Self::Tl181 => 180.98626f64,
104            Self::Tl182 => 181.985713f64,
105            Self::Tl183 => 182.982193f64,
106            Self::Tl184 => 183.981886f64,
107            Self::Tl185 => 184.978789f64,
108            Self::Tl186 => 185.978651f64,
109            Self::Tl187 => 186.9759063f64,
110            Self::Tl188 => 187.976021f64,
111            Self::Tl189 => 188.973588f64,
112            Self::Tl190 => 189.973828f64,
113            Self::Tl191 => 190.9717842f64,
114            Self::Tl192 => 191.972225f64,
115            Self::Tl193 => 192.970502f64,
116            Self::Tl194 => 193.971081f64,
117            Self::Tl195 => 194.969774f64,
118            Self::Tl196 => 195.970481f64,
119            Self::Tl197 => 196.969576f64,
120            Self::Tl198 => 197.970483f64,
121            Self::Tl199 => 198.969877f64,
122            Self::Tl200 => 199.9709633f64,
123            Self::Tl201 => 200.970822f64,
124            Self::Tl202 => 201.972102f64,
125            Self::Tl203 => 202.9723446f64,
126            Self::Tl204 => 203.9738639f64,
127            Self::Tl205 => 204.9744278f64,
128            Self::Tl206 => 205.9761106f64,
129            Self::Tl207 => 206.9774197f64,
130            Self::Tl208 => 207.982019f64,
131            Self::Tl209 => 208.9853594f64,
132            Self::Tl210 => 209.990074f64,
133            Self::Tl211 => 210.993475f64,
134            Self::Tl212 => 211.99834f64,
135            Self::Tl213 => 213.001915f64,
136            Self::Tl214 => 214.00694f64,
137            Self::Tl215 => 215.01064f64,
138            Self::Tl216 => 216.0158f64,
139            Self::Tl217 => 217.01966f64,
140            Self::Tl218 => 218.02479f64,
141        }
142    }
143}
144impl super::ElementVariant for ThalliumIsotope {
145    #[inline]
146    fn element(&self) -> crate::Element {
147        crate::Element::Tl
148    }
149}
150impl super::MassNumber for ThalliumIsotope {
151    #[inline]
152    fn mass_number(&self) -> u16 {
153        match self {
154            Self::Tl176 => 176u16,
155            Self::Tl177 => 177u16,
156            Self::Tl178 => 178u16,
157            Self::Tl179 => 179u16,
158            Self::Tl180 => 180u16,
159            Self::Tl181 => 181u16,
160            Self::Tl182 => 182u16,
161            Self::Tl183 => 183u16,
162            Self::Tl184 => 184u16,
163            Self::Tl185 => 185u16,
164            Self::Tl186 => 186u16,
165            Self::Tl187 => 187u16,
166            Self::Tl188 => 188u16,
167            Self::Tl189 => 189u16,
168            Self::Tl190 => 190u16,
169            Self::Tl191 => 191u16,
170            Self::Tl192 => 192u16,
171            Self::Tl193 => 193u16,
172            Self::Tl194 => 194u16,
173            Self::Tl195 => 195u16,
174            Self::Tl196 => 196u16,
175            Self::Tl197 => 197u16,
176            Self::Tl198 => 198u16,
177            Self::Tl199 => 199u16,
178            Self::Tl200 => 200u16,
179            Self::Tl201 => 201u16,
180            Self::Tl202 => 202u16,
181            Self::Tl203 => 203u16,
182            Self::Tl204 => 204u16,
183            Self::Tl205 => 205u16,
184            Self::Tl206 => 206u16,
185            Self::Tl207 => 207u16,
186            Self::Tl208 => 208u16,
187            Self::Tl209 => 209u16,
188            Self::Tl210 => 210u16,
189            Self::Tl211 => 211u16,
190            Self::Tl212 => 212u16,
191            Self::Tl213 => 213u16,
192            Self::Tl214 => 214u16,
193            Self::Tl215 => 215u16,
194            Self::Tl216 => 216u16,
195            Self::Tl217 => 217u16,
196            Self::Tl218 => 218u16,
197        }
198    }
199}
200impl super::IsotopicComposition for ThalliumIsotope {
201    #[inline]
202    fn isotopic_composition(&self) -> Option<f64> {
203        match self {
204            Self::Tl203 => Some(0.2952f64),
205            Self::Tl205 => Some(0.7048f64),
206            _ => None,
207        }
208    }
209}
210impl super::MostAbundantIsotope for ThalliumIsotope {
211    fn most_abundant_isotope() -> Self {
212        Self::Tl205
213    }
214}
215impl From<ThalliumIsotope> for crate::Isotope {
216    fn from(isotope: ThalliumIsotope) -> Self {
217        crate::Isotope::Tl(isotope)
218    }
219}
220impl From<ThalliumIsotope> for crate::Element {
221    fn from(_isotope: ThalliumIsotope) -> Self {
222        crate::Element::Tl
223    }
224}
225impl TryFrom<u64> for ThalliumIsotope {
226    type Error = crate::errors::Error;
227    fn try_from(value: u64) -> Result<Self, Self::Error> {
228        match value {
229            176u64 => Ok(Self::Tl176),
230            177u64 => Ok(Self::Tl177),
231            178u64 => Ok(Self::Tl178),
232            179u64 => Ok(Self::Tl179),
233            180u64 => Ok(Self::Tl180),
234            181u64 => Ok(Self::Tl181),
235            182u64 => Ok(Self::Tl182),
236            183u64 => Ok(Self::Tl183),
237            184u64 => Ok(Self::Tl184),
238            185u64 => Ok(Self::Tl185),
239            186u64 => Ok(Self::Tl186),
240            187u64 => Ok(Self::Tl187),
241            188u64 => Ok(Self::Tl188),
242            189u64 => Ok(Self::Tl189),
243            190u64 => Ok(Self::Tl190),
244            191u64 => Ok(Self::Tl191),
245            192u64 => Ok(Self::Tl192),
246            193u64 => Ok(Self::Tl193),
247            194u64 => Ok(Self::Tl194),
248            195u64 => Ok(Self::Tl195),
249            196u64 => Ok(Self::Tl196),
250            197u64 => Ok(Self::Tl197),
251            198u64 => Ok(Self::Tl198),
252            199u64 => Ok(Self::Tl199),
253            200u64 => Ok(Self::Tl200),
254            201u64 => Ok(Self::Tl201),
255            202u64 => Ok(Self::Tl202),
256            203u64 => Ok(Self::Tl203),
257            204u64 => Ok(Self::Tl204),
258            205u64 => Ok(Self::Tl205),
259            206u64 => Ok(Self::Tl206),
260            207u64 => Ok(Self::Tl207),
261            208u64 => Ok(Self::Tl208),
262            209u64 => Ok(Self::Tl209),
263            210u64 => Ok(Self::Tl210),
264            211u64 => Ok(Self::Tl211),
265            212u64 => Ok(Self::Tl212),
266            213u64 => Ok(Self::Tl213),
267            214u64 => Ok(Self::Tl214),
268            215u64 => Ok(Self::Tl215),
269            216u64 => Ok(Self::Tl216),
270            217u64 => Ok(Self::Tl217),
271            218u64 => Ok(Self::Tl218),
272            _ => Err(crate::errors::Error::Isotope(crate::Element::Tl, value)),
273        }
274    }
275}
276impl TryFrom<u8> for ThalliumIsotope {
277    type Error = crate::errors::Error;
278    fn try_from(value: u8) -> Result<Self, Self::Error> {
279        Self::try_from(u64::from(value))
280    }
281}
282impl TryFrom<u16> for ThalliumIsotope {
283    type Error = crate::errors::Error;
284    fn try_from(value: u16) -> Result<Self, Self::Error> {
285        Self::try_from(u64::from(value))
286    }
287}
288impl TryFrom<u32> for ThalliumIsotope {
289    type Error = crate::errors::Error;
290    fn try_from(value: u32) -> Result<Self, Self::Error> {
291        Self::try_from(u64::from(value))
292    }
293}
294impl core::fmt::Display for ThalliumIsotope {
295    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
296        match self {
297            Self::Tl176 => write!(f, "Tl176"),
298            Self::Tl177 => write!(f, "Tl177"),
299            Self::Tl178 => write!(f, "Tl178"),
300            Self::Tl179 => write!(f, "Tl179"),
301            Self::Tl180 => write!(f, "Tl180"),
302            Self::Tl181 => write!(f, "Tl181"),
303            Self::Tl182 => write!(f, "Tl182"),
304            Self::Tl183 => write!(f, "Tl183"),
305            Self::Tl184 => write!(f, "Tl184"),
306            Self::Tl185 => write!(f, "Tl185"),
307            Self::Tl186 => write!(f, "Tl186"),
308            Self::Tl187 => write!(f, "Tl187"),
309            Self::Tl188 => write!(f, "Tl188"),
310            Self::Tl189 => write!(f, "Tl189"),
311            Self::Tl190 => write!(f, "Tl190"),
312            Self::Tl191 => write!(f, "Tl191"),
313            Self::Tl192 => write!(f, "Tl192"),
314            Self::Tl193 => write!(f, "Tl193"),
315            Self::Tl194 => write!(f, "Tl194"),
316            Self::Tl195 => write!(f, "Tl195"),
317            Self::Tl196 => write!(f, "Tl196"),
318            Self::Tl197 => write!(f, "Tl197"),
319            Self::Tl198 => write!(f, "Tl198"),
320            Self::Tl199 => write!(f, "Tl199"),
321            Self::Tl200 => write!(f, "Tl200"),
322            Self::Tl201 => write!(f, "Tl201"),
323            Self::Tl202 => write!(f, "Tl202"),
324            Self::Tl203 => write!(f, "Tl203"),
325            Self::Tl204 => write!(f, "Tl204"),
326            Self::Tl205 => write!(f, "Tl205"),
327            Self::Tl206 => write!(f, "Tl206"),
328            Self::Tl207 => write!(f, "Tl207"),
329            Self::Tl208 => write!(f, "Tl208"),
330            Self::Tl209 => write!(f, "Tl209"),
331            Self::Tl210 => write!(f, "Tl210"),
332            Self::Tl211 => write!(f, "Tl211"),
333            Self::Tl212 => write!(f, "Tl212"),
334            Self::Tl213 => write!(f, "Tl213"),
335            Self::Tl214 => write!(f, "Tl214"),
336            Self::Tl215 => write!(f, "Tl215"),
337            Self::Tl216 => write!(f, "Tl216"),
338            Self::Tl217 => write!(f, "Tl217"),
339            Self::Tl218 => write!(f, "Tl218"),
340        }
341    }
342}
343#[cfg(test)]
344mod tests {
345    use strum::IntoEnumIterator;
346
347    use super::*;
348    use crate::isotopes::{
349        ElementVariant, IsotopicComposition, MassNumber, MostAbundantIsotope, RelativeAtomicMass,
350    };
351    #[test]
352    fn test_relative_atomic_mass() {
353        for isotope in ThalliumIsotope::iter() {
354            let mass = isotope.relative_atomic_mass();
355            assert!(mass > 0.0, "Mass should be positive for {isotope:?}");
356        }
357    }
358    #[test]
359    fn test_element() {
360        for isotope in ThalliumIsotope::iter() {
361            let element = isotope.element();
362            assert_eq!(element, crate::Element::Tl, "Element should be correct for {isotope:?}");
363        }
364    }
365    #[test]
366    fn test_mass_number() {
367        for isotope in ThalliumIsotope::iter() {
368            let mass_number = isotope.mass_number();
369            assert!(
370                mass_number > 0 && mass_number < 300,
371                "Mass number should be reasonable for {isotope:?}"
372            );
373        }
374    }
375    #[test]
376    fn test_isotopic_composition() {
377        for isotope in ThalliumIsotope::iter() {
378            let comp = isotope.isotopic_composition();
379            if let Some(c) = comp {
380                assert!(
381                    (0.0..=1.0).contains(&c),
382                    "Composition should be between 0 and 1 for {isotope:?}"
383                );
384            }
385        }
386    }
387    #[test]
388    fn test_most_abundant() {
389        let most_abundant = ThalliumIsotope::most_abundant_isotope();
390        let _ = most_abundant.relative_atomic_mass();
391    }
392    #[test]
393    fn test_from_isotope() {
394        for isotope in ThalliumIsotope::iter() {
395            let iso: crate::Isotope = isotope.into();
396            match iso {
397                crate::Isotope::Tl(i) => assert_eq!(i, isotope),
398                _ => panic!("Wrong isotope type"),
399            }
400        }
401    }
402    #[test]
403    fn test_from_element() {
404        for isotope in ThalliumIsotope::iter() {
405            let elem: crate::Element = isotope.into();
406            assert_eq!(elem, crate::Element::Tl);
407        }
408    }
409    #[test]
410    fn test_try_from_mass_number() {
411        for isotope in ThalliumIsotope::iter() {
412            let mass = isotope.mass_number();
413            let iso = ThalliumIsotope::try_from(mass).unwrap();
414            assert_eq!(iso, isotope);
415            let iso_u32 = ThalliumIsotope::try_from(u32::from(mass)).unwrap();
416            assert_eq!(iso_u32, isotope);
417            if let Ok(mass_u8) = u8::try_from(mass) {
418                let iso_u8 = ThalliumIsotope::try_from(mass_u8).unwrap();
419                assert_eq!(iso_u8, isotope);
420            }
421        }
422        assert!(ThalliumIsotope::try_from(0_u16).is_err());
423        assert!(ThalliumIsotope::try_from(1000_u16).is_err());
424        assert!(ThalliumIsotope::try_from(0_u32).is_err());
425        assert!(ThalliumIsotope::try_from(1000_u32).is_err());
426        assert!(ThalliumIsotope::try_from(0_u8).is_err());
427    }
428    #[test]
429    fn test_display() {
430        for isotope in ThalliumIsotope::iter() {
431            let s = alloc::format!("{isotope}");
432            assert!(!s.is_empty(), "Display should not be empty for {isotope:?}");
433        }
434    }
435}