From 6b58736bf876bd2f9e7fb58c42fa648486493824 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 22 Feb 2024 10:00:46 +0200 Subject: [PATCH] Add AngularMomentum. --- src/si/angular_momentum.rs | 203 +++++++++++++++++++++++++++++++++++++ src/si/mod.rs | 1 + 2 files changed, 204 insertions(+) create mode 100644 src/si/angular_momentum.rs diff --git a/src/si/angular_momentum.rs b/src/si/angular_momentum.rs new file mode 100644 index 00000000..72571728 --- /dev/null +++ b/src/si/angular_momentum.rs @@ -0,0 +1,203 @@ +//! Angular momentum (base unit kilogram square meter per second, kg · m² · s⁻¹). + +quantity! { + /// Angular momentum (base unit kilogram square meter per second, kg · m² · s⁻¹). + quantity: AngularMomentum; "angular momentum"; + /// Dimension of angular momentum, L²MT⁻¹ (base unit kilogram square meter per second, kg · m² · s⁻¹). + dimension: ISQ< + P2, // length + P1, // mass + N1, // time + Z0, // electric current + Z0, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + kind: dyn (crate::si::marker::AngleKind); + units { + /// Derived unit of angular velocity. + @kilogram_square_meter_per_second: prefix!(kilo) / prefix!(kilo); "kg · m²/s", + "kilogram square meter per second", "kilogram square meters per second"; + + @yottanewton_meter_second: prefix!(yotta); "YN · m · s", "yottanewton meter second", + "yottanewton meter seconds"; + @zettanewton_meter_second: prefix!(zetta); "ZN · m · s", "zettanewton meter second", + "zettanewton meter seconds"; + @exanewton_meter_second: prefix!(exa); "EN · m · s", "exanewton meter second", + "exanewton meter seconds"; + @petanewton_meter_second: prefix!(peta); "PN · m · s", "petanewton meter second", + "petanewton meter seconds"; + @teranewton_meter_second: prefix!(tera); "TN · m · s", "teranewton meter second", + "teranewton meter seconds"; + @giganewton_meter_second: prefix!(giga); "GN · m · s", "giganewton meter second", + "giganewton meter seconds"; + @meganewton_meter_second: prefix!(mega); "MN · m · s", "meganewton meter second", + "meganewton meter seconds"; + @kilonewton_meter_second: prefix!(kilo); "kN · m · s", "kilonewton meter second", + "kilonewton meter seconds"; + @hectonewton_meter_second: prefix!(hecto); "hN · m · s", "hectonewton meter second", + "hectonewton meter seconds"; + @decanewton_meter_second: prefix!(deca); "daN · m · s", "decanewton meter second", + "decanewton meter seconds"; + @newton_meter_second: prefix!(none); "N · m · s", "newton meter second", + "newton meter seconds"; + @decinewton_meter_second: prefix!(deci); "dN · m · s", "decinewton meter second", + "decinewton meter seconds"; + @centinewton_meter_second: prefix!(centi); "cN · m · s", "centinewton meter second", + "centinewton meter seconds"; + @millinewton_meter_second: prefix!(milli); "mN · m · s", "millinewton meter second", + "millinewton meter seconds"; + @micronewton_meter_second: prefix!(micro); "µN · m · s", "micronewton meter second", + "micronewton meter seconds"; + @nanonewton_meter_second: prefix!(nano); "nN · m · s", "nanonewton meter second", + "nanonewton meter seconds"; + @piconewton_meter_second: prefix!(pico); "pN · m · s", "piconewton meter second", + "piconewton meter seconds"; + @femtonewton_meter_second: prefix!(femto); "fN · m · s", "femtonewton meter second", + "femtonewton meter seconds"; + @attonewton_meter_second: prefix!(atto); "aN · m · s", "attonewton meter second", + "attonewton meter seconds"; + @zeptonewton_meter_second: prefix!(zepto); "zN · m · s", "zeptonewton meter second", + "zeptonewton meter seconds"; + @yoctonewton_meter_second: prefix!(yocto); "yN · m · s", "yoctonewton meter second", + "yoctonewton meter seconds"; + + @newton_yottameter_second: prefix!(yotta); "N · Ym · s", "newton yottameter second", + "newton yottameter seconds"; + @newton_zettameter_second: prefix!(zetta); "N · Zm · s", "newton zettameter second", + "newton zettameter seconds"; + @newton_exameter_second: prefix!(exa); "N · Em · s", "newton exameter second", + "newton exameter seconds"; + @newton_petameter_second: prefix!(peta); "N · Pm · s", "newton petameter second", + "newton petameter seconds"; + @newton_terameter_second: prefix!(tera); "N · Tm · s", "newton terameter second", + "newton terameter seconds"; + @newton_gigameter_second: prefix!(giga); "N · Gm · s", "newton gigameter second", + "newton gigameter seconds"; + @newton_megameter_second: prefix!(mega); "N · Mm · s", "newton megameter second", + "newton megameter seconds"; + @newton_kilometer_second: prefix!(kilo); "N · km · s", "newton kilometer second", + "newton kilometer seconds"; + @newton_hectometer_second: prefix!(hecto); "N · hm · s", "newton hectometer second", + "newton hectometer seconds"; + @newton_decameter_second: prefix!(deca); "N · dam · s", "newton decameter second", + "newton decameter seconds"; + @newton_decimeter_second: prefix!(deci); "N · dm · s", "newton decimeter second", + "newton decimeter seconds"; + @newton_centimeter_second: prefix!(centi); "N · cm · s", "newton centimeter second", + "newton centimeter seconds"; + @newton_millimeter_second: prefix!(milli); "N · mm · s", "newton millimeter second", + "newton millimeter seconds"; + @newton_micrometer_second: prefix!(micro); "N · µm · s", "newton micrometer second", + "newton micrometer seconds"; + @newton_nanometer_second: prefix!(nano); "N · nm · s", "newton nanometer second", + "newton nanometer seconds"; + @newton_picometer_second: prefix!(pico); "N · pm · s", "newton picometer second", + "newton picometer seconds"; + @newton_femtometer_second: prefix!(femto); "N · fm · s", "newton femtometer second", + "newton femtometer seconds"; + @newton_attometer_second: prefix!(atto); "N · am · s", "newton attometer second", + "newton attometer seconds"; + @newton_zeptometer_second: prefix!(zepto); "N · zm · s", "newton zeptometer second", + "newton zeptometer seconds"; + @newton_yoctometer_second: prefix!(yocto); "N · ym · s", "newton yoctometer second", + "newton yoctometer seconds"; + } +} + +#[cfg(test)] +mod tests { + storage_types! { + use crate::num::One; + use crate::si::angular_momentum as am; + use crate::si::area as a; + use crate::si::force as f; + use crate::si::length as l; + use crate::si::mass as m; + use crate::si::quantities::*; + use crate::si::time as t; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: AngularMomentum = (Mass::new::(V::one()) + * Area::new::(V::one()) + / Time::new::(V::one())) + .into(); + let _: AngularMomentum = (Force::new::(V::one()) + * Length::new::(V::one()) + * Time::new::(V::one())) + .into(); + } + + #[test] + fn check_units_mass_area() { + test::(); + + fn test, A: a::Conversion, AM: am::Conversion>() { + Test::assert_approx_eq( + &AngularMomentum::new::(V::one()), + &(Mass::new::(V::one()) + * Area::new::(V::one()) + / Time::new::(V::one())) + .into(), + ); + } + } + + #[test] + fn check_units_force_length() { + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + test::(); + + fn test, L: l::Conversion, AM: am::Conversion>() { + Test::assert_approx_eq( + &AngularMomentum::new::(V::one()), + &(Force::new::(V::one()) + * Length::new::(V::one()) + * Time::new::(V::one())) + .into(), + ); + } + } + } +} diff --git a/src/si/mod.rs b/src/si/mod.rs index efa9ea5d..eac7b306 100644 --- a/src/si/mod.rs +++ b/src/si/mod.rs @@ -53,6 +53,7 @@ system! { angular_absement::AngularAbsement, angular_acceleration::AngularAcceleration, angular_jerk::AngularJerk, + angular_momentum::AngularMomentum, angular_velocity::AngularVelocity, area::Area, areal_density_of_states::ArealDensityOfStates,