diff --git a/src/si/mod.rs b/src/si/mod.rs index 4d68ba30..753e32a9 100644 --- a/src/si/mod.rs +++ b/src/si/mod.rs @@ -125,6 +125,7 @@ system! { moment_of_inertia::MomentOfInertia, momentum::Momentum, power::Power, + power_rate::PowerRate, pressure::Pressure, radiant_exposure::RadiantExposure, radioactivity::Radioactivity, diff --git a/src/si/power_rate.rs b/src/si/power_rate.rs new file mode 100644 index 00000000..91342085 --- /dev/null +++ b/src/si/power_rate.rs @@ -0,0 +1,122 @@ +//! Power rate (base unit watt per second, m² · kg · s⁻⁴). + +quantity! { + /// Power rate (base unit watt per second, m² · kg · s⁻⁴). + quantity: PowerRate; "power rate"; + /// Dimension of power rate, L²MT⁻⁴ (base unit watt per second, m² · kg · s⁻⁴). + dimension: ISQ< + P2, // length + P1, // mass + N4, // time + Z0, // electric current + Z0, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + units { + @yottawatt_per_second: prefix!(yotta); "YW/s", "yottawatt per second", + "yottawatts per second"; + @zettawatt_per_second: prefix!(zetta); "ZW/s", "zettawatt per second", + "zettawatts per second"; + @exawatt_per_second: prefix!(exa); "EW/s", "exawatt per second", "exawatts per second"; + @petawatt_per_second: prefix!(peta); "PW/s", "petawatt per second", "petawatts per second"; + @terawatt_per_second: prefix!(tera); "TW/s", "terawatt per second", "terawatts per second"; + @gigawatt_per_second: prefix!(giga); "GW/s", "gigawatt per second", "gigawatts per second"; + @megawatt_per_second: prefix!(mega); "MW/s", "megawatt per second", "megawatts per second"; + @kilowatt_per_second: prefix!(kilo); "kW/s", "kilowatt per second", "kilowatts per second"; + @hectowatt_per_second: prefix!(hecto); "hW/s", "hectowatt per second", + "hectowatts per second"; + @decawatt_per_second: prefix!(deca); "daW/s", "decawatt per second", "decawatts per second"; + /// Derived unit of power rate. + @watt_per_second: prefix!(none); "W/s", "watt per second", "watts per second"; + @deciwatt_per_second: prefix!(deci); "dW/s", "deciwatt per second", "deciwatts per second"; + @centiwatt_per_second: prefix!(centi); "cW/s", "centiwatt per second", + "centiwatts per second"; + @milliwatt_per_second: prefix!(milli); "mW/s", "milliwatt per second", + "milliwatts per second"; + @microwatt_per_second: prefix!(micro); "µW/s", "microwatt per second", + "microwatts per second"; + @nanowatt_per_second: prefix!(nano); "nW/s", "nanowatt per second", "nanowatts per second"; + @picowatt_per_second: prefix!(pico); "pW/s", "picowatt per second", "picowatts per second"; + @femtowatt_per_second: prefix!(femto); "fW/s", "femtowatt per second", + "femtowatts per second"; + @attowatt_per_second: prefix!(atto); "aW/s", "attowatt per second", "attowatts per second"; + @zeptowatt_per_second: prefix!(zepto); "zW/s", "zeptowatt per second", + "zeptowatts per second"; + @yoctowatt_per_second: prefix!(yocto); "yW/s", "yoctowatt per second", + "yoctowatts per second"; + + @erg_per_second_squared: 1.0_E-7; "erg/s²", "erg per second squared", + "ergs per second squared"; + @foot_pound_per_second_squared: 1.355_818; "ft · lbf/s²", + "foot pound-force per second squared", "foot pounds-force per second squared"; + @horsepower_per_second: 7.456_999_E2; "hp/s", "horsepower per second", + "horsepower per second"; + @horsepower_per_second_boiler: 9.809_50_E3; "hp/s (S)", "horsepower per second (boiler)", + "horsepower per second (boiler)"; + @horsepower_per_second_electric: 7.46_E2; "hp/s (E)", "horsepower per second (electric)", + "horsepower per second (electric)"; + @horsepower_per_second_metric: 7.354_988_E2; "hp/s (M)", "metric horsepower per second", + "metric horsepower per second"; + @horsepower_per_second_imperial: 7.457_0_E2; "hp/s (I)", "horsepower per second (Imperial)", + "horsepower per second (Imperial)"; + @hydraulic_horsepower_per_second: 7.460_43_E2; "hp/s (hydraulic)", + "hydraulic horsepower per second", "hydraulic horsepower per second"; + } +} + +#[cfg(test)] +mod tests { + storage_types! { + use crate::num::One; + use crate::si::power as p; + use crate::si::power_rate as r; + use crate::si::quantities::*; + use crate::si::time as t; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: PowerRate = Power::new::(V::one()) + / Time::new::(V::one()); + } + + #[test] + fn check_units() { + 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, T: t::Conversion, R: r::Conversion>() { + Test::assert_approx_eq(&PowerRate::new::(V::one()), + &(Power::new::

(V::one()) / Time::new::(V::one()))); + } + } + } +}