uom/si/
temperature_coefficient.rs

1//! Temperature coefficient (base unit 1 / kelvin, K⁻¹).
2
3quantity! {
4    /// Temperature coefficient (base unit 1 / kelvin, K⁻¹).
5    quantity: TemperatureCoefficient; "temperature coefficient";
6    /// Dimension of temperature coefficient, Th⁻¹ (base unit 1 / kelvin, K⁻¹).
7    dimension: ISQ<
8        Z0,     // length
9        Z0,     // mass
10        Z0,     // time
11        Z0,     // electric current
12        N1,     // thermodynamic temperature
13        Z0,     // amount of substance
14        Z0>;    // luminous intensity
15    units {
16        @per_kelvin: prefix!(none); "K⁻¹", "per kelvin", "per kelvin";
17        @ppm_per_kelvin: 1E-6; "ppm/K", "ppm per kelvin", "ppm per kelvin";
18        @ppm_per_degree_celsius: 1E-6; "ppm/°C", "ppm per degree Celsius", "ppm per degree Celsius";
19    }
20}
21
22#[cfg(test)]
23mod test {
24    storage_types! {
25        use crate::num::One;
26        use crate::si::temperature_interval as ti;
27        use crate::si::temperature_coefficient as tc;
28        use crate::si::quantities::*;
29        use crate::tests::Test;
30
31        #[test]
32        fn check_dimension() {
33            let _: TemperatureCoefficient<V> = V::one()
34                / TemperatureInterval::new::<ti::kelvin>(V::one());
35        }
36
37        #[test]
38        fn check_units() {
39            test::<ti::kelvin, tc::per_kelvin>();
40            test::<ti::megakelvin, tc::ppm_per_kelvin>();
41            test::<ti::megakelvin, tc::ppm_per_degree_celsius>();
42
43            fn test<TI: ti::Conversion<V>, TC: tc::Conversion<V>>() {
44                Test::assert_approx_eq(&TemperatureCoefficient::new::<TC>(V::one()),
45                    &(V::one()
46                        / TemperatureInterval::new::<TI>(V::one())));
47            }
48        }
49    }
50}