|
| 1 | +//! Molar volume (base unit cubic meter per mole, m³ · mol⁻¹). |
| 2 | +
|
| 3 | +quantity! { |
| 4 | + /// Molar volume (base unit cubic meter per mole, m³ · mol⁻¹). |
| 5 | + quantity: MolarVolume; "molar volume"; |
| 6 | + /// Dimension of molar volume, L³N⁻¹ (base unit cubic meter per mole, m³ · mol⁻¹). |
| 7 | + dimension: ISQ< |
| 8 | + P3, // length |
| 9 | + Z0, // mass |
| 10 | + Z0, // time |
| 11 | + Z0, // electric current |
| 12 | + Z0, // thermodynamic temperature |
| 13 | + N1, // amount of substance |
| 14 | + Z0>; // luminous intensity |
| 15 | + units { |
| 16 | + @cubic_meter_per_mole: prefix!(none); "m³/mol", |
| 17 | + "cubic meter per mole", "cubic meters per mole"; |
| 18 | + @cubic_decimeter_per_mole: prefix!(deci) * prefix!(deci) * prefix!(deci); "dm³/mol", |
| 19 | + "cubic decimeter per mole", "cubic decimeters per mole"; |
| 20 | + @cubic_centimeter_per_mole: prefix!(centi) * prefix!(centi) * prefix!(centi); "cm³/mol", |
| 21 | + "cubic centimeter per mole", "cubic centimeters per mole"; |
| 22 | + |
| 23 | + @cubic_meter_per_particle: 6.022_140_76_E23; "m³/particle", |
| 24 | + "cubic meter per particle", "cubic meters per particle"; |
| 25 | + @cubic_micrometer_per_particle: prefix!(micro) * prefix!(micro) * prefix!(micro) * 6.022_140_76_E23; "µm³/particle", |
| 26 | + "cubic micrometer per particle", "cubic micrometers per particle"; |
| 27 | + @cubic_nanometer_per_particle: prefix!(nano) * prefix!(nano) * prefix!(nano) * 6.022_140_76_E23; "nm³/particle", |
| 28 | + "cubic nanometer per particle", "cubic nanometers per particle"; |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +#[cfg(test)] |
| 33 | +mod test { |
| 34 | + storage_types! { |
| 35 | + use crate::num::One; |
| 36 | + use crate::si::amount_of_substance as aos; |
| 37 | + use crate::si::molar_volume as mv; |
| 38 | + use crate::si::quantities::*; |
| 39 | + use crate::si::volume as v; |
| 40 | + use crate::tests::Test; |
| 41 | + |
| 42 | + #[test] |
| 43 | + fn check_dimension() { |
| 44 | + let _: MolarVolume<V> = Volume::new::<v::cubic_meter>(V::one()) |
| 45 | + / AmountOfSubstance::new::<aos::mole>(V::one()); |
| 46 | + } |
| 47 | + |
| 48 | + #[test] |
| 49 | + fn check_units() { |
| 50 | + test::<v::cubic_meter, aos::mole, mv::cubic_meter_per_mole>(); |
| 51 | + test::<v::cubic_decimeter, aos::mole, mv::cubic_decimeter_per_mole>(); |
| 52 | + test::<v::cubic_centimeter, aos::mole, mv::cubic_centimeter_per_mole>(); |
| 53 | + test::<v::cubic_meter, aos::particle, mv::cubic_meter_per_particle>(); |
| 54 | + test::<v::cubic_micrometer, aos::particle, mv::cubic_micrometer_per_particle>(); |
| 55 | + test::<v::cubic_nanometer, aos::particle, mv::cubic_nanometer_per_particle>(); |
| 56 | + |
| 57 | + fn test<U: v::Conversion<V>, AOS: aos::Conversion<V>, MV: mv::Conversion<V>>() { |
| 58 | + Test::assert_approx_eq(&MolarVolume::new::<MV>(V::one()), |
| 59 | + &(Volume::new::<U>(V::one()) / AmountOfSubstance::new::<AOS>(V::one()) )); |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | +} |
0 commit comments