1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//! 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::{FromPrimitive, 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() * V::from_f64(3.7_E10).unwrap()
                        * 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() / V::from_f64(6_E1).unwrap()
                        * Radioactivity::new::<RadBq>(V::one())),
                    &Radioactivity::new::<RadCi>(V::one()));
            }
        }
    }
}