From 3b41059caa74adcf71ca7807d44e17d696c3bc93 Mon Sep 17 00:00:00 2001 From: Mike Boutin Date: Thu, 1 Sep 2022 08:50:43 -0400 Subject: [PATCH] fixup! Add NumberDensity quantities: Volumetric, Areal, and Linear. --- src/si/areal_number_density.rs | 34 +++++++++++++++++------ src/si/linear_number_density.rs | 26 ++++++++++------- src/si/mod.rs | 2 +- src/si/volumetric_number_density.rs | 43 +++++++++++++++++++++++++---- 4 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/si/areal_number_density.rs b/src/si/areal_number_density.rs index 8cec79f6..b81dc145 100644 --- a/src/si/areal_number_density.rs +++ b/src/si/areal_number_density.rs @@ -16,19 +16,29 @@ quantity! { units { @per_square_kilometer: prefix!(none) / prefix!(kilo) / prefix!(kilo); "km⁻²", "per square kilometer", "per square kilometer"; - @per_square_meter: prefix!(none); "m⁻²", - "per square meter", "per square meter"; + @per_square_meter: prefix!(none); "m⁻²", "per square meter", "per square meter"; @per_square_decimeter: prefix!(none) / prefix!(deci) / prefix!(deci); "dm⁻²", "per square decimeter", "per square decimeter"; @per_square_centimeter: prefix!(none) / prefix!(centi) / prefix!(centi); "cm⁻²", "per square centimeter", "per square centimeter"; @per_square_millimeter: prefix!(none) / prefix!(milli) / prefix!(milli); "mm⁻²", - "per square millimeter", "per square millimeter"; + "per square millimeter", "per square millimeter"; @per_square_micrometer: prefix!(none) / prefix!(micro) / prefix!(micro); "µm⁻²", - "per square micrometer", "per square micrometer"; - - @per_square_mile: prefix!(none) / 2.589_988_E6; "mi⁻²", - "per square mile", "per square mile"; + "per square micrometer", "per square micrometer"; + + @per_acre: prefix!(none) / 4.046_873_E3; "ac⁻²", "per acre", "per acre"; + @per_are: prefix!(none) / 1.0_E2; "a⁻²", "per are", "per are"; + @per_barn: prefix!(none) / 1.0_E-28; "b⁻²", "per barn", "per barn"; + @per_circular_mil: prefix!(none) / 5.067_075_E-10; "cmil⁻²", "per circular mil", + "per circular mil"; + @per_hectare: prefix!(none) / 1.0_E4; "ha⁻²", "per hectare", "per hectare"; + @per_square_foot: prefix!(none) / 9.290_304_E-2; "ft⁻²", "per square foot", + "per square foot"; + @per_square_inch: prefix!(none) / 6.451_6_E-4; "in⁻²", "per square inch", "per square inch"; + @per_square_mile: prefix!(none) / 2.589_988_E6; "mi⁻²", "per square mile", + "per square mile"; + @per_square_yard: prefix!(none) / 8.361_274_E-1; "yd⁻²", "per square yard", + "per square yard"; } } @@ -55,8 +65,16 @@ mod test { test::(); test::(); test::(); - test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); fn test, A: a::Conversion>() { Test::assert_approx_eq(&ArealNumberDensity::new::(V::one()), diff --git a/src/si/linear_number_density.rs b/src/si/linear_number_density.rs index 11cf46a0..9d2cc55b 100644 --- a/src/si/linear_number_density.rs +++ b/src/si/linear_number_density.rs @@ -14,16 +14,22 @@ quantity! { Z0>; // luminous intensity kind: dyn (crate::si::marker::ConstituentConcentrationKind); units { - @per_kilometer: prefix!(none) / prefix!(kilo); "km⁻¹", - "per kilometer", "per kilometer"; - @per_meter: prefix!(none); "m⁻¹", - "per meter", "per meter"; - @per_decimeter: prefix!(none) / prefix!(deci); "dm⁻¹", - "per decimeter", "per decimeter"; - @per_centimeter: prefix!(none) / prefix!(centi); "cm⁻¹", - "per centimeter", "per centimeter"; - @per_millimeter: prefix!(none) / prefix!(milli); "mm⁻¹", - "per millimeter", "per millimeter"; + @per_kilometer: prefix!(none) / prefix!(kilo); "km⁻¹", "per kilometer", "per kilometer"; + @per_meter: prefix!(none); "m⁻¹", "per meter", "per meter"; + @per_decimeter: prefix!(none) / prefix!(deci); "dm⁻¹", "per decimeter", "per decimeter"; + @per_centimeter: prefix!(none) / prefix!(centi); "cm⁻¹", "per centimeter", "per centimeter"; + @per_millimeter: prefix!(none) / prefix!(milli); "mm⁻¹", "per millimeter", "per millimeter"; + + @per_foot: prefix!(none) / 3.048_E-1; "ft⁻¹", "per foot", "per foot"; + @per_foot_survey: prefix!(none) / 3.048_006_E-1; "ft (U.S. survey)", "foot (U.S. survey)", + "foot (U.S. survey)"; + @per_inch: prefix!(none) / 2.54_E-2; "in⁻¹", "per inch", "per inch"; + @per_mile: prefix!(none) / 1.609_344_E3; "mi⁻¹", "per mile", "per mile"; + @per_mile_survey: prefix!(none) / 1.609_347_E3; "mi⁻¹ (U.S. survey)", + "per mile (U.S. survey)", "per mile (U.S. survey)"; + @per_nautical_mile: prefix!(none) / 1.852_E3; "M⁻¹", "per nautical mile", + "per nautical mile"; + @per_yard: prefix!(none) / 9.144_E-1; "yd⁻¹", "per yard", "per yard"; } } diff --git a/src/si/mod.rs b/src/si/mod.rs index 752172d1..afd06ade 100644 --- a/src/si/mod.rs +++ b/src/si/mod.rs @@ -103,8 +103,8 @@ system! { torque::Torque, velocity::Velocity, volume::Volume, - volumetric_number_density::VolumetricNumberDensity, volume_rate::VolumeRate, + volumetric_number_density::VolumetricNumberDensity, } } diff --git a/src/si/volumetric_number_density.rs b/src/si/volumetric_number_density.rs index d980231b..3da330fd 100644 --- a/src/si/volumetric_number_density.rs +++ b/src/si/volumetric_number_density.rs @@ -16,14 +16,32 @@ quantity! { units { @per_cubic_kilometer: prefix!(none) / prefix!(kilo) / prefix!(kilo) / prefix!(kilo); "km⁻³", "per cubic kilometer", "per cubic kilometer"; - @per_cubic_meter: prefix!(none); "m⁻³", - "per cubic meter", "per cubic meter"; + @per_cubic_meter: prefix!(none); "m⁻³", "per cubic meter", "per cubic meter"; @per_cubic_decimeter: prefix!(none) / prefix!(deci) / prefix!(deci) / prefix!(deci); "dm⁻³", "per cubic decimeter", "per cubic decimeter"; - @per_cubic_centimeter: prefix!(none) / prefix!(centi) / prefix!(centi) / prefix!(centi); "cm⁻³", - "per cubic centimeter", "per cubic centimeter"; - @per_cubic_millimeter: prefix!(none) / prefix!(milli) / prefix!(milli) / prefix!(milli); "mm⁻³", - "per cubic millimeter", "per cubic millimeter"; + @per_cubic_centimeter: prefix!(none) / prefix!(centi) / prefix!(centi) / prefix!(centi); + "cm⁻³", "per cubic centimeter", "per cubic centimeter"; + @per_cubic_millimeter: prefix!(none) / prefix!(milli) / prefix!(milli) / prefix!(milli); + "mm⁻³", "per cubic millimeter", "per cubic millimeter"; + + @per_cubic_foot: prefix!(none) / 2.831_685_E-2; "ft⁻³", "per cubic foot", "per cubic foot"; + @per_cubic_inch: prefix!(none) / 1.638_706_E-5; "in⁻³", "per cubic inch", "per cubic inch"; + @per_cubic_mile: prefix!(none) / 4.168_182_E9; "mi⁻³", "per cubic mile", "per cubic mile"; + @per_cubic_yard: prefix!(none) / 7.645_549_E-1; "yd⁻³", "per cubic yard", "per cubic yard"; + @per_fluid_ounce: prefix!(none) / 2.957_353_E-5; "per fl oz", "per fluid ounce", + "per fluid ounce"; + @per_fluid_ounce_imperial: prefix!(none) / 2.841_306_E-5; "per fl oz (UK)", + "per Imperial fluid ounce", "per Imperial fluid ounce"; + @per_gallon_imperial: prefix!(none) / 4.546_09_E-3; "per gal (UK)", "per Imperial gallon", + "per Imperial gallon"; + @per_gallon: prefix!(none) / 3.785_412_E-3; "per gal", "per gallon", "per gallon"; + @per_liter: prefix!(none) / prefix!(milli); "L⁻¹", "per liter", "per liter"; + @per_deciliter: prefix!(none) / prefix!(milli) / prefix!(deci); "dL⁻¹", "per deciliter", + "per deciliter"; + @per_centiliter: prefix!(none) / prefix!(milli) / prefix!(centi); "cL⁻¹", + "per centiliter", "per centiliter"; + @per_milliliter: prefix!(none) / prefix!(milli) / prefix!(milli); "mL⁻¹", + "per milliliter", "per milliliter"; } } @@ -50,6 +68,19 @@ mod test { test::(); test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + fn test, U: v::Conversion>() { Test::assert_approx_eq(&VolumetricNumberDensity::new::(V::one()), &(V::one() / Volume::new::(V::one())).into());