diff --git a/src/si/coulomb_constant.rs b/src/si/coulomb_constant.rs new file mode 100644 index 00000000..ea04c8f8 --- /dev/null +++ b/src/si/coulomb_constant.rs @@ -0,0 +1,96 @@ +//! Coulomb constant (base unit kilogram cubic meter per second to the fourth power square ampere, kg · m³ · s⁻⁴ · A⁻²). + +quantity! { + /// Coulomb constant (base unit kilogram cubic meter per second to the fourth power square ampere, kg · m³ · s⁻⁴ · A⁻²). + quantity: CoulombConstant; "coulomb constant"; + /// Dimension of coulomb constant, ML³T⁻⁴I⁻² (base unit kilogram cubic meter per second to the fourth power square ampere, kg · m³ · s⁻⁴ · A⁻²). + dimension: ISQ< + P3, // length + P1, // mass + N4, // time + N2, // electric current + Z0, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + units { + @kilogram_cubic_meter_per_second_to_the_fourth_power_square_ampere: prefix!(none); "kg·m³·s⁻⁴·A⁻²", + "kilogram cubic meter per second to the fourth power square ampere", "kilograms cubic meter per second to the fourth power square ampere"; + @meter_per_farad: prefix!(none); "m/F", + "meter per farad", "meters_per_farad"; + @coulomb_constant: 8.987_551_792_261_172_E9 ; "kₑ", // Derived from CODATA as 1/(4πε₀) + "coulomb constant", "coulomb constants"; + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + use crate::si::electric_current as i; + use crate::si::electric_permittivity as epsilon; + + use crate::si::coulomb_constant as ke; + use crate::si::quantities::*; + use crate::si::mass as m; + use crate::si::time as t; + use crate::si::volume as v; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: CoulombConstant = Mass::new::(V::one()) + * Volume::new::(V::one()) + / Time::new::(V::one()) + / Time::new::(V::one()) + / Time::new::(V::one()) + / Time::new::(V::one()) + / ElectricCurrent::new::(V::one()) + / ElectricCurrent::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + + fn test, VOL: v::Conversion, T: t::Conversion, I: i::Conversion, KE: ke::Conversion>() { + Test::assert_approx_eq(&CoulombConstant::new::(V::one()), + &(Mass::new::(V::one()) + * Volume::new::(V::one()) + / Time::new::(V::one()) + / Time::new::(V::one()) + / Time::new::(V::one()) + / Time::new::(V::one()) + / ElectricCurrent::new::(V::one()) + / ElectricCurrent::new::(V::one()))); + } + } + + #[test] + fn check_units_farad_meter() { + test::(); + test::(); + + fn test, KE: ke::Conversion>() { + Test::assert_approx_eq(&CoulombConstant::new::(V::one()), + &(V::one() + / ElectricPermittivity::new::(V::one()) + )); + } + } + + #[test] + fn check_units_ke() { + test::(); + + fn test, KE: ke::Conversion>() { + Test::assert_approx_eq(&CoulombConstant::new::(V::one()), + &( + + // 1 / (4 · π) + 7.957_747_154_594_768_E-2 * V::one() / ElectricPermittivity::new::(V::one()) + )); + } + } + + } +} diff --git a/src/si/mod.rs b/src/si/mod.rs index 9e7d9ff0..81341984 100644 --- a/src/si/mod.rs +++ b/src/si/mod.rs @@ -60,6 +60,7 @@ system! { capacitance::Capacitance, catalytic_activity::CatalyticActivity, catalytic_activity_concentration::CatalyticActivityConcentration, + coulomb_constant::CoulombConstant, curvature::Curvature, diffusion_coefficient::DiffusionCoefficient, dynamic_viscosity::DynamicViscosity, @@ -103,16 +104,19 @@ system! { mass_flux::MassFlux, mass_rate::MassRate, molar_concentration::MolarConcentration, + molar_electric_charge::MolarElectricCharge, molar_energy::MolarEnergy, molar_flux::MolarFlux, molar_heat_capacity::MolarHeatCapacity, molar_mass::MolarMass, molar_volume::MolarVolume, momentum::Momentum, + newtonian_constant_of_gravitation::NewtonianConstantOfGravitation, power::Power, pressure::Pressure, radiant_exposure::RadiantExposure, ratio::Ratio, + reciprocal_amount_of_substance::ReciprocalAmountOfSubstance, solid_angle::SolidAngle, specific_area::SpecificArea, specific_heat_capacity::SpecificHeatCapacity, @@ -120,6 +124,7 @@ system! { surface_electric_current_density::SurfaceElectricCurrentDensity, temperature_coefficient::TemperatureCoefficient, temperature_gradient::TemperatureGradient, + stefan_boltzmann_constant::StefanBoltzmannConstant, temperature_interval::TemperatureInterval, thermal_conductivity::ThermalConductivity, thermodynamic_temperature::ThermodynamicTemperature, diff --git a/src/si/molar_electric_charge.rs b/src/si/molar_electric_charge.rs new file mode 100644 index 00000000..d718aa2a --- /dev/null +++ b/src/si/molar_electric_charge.rs @@ -0,0 +1,65 @@ +//! Molar electric charge (base unit coulomb per mole, s · A · mol⁻¹). + +quantity! { + /// Molar electric charge (base unit coulomb per mole, s · A · mol⁻¹). + quantity: MolarElectricCharge; "molar electric charge"; + /// Dimension of molar electric charge, TIN⁻¹ (base unit coulomb per mole, s · A · mol⁻¹). + dimension: ISQ< + Z0, // length + Z0, // mass + P1, // time + P1, // electric current + Z0, // thermodynamic temperature + N1, // amount of substance + Z0>; // luminous intensity + units { + @coulomb_per_mole: prefix!(none); "C/mol", + "coulomb per mole", "coulombs per mole"; + @faraday_constant: 96_485.332_123_310_03 ; "F", // CODATA value 96_485.332_12 + "faraday constant", "faraday constants"; + + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + + use crate::si::amount_of_substance as aos; + use crate::si::quantities::*; + use crate::si::electric_charge as q; + use crate::si::molar_electric_charge as mec; + use crate::si::reciprocal_amount_of_substance as raos; + + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: MolarElectricCharge = ElectricCharge::new::(V::one()) + / AmountOfSubstance::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + + fn test, AOS: aos::Conversion, MEC: mec::Conversion>() { + Test::assert_approx_eq(&MolarElectricCharge::new::(V::one()), + &(ElectricCharge::new::(V::one()) + / AmountOfSubstance::new::(V::one()))); + } + } + + #[test] + fn check_units_na() { + test::(); + + fn test, RAOS: raos::Conversion, MEC: mec::Conversion>() { + Test::assert_approx_eq(&MolarElectricCharge::new::(V::one()), + &(ElectricCharge::new::(V::one()) + * ReciprocalAmountOfSubstance::new::(V::one()))); + } + } + } +} diff --git a/src/si/newtonian_constant_of_gravitation.rs b/src/si/newtonian_constant_of_gravitation.rs new file mode 100644 index 00000000..0275ee47 --- /dev/null +++ b/src/si/newtonian_constant_of_gravitation.rs @@ -0,0 +1,59 @@ +//! Newtonian constant of gravitation (base unit cubic meter per kilogram square second, m³ · kg⁻¹ · s⁻²). + +quantity! { + /// Newtonian constant of gravitation (base unit cubic meter per kilogram square second, m³ · kg⁻¹ · s⁻²). + quantity: NewtonianConstantOfGravitation; "newtonian constant of gravitation"; + /// Dimension of newtonian constant of gravitation, L³M⁻¹T⁻² (base unit cubic meter per kilogram square second, m³ · kg⁻¹ · s⁻²). + dimension: ISQ< + P3, // length + N1, // mass + N2, // time + Z0, // electric current + Z0, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + units { + @cubic_meter_pre_kilogram_square_second: prefix!(none); "m³·kg⁻¹·s⁻²", + "cubic meter per kilogram square second", "cubic meters per kilogram square second"; + @newtonian_constant_of_gravitation: 6.674_30_E-11; "G", + "newtonian constant of gravitation", "newtonian constants of gravitation"; + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + use crate::si::mass as m; + use crate::si::newtonian_constant_of_gravitation as g; + use crate::si::quantities::*; + use crate::si::time as t; + use crate::si::length as l; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: NewtonianConstantOfGravitation = Length::new::(V::one()) + * Length::new::(V::one()) + * Length::new::(V::one()) + / Mass::new::(V::one()) + / Time::new::(V::one()) + / Time::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + + fn test, M: m::Conversion, T: t::Conversion, G: g::Conversion>() { + Test::assert_approx_eq(&NewtonianConstantOfGravitation::new::(V::one()), + &(Length::new::(V::one()) + * Length::new::(V::one()) + * Length::new::(V::one()) + / Mass::new::(V::one()) + / Time::new::(V::one()) + / Time::new::(V::one()))); + } + } + } +} diff --git a/src/si/reciprocal_amount_of_substance.rs b/src/si/reciprocal_amount_of_substance.rs new file mode 100644 index 00000000..f25d2cc5 --- /dev/null +++ b/src/si/reciprocal_amount_of_substance.rs @@ -0,0 +1,50 @@ +//! Reciprocal amount of substance (base unit reciprocal mole, mol⁻¹). + +quantity! { + /// Reciprocal amount of substance (base unit reciprocal mole, mol⁻¹). + quantity: ReciprocalAmountOfSubstance; "reciprocal amount of substance"; + /// Dimension of reciprocal amount of substance, N⁻¹ (base unit reciprocal mole, mol⁻¹). + dimension: ISQ< + Z0, // length + Z0, // mass + Z0, // time + Z0, // electric current + Z0, // thermodynamic temperature + N1, // amount of substance + Z0>; // luminous intensity + units { + @reciprocal_mole: prefix!(none); "mol⁻¹", + "reciprocal mole", "reciprocal moles"; + @avogadro_constant: 6.022_140_76_E23; "Nᴀ", + "Avogadro constant", "Avogadro constants"; + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + use crate::si::amount_of_substance as aos; + use crate::si::quantities::*; + use crate::si::reciprocal_amount_of_substance as raos; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: ReciprocalAmountOfSubstance = V::one() + / AmountOfSubstance::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + test::(); + + fn test, RAOS: raos::Conversion>() { + Test::assert_approx_eq(&ReciprocalAmountOfSubstance::new::(V::one()), + &(V::one() + / AmountOfSubstance::new::(V::one()))); + } + } + } +} diff --git a/src/si/stefan_boltzmann_constant.rs b/src/si/stefan_boltzmann_constant.rs new file mode 100644 index 00000000..fbbb4a8f --- /dev/null +++ b/src/si/stefan_boltzmann_constant.rs @@ -0,0 +1,60 @@ +//! Stefan-Boltzmann constant (base unit watt per square meter kelvin to the fourth power, kg · s⁻³ · K⁻⁴). + +quantity! { + /// Stefan-Boltzmann constant (base unit watt per square meter kelvin to the fourth power, kg · s⁻³ · K⁻⁴). + quantity: StefanBoltzmannConstant; "Stefan-Boltzmann constant"; + /// Dimension of Stefan-Boltzmann constant, MT⁻³Th⁻⁴ (base unit watt per square meter kelvin to the fourth power, kg · s⁻³ · K⁻⁴). + dimension: ISQ< + Z0, // length + P1, // mass + N3, // time + Z0, // electric current + N4, // thermodynamic temperature + Z0, // amount of substance + Z0>; // luminous intensity + units { + @watt_per_square_meter_kelvin_to_the_fourth_power: prefix!(none); "W/(m²·K⁴)", + "watt per square meter kelvin to the fourth power", "watt per square meter kelvin to the fourth power"; + @stefan_boltzmann_constant: 5.670_374_419_E-8; "σ", + "stefan-boltzmann constant", "stefan-boltzmann constants"; + } +} + +#[cfg(test)] +mod test { + storage_types! { + use crate::num::One; + use crate::si::power as p; + use crate::si::stefan_boltzmann_constant as sigma; + use crate::si::quantities::*; + use crate::si::thermodynamic_temperature as t; + use crate::si::area as area; + use crate::tests::Test; + + #[test] + fn check_dimension() { + let _: StefanBoltzmannConstant = Power::new::(V::one()) + / Area::new::(V::one()) + / ThermodynamicTemperature::new::(V::one()) + / ThermodynamicTemperature::new::(V::one()) + / ThermodynamicTemperature::new::(V::one()) + / ThermodynamicTemperature::new::(V::one()); + } + + #[test] + fn check_units() { + test::(); + + fn test, A: area::Conversion, T: t::Conversion, SIGMA: sigma::Conversion>() { + Test::assert_approx_eq(&StefanBoltzmannConstant::new::(V::one()), + &(Power::new::

(V::one()) + / Area::new::(V::one()) + / ThermodynamicTemperature::new::(V::one()) + / ThermodynamicTemperature::new::(V::one()) + / ThermodynamicTemperature::new::(V::one()) + / ThermodynamicTemperature::new::(V::one()) + )); + } + } + } +}