elements_rs/isotopes/
niobium.rs

1//! Isotopes of the element Niobium
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, strum :: EnumIter)]
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4/// Isotopes of the element Niobium
5pub enum NiobiumIsotope {
6    /// Isotope Nb81 of Niobium
7    Nb81,
8    /// Isotope Nb82 of Niobium
9    Nb82,
10    /// Isotope Nb83 of Niobium
11    Nb83,
12    /// Isotope Nb84 of Niobium
13    Nb84,
14    /// Isotope Nb85 of Niobium
15    Nb85,
16    /// Isotope Nb86 of Niobium
17    Nb86,
18    /// Isotope Nb87 of Niobium
19    Nb87,
20    /// Isotope Nb88 of Niobium
21    Nb88,
22    /// Isotope Nb89 of Niobium
23    Nb89,
24    /// Isotope Nb90 of Niobium
25    Nb90,
26    /// Isotope Nb91 of Niobium
27    Nb91,
28    /// Isotope Nb92 of Niobium
29    Nb92,
30    /// Isotope Nb93 of Niobium
31    Nb93,
32    /// Isotope Nb94 of Niobium
33    Nb94,
34    /// Isotope Nb95 of Niobium
35    Nb95,
36    /// Isotope Nb96 of Niobium
37    Nb96,
38    /// Isotope Nb97 of Niobium
39    Nb97,
40    /// Isotope Nb98 of Niobium
41    Nb98,
42    /// Isotope Nb99 of Niobium
43    Nb99,
44    /// Isotope Nb100 of Niobium
45    Nb100,
46    /// Isotope Nb101 of Niobium
47    Nb101,
48    /// Isotope Nb102 of Niobium
49    Nb102,
50    /// Isotope Nb103 of Niobium
51    Nb103,
52    /// Isotope Nb104 of Niobium
53    Nb104,
54    /// Isotope Nb105 of Niobium
55    Nb105,
56    /// Isotope Nb106 of Niobium
57    Nb106,
58    /// Isotope Nb107 of Niobium
59    Nb107,
60    /// Isotope Nb108 of Niobium
61    Nb108,
62    /// Isotope Nb109 of Niobium
63    Nb109,
64    /// Isotope Nb110 of Niobium
65    Nb110,
66    /// Isotope Nb111 of Niobium
67    Nb111,
68    /// Isotope Nb112 of Niobium
69    Nb112,
70    /// Isotope Nb113 of Niobium
71    Nb113,
72    /// Isotope Nb114 of Niobium
73    Nb114,
74    /// Isotope Nb115 of Niobium
75    Nb115,
76}
77impl super::RelativeAtomicMass for NiobiumIsotope {
78    #[inline]
79    fn relative_atomic_mass(&self) -> f64 {
80        match self {
81            Self::Nb81 => 80.9496f64,
82            Self::Nb82 => 81.94396f64,
83            Self::Nb83 => 82.93729f64,
84            Self::Nb84 => 83.93449f64,
85            Self::Nb85 => 84.9288458f64,
86            Self::Nb86 => 85.9257828f64,
87            Self::Nb87 => 86.9206937f64,
88            Self::Nb88 => 87.918222f64,
89            Self::Nb89 => 88.913445f64,
90            Self::Nb90 => 89.9112584f64,
91            Self::Nb91 => 90.9069897f64,
92            Self::Nb92 => 91.9071881f64,
93            Self::Nb93 => 92.906373f64,
94            Self::Nb94 => 93.9072788f64,
95            Self::Nb95 => 94.9068324f64,
96            Self::Nb96 => 95.9080973f64,
97            Self::Nb97 => 96.9080959f64,
98            Self::Nb98 => 97.9103265f64,
99            Self::Nb99 => 98.911613f64,
100            Self::Nb100 => 99.9143276f64,
101            Self::Nb101 => 100.9153103f64,
102            Self::Nb102 => 101.9180772f64,
103            Self::Nb103 => 102.9194572f64,
104            Self::Nb104 => 103.9228925f64,
105            Self::Nb105 => 104.9249465f64,
106            Self::Nb106 => 105.9289317f64,
107            Self::Nb107 => 106.9315937f64,
108            Self::Nb108 => 107.9360748f64,
109            Self::Nb109 => 108.93922f64,
110            Self::Nb110 => 109.94403f64,
111            Self::Nb111 => 110.94753f64,
112            Self::Nb112 => 111.95247f64,
113            Self::Nb113 => 112.95651f64,
114            Self::Nb114 => 113.96201f64,
115            Self::Nb115 => 114.96634f64,
116        }
117    }
118}
119impl super::ElementVariant for NiobiumIsotope {
120    #[inline]
121    fn element(&self) -> crate::Element {
122        crate::Element::Nb
123    }
124}
125impl super::MassNumber for NiobiumIsotope {
126    #[inline]
127    fn mass_number(&self) -> u16 {
128        match self {
129            Self::Nb81 => 81u16,
130            Self::Nb82 => 82u16,
131            Self::Nb83 => 83u16,
132            Self::Nb84 => 84u16,
133            Self::Nb85 => 85u16,
134            Self::Nb86 => 86u16,
135            Self::Nb87 => 87u16,
136            Self::Nb88 => 88u16,
137            Self::Nb89 => 89u16,
138            Self::Nb90 => 90u16,
139            Self::Nb91 => 91u16,
140            Self::Nb92 => 92u16,
141            Self::Nb93 => 93u16,
142            Self::Nb94 => 94u16,
143            Self::Nb95 => 95u16,
144            Self::Nb96 => 96u16,
145            Self::Nb97 => 97u16,
146            Self::Nb98 => 98u16,
147            Self::Nb99 => 99u16,
148            Self::Nb100 => 100u16,
149            Self::Nb101 => 101u16,
150            Self::Nb102 => 102u16,
151            Self::Nb103 => 103u16,
152            Self::Nb104 => 104u16,
153            Self::Nb105 => 105u16,
154            Self::Nb106 => 106u16,
155            Self::Nb107 => 107u16,
156            Self::Nb108 => 108u16,
157            Self::Nb109 => 109u16,
158            Self::Nb110 => 110u16,
159            Self::Nb111 => 111u16,
160            Self::Nb112 => 112u16,
161            Self::Nb113 => 113u16,
162            Self::Nb114 => 114u16,
163            Self::Nb115 => 115u16,
164        }
165    }
166}
167impl super::IsotopicComposition for NiobiumIsotope {
168    #[inline]
169    fn isotopic_composition(&self) -> Option<f64> {
170        match self {
171            Self::Nb93 => Some(1f64),
172            _ => None,
173        }
174    }
175}
176impl super::MostAbundantIsotope for NiobiumIsotope {
177    fn most_abundant_isotope() -> Self {
178        Self::Nb93
179    }
180}
181impl From<NiobiumIsotope> for crate::Isotope {
182    fn from(isotope: NiobiumIsotope) -> Self {
183        crate::Isotope::Nb(isotope)
184    }
185}
186impl From<NiobiumIsotope> for crate::Element {
187    fn from(_isotope: NiobiumIsotope) -> Self {
188        crate::Element::Nb
189    }
190}
191impl TryFrom<u64> for NiobiumIsotope {
192    type Error = crate::errors::Error;
193    fn try_from(value: u64) -> Result<Self, Self::Error> {
194        match value {
195            81u64 => Ok(Self::Nb81),
196            82u64 => Ok(Self::Nb82),
197            83u64 => Ok(Self::Nb83),
198            84u64 => Ok(Self::Nb84),
199            85u64 => Ok(Self::Nb85),
200            86u64 => Ok(Self::Nb86),
201            87u64 => Ok(Self::Nb87),
202            88u64 => Ok(Self::Nb88),
203            89u64 => Ok(Self::Nb89),
204            90u64 => Ok(Self::Nb90),
205            91u64 => Ok(Self::Nb91),
206            92u64 => Ok(Self::Nb92),
207            93u64 => Ok(Self::Nb93),
208            94u64 => Ok(Self::Nb94),
209            95u64 => Ok(Self::Nb95),
210            96u64 => Ok(Self::Nb96),
211            97u64 => Ok(Self::Nb97),
212            98u64 => Ok(Self::Nb98),
213            99u64 => Ok(Self::Nb99),
214            100u64 => Ok(Self::Nb100),
215            101u64 => Ok(Self::Nb101),
216            102u64 => Ok(Self::Nb102),
217            103u64 => Ok(Self::Nb103),
218            104u64 => Ok(Self::Nb104),
219            105u64 => Ok(Self::Nb105),
220            106u64 => Ok(Self::Nb106),
221            107u64 => Ok(Self::Nb107),
222            108u64 => Ok(Self::Nb108),
223            109u64 => Ok(Self::Nb109),
224            110u64 => Ok(Self::Nb110),
225            111u64 => Ok(Self::Nb111),
226            112u64 => Ok(Self::Nb112),
227            113u64 => Ok(Self::Nb113),
228            114u64 => Ok(Self::Nb114),
229            115u64 => Ok(Self::Nb115),
230            _ => Err(crate::errors::Error::Isotope(crate::Element::Nb, value)),
231        }
232    }
233}
234impl TryFrom<u8> for NiobiumIsotope {
235    type Error = crate::errors::Error;
236    fn try_from(value: u8) -> Result<Self, Self::Error> {
237        Self::try_from(u64::from(value))
238    }
239}
240impl TryFrom<u16> for NiobiumIsotope {
241    type Error = crate::errors::Error;
242    fn try_from(value: u16) -> Result<Self, Self::Error> {
243        Self::try_from(u64::from(value))
244    }
245}
246impl TryFrom<u32> for NiobiumIsotope {
247    type Error = crate::errors::Error;
248    fn try_from(value: u32) -> Result<Self, Self::Error> {
249        Self::try_from(u64::from(value))
250    }
251}
252impl core::fmt::Display for NiobiumIsotope {
253    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
254        match self {
255            Self::Nb81 => write!(f, "Nb81"),
256            Self::Nb82 => write!(f, "Nb82"),
257            Self::Nb83 => write!(f, "Nb83"),
258            Self::Nb84 => write!(f, "Nb84"),
259            Self::Nb85 => write!(f, "Nb85"),
260            Self::Nb86 => write!(f, "Nb86"),
261            Self::Nb87 => write!(f, "Nb87"),
262            Self::Nb88 => write!(f, "Nb88"),
263            Self::Nb89 => write!(f, "Nb89"),
264            Self::Nb90 => write!(f, "Nb90"),
265            Self::Nb91 => write!(f, "Nb91"),
266            Self::Nb92 => write!(f, "Nb92"),
267            Self::Nb93 => write!(f, "Nb93"),
268            Self::Nb94 => write!(f, "Nb94"),
269            Self::Nb95 => write!(f, "Nb95"),
270            Self::Nb96 => write!(f, "Nb96"),
271            Self::Nb97 => write!(f, "Nb97"),
272            Self::Nb98 => write!(f, "Nb98"),
273            Self::Nb99 => write!(f, "Nb99"),
274            Self::Nb100 => write!(f, "Nb100"),
275            Self::Nb101 => write!(f, "Nb101"),
276            Self::Nb102 => write!(f, "Nb102"),
277            Self::Nb103 => write!(f, "Nb103"),
278            Self::Nb104 => write!(f, "Nb104"),
279            Self::Nb105 => write!(f, "Nb105"),
280            Self::Nb106 => write!(f, "Nb106"),
281            Self::Nb107 => write!(f, "Nb107"),
282            Self::Nb108 => write!(f, "Nb108"),
283            Self::Nb109 => write!(f, "Nb109"),
284            Self::Nb110 => write!(f, "Nb110"),
285            Self::Nb111 => write!(f, "Nb111"),
286            Self::Nb112 => write!(f, "Nb112"),
287            Self::Nb113 => write!(f, "Nb113"),
288            Self::Nb114 => write!(f, "Nb114"),
289            Self::Nb115 => write!(f, "Nb115"),
290        }
291    }
292}
293#[cfg(test)]
294mod tests {
295    use strum::IntoEnumIterator;
296
297    use super::*;
298    use crate::isotopes::{
299        ElementVariant, IsotopicComposition, MassNumber, MostAbundantIsotope, RelativeAtomicMass,
300    };
301    #[test]
302    fn test_relative_atomic_mass() {
303        for isotope in NiobiumIsotope::iter() {
304            let mass = isotope.relative_atomic_mass();
305            assert!(mass > 0.0, "Mass should be positive for {isotope:?}");
306        }
307    }
308    #[test]
309    fn test_element() {
310        for isotope in NiobiumIsotope::iter() {
311            let element = isotope.element();
312            assert_eq!(element, crate::Element::Nb, "Element should be correct for {isotope:?}");
313        }
314    }
315    #[test]
316    fn test_mass_number() {
317        for isotope in NiobiumIsotope::iter() {
318            let mass_number = isotope.mass_number();
319            assert!(
320                mass_number > 0 && mass_number < 300,
321                "Mass number should be reasonable for {isotope:?}"
322            );
323        }
324    }
325    #[test]
326    fn test_isotopic_composition() {
327        for isotope in NiobiumIsotope::iter() {
328            let comp = isotope.isotopic_composition();
329            if let Some(c) = comp {
330                assert!(
331                    (0.0..=1.0).contains(&c),
332                    "Composition should be between 0 and 1 for {isotope:?}"
333                );
334            }
335        }
336    }
337    #[test]
338    fn test_most_abundant() {
339        let most_abundant = NiobiumIsotope::most_abundant_isotope();
340        let _ = most_abundant.relative_atomic_mass();
341    }
342    #[test]
343    fn test_from_isotope() {
344        for isotope in NiobiumIsotope::iter() {
345            let iso: crate::Isotope = isotope.into();
346            match iso {
347                crate::Isotope::Nb(i) => assert_eq!(i, isotope),
348                _ => panic!("Wrong isotope type"),
349            }
350        }
351    }
352    #[test]
353    fn test_from_element() {
354        for isotope in NiobiumIsotope::iter() {
355            let elem: crate::Element = isotope.into();
356            assert_eq!(elem, crate::Element::Nb);
357        }
358    }
359    #[test]
360    fn test_try_from_mass_number() {
361        for isotope in NiobiumIsotope::iter() {
362            let mass = isotope.mass_number();
363            let iso = NiobiumIsotope::try_from(mass).unwrap();
364            assert_eq!(iso, isotope);
365            let iso_u32 = NiobiumIsotope::try_from(u32::from(mass)).unwrap();
366            assert_eq!(iso_u32, isotope);
367            if let Ok(mass_u8) = u8::try_from(mass) {
368                let iso_u8 = NiobiumIsotope::try_from(mass_u8).unwrap();
369                assert_eq!(iso_u8, isotope);
370            }
371        }
372        assert!(NiobiumIsotope::try_from(0_u16).is_err());
373        assert!(NiobiumIsotope::try_from(1000_u16).is_err());
374        assert!(NiobiumIsotope::try_from(0_u32).is_err());
375        assert!(NiobiumIsotope::try_from(1000_u32).is_err());
376        assert!(NiobiumIsotope::try_from(0_u8).is_err());
377    }
378    #[test]
379    fn test_display() {
380        for isotope in NiobiumIsotope::iter() {
381            let s = alloc::format!("{isotope}");
382            assert!(!s.is_empty(), "Display should not be empty for {isotope:?}");
383        }
384    }
385}