diff --git a/src/si/dynamic_viscosity.rs b/src/si/dynamic_viscosity.rs new file mode 100644 index 00000000..8c14e0cb --- /dev/null +++ b/src/si/dynamic_viscosity.rs @@ -0,0 +1,95 @@ +//! Dynamic viscosity (base unit pascal second, kg · m⁻¹ · s⁻¹). + +quantity! { + /// Dynamic viscosity (base unit pascal second, kg · m⁻¹ · s⁻¹). + quantity: DynamicViscosity; "dynamic viscosity"; + /// Dimension of dynamic viscosity, L⁻¹MT⁻¹ (base unit pascal second, kg · m⁻¹ · s⁻¹). + dimension: ISQ< + N1, // length + P1, // mass + N1, // time + Z0, // electric current + Z0, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + units { + @pascal_second: prefix!(none); "Pa · s", "pascal second", "pascal seconds"; + @millipascal_second: prefix!(milli); "mPa · s", "millipascal second", "millipascal seconds"; + @micropascal_second: prefix!(micro); "µPa · s", "micropascal second", "micropascal seconds"; + // poise = 0.1 Pa · s + @poise: 1.0_E-1; "P", "poise", "poises"; + // centipoise = 1 mPa · s + @centipoise: prefix!(centi) * 1.0_E-1; "cP", "centipoise", "centipoises"; + @pound_force_second_per_square_foot: 4.448_222_E0 / 3.048_E-1 / 3.048_E-1; "lbf · s/ft²", + "pound-force second per square foot", "pound-force seconds per square foot"; + @pound_force_second_per_square_inch: 4.448_222_E0 / 2.54_E-2 / 2.54_E-2; "lbf · s/in²", + "pound-force second per square inch", "pound-force seconds per square inch"; + // Reyn = 1 lbf · s/in² + @reyn: 4.448_222_E0 / 2.54_E-2 / 2.54_E-2; "reyn", "reyn", "reyns"; + @pound_per_foot_second: 4.535_924_E-1 / 3.048_E-1; "lb/(ft · s)", "pound per foot second", + "pounds per foot second"; + @pound_per_foot_hour: 4.535_924_E-1 / 3.048_E-1 / 3.6_E3; "lb/(ft · h)", + "pound per foot hour", "pounds per foot hour"; + @slug_per_foot_second: 1.459_390_E1 / 3.048_E-1; "slug/(ft · s)", "slug per foot second", + "slugs per foot second"; + @gram_per_centimeter_second: prefix!(milli) / prefix!(centi); "g/(cm · s)", + "gram per centimeter second", "grams per centimeter second"; + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + use crate::si::quantities::*; + use crate::si::dynamic_viscosity as dv; + use crate::si::time as t; + use crate::si::mass as m; + use crate::si::length as l; + use crate::si::pressure as p; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: DynamicViscosity = Pressure::new::(V::one()) + * Time::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + + fn test, T: t::Conversion, DV: dv::Conversion>() { + Test::assert_approx_eq(&DynamicViscosity::new::(V::one()), + &(Pressure::new::

(V::one()) + * Time::new::(V::one()))); + } + } + + #[test] + fn check_units_mlt() { + test::(); + test::(); + test::(); + test::(); + + fn test, L: l::Conversion, T: t::Conversion, + DV: dv::Conversion>() + { + Test::assert_approx_eq(&DynamicViscosity::new::(V::one()), + &(Mass::new::(V::one()) + / Length::new::(V::one()) + / Time::new::(V::one()))); + } + } + } +} diff --git a/src/si/mod.rs b/src/si/mod.rs index 175cddf6..4dc28f61 100644 --- a/src/si/mod.rs +++ b/src/si/mod.rs @@ -59,6 +59,7 @@ system! { catalytic_activity_concentration::CatalyticActivityConcentration, curvature::Curvature, diffusion_coefficient::DiffusionCoefficient, + dynamic_viscosity::DynamicViscosity, electric_charge::ElectricCharge, electric_current::ElectricCurrent, electric_potential::ElectricPotential,