pub struct Dose {
pub absorbed_dose: f64,
}Expand description
A simple absorbed dose wrapper in gray.
Fields§
§absorbed_dose: f64Absorbed dose in gray.
Implementations§
Source§impl Dose
impl Dose
Sourcepub fn new(absorbed_dose: f64) -> Option<Self>
pub fn new(absorbed_dose: f64) -> Option<Self>
Creates a dose from a non-negative finite absorbed dose.
Examples found in repository?
examples/basic_usage.rs (line 8)
5fn main() -> Result<(), &'static str> {
6 let beam = RadiationBeam::new(10.0, 2.0).ok_or("expected valid beam")?;
7 let shield = Shield::new(core::f64::consts::LN_2, 1.0).ok_or("expected valid shield")?;
8 let dose = Dose::new(2.0).ok_or("expected valid dose")?;
9 let weighting = default_radiation_weighting_factor(RadiationKind::Gamma)
10 .ok_or("expected gamma weighting")?;
11
12 assert_eq!(beam.intensity(), Some(5.0));
13 assert_eq!(beam.photon_flux(2.0), Some(5.0));
14 assert!(
15 (shield
16 .transmitted_fraction()
17 .ok_or("expected transmitted fraction")?
18 - 0.5)
19 .abs()
20 < 1.0e-12
21 );
22 assert_eq!(dose.equivalent(weighting), Some(2.0));
23
24 Ok(())
25}Sourcepub fn equivalent(self, radiation_weighting_factor: f64) -> Option<f64>
pub fn equivalent(self, radiation_weighting_factor: f64) -> Option<f64>
Computes equivalent dose from this absorbed dose.
§Examples
use use_radiation::Dose;
let dose = Dose::new(2.0).ok_or("expected dose")?;
assert_eq!(dose.equivalent(20.0), Some(40.0));Examples found in repository?
examples/basic_usage.rs (line 22)
5fn main() -> Result<(), &'static str> {
6 let beam = RadiationBeam::new(10.0, 2.0).ok_or("expected valid beam")?;
7 let shield = Shield::new(core::f64::consts::LN_2, 1.0).ok_or("expected valid shield")?;
8 let dose = Dose::new(2.0).ok_or("expected valid dose")?;
9 let weighting = default_radiation_weighting_factor(RadiationKind::Gamma)
10 .ok_or("expected gamma weighting")?;
11
12 assert_eq!(beam.intensity(), Some(5.0));
13 assert_eq!(beam.photon_flux(2.0), Some(5.0));
14 assert!(
15 (shield
16 .transmitted_fraction()
17 .ok_or("expected transmitted fraction")?
18 - 0.5)
19 .abs()
20 < 1.0e-12
21 );
22 assert_eq!(dose.equivalent(weighting), Some(2.0));
23
24 Ok(())
25}Trait Implementations§
impl Copy for Dose
impl StructuralPartialEq for Dose
Auto Trait Implementations§
impl Freeze for Dose
impl RefUnwindSafe for Dose
impl Send for Dose
impl Sync for Dose
impl Unpin for Dose
impl UnsafeUnpin for Dose
impl UnwindSafe for Dose
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