pub struct DecayLaw {
pub decay_constant: f64,
}Expand description
Simple exponential-decay law parameterized by a decay constant.
Fields§
§decay_constant: f64Decay constant in inverse time units.
Implementations§
Source§impl DecayLaw
impl DecayLaw
Sourcepub fn from_decay_constant(decay_constant: f64) -> Option<DecayLaw>
pub fn from_decay_constant(decay_constant: f64) -> Option<DecayLaw>
Creates a decay law from a non-negative, finite decay constant.
Sourcepub fn from_half_life(half_life: f64) -> Option<DecayLaw>
pub fn from_half_life(half_life: f64) -> Option<DecayLaw>
Creates a decay law from a positive, finite half-life.
Sourcepub fn mean_lifetime(&self) -> Option<f64>
pub fn mean_lifetime(&self) -> Option<f64>
Returns the mean lifetime for this decay law.
Sourcepub fn remaining_fraction(&self, time: f64) -> Option<f64>
pub fn remaining_fraction(&self, time: f64) -> Option<f64>
Returns the remaining fraction after the given elapsed time.
Sourcepub fn remaining_quantity(
&self,
initial_quantity: f64,
time: f64,
) -> Option<f64>
pub fn remaining_quantity( &self, initial_quantity: f64, time: f64, ) -> Option<f64>
Returns the remaining quantity after the given elapsed time.
§Examples
use use_nuclear::DecayLaw;
let decay_law = DecayLaw::from_half_life(10.0).ok_or("expected valid half-life")?;
let remaining = decay_law
.remaining_quantity(100.0, 10.0)
.ok_or("expected valid remaining quantity")?;
assert!((remaining - 50.0).abs() < 1.0e-12);Trait Implementations§
impl Copy for DecayLaw
impl StructuralPartialEq for DecayLaw
Auto Trait Implementations§
impl Freeze for DecayLaw
impl RefUnwindSafe for DecayLaw
impl Send for DecayLaw
impl Sync for DecayLaw
impl Unpin for DecayLaw
impl UnsafeUnpin for DecayLaw
impl UnwindSafe for DecayLaw
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more