runtime_units/unit_definitions/temperature_interval.rs
1//! Temperature interval (base UnitDefinition kelvin, K).
2//!
3//! Temperature interval has the same dimensions as [thermodynamic temperature][tt] but is not
4//! directly comparable. See [thermodynamic temperature][tt] for a full explanation.
5//!
6//! [tt]: ../thermodynamic_temperature/index.html
7
8//use crate::units::thermodynamic_temperature::ThermodynamicTemperature;
9use crate::{prefix, quantity};
10quantity! {
11 /// Temperature interval (base UnitDefinition kelvin, K).
12 quantity: TemperatureInterval; "temperature interval";
13 /// Dimension of temperature interval, Th (base UnitDefinition kelvin, K).
14 dimension: ISQ[
15 0.0, // length
16 0.0, // mass
17 0.0, // time
18 0.0, // electric current
19 1.0, // thermodynamic temperature
20 0.0, // amount of substance
21 0.0]; // luminous intensity
22 units {
23 @yottakelvin: prefix!(yotta); "YK", "yottakelvin", "yottakelvins";
24 @zettakelvin: prefix!(zetta); "ZK", "zettakelvin", "zettakelvins";
25 @exakelvin: prefix!(exa); "EK", "exakelvin", "exakelvins";
26 @petakelvin: prefix!(peta); "PK", "petakelvin", "petakelvins";
27 @terakelvin: prefix!(tera); "TK", "terakelvin", "terakelvins";
28 @gigakelvin: prefix!(giga); "GK", "gigakelvin", "gigakelvins";
29 @megakelvin: prefix!(mega); "MK", "megakelvin", "megakelvins";
30 @kilokelvin: prefix!(kilo); "kK", "kilokelvin", "kilokelvins";
31 @hectokelvin: prefix!(hecto); "hK", "hectokelvin", "hectokelvins";
32 @decakelvin: prefix!(deca); "daK", "decakelvin", "decakelvins";
33 /// The kelvin is the SI UnitDefinition of thermodynamic temperature. It is defined by taking the
34 /// fixed numerical value of the Boltzmann constant *k* to be 1.380 649 × 10⁻²³ when
35 /// expressed in the UnitDefinition J K⁻¹, which is equal to kg m² s⁻² K⁻¹, where the kilogram, meter,
36 /// and second are defined in terms of *h*, *c*, and ∆*ν*<sub>Cs</sub>.
37 @kelvin: prefix!(none); "K", "kelvin", "kelvins";
38 @decikelvin: prefix!(deci); "dK", "decikelvin", "decikelvins";
39 @centikelvin: prefix!(centi); "cK", "centikelvin", "centikelvins";
40 @millikelvin: prefix!(milli); "mK", "millikelvin", "millikelvins";
41 @microkelvin: prefix!(micro); "µK", "microkelvin", "microkelvins";
42 @nanokelvin: prefix!(nano); "nK", "nanokelvin", "nanokelvins";
43 @picokelvin: prefix!(pico); "pK", "picokelvin", "picokelvins";
44 @femtokelvin: prefix!(femto); "fK", "femtokelvin", "femtokelvins";
45 @attokelvin: prefix!(atto); "aK", "attokelvin", "attokelvins";
46 @zeptokelvin: prefix!(zepto); "zK", "zeptokelvin", "zeptokelvins";
47 @yoctokelvin: prefix!(yocto); "yK", "yoctokelvin", "yoctokelvins";
48
49 @degree_celsius: 1.0_E0; "°C", "degree Celsius", "degrees Celsius";
50 @degree_fahrenheit: 5.0_E0 / 9.0_E0; "°F", "degree Fahrenheit", "degrees Fahrenheit";
51 @degree_rankine: 5.0_E0 / 9.0_E0; "°R", "degree Rankine", "degrees Rankine";
52 }
53}
54
55// #[cfg(feature = "autoconvert")]
56// impl<Ul, Ur, V> crate::lib::ops::Add<ThermodynamicTemperature<Ur, V>> for TemperatureInterval<Ul, V>
57// where
58// Ul: super::Units<V> + ?Sized,
59// Ur: super::Units<V> + ?Sized,
60// V: crate::num::Num + crate::Conversion<V>,
61// {
62// type Output = ThermodynamicTemperature<Ul, V];
63
64// #[inline(always)]
65// fn add(self, rhs: ThermodynamicTemperature<Ur, V>) -> Self::Output {
66// super::Quantity {
67// dimension: crate::lib::marker::PhantomData,
68// units: crate::lib::marker::PhantomData,
69// value: self.value + super::change_base::<Dimension, Ul, Ur, V>(&rhs.value),
70// }
71// }
72// }
73
74// #[cfg(not(feature = "autoconvert"))]
75// impl<U, V> crate::lib::ops::Add<ThermodynamicTemperature<U, V>> for TemperatureInterval<U, V>
76// where
77// U: super::Units<V> + ?Sized,
78// V: crate::num::Num + crate::Conversion<V>,
79// {
80// type Output = ThermodynamicTemperature<U, V];
81
82// #[inline(always)]
83// fn add(self, rhs: ThermodynamicTemperature<U, V>) -> Self::Output {
84// super::Quantity {
85// dimension: crate::lib::marker::PhantomData,
86// units: crate::lib::marker::PhantomData,
87// value: self.value + rhs.value,
88// }
89// }
90// }
91
92// #[cfg(test)]
93// mod tests {
94// use crate::traits::Unit;
95// storage_types! {
96// use crate::si::quantities::*;
97// use crate::si::temperature_interval as ti;
98// use crate::si::thermodynamic_temperature as tt;
99// use crate::tests::{A, Test};
100
101// quickcheck! {
102// #[allow(trivial_casts)]
103// fn add(l: A<V>, r: A<V>) -> bool {
104// Test::eq(&ThermodynamicTemperature::<V>::new::<tt::kelvin>(&*l + &*r),
105// &(TemperatureInterval::<V>::new::<ti::kelvin>((*l).clone())
106// + ThermodynamicTemperature::<V>::new::<tt::kelvin>((*r).clone())))
107// }
108// }
109// }
110// }