Struct Zai

Source
pub struct Zai { /* private fields */ }
Expand description

Nuclide identifier ZAI.

  • Z: atomic number / proton number / nuclear charge number
  • A: mass number / nucleon number
  • I: isomeric state number / nuclear energy state / metastable state level

§Examples

use nkl::core::{Element, Zai};

// From atomic/mass/isomeric-state numbers
let h1 = Zai::new(1, 1, 0);
// From standard name
let h1 = Zai::from_name("H1").unwrap();
// From id
let h1 = Zai::from_id(10010).unwrap();

assert_eq!(h1.atomic_number(), 1);
assert_eq!(h1.mass_number(), 1);
assert_eq!(h1.isomeric_state_number(), 0);
assert_eq!(h1.element(), Element::Hydrogen)

Implementations§

Source§

impl Zai

Source

pub fn new( atomic_number: u32, mass_number: u32, isomeric_state_number: u32, ) -> Self

Creates a new nuclide identifier (ZAI) from specified numbers.

§Parameters
  • atomic_number: atomic number Z
  • mass_number: mass number A
  • isomeric_state_number: isomeric state number I
§Examples
use nkl::core::Zai;

// H1 -> Z = 1, A = 1, I = 0
let protium = Zai::new(1, 1, 0);
// H2 -> Z = 1, A = 2, I = 0
let deuterium = Zai::new(1, 2, 0);
// H3 -> Z = 1, A = 3, I = 0
let tritium = Zai::new(1, 3, 0);
§Panics

Panics if

  • atomic_number[1, 118]
  • number of nucleons is less than number of protons (mass_number < atomic_number)
  • mass_number >= 1000
  • isomeric_state_number >= 10
Source

pub fn from_name(name: &str) -> Option<Self>

Creates a new nuclide identifier from nuclide’s name.

§Format
  • Ground state nuclide: XxAAA
  • Metastable nuclide: XxAAAmI

with:

  • Xx: one or two letter element’s symbol (see Element)
  • AAA: one to three (inclusive) digit(s) mass number
  • I: one digit isomeric state number
§Returns
  • Some(zai) if name is a conformant nuclide’s name
  • None otherwise
§Examples
use nkl::core::Zai;

// H1 -> Z = 1, A = 1, I = 0
assert_eq!(Zai::from_name("H1"), Some(Zai::new(1, 1, 0)));
// U235 -> Z = 92, A = 235, I = 0
assert_eq!(Zai::from_name("U235"), Some(Zai::new(92, 235, 0)));
// Pu239 -> Z = 94, A = 239, I = 0
assert_eq!(Zai::from_name("Pu239"), Some(Zai::new(94, 239, 0)));
// Am242 -> Z = 95, A = 242, I = 0
assert_eq!(Zai::from_name("Am242"), Some(Zai::new(95, 242, 0)));
// Am242m1 -> Z = 95, A = 242, I = 1
assert_eq!(Zai::from_name("Am242m1"), Some(Zai::new(95, 242, 1)));
// Am242m1 -> Z = 95, A = 242, I = 2
assert_eq!(Zai::from_name("Am242m2"), Some(Zai::new(95, 242, 2)));
Source

pub fn from_id(id: u32) -> Option<Self>

Creates a new nuclide identifier from nuclide’s id.

§Format
ID = Z × 10000 + A × 10 + I

with:

  • Z: atomic number
  • A: mass number
  • I: isomeric state number
§Returns
  • Some(zai) if id is a conformant nuclide’s id
  • None otherwise
§Examples
use nkl::core::Zai;

// H1 -> Z = 1, A = 1, I = 0
assert_eq!(Zai::from_id(10010), Some(Zai::new(1, 1, 0)));
// U235 -> Z = 92, A = 235, I = 0
assert_eq!(Zai::from_id(922350), Some(Zai::new(92, 235, 0)));
// Pu239 -> Z = 94, A = 239, I = 0
assert_eq!(Zai::from_id(942390), Some(Zai::new(94, 239, 0)));
// Am242 -> Z = 95, A = 242, I = 0
assert_eq!(Zai::from_id(952420), Some(Zai::new(95, 242, 0)));
// Am242m1 -> Z = 95, A = 242, I = 1
assert_eq!(Zai::from_id(952421), Some(Zai::new(95, 242, 1)));
// Am242m2 -> Z = 95, A = 242, I = 2
assert_eq!(Zai::from_id(952422), Some(Zai::new(95, 242, 2)));
Source

