From 94f1b8ce996cc05227bbc694ccc4895601e3682b Mon Sep 17 00:00:00 2001 From: Vlad Voronenkov Date: Tue, 2 Aug 2022 19:01:55 +0200 Subject: [PATCH] Add diffusion coefficient quantities and related units. Resolves #321 Co-authored-by: Mike Boutin --- src/si/diffusion_coefficient.rs | 66 +++++++++++++++++++++++++++++++++ src/si/mod.rs | 1 + 2 files changed, 67 insertions(+) create mode 100644 src/si/diffusion_coefficient.rs diff --git a/src/si/diffusion_coefficient.rs b/src/si/diffusion_coefficient.rs new file mode 100644 index 00000000..959d4ac0 --- /dev/null +++ b/src/si/diffusion_coefficient.rs @@ -0,0 +1,66 @@ +//! Diffusion coefficient (base unit square meter per second, m² · s⁻¹). + +quantity! { + /// Diffusion coefficient (base unit square meter per second, m² · s⁻¹). + quantity: DiffusionCoefficient; "diffusion coefficient"; + /// Dimension of diffusion coefficient, L²T⁻¹ (base unit square meter per second, m² · s⁻¹). + dimension: ISQ< + P2, // length + Z0, // mass + N1, // time + Z0, // electric current + Z0, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + units { + @square_meter_per_second: prefix!(none); "m²/s", "square meter per second", + "square meters per second"; + @square_centimeter_per_second: prefix!(centi) * prefix!(centi); "cm²/s", + "square centimeter per second", "square centimeters per second"; + @square_millimeter_per_second: prefix!(milli) * prefix!(milli); "mm²/s", + "square millimeter per second", "square millimeters per second"; + @square_micrometer_per_second: prefix!(micro) * prefix!(micro); "µm²/s", + "square micrometer per second", "square micrometers per second"; + @square_nanometer_per_second: prefix!(nano) * prefix!(nano); "nm²/s", + "square nanometer per second", "square nanometers per second"; + @stokes: prefix!(centi) * prefix!(centi); "St", "Stokes", "Stokes"; + @centistokes: prefix!(centi) * prefix!(centi) * prefix!(centi); "cSt", "centistokes", + "centistokes"; + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + use crate::si::quantities::*; + use crate::si::time as t; + use crate::si::area as area; + use crate::si::diffusion_coefficient as dc; + + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: DiffusionCoefficient = Area::new::(V::one()) + / Time::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + + fn test, T: t::Conversion, DC: dc::Conversion>() { + Test::assert_approx_eq(&DiffusionCoefficient::new::(V::one()), + &(Area::new::(V::one()) + / Time::new::(V::one()))); + } + } + } +} diff --git a/src/si/mod.rs b/src/si/mod.rs index 5a986a4c..175cddf6 100644 --- a/src/si/mod.rs +++ b/src/si/mod.rs @@ -58,6 +58,7 @@ system! { catalytic_activity::CatalyticActivity, catalytic_activity_concentration::CatalyticActivityConcentration, curvature::Curvature, + diffusion_coefficient::DiffusionCoefficient, electric_charge::ElectricCharge, electric_current::ElectricCurrent, electric_potential::ElectricPotential,