Skip to main content

NuclideNumbers

Struct NuclideNumbers 

Source
pub struct NuclideNumbers {
    pub mass_number: u32,
    pub atomic_number: u32,
}
Expand description

Mass and atomic numbers for a nuclide.

Fields§

§mass_number: u32

Mass number A, equal to total nucleons.

§atomic_number: u32

Atomic number Z, equal to total protons.

Implementations§

Source§

impl NuclideNumbers

Source

pub const fn new(mass_number: u32, atomic_number: u32) -> Option<Self>

Creates validated nuclide numbers.

§Examples
use use_nuclear::NuclideNumbers;

let helium = NuclideNumbers::new(4, 2);

assert_eq!(helium, Some(NuclideNumbers { mass_number: 4, atomic_number: 2 }));
Examples found in repository?
examples/basic_usage.rs (line 13)
8fn main() -> Result<(), &'static str> {
9    let decay_law = DecayLaw::from_half_life(10.0).ok_or("expected valid half-life")?;
10    let remaining = decay_law
11        .remaining_quantity(100.0, 10.0)
12        .ok_or("expected valid remaining quantity")?;
13    let helium = NuclideNumbers::new(4, 2).ok_or("expected valid nuclide numbers")?;
14
15    assert!((remaining - 50.0).abs() < 1.0e-12);
16    assert_eq!(activity(2.0, 10.0), Some(20.0));
17    assert_eq!(helium.proton_count(), 2);
18    assert_eq!(helium.neutron_count(), 2);
19    assert_eq!(
20        binding_energy_mev_from_mass_defect_u(1.0),
21        Some(ATOMIC_MASS_UNIT_MEV_C2),
22    );
23
24    Ok(())
25}
Source

pub const fn proton_count(&self) -> u32

Returns the proton count for this nuclide.

Examples found in repository?
examples/basic_usage.rs (line 17)
8fn main() -> Result<(), &'static str> {
9    let decay_law = DecayLaw::from_half_life(10.0).ok_or("expected valid half-life")?;
10    let remaining = decay_law
11        .remaining_quantity(100.0, 10.0)
12        .ok_or("expected valid remaining quantity")?;
13    let helium = NuclideNumbers::new(4, 2).ok_or("expected valid nuclide numbers")?;
14
15    assert!((remaining - 50.0).abs() < 1.0e-12);
16    assert_eq!(activity(2.0, 10.0), Some(20.0));
17    assert_eq!(helium.proton_count(), 2);
18    assert_eq!(helium.neutron_count(), 2);
19    assert_eq!(
20        binding_energy_mev_from_mass_defect_u(1.0),
21        Some(ATOMIC_MASS_UNIT_MEV_C2),
22    );
23
24    Ok(())
25}
Source

pub const fn neutron_count(&self) -> u32

Returns the neutron count for this nuclide.

Examples found in repository?
examples/basic_usage.rs (line 18)
8fn main() -> Result<(), &'static str> {
9    let decay_law = DecayLaw::from_half_life(10.0).ok_or("expected valid half-life")?;
10    let remaining = decay_law
11        .remaining_quantity(100.0, 10.0)
12        .ok_or("expected valid remaining quantity")?;
13    let helium = NuclideNumbers::new(4, 2).ok_or("expected valid nuclide numbers")?;
14
15    assert!((remaining - 50.0).abs() < 1.0e-12);
16    assert_eq!(activity(2.0, 10.0), Some(20.0));
17    assert_eq!(helium.proton_count(), 2);
18    assert_eq!(helium.neutron_count(), 2);
19    assert_eq!(
20        binding_energy_mev_from_mass_defect_u(1.0),
21        Some(ATOMIC_MASS_UNIT_MEV_C2),
22    );
23
24    Ok(())
25}
Source

pub const fn nucleon_count(&self) -> u32

Returns the total nucleon count for this nuclide.

Trait Implementations§

Source§

impl Clone for NuclideNumbers

Source§

fn clone(&self) -> NuclideNumbers

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for NuclideNumbers

Source§

impl Debug for NuclideNumbers

Source§

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

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

impl Eq for NuclideNumbers

Source§

impl PartialEq for NuclideNumbers

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NuclideNumbers

Auto Trait Implementations§

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.