-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from crystal-growth/add_radioactivity
Add quantities for radioactivity, molar radioactivity, and specific radioactivity.
- Loading branch information
Showing
5 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! Molar radioactivity (base unit becquerel per mole, s⁻¹ · mol⁻¹). | ||
quantity! { | ||
/// Molar radioactivity (base unit becquerel per mole, s⁻¹ · mol⁻¹). | ||
quantity: MolarRadioactivity; "molar radioactivity"; | ||
/// Dimension of molar radioactivity, T⁻¹N⁻¹ (base unit becquerel per mole, s⁻¹ · mol⁻¹). | ||
dimension: ISQ< | ||
Z0, // length | ||
Z0, // mass | ||
N1, // time | ||
Z0, // electric current | ||
Z0, // thermodynamic temperature | ||
N1, // amount of substance | ||
Z0>; // luminous intensity | ||
kind: dyn (crate::si::marker::ConstituentConcentrationKind); | ||
units { | ||
@becquerel_per_mole: prefix!(none); "Bq/mol", "becquerel per mole", "becquerels per mole"; | ||
|
||
@curie_per_mole: 3.7_E10; "Ci/mol", "curie per mole", "curies per mole"; | ||
|
||
@disintegrations_per_minute_per_mole: 1.0 / 6.0_E1; "dpm/mol", | ||
"disintegration per minute per mole", "disintegrations per minute per mole"; | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
storage_types! { | ||
use crate::num::One; | ||
use crate::si::radioactivity as rad; | ||
use crate::si::molar_radioactivity as mrad; | ||
use crate::si::quantities::*; | ||
use crate::si::amount_of_substance as aos; | ||
use crate::tests::Test; | ||
|
||
#[test] | ||
fn check_dimension() { | ||
let _: MolarRadioactivity<V> = (Radioactivity::new::<rad::becquerel>(V::one()) | ||
/ AmountOfSubstance::new::<aos::mole>(V::one())).into(); | ||
} | ||
|
||
#[test] | ||
fn check_units() { | ||
test::<rad::becquerel, aos::mole, mrad::becquerel_per_mole>(); | ||
test::<rad::curie, aos::mole, mrad::curie_per_mole>(); | ||
test::<rad::disintegrations_per_minute, aos::mole, | ||
mrad::disintegrations_per_minute_per_mole>(); | ||
|
||
fn test<RAD: rad::Conversion<V>, AOS: aos::Conversion<V>, SRAD: mrad::Conversion<V>>() { | ||
Test::assert_approx_eq(&MolarRadioactivity::new::<SRAD>(V::one()), | ||
&(Radioactivity::new::<RAD>(V::one()) | ||
/ AmountOfSubstance::new::<AOS>(V::one())).into()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
//! Radioactivity (base unit becquerel, s⁻¹). | ||
quantity! { | ||
/// Radioactivity (base unit becquerel, s⁻¹). | ||
quantity: Radioactivity; "radioactivity"; | ||
/// Dimension of radioactivity, T⁻¹ (base unit becquerel, s⁻¹). | ||
dimension: ISQ< | ||
Z0, // length | ||
Z0, // mass | ||
N1, // time | ||
Z0, // electric current | ||
Z0, // thermodynamic temperature | ||
Z0, // amount of substance | ||
Z0>; // luminous intensity | ||
kind: dyn (crate::si::marker::ConstituentConcentrationKind); | ||
units { | ||
@yottabecquerel: prefix!(yotta); "YBq", "yottabecquerel", "yottabecquerels"; | ||
@zettabecquerel: prefix!(zetta); "ZBq", "zettabecquerel", "zettabecquerels"; | ||
@exabecquerel: prefix!(exa); "EBq", "exabecquerel", "exabecquerels"; | ||
@petabecquerel: prefix!(peta); "PBq", "petabecquerel", "petabecquerels"; | ||
@terabecquerel: prefix!(tera); "TBq", "terabecquerel", "terabecquerels"; | ||
@gigabecquerel: prefix!(giga); "GBq", "gigabecquerel", "gigabecquerels"; | ||
@megabecquerel: prefix!(mega); "MBq", "megabecquerel", "megabecquerels"; | ||
@kilobecquerel: prefix!(kilo); "kBq", "kilobecquerel", "kilobecquerels"; | ||
@hectobecquerel: prefix!(hecto); "hBq", "hectobecquerel", "hectobecquerels"; | ||
@decabecquerel: prefix!(deca); "daBq", "decabecquerel", "decabecquerels"; | ||
/// The becquerel is one decay per second. | ||
@becquerel: prefix!(none); "Bq", "becquerel", "becquerels"; | ||
@millibecquerel: prefix!(milli); "mBq", "millibecquerel", "millibecquerels"; | ||
@microbecquerel: prefix!(micro); "µBq", "microbecquerel", "microbecquerels"; | ||
@nanobecquerel: prefix!(nano); "nBq", "nanobecquerel", "nanobecquerels"; | ||
|
||
@gigacurie: prefix!(giga) * 3.7_E10; "GCi", "gigacurie", "gigacuries"; | ||
@megacurie: prefix!(mega) * 3.7_E10; "MCi", "megacurie", "megacuries"; | ||
@kilocurie: prefix!(kilo) * 3.7_E10; "kCi", "kilocurie", "kilocuries"; | ||
@curie: 3.7_E10; "Ci", "curie", "curies"; | ||
@millicurie: prefix!(milli) * 3.7_E10; "mCi", "millicurie", "millicuries"; | ||
@microcurie: prefix!(micro) * 3.7_E10; "µCi", "microcurie", "microcuries"; | ||
@nanocurie: prefix!(nano) * 3.7_E10; "nCi", "nanocurie", "nanocuries"; | ||
|
||
@disintegrations_per_minute: 1.0 / 6.0_E1; "dpm", "disintegration per minute", | ||
"disintegrations per minute"; | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
storage_types! { | ||
use crate::num::One; | ||
use crate::si::radioactivity as rad; | ||
use crate::si::quantities::*; | ||
use crate::si::time as t; | ||
use crate::tests::Test; | ||
|
||
#[test] | ||
fn check_dimension() { | ||
let _: Time<V> = (V::one() / Radioactivity::new::<rad::becquerel>(V::one())).into(); | ||
let _: Radioactivity<V> = (V::one() / Time::new::<t::second>(V::one())).into(); | ||
} | ||
|
||
#[test] | ||
fn check_units() { | ||
test::<t::second, rad::becquerel>(); | ||
test::<t::decisecond, rad::decabecquerel>(); | ||
test::<t::centisecond, rad::hectobecquerel>(); | ||
test::<t::millisecond, rad::kilobecquerel>(); | ||
test::<t::microsecond, rad::megabecquerel>(); | ||
test::<t::nanosecond, rad::gigabecquerel>(); | ||
test::<t::picosecond, rad::terabecquerel>(); | ||
test::<t::femtosecond, rad::petabecquerel>(); | ||
test::<t::attosecond, rad::exabecquerel>(); | ||
test::<t::zeptosecond, rad::zettabecquerel>(); | ||
test::<t::yoctosecond, rad::yottabecquerel>(); | ||
|
||
fn test<T: t::Conversion<V>, RAD: rad::Conversion<V>>() { | ||
Test::assert_approx_eq(&(V::one() / Time::new::<T>(V::one())), | ||
&Radioactivity::new::<RAD>(V::one()).into()); | ||
Test::assert_approx_eq(&Time::new::<T>(V::one()), | ||
&(V::one() / Radioactivity::new::<RAD>(V::one())).into()); | ||
} | ||
} | ||
|
||
#[test] | ||
fn check_curie() { | ||
test::<rad::gigabecquerel, rad::gigacurie>(); | ||
test::<rad::megabecquerel, rad::megacurie>(); | ||
test::<rad::kilobecquerel, rad::kilocurie>(); | ||
test::<rad::becquerel, rad::curie>(); | ||
test::<rad::millibecquerel, rad::millicurie>(); | ||
test::<rad::microbecquerel, rad::microcurie>(); | ||
test::<rad::nanobecquerel, rad::nanocurie>(); | ||
|
||
fn test<RadBq: rad::Conversion<V>, RadCi: rad::Conversion<V>>() { | ||
Test::assert_approx_eq( | ||
&(V::one() * 3.7_E10 * Radioactivity::new::<RadBq>(V::one())), | ||
&Radioactivity::new::<RadCi>(V::one())); | ||
} | ||
} | ||
|
||
#[test] | ||
fn check_dpm() { | ||
test::<rad::becquerel, rad::disintegrations_per_minute>(); | ||
|
||
fn test<RadBq: rad::Conversion<V>, RadCi: rad::Conversion<V>>() { | ||
Test::assert_approx_eq(&(V::one() / 6_E1 * Radioactivity::new::<RadBq>(V::one())), | ||
&Radioactivity::new::<RadCi>(V::one())); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! Specific radioactivity (base unit becquerel per kilogram, kg⁻¹ · s⁻¹). | ||
quantity! { | ||
/// Specific radioactivity (base unit becquerel per kilogram, kg⁻¹ · s⁻¹). | ||
quantity: SpecificRadioactivity; "specific radioactivity"; | ||
/// Dimension of specific radioactivity, M⁻¹T⁻¹ (base unit becquerel per kilogram, kg⁻¹ · s⁻¹). | ||
dimension: ISQ< | ||
Z0, // length | ||
N1, // mass | ||
N1, // time | ||
Z0, // electric current | ||
Z0, // thermodynamic temperature | ||
Z0, // amount of substance | ||
Z0>; // luminous intensity | ||
kind: dyn (crate::si::marker::ConstituentConcentrationKind); | ||
units { | ||
@becquerel_per_kilogram: prefix!(none); "Bq/kg", "becquerel per kilogram", | ||
"becquerels per kilogram"; | ||
|
||
@curie_per_kilogram: 3.7_E10; "Ci/kg", "curie per kilogram", "curie per kilogram"; | ||
|
||
@disintegrations_per_minute_per_kilogram: 1.0 / 6.0_E1; "dpm/kg", | ||
"disintegration per minute per kilogram", "disintegrations per minute per kilogram"; | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
storage_types! { | ||
use crate::num::One; | ||
use crate::si::radioactivity as rad; | ||
use crate::si::specific_radioactivity as srad; | ||
use crate::si::quantities::*; | ||
use crate::si::mass as m; | ||
use crate::tests::Test; | ||
|
||
#[test] | ||
fn check_dimension() { | ||
let _: SpecificRadioactivity<V> = (Radioactivity::new::<rad::becquerel>(V::one()) | ||
/ Mass::new::<m::kilogram>(V::one())).into(); | ||
} | ||
|
||
#[test] | ||
fn check_units() { | ||
test::<rad::becquerel, m::kilogram, srad::becquerel_per_kilogram>(); | ||
test::<rad::curie, m::kilogram, srad::curie_per_kilogram>(); | ||
test::<rad::disintegrations_per_minute, m::kilogram, | ||
srad::disintegrations_per_minute_per_kilogram>(); | ||
|
||
fn test<RAD: rad::Conversion<V>, M: m::Conversion<V>, SRAD: srad::Conversion<V>>() { | ||
Test::assert_approx_eq(&SpecificRadioactivity::new::<SRAD>(V::one()), | ||
&(Radioactivity::new::<RAD>(V::one()) / Mass::new::<M>(V::one())).into()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters