|
| 1 | +//! Radioactivity (base unit becquerel, s⁻¹). |
| 2 | +
|
| 3 | +quantity! { |
| 4 | + /// Radioactivity (base unit becquerel, s⁻¹). |
| 5 | + quantity: Radioactivity; "radioactivity"; |
| 6 | + /// Dimension of radioactivity, T⁻¹ (base unit becquerel, s⁻¹). |
| 7 | + dimension: ISQ< |
| 8 | + Z0, // length |
| 9 | + Z0, // mass |
| 10 | + N1, // time |
| 11 | + Z0, // electric current |
| 12 | + Z0, // thermodynamic temperature |
| 13 | + Z0, // amount of substance |
| 14 | + Z0>; // luminous intensity |
| 15 | + kind: dyn (crate::si::marker::ConstituentConcentrationKind); |
| 16 | + units { |
| 17 | + @yottabecquerel: prefix!(yotta); "YBq", "yottabecquerel", "yottabecquerels"; |
| 18 | + @zettabecquerel: prefix!(zetta); "ZBq", "zettabecquerel", "zettabecquerels"; |
| 19 | + @exabecquerel: prefix!(exa); "EBq", "exabecquerel", "exabecquerels"; |
| 20 | + @petabecquerel: prefix!(peta); "PBq", "petabecquerel", "petabecquerels"; |
| 21 | + @terabecquerel: prefix!(tera); "TBq", "terabecquerel", "terabecquerels"; |
| 22 | + @gigabecquerel: prefix!(giga); "GBq", "gigabecquerel", "gigabecquerels"; |
| 23 | + @megabecquerel: prefix!(mega); "MBq", "megabecquerel", "megabecquerels"; |
| 24 | + @kilobecquerel: prefix!(kilo); "kBq", "kilobecquerel", "kilobecquerels"; |
| 25 | + @hectobecquerel: prefix!(hecto); "hBq", "hectobecquerel", "hectobecquerels"; |
| 26 | + @decabecquerel: prefix!(deca); "daBq", "decabecquerel", "decabecquerels"; |
| 27 | + /// The becquerel is one decay per second. |
| 28 | + @becquerel: prefix!(none); "Bq", "becquerel", "becquerels"; |
| 29 | + @millibecquerel: prefix!(milli); "mBq", "millibecquerel", "millibecquerels"; |
| 30 | + @microbecquerel: prefix!(micro); "µBq", "microbecquerel", "microbecquerels"; |
| 31 | + @nanobecquerel: prefix!(nano); "nBq", "nanobecquerel", "nanobecquerels"; |
| 32 | + |
| 33 | + @gigacurie: prefix!(giga) * 3.7_E10; "GCi", "gigacurie", "gigacuries"; |
| 34 | + @megacurie: prefix!(mega) * 3.7_E10; "MCi", "megacurie", "megacuries"; |
| 35 | + @kilocurie: prefix!(kilo) * 3.7_E10; "kCi", "kilocurie", "kilocuries"; |
| 36 | + @curie: 3.7_E10; "Ci", "curie", "curies"; |
| 37 | + @millicurie: prefix!(milli) * 3.7_E10; "mCi", "millicurie", "millicuries"; |
| 38 | + @microcurie: prefix!(micro) * 3.7_E10; "µCi", "microcurie", "microcuries"; |
| 39 | + @nanocurie: prefix!(nano) * 3.7_E10; "nCi", "nanocurie", "nanocuries"; |
| 40 | + |
| 41 | + @disintegrations_per_minute: 1.0 / 6.0_E1; "dpm", "disintegration per minute", |
| 42 | + "disintegrations per minute"; |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +#[cfg(test)] |
| 47 | +mod tests { |
| 48 | + storage_types! { |
| 49 | + use crate::num::{FromPrimitive, One}; |
| 50 | + use crate::si::radioactivity as rad; |
| 51 | + use crate::si::quantities::*; |
| 52 | + use crate::si::time as t; |
| 53 | + use crate::tests::Test; |
| 54 | + |
| 55 | + #[test] |
| 56 | + fn check_dimension() { |
| 57 | + let _: Time<V> = (V::one() / Radioactivity::new::<rad::becquerel>(V::one())).into(); |
| 58 | + let _: Radioactivity<V> = (V::one() / Time::new::<t::second>(V::one())).into(); |
| 59 | + } |
| 60 | + |
| 61 | + #[test] |
| 62 | + fn check_units() { |
| 63 | + test::<t::second, rad::becquerel>(); |
| 64 | + test::<t::decisecond, rad::decabecquerel>(); |
| 65 | + test::<t::centisecond, rad::hectobecquerel>(); |
| 66 | + test::<t::millisecond, rad::kilobecquerel>(); |
| 67 | + test::<t::microsecond, rad::megabecquerel>(); |
| 68 | + test::<t::nanosecond, rad::gigabecquerel>(); |
| 69 | + test::<t::picosecond, rad::terabecquerel>(); |
| 70 | + test::<t::femtosecond, rad::petabecquerel>(); |
| 71 | + test::<t::attosecond, rad::exabecquerel>(); |
| 72 | + test::<t::zeptosecond, rad::zettabecquerel>(); |
| 73 | + test::<t::yoctosecond, rad::yottabecquerel>(); |
| 74 | + |
| 75 | + fn test<T: t::Conversion<V>, RAD: rad::Conversion<V>>() { |
| 76 | + Test::assert_approx_eq(&(V::one() / Time::new::<T>(V::one())), |
| 77 | + &Radioactivity::new::<RAD>(V::one()).into()); |
| 78 | + Test::assert_approx_eq(&Time::new::<T>(V::one()), |
| 79 | + &(V::one() / Radioactivity::new::<RAD>(V::one())).into()); |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + #[test] |
| 84 | + fn check_curie() { |
| 85 | + test::<rad::gigabecquerel, rad::gigacurie>(); |
| 86 | + test::<rad::megabecquerel, rad::megacurie>(); |
| 87 | + test::<rad::kilobecquerel, rad::kilocurie>(); |
| 88 | + test::<rad::becquerel, rad::curie>(); |
| 89 | + test::<rad::millibecquerel, rad::millicurie>(); |
| 90 | + test::<rad::microbecquerel, rad::microcurie>(); |
| 91 | + test::<rad::nanobecquerel, rad::nanocurie>(); |
| 92 | + |
| 93 | + fn test<RadBq: rad::Conversion<V>, RadCi: rad::Conversion<V>>() { |
| 94 | + Test::assert_approx_eq( |
| 95 | + &(V::one() * V::from_f64(3.7_E10).unwrap() |
| 96 | + * Radioactivity::new::<RadBq>(V::one())), |
| 97 | + &Radioactivity::new::<RadCi>(V::one())); |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + #[test] |
| 102 | + fn check_dpm() { |
| 103 | + test::<rad::becquerel, rad::disintegrations_per_minute>(); |
| 104 | + |
| 105 | + fn test<RadBq: rad::Conversion<V>, RadCi: rad::Conversion<V>>() { |
| 106 | + Test::assert_approx_eq(&(V::one() / V::from_f64(6_E1).unwrap() |
| 107 | + * Radioactivity::new::<RadBq>(V::one())), |
| 108 | + &Radioactivity::new::<RadCi>(V::one())); |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | +} |
0 commit comments