#![forbid(unsafe_code)]
pub const SPEED_OF_LIGHT: f64 = 299_792_458.0;
pub const PLANCK_CONSTANT: f64 = 6.626_070_15e-34;
pub const REDUCED_PLANCK_CONSTANT: f64 = 1.054_571_817e-34;
pub const ELEMENTARY_CHARGE: f64 = 1.602_176_634e-19;
pub const BOLTZMANN_CONSTANT: f64 = 1.380_649e-23;
pub const AVOGADRO_CONSTANT: f64 = 6.022_140_76e23;
pub const FINE_STRUCTURE_CONSTANT: f64 = 7.297_352_564_3e-3;
pub const GRAVITATIONAL_CONSTANT: f64 = 6.674_30e-11;
pub const VACUUM_PERMITTIVITY: f64 = 8.854_187_812_8e-12;
pub const VACUUM_PERMEABILITY: f64 = 1.256_637_062_12e-6;
pub const STEFAN_BOLTZMANN_CONSTANT: f64 = 5.670_374_419e-8;
#[cfg(test)]
mod tests {
use core::f64::consts::TAU;
use super::{
PLANCK_CONSTANT, REDUCED_PLANCK_CONSTANT, SPEED_OF_LIGHT, STEFAN_BOLTZMANN_CONSTANT,
};
fn approx_eq(left: f64, right: f64, relative_tolerance: f64) {
let scale = left.abs().max(right.abs()).max(1.0);
let delta = (left - right).abs();
assert!(
delta <= relative_tolerance * scale,
"left={left:e} right={right:e} delta={delta:e} rel_tol={relative_tolerance:e}"
);
}
#[test]
fn reduced_planck_matches_h_over_tau() {
approx_eq(REDUCED_PLANCK_CONSTANT, PLANCK_CONSTANT / TAU, 1.0e-9);
}
#[test]
fn representative_constants_are_positive() {
assert!(SPEED_OF_LIGHT > 0.0);
assert!(PLANCK_CONSTANT > 0.0);
assert!(STEFAN_BOLTZMANN_CONSTANT > 0.0);
}
}