pub fn atomic_number(&self) -> u32

Returns atomic number Z.

§Examples
use nkl::core::Zai;

let zai = Zai::new(1, 2, 0);
assert_eq!(zai.atomic_number(), 1);
Source

pub fn mass_number(&self) -> u32

Returns mass number A.

§Examples
use nkl::core::Zai;

let zai = Zai::new(1, 2, 0);
assert_eq!(zai.mass_number(), 2);
Source

pub fn isomeric_state_number(&self) -> u32

Returns isomeric state number I.

§Examples
use nkl::core::Zai;

let zai = Zai::new(1, 2, 0);
assert_eq!(zai.isomeric_state_number(), 0);
Source

pub fn id(&self) -> u32

Returns nuclide ID.

§Format

Nuclide ID is given by:

ID = Z × 10000 + A × 10 + I

with:

  • Z: atomic number
  • A: mass number
  • I: isomeric state number
§Examples
use nkl::core::Zai;

let h1 = Zai::new(1, 1, 0);
assert_eq!(h1.id(), 10010);

let u235 = Zai::new(92, 235, 0);
assert_eq!(u235.id(), 922350);

let am242m1 = Zai::new(95, 242, 1);
assert_eq!(am242m1.id(), 952421);

let am242m2 = Zai::new(95, 242, 2);
assert_eq!(am242m2.id(), 952422);
Source

pub fn protons(&self) -> u32

Returns number of protons Z (identical to atomic number).

§Examples
use nkl::core::Zai;

let tritium = Zai::new(1, 3, 0);
assert_eq!(tritium.protons(), 1);
§See also

atomic_number

Source

pub fn neutrons(&self) -> u32

Returns number of neutrons N = A - Z.

§Examples
use nkl::core::Zai;

let tritium = Zai::new(1, 3, 0);
assert_eq!(tritium.neutrons(), 2);
Source

pub fn nucleons(&self) -> u32

Returns number of nucleons A (identical to mass number).

§Examples
use nkl::core::Zai;

let tritium = Zai::new(1, 3, 0);
assert_eq!(tritium.nucleons(), 3);
§See also

mass_number

Source

pub fn element(&self) -> Element

Returns nuclide identifier’s chemical element.

§Examples
use nkl::core::{Element, Zai};

let protium = Zai::new(1, 1, 0);
assert_eq!(protium.element(), Element::Hydrogen);
§See Also
Source

pub fn as_tuple(&self) -> (u32, u32, u32)

Converts ZAI to (Z, A, I) tuple.

§Examples
use nkl::core::Zai;

let zai = Zai::new(1, 2, 0);
assert_eq!(zai.as_tuple(), (1, 2, 0));
Source

pub fn into_tuple(self) -> (u32, u32, u32)

Converts ZAI into (Z, A, I) tuple.

§Examples
use nkl::core::Zai;

let zai = Zai::new(1, 2, 0);
assert_eq!(zai.into_tuple(), (1, 2, 0));
Source

pub fn is_ground_state(&self) -> bool

Returns true if the nuclide identifier isomeric state I is 0.

§Examples
use nkl::core::Zai;

let tc99 = Zai::new(43, 99, 0);
assert!(tc99.is_ground_state());
Source

pub fn is_metastable_state(&self) -> bool

Returns true if the nuclide identifier isomeric state I is not 0.

§Examples
use nkl::core::Zai;

let tc99m1 = Zai::new(43, 99, 1);
assert!(tc99m1.is_metastable_state());
Source

pub fn name(&self) -> String

Returns nuclide’s name identified by this ZAI identifier.

§Examples
use nkl::core::Zai;

let h1 = Zai::new(1, 1, 0);
assert_eq!(h1.name(), "H1");

let tc99m1 = Zai::new(43, 99, 1);
assert_eq!(tc99m1.name(), "Tc99m1");

Trait Implementations§

Source§

impl Clone for Zai

Source§

fn clone(&self) -> Zai

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Zai

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Zai

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Zai

Source§

fn cmp(&self, other: &Zai) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Zai

Source§

fn eq(&self, other: &Zai) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Zai

Source§

fn partial_cmp(&self, other: &Zai) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Zai

Source§

impl Eq for Zai

Source§

impl StructuralPartialEq for Zai

Auto Trait Implementations§

§

impl Freeze for Zai

§

impl RefUnwindSafe for Zai

§

impl Send for Zai

§

impl Sync for Zai

§

impl Unpin for Zai

§

impl UnwindSafe for Zai

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.