Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ElectricPermittivity with related units. #332

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions src/si/electric_permittivity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//! Electric permittivity (base unit farad per meter, m⁻³ · kg⁻¹ · s⁴ · A²).

quantity! {
/// Electric permittivity (base unit farad per meter, m⁻³ · kg⁻¹ · s⁴ · A²).
quantity: ElectricPermittivity; "electric permittivity";
/// Dimension of electric permittivity, L⁻³M⁻¹T⁴I² (base unit farad per meter,
/// m⁻³ · kg⁻¹ · s⁴ · A²).
dimension: ISQ<
N3, // length
N1, // mass
P4, // time
P2, // electric current
Z0, // thermodynamic temperature
Z0, // amount of substance
Z0>; // luminous intensity
units {
@farad_per_meter: prefix!(none); "F/m", "farad per meter", "farads per meter";
@vacuum_electric_permittivity: 8.854_187_8128_E-12; "ε₀", "vacuum electric permittivity",
"vacuum electric permittivity";
}
}

#[cfg(test)]
mod test {
storage_types! {
use crate::num::One;
use crate::si::capacitance as c;
use crate::si::electric_permittivity as ep;
use crate::si::length as l;
use crate::si::quantities::*;
use crate::tests::Test;

#[test]
fn check_dimension() {
let _: ElectricPermittivity<V> = Capacitance::new::<c::farad>(V::one())
/ Length::new::<l::meter>(V::one());
}

#[test]
fn check_units() {
test::<ep::farad_per_meter, c::farad, l::meter>();

fn test<EP: ep::Conversion<V>, C: c::Conversion<V>, L: l::Conversion<V>>() {
Test::assert_approx_eq(&ElectricPermittivity::new::<EP>(V::one()),
&(Capacitance::new::<C>(V::one())
/ Length::new::<L>(V::one())));
}
}
}
}
1 change: 1 addition & 0 deletions src/si/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ system! {
dynamic_viscosity::DynamicViscosity,
electric_charge::ElectricCharge,
electric_current::ElectricCurrent,
electric_permittivity::ElectricPermittivity,
electric_potential::ElectricPotential,
electrical_conductance::ElectricalConductance,
electrical_resistance::ElectricalResistance,
Expand Down