-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add volumetric, areal, and linear densities of states.
- Loading branch information
1 parent
d55d64a
commit 6e3f3e7
Showing
4 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//! Areal density of states (base unit 1 / square meter joule, kg⁻¹ · m⁻⁴ · s²). | ||
quantity! { | ||
/// Areal density of states (base unit 1 / square meter joule, kg⁻¹ · m⁻⁴ · s²). | ||
quantity: ArealDensityOfStates; "areal density of states"; | ||
/// Dimension of areal density of states, L⁻⁴M⁻¹T² (base unit 1 / square meter joule, kg⁻¹ · m⁻⁴ · s²). | ||
dimension: ISQ< | ||
N4, // length | ||
N1, // mass | ||
P2, // time | ||
Z0, // electric current | ||
Z0, // thermodynamic temperature | ||
Z0, // amount of substance | ||
Z0>; // luminous intensity | ||
kind: dyn (crate::si::marker::ConstituentConcentrationKind); | ||
units { | ||
@state_per_square_meter_joule: prefix!(none); "1/(m²·J)", | ||
"state per square meter joule", "states per square meter joule"; | ||
@state_per_square_centimeter_joule: prefix!(none) / prefix!(centi) / prefix!(centi); "1/(cm²·J)", | ||
"state per square centimeter joule", "states per square centimeter joule"; | ||
@state_per_square_centimeter_electronvolt: prefix!(none) / prefix!(centi) / prefix!(centi) / 1.602_176_634_E-19; "1/(cm²·eV)", | ||
"state per square centimeter electronvolt", "states per square centimeter electronvolt"; | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
storage_types! { | ||
use crate::num::One; | ||
use crate::si::areal_density_of_states as ados; | ||
use crate::si::energy as e; | ||
use crate::si::quantities::*; | ||
use crate::si::area as a; | ||
use crate::tests::Test; | ||
|
||
#[test] | ||
fn check_dimension() { | ||
let _: ArealDensityOfStates<V> = (V::one() | ||
/ Energy::new::<e::joule>(V::one()) | ||
/ Area::new::<a::square_meter>(V::one())).into(); | ||
} | ||
|
||
#[test] | ||
fn check_units() { | ||
test::<a::square_meter, e::joule, ados::state_per_square_meter_joule>(); | ||
test::<a::square_centimeter, e::joule, ados::state_per_square_centimeter_joule>(); | ||
test::<a::square_centimeter, e::electronvolt, ados::state_per_square_centimeter_electronvolt>(); | ||
|
||
fn test<A: a::Conversion<V>, E: e::Conversion<V>, ADOS: ados::Conversion<V>>() { | ||
Test::assert_approx_eq(&ArealDensityOfStates::new::<ADOS>(V::one()), | ||
&(V::one() | ||
/ Energy::new::<E>(V::one()) | ||
/ Area::new::<A>(V::one())).into()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//! Linear density of states (base unit 1 / meter joule, kg⁻¹ · m⁻³ · s²). | ||
quantity! { | ||
/// Linear density of states (base unit 1 / meter joule, kg⁻¹ · m⁻³ · s²). | ||
quantity: LinearDensityOfStates; "linear density of states"; | ||
/// Dimension of linear density of states, L⁻³M⁻¹T² (base unit 1 / meter joule, kg⁻¹ · m⁻³ · s²). | ||
dimension: ISQ< | ||
N3, // length | ||
N1, // mass | ||
P2, // time | ||
Z0, // electric current | ||
Z0, // thermodynamic temperature | ||
Z0, // amount of substance | ||
Z0>; // luminous intensity | ||
kind: dyn (crate::si::marker::ConstituentConcentrationKind); | ||
units { | ||
@state_per_meter_joule: prefix!(none); "1/(m·J)", | ||
"state per meter joule", "states per meter joule"; | ||
@state_per_centimeter_joule: prefix!(none) / prefix!(centi); "1/(cm·J)", | ||
"state per centimeter joule", "states per centimeter joule"; | ||
@state_per_centimeter_electronvolt: prefix!(none) / prefix!(centi) / 1.602_176_634_E-19; "1/(cm·eV)", | ||
"state per centimeter electronvolt", "states per centimeter electronvolt"; | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
storage_types! { | ||
use crate::num::One; | ||
use crate::si::linear_density_of_states as ldos; | ||
use crate::si::energy as e; | ||
use crate::si::quantities::*; | ||
use crate::si::length as l; | ||
use crate::tests::Test; | ||
|
||
#[test] | ||
fn check_dimension() { | ||
let _: LinearDensityOfStates<V> = (V::one() | ||
/ Energy::new::<e::joule>(V::one()) | ||
/ Length::new::<l::meter>(V::one())).into(); | ||
} | ||
|
||
#[test] | ||
fn check_units() { | ||
test::<l::meter, e::joule, ldos::state_per_meter_joule>(); | ||
test::<l::centimeter, e::joule, ldos::state_per_centimeter_joule>(); | ||
test::<l::centimeter, e::electronvolt, ldos::state_per_centimeter_electronvolt>(); | ||
|
||
fn test<L: l::Conversion<V>, E: e::Conversion<V>, LDOS: ldos::Conversion<V>>() { | ||
Test::assert_approx_eq(&LinearDensityOfStates::new::<LDOS>(V::one()), | ||
&(V::one() | ||
/ Energy::new::<E>(V::one()) | ||
/ Length::new::<L>(V::one())).into()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//! Volumetric density of states (base unit 1 / cubic meter joule, kg⁻¹ · m⁻⁵ · s²). | ||
quantity! { | ||
/// Volumetric density of states (base unit 1 / cubic meter joule, kg⁻¹ · m⁻⁵ · s²). | ||
quantity: VolumetricDensityOfStates; "volumetric density of states"; | ||
/// Dimension of volumetric density of states, L⁻⁵M⁻¹T² (base unit 1 / cubic meter joule, kg⁻¹ · m⁻⁵ · s²). | ||
dimension: ISQ< | ||
N5, // length | ||
N1, // mass | ||
P2, // time | ||
Z0, // electric current | ||
Z0, // thermodynamic temperature | ||
Z0, // amount of substance | ||
Z0>; // luminous intensity | ||
kind: dyn (crate::si::marker::ConstituentConcentrationKind); | ||
units { | ||
@state_per_cubic_meter_joule: prefix!(none); "1/(m³·J)", | ||
"state per cubic meter joule", "states per cubic meter joule"; | ||
@state_per_cubic_centimeter_joule: prefix!(none) / prefix!(centi) / prefix!(centi) / prefix!(centi); "1/(cm³·J)", | ||
"state per cubic centimeter joule", "states per cubic centimeter joule"; | ||
@state_per_cubic_centimeter_electronvolt: prefix!(none) / prefix!(centi) / prefix!(centi) / prefix!(centi) / 1.602_176_634_E-19; "1/(cm³·eV)", | ||
"state per cubic centimeter electronvolt", "states per cubic centimeter electronvolt"; | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
storage_types! { | ||
use crate::num::One; | ||
use crate::si::volumetric_density_of_states as vdos; | ||
use crate::si::energy as e; | ||
use crate::si::quantities::*; | ||
use crate::si::volume as v; | ||
use crate::tests::Test; | ||
|
||
#[test] | ||
fn check_dimension() { | ||
let _: VolumetricDensityOfStates<V> = (V::one() | ||
/ Energy::new::<e::joule>(V::one()) | ||
/ Volume::new::<v::cubic_meter>(V::one())).into(); | ||
} | ||
|
||
#[test] | ||
fn check_units() { | ||
test::<v::cubic_meter, e::joule, vdos::state_per_cubic_meter_joule>(); | ||
test::<v::cubic_centimeter, e::joule, vdos::state_per_cubic_centimeter_joule>(); | ||
test::<v::cubic_centimeter, e::electronvolt, vdos::state_per_cubic_centimeter_electronvolt>(); | ||
|
||
fn test<U: v::Conversion<V>, E: e::Conversion<V>, VDOS: vdos::Conversion<V>>() { | ||
Test::assert_approx_eq(&VolumetricDensityOfStates::new::<VDOS>(V::one()), | ||
&(V::one() | ||
/ Energy::new::<E>(V::one()) | ||
/ Volume::new::<U>(V::one())).into()); | ||
} | ||
} | ||
} | ||
} |