From ede7791abf9cb8859d6d9aa23dc9540c6454b972 Mon Sep 17 00:00:00 2001 From: Vlad Voronenkov Date: Thu, 11 Aug 2022 16:35:39 +0200 Subject: [PATCH] Add TemperatureGradient quantity with related units. --- src/si/mod.rs | 1 + src/si/temperature_gradient.rs | 62 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/si/temperature_gradient.rs diff --git a/src/si/mod.rs b/src/si/mod.rs index 90168a64..38cd5a04 100644 --- a/src/si/mod.rs +++ b/src/si/mod.rs @@ -113,6 +113,7 @@ system! { specific_heat_capacity::SpecificHeatCapacity, surface_electric_current_density::SurfaceElectricCurrentDensity, temperature_coefficient::TemperatureCoefficient, + temperature_gradient::TemperatureGradient, temperature_interval::TemperatureInterval, thermal_conductivity::ThermalConductivity, thermodynamic_temperature::ThermodynamicTemperature, diff --git a/src/si/temperature_gradient.rs b/src/si/temperature_gradient.rs new file mode 100644 index 00000000..f1e8233e --- /dev/null +++ b/src/si/temperature_gradient.rs @@ -0,0 +1,62 @@ +//! Temperature gradient (base unit kelvin per meter, m⁻¹ · K). + +quantity! { + /// Temperature gradient (base unit kelvin per meter, m⁻¹ · K). + quantity: TemperatureGradient; "temperature gradient"; + /// Dimension of temperature gradient, L⁻¹Th (base unit kelvin per meter, K · m⁻¹). + dimension: ISQ< + N1, // length + Z0, // mass + Z0, // time + Z0, // electric current + P1, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + units { + @kelvin_per_kilometer: prefix!(none) / prefix!(kilo); "K/km", "kelvin per kilometer", + "kelvins per kilometer"; + @kelvin_per_hectometer: prefix!(none) / prefix!(hecto); "K/hm", "kelvin per hectometer", + "kelvins per hectometer"; + @kelvin_per_meter: prefix!(none); "K/m", "kelvin per meter", "kelvins per meter"; + @kelvin_per_centimeter: prefix!(none) / prefix!(centi); "K/cm", "kelvin per centimeter", + "kelvins per centimeter"; + @kelvin_per_millimeter: prefix!(none) / prefix!(milli); "K/mm", "kelvin per millimeter", + "kelvins per millimeter"; + @kelvin_per_micrometer: prefix!(none) / prefix!(micro); "K/µm", "kelvin per micrometer", + "kelvins per micrometer"; + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + use crate::si::temperature_gradient as tg; + use crate::si::temperature_interval as ti; + use crate::si::quantities::*; + use crate::si::length as l; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: TemperatureGradient = TemperatureInterval::new::(V::one()) + / Length::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + + fn test, L: l::Conversion, TG: tg::Conversion>() { + Test::assert_approx_eq(&TemperatureGradient::new::(V::one()), + &(TemperatureInterval::new::(V::one()) + / Length::new::(V::one()))); + } + } + } +}