Struct DecayLaw
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§
§impl DecayLaw
impl DecayLaw
pub 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.
pub 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.
pub fn mean_lifetime(&self) -> Option<f64>
pub fn mean_lifetime(&self) -> Option<f64>
Returns the mean lifetime for this decay law.
pub 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.
pub 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);pub fn decayed_quantity(&self, initial_quantity: f64, time: f64) -> Option<f64>
pub fn decayed_quantity(&self, initial_quantity: f64, time: f64) -> Option<f64>
Returns the decayed quantity after the given elapsed time.
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