uom/si/
inductance.rs

1//! Inductance (base unit henry, m² · kg · s⁻² · A⁻²).
2
3quantity! {
4    /// Inductance (base unit henry, m² · kg · s⁻² · A⁻²).
5    quantity: Inductance; "inductance";
6    /// Dimension of inductance, L²MT⁻²I⁻² (base unit henry, m² · kg · s⁻² · A⁻²).
7    dimension: ISQ<
8        P2,     // length
9        P1,     // mass
10        N2,     // time
11        N2,     // electric current
12        Z0,     // thermodynamic temperature
13        Z0,     // amount of substance
14        Z0>;    // luminous intensity
15    units {
16        @yottahenry: prefix!(yotta); "YH", "yottahenry", "yottahenries";
17        @zettahenry: prefix!(zetta); "ZH", "zettahenry", "zettahenries";
18        @exahenry: prefix!(exa); "EH", "exahenry", "exahenries";
19        @petahenry: prefix!(peta); "PH", "petahenry", "petahenries";
20        @terahenry: prefix!(tera); "TH", "terahenry", "terahenries";
21        @gigahenry: prefix!(giga); "GH", "gigahenry", "gigahenries";
22        @megahenry: prefix!(mega); "MH", "megahenry", "megahenries";
23        @kilohenry: prefix!(kilo); "kH", "kilohenry", "kilohenries";
24        @hectohenry: prefix!(hecto); "hH", "hectohenry", "hectohenries";
25        @decahenry: prefix!(deca); "daH", "decahenry", "decahenries";
26        /// Derived unit of inductance.
27        @henry: prefix!(none); "H", "henry", "henries";
28        @decihenry: prefix!(deci); "dH", "decihenry", "decihenries";
29        @centihenry: prefix!(centi); "cH", "centihenry", "centihenries";
30        @millihenry: prefix!(milli); "mH", "millihenry", "millihenries";
31        @microhenry: prefix!(micro); "µH", "microhenry", "microhenries";
32        @nanohenry: prefix!(nano); "nH", "nanohenry", "nanohenries";
33        @picohenry: prefix!(pico); "pH", "picohenry", "picohenries";
34        @femtohenry: prefix!(femto); "fH", "femtohenry", "femtohenries";
35        @attohenry: prefix!(atto); "aH", "attohenry", "attohenries";
36        @zeptohenry: prefix!(zepto); "zH", "zeptohenry", "zeptohenries";
37        @yoctohenry: prefix!(yocto); "yH", "yoctohenry", "yoctohenries";
38
39        @abhenry: 1.0_E-9; "abH", "abhenry", "abhenries";
40        @stathenry: 8.987_552_917_115_481_E11; "statH", "stathenry", "stathenries";
41    }
42}
43
44#[cfg(test)]
45mod tests {
46    storage_types! {
47        use crate::num::One;
48        use crate::si::electric_current as i;
49        use crate::si::electric_potential as v;
50        use crate::si::inductance as l;
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 _: Inductance<V> = ElectricPotential::new::<v::volt>(V::one())
58                * Time::new::<t::second>(V::one())
59                / ElectricCurrent::new::<i::ampere>(V::one());
60        }
61
62        #[test]
63        fn check_units() {
64            test::<i::ampere, v::yottavolt, l::yottahenry>();
65            test::<i::ampere, v::zettavolt, l::zettahenry>();
66            test::<i::ampere, v::exavolt, l::exahenry>();
67            test::<i::ampere, v::petavolt, l::petahenry>();
68            test::<i::ampere, v::teravolt, l::terahenry>();
69            test::<i::ampere, v::gigavolt, l::gigahenry>();
70            test::<i::ampere, v::megavolt, l::megahenry>();
71            test::<i::ampere, v::kilovolt, l::kilohenry>();
72            test::<i::ampere, v::hectovolt, l::hectohenry>();
73            test::<i::ampere, v::decavolt, l::decahenry>();
74            test::<i::ampere, v::volt, l::henry>();
75            test::<i::ampere, v::decivolt, l::decihenry>();
76            test::<i::ampere, v::centivolt, l::centihenry>();
77            test::<i::ampere, v::millivolt, l::millihenry>();
78            test::<i::ampere, v::microvolt, l::microhenry>();
79            test::<i::ampere, v::nanovolt, l::nanohenry>();
80            test::<i::ampere, v::picovolt, l::picohenry>();
81            test::<i::ampere, v::femtovolt, l::femtohenry>();
82            test::<i::ampere, v::attovolt, l::attohenry>();
83            test::<i::ampere, v::zeptovolt, l::zeptohenry>();
84            test::<i::ampere, v::yoctovolt, l::yoctohenry>();
85
86            test::<i::statampere, v::statvolt, l::stathenry>();
87            test::<i::abampere, v::abvolt, l::abhenry>();
88
89            fn test<I: i::Conversion<V>, U: v::Conversion<V>, L: l::Conversion<V>>() {
90                Test::assert_approx_eq(&Inductance::new::<L>(V::one()),
91                    &(ElectricPotential::new::<U>(V::one())
92                        * Time::new::<t::second>(V::one())
93                        / ElectricCurrent::new::<I>(V::one())));
94            }
95        }
96    }
97}