diff --git a/.appveyor.yml b/.appveyor.yml index 3c9ce83..52d0a91 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -6,6 +6,7 @@ environment: - julia_version: 1.3 - julia_version: 1.4 - julia_version: 1.5 + - julia_version: 1.6 - julia_version: nightly platform: diff --git a/.travis.yml b/.travis.yml index f653184..0bac303 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ julia: - 1.3 - 1.4 - 1.5 + - 1.6 - nightly matrix: allow_failures: diff --git a/Project.toml b/Project.toml index 9c8105d..163bb63 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "UnitSystems" uuid = "3a241a3c-2137-41aa-af5e-1388e404ca09" authors = ["Michael Reed"] -version = "0.2.2" +version = "0.3" [compat] julia = "1" diff --git a/README.md b/README.md index ecd07a6..c75c05c 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,10 @@ [![Coverage Status](https://coveralls.io/repos/chakravala/UnitSystems.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/chakravala/UnitSystems.jl?branch=master) [![codecov.io](https://codecov.io/github/chakravala/UnitSystems.jl/coverage.svg?branch=master)](https://codecov.io/github/chakravala/UnitSystems.jl?branch=master) -Specifications for dimensional units are in the [UnitSystems.jl](https://github.com/chakravala/UnitSystems.jl) and [UnitfulSystems.jl](https://github.com/chakravala/UnitfulSystems.jl) repositories. -The two packages are designed so that they can be interchanged if compatibility with [Unitful.jl](https://github.com/PainterQubits/Unitful.jl) is desired or not. -However, the `UnitfulSystems` package has fewer `UnitSystem` specifications available than the `UnitSystems` package due to limitations in combination with the `Unitful` package. -Specifically, `Metric`, `SI2019`, `CODATA`, `Conventional`, `MTS`, `EMU2019`, `English`, and `EnglishUS` can have `Unitful` values; while `Gauss`, `LorentzHeaviside`, `Thomson`, `EMU`, `ESU`, `ESU2019`, `IAU`, `FFF`, `Planck`, `PlanckGauss`, `Stoney`, `Hartree`, `Rydberg`, `Schrodinger`, `Electronic`, `Natural`, `NaturalGauss`, `QCD`, `QCDGauss`, and `QCDoriginal` are plain valued. +Specifications for dimensional units are in the [UnitSystems.jl](https://github.com/chakravala/UnitSystems.jl) and [MeasureSystems.jl](https://github.com/chakravala/MeasureSystems.jl) and [UnitfulSystems.jl](https://github.com/chakravala/UnitfulSystems.jl) repositories. +The three packages are designed so that they can be interchanged if compatibility with [Measurements.jl](https://github.com/JuliaPhysics/Measurements.jl) or [Unitful.jl](https://github.com/PainterQubits/Unitful.jl) is desired or not. +However, the `UnitfulSystems` package has fewer `UnitSystem` specifications available than the `UnitSystems` and `MeasureSystems` packages due to limitations in combination with the `Unitful` package. +Specifically, `Metric`, `SI2019`, `CODATA`, `Conventional`, `MTS`, `EMU2019`, `English`, and `EnglishUS` can have `Unitful` values; while `Gauss`, `LorentzHeaviside`, `Thomson`, `EMU`, `ESU`, `ESU2019`, `IAU`, `FFF`, `Planck`, `PlanckGauss`, `Stoney`, `Hartree`, `Rydberg`, `Schrodinger`, `Electronic`, `Natural`, `NaturalGauss`, `QCD`, `QCDGauss`, and `QCDoriginal` are plain valued or are limited to `Measurement` values. ```Julia pkg> add UnitSystems # or UnitfulSystems @@ -55,4 +55,12 @@ Thermodynamics: `temperature`, `entropy`, `specificentropy`, `volumeheatcapacity `molarmass`, `molality`, `mole`, `molarity`, `molarvolume`, `molarentropy`, `molarenergy`, `molarconductivity`, `molarsusceptibility`, `catalysis`, `specificity`, `luminousflux`, `luminance`, `luminousenergy`, `luminousexposure`, `luminousefficacy`. -Other similar packages include [PhysicalConstants.jl](https://github.com/JuliaPhysics/PhysicalConstants.jl), [MathPhysicalConstants.jl](https://github.com/LaGuer/MathPhysicalConstants.jl), [Unitful.jl](https://github.com/PainterQubits/Unitful.jl.git), [UnitfulSystems.jl](https://github.com/chakravala/UnitfulSystems.jl), [UnitfulUS.jl](https://github.com/PainterQubits/UnitfulUS.jl), [UnitfulAstro.jl](https://github.com/JuliaAstro/UnitfulAstro.jl), [UnitfulAtomic.jl](https://github.com/sostock/UnitfulAtomic.jl), [NaturallyUnitful.jl](https://github.com/MasonProtter/NaturallyUnitful.jl), and [UnitfulMoles.jl](https://github.com/rafaqz/UnitfulMoles.jl). +**Generalized dimensionless `Coupling`:** + +```Julia +Coupling{αG,α,μₑᵤ,μₚᵤ} +``` +Specification of `Universe` with the dimensionless `Coupling` constants `coupling`, `finestructure`, `electronunit`, `protonunit`, and `protonelectron`. Alterations to these values can be facilitated and quantified using parametric polymorphism. +Due to the `Coupling` interoperability, the `MeasureSystems` package is made possible to support calculations with `Measurements` having error standard deviations. + +Other similar packages include [MeasureSystems.jl](https://github.com/chakravala/MeasureSystems.jl), [PhysicalConstants.jl](https://github.com/JuliaPhysics/PhysicalConstants.jl), [MathPhysicalConstants.jl](https://github.com/LaGuer/MathPhysicalConstants.jl), [Unitful.jl](https://github.com/PainterQubits/Unitful.jl.git), [UnitfulSystems.jl](https://github.com/chakravala/UnitfulSystems.jl), [UnitfulUS.jl](https://github.com/PainterQubits/UnitfulUS.jl), [UnitfulAstro.jl](https://github.com/JuliaAstro/UnitfulAstro.jl), [UnitfulAtomic.jl](https://github.com/sostock/UnitfulAtomic.jl), [NaturallyUnitful.jl](https://github.com/MasonProtter/NaturallyUnitful.jl), and [UnitfulMoles.jl](https://github.com/rafaqz/UnitfulMoles.jl). diff --git a/src/UnitSystems.jl b/src/UnitSystems.jl index c7996aa..1864085 100644 --- a/src/UnitSystems.jl +++ b/src/UnitSystems.jl @@ -5,10 +5,6 @@ module UnitSystems import Base: @pure, length, time -export slug, ft, ftUS, KJ1990, KJ2014, RK1990, RK2014, mₑ1990, mₑ2014, temp, units -export slugs, kilograms, lbm, meters, feet, rankine, kelvin, moles, molecules -export UnitSystem, US, SI, MKS, CGS, CGS2019, CGSm, CGSe, HLU, FFF - const Systems = (:Metric,:SI2019,:CODATA,:Conventional,:MTS,:English,:EnglishUS,:IAU,:SI1976,:Mixed,:ESU2019,:EMU2019,:EMU,:ESU,:Gauss,:LorentzHeaviside,:Thomson,:Kennelly,:Planck,:PlanckGauss,:Stoney,:Hartree,:Rydberg,:Schrodinger,:Electronic,:Natural,:NaturalGauss,:QCD,:QCDGauss,:QCDoriginal) const Constants = (:hyperfine,:lightspeed,:planck,:planckreduced,:electronmass,:molarmass,:boltzmann,:permeability,:rationalization,:lorentz,:luminousefficacy) const Physics = (:atomicmass,:protonmass,:planckmass,:newton,:einstein,:hartree,:rydberg,:bohr,:bohrreduced,:electronradius,:avogadro,:universal,:stefan,:radiationdensity,:permittivity,:coulomb,:ampere,:biotsavart,:charge,:faraday,:impedance,:conductance,:klitzing,:josephson,:magneticflux,:magneton) @@ -23,6 +19,25 @@ const Convert = [Mechanics...,Electromagnetic...,Thermodynamic...,Molar...,Photo listext(x) = join(x,"`, `") +@pure measure(x) = x + +# universe + +""" + Coupling{αG,α,μₑᵤ,μₚᵤ} + +Specification of `Universe` with the dimensionless `Coupling` constants `coupling`, `finestructure`, `electronunit`, `protonunit`, and `protonelectron`. +Alterations to these values can be facilitated and quantified using parametric polymorphism. +Due to the `Coupling` interoperability, the `MeasureSystems` package is made possible to support calculations with `Measurements` having error standard deviations. +""" +struct Coupling{αG,α,μₑᵤ,μₚᵤ} end +@pure coupling(U::Coupling{αG}) where αG = measure(αG) +@pure finestructure(U::Coupling{αG,α}) where {αG,α} = measure(α) +@pure electronunit(U::Coupling{αG,α,μₑᵤ}) where {αG,α,μₑᵤ} = measure(μₑᵤ) +@pure protonunit(U::Coupling{αG,α,μₑᵤ,μₚᵤ}) where {αG,α,μₑᵤ,μₚᵤ} = measure(μₚᵤ) +@pure protonelectron(U::Coupling) = protonunit(U)/electronunit(U) +Base.display(U::Coupling) = println("Coupling{αG=$(coupling(U)),α=$(finestructure(U)),μₑᵤ=$(electronunit(U)),μₚᵤ=$(protonunit(U))}") + # unit systems """ @@ -45,28 +60,36 @@ Thermodynamics: `$(listext(Thermodynamic))`, struct UnitSystem{kB,ħ,𝘤,μ₀,mₑ,λ,αL} end @pure UnitSystem{k,ħ,𝘤,μ,m,λ}() where {k,ħ,𝘤,μ,m,λ} = UnitSystem{k,ħ,𝘤,μ,m,λ,1}() @pure UnitSystem{k,ħ,𝘤,μ,m}() where {k,ħ,𝘤,μ,m} = UnitSystem{k,ħ,𝘤,μ,m,1}() -@pure boltzmann(::UnitSystem{k}) where k = k -@pure planckreduced(::UnitSystem{k,ħ}) where {k,ħ} = ħ -@pure lightspeed(::UnitSystem{k,ħ,𝘤}) where {k,ħ,𝘤} = 𝘤 -@pure permeability(::UnitSystem{k,ħ,𝘤,μ}) where {k,ħ,𝘤,μ} = μ -@pure electronmass(::UnitSystem{k,ħ,𝘤,μ,m}) where {k,ħ,𝘤,μ,m} = m -@pure rationalization(::UnitSystem{k,ħ,𝘤,μ,m,λ}) where {k,ħ,𝘤,μ,m,λ} = λ -@pure lorentz(::UnitSystem{k,ħ,𝘤,μ,m,λ,α}) where {k,ħ,𝘤,μ,m,λ,α} = α +@pure boltzmann(::UnitSystem{k}) where k = measure(k) +@pure planckreduced(::UnitSystem{k,ħ}) where {k,ħ} = measure(ħ) +@pure lightspeed(::UnitSystem{k,ħ,𝘤}) where {k,ħ,𝘤} = measure(𝘤) +@pure permeability(::UnitSystem{k,ħ,𝘤,μ}) where {k,ħ,𝘤,μ} = measure(μ) +@pure electronmass(::UnitSystem{k,ħ,𝘤,μ,m}) where {k,ħ,𝘤,μ,m} = measure(m) +@pure rationalization(::UnitSystem{k,ħ,𝘤,μ,m,λ}) where {k,ħ,𝘤,μ,m,λ} = measure(λ) +@pure lorentz(::UnitSystem{k,ħ,𝘤,μ,m,λ,α}) where {k,ħ,𝘤,μ,m,λ,α} = measure(α) # ΔνCs:s⁻¹, c:m⋅s⁻¹, h:kg⋅m²⋅s⁻¹, kB:kg⋅m²⋅s⁻²⋅K⁻¹, NA:mol⁻¹, Kcd: cd⋅sr⋅s³⋅kg⁻¹⋅m⁻² isrationalized(U::UnitSystem) = rationalization(U) ≠ 4π Base.display(U::UnitSystem) = println("UnitSystem{kB=$(boltzmann(U)),ħ=$(planckreduced(U)),𝘤=$(lightspeed(U)),μ₀=$(permeability(U)),mᵤ=$(electronmass(U)),λ=$(isrationalized(U) ? rationalization(U) : "4π"),αL=$(lorentz(U))}") +@pure universe(::UnitSystem) = Universe @pure unit(x,y=1) = isapprox(y,x,rtol=eps()^0.9) ? y : x @pure mass(U::UnitSystem,S::UnitSystem) = electronmass(U,S) -@pure electronmass(𝘩::Float64,R∞::Float64=R∞) = αinv^2*R∞*2𝘩/𝘤 -@pure planckmass(U::UnitSystem) = mass(mP,U) -@pure planck(U::UnitSystem) = 2π*planckreduced(U) -@pure newton(U::UnitSystem) = lightspeed(U)*planckreduced(U)/planckmass(U)^2 -@pure charge(U::UnitSystem) = sqrt(2planck(U)/impedance(U)/αinv) # fine structure -@pure impedance(U::UnitSystem) = permeability(U)*lightspeed(U)*rationalization(U)*lorentz(U)^2 - +@pure electronmass(𝘩::Float64) = αinv^2*R∞*2𝘩/𝘤 +@pure electronmass(𝘩::Float64,C::Coupling) = inv(finestructure(C))^2*R∞*2𝘩/𝘤 +@pure planckmass(U::UnitSystem,C::Coupling=universe(U)) = electronmass(U,C)/√coupling(C) +@pure planck(U::UnitSystem,C::Coupling=universe(U)) = 2π*planckreduced(U,C) +@pure newton(U::UnitSystem,C::Coupling=universe(U)) = lightspeed(U,C)*planckreduced(U,C)/planckmass(U,C)^2 +@pure charge(U::UnitSystem,C::Coupling=universe(U)) = sqrt(2planck(U,C)*finestructure(C)/impedance(U,C)) +@pure impedance(U::UnitSystem,C::Coupling=universe(U)) = permeability(U,C)*lightspeed(U,C)*rationalization(U)*lorentz(U)^2 + +for unit ∈ (:coupling,:finestructure,:electronunit,:protonunit,:protonelectron) + @eval @pure $unit(U::UnitSystem) = $unit(universe(U)) +end +for unit ∈ (:boltzmann,:planckreduced,:lightspeed,:permeability,:electronmass,:molarmass) + @eval @pure $unit(U::UnitSystem,C::Coupling) = $unit(U) +end for unit ∈ Constants @eval @pure $unit(U::UnitSystem,S::UnitSystem) = unit($unit(S)/$unit(U)) end @@ -106,17 +129,18 @@ const kcal = kcalₜₕ; const cal = kcal/1000 # calₜₕ thermal calorie # fundamental constants, αinv = (34259-1/4366.8123)/250 # 137.036 exactly? -const ΔνCs,Kcd,mP = 9192631770.0,683.002,2.176434e-8 # planck mass (kg) +const ΔνCs,Kcd,mP = 9192631770.0,683*555.016/555,2.176434e-8 # planck mass (kg) const NA,kB,𝘩,𝘤,𝘦 = 6.02214076e23,1.380649e-23,6.62607015e-34,299792458.,1.602176634e-19 const μₑᵤ,μₚᵤ,αinv,R∞ = 1/1822.888486209,1.007276466621,137.035999084,10973731.5681601 -const αL,μ₀ = 0.01/𝘤,2𝘩/𝘤/αinv/𝘦^2 # ≈ 4π*(1e-7+5.5e-17), exact charge -const ħ,δμ₀,μₚₑ,Rᵤ,mₑ = 𝘩/2π,μ₀-4π*1e-7,μₚᵤ/μₑᵤ,NA*kB,electronmass(𝘩) +const mₑ,μ₀ = electronmass(𝘩),2𝘩/𝘤/αinv/𝘦^2 # ≈ 4π*(1e-7+5.5e-17), exact charge +const ħ,δμ₀,μₚₑ,Rᵤ,αL,αG = 𝘩/2π,μ₀-4π*1e-7,μₚᵤ/μₑᵤ,NA*kB,0.01/𝘤,(mₑ/mP)^2 const RK1990,RK2014,KJ1990,KJ2014 = 25812.807,25812.8074555,4.835979e14,4.835978525e14 const ħ1990,ħ2014 = 2/RK1990/KJ1990^2/π,2/RK2014/KJ2014^2/π const mₑ1990,mₑ2014 = electronmass(2π*ħ1990),electronmass(2π*ħ2014) # engineering units # Thomson: αL = 1/2 +const Universe = Coupling{αG,1/αinv,μₑᵤ,μₚᵤ}() const Gauss = UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,4π,0.01/𝘤}() const LorentzHeaviside = UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,1,0.01/𝘤}() const Thomson = UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,4π,1/2}() @@ -137,9 +161,9 @@ const EnglishUS = UnitSystem{1000Rᵤ*mₑ/μₑᵤ*rankine/slug/ftUS^2,ħ/slug/ # astronomical units -const GMsun,GMearth,GMjupiter = 1.32712442099e20,398600441.8e6,1.26686534e17 +const GMsun,GMearth,GMjupiter = 1.32712442099e20,398600441.8e6,1.26686534e17 const au,LD,day = 149597870.7e3,384402e3,60^2*24 -const pc,ly,GG = au*648000/π,365.25𝘤*day,newton(SI2019) +const pc,ly,GG = au*648000/π,365.25𝘤*day,𝘤*ħ/mP^2 const mₛ = GMsun/GG; const Jₛ = mₛ*au^2/day^2; export mₛ,Jₛ,au,day const IAU = UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001/Jₛ,ħ/day/Jₛ,day*𝘤/au,4π*1e-7*day^2/Jₛ,mₑ/mₛ}() @@ -152,7 +176,6 @@ const CGS, CGS2019, CGSm, CGSe, HLU = Gauss, EMU2019, EMU, ESU, LorentzHeaviside # natural units -const αG = (mₑ/mP)^2 const Planck = UnitSystem{1,1,1,1,√(4π*αG)}() const PlanckGauss = UnitSystem{1,1,1,4π,√αG}() const Stoney = UnitSystem{1,αinv,1,4π,√(αG*αinv)}() @@ -168,15 +191,37 @@ const QCDoriginal = UnitSystem{1,1,1,4π/αinv,1/μₚₑ}() # physical constants +@pure electronmass(U::typeof(Planck),C::Coupling) = sqrt(4π*coupling(C)) +@pure electronmass(U::typeof(PlanckGauss),C::Coupling) = sqrt(coupling(C)) +@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,√(αG*αinv)},C::Coupling) where {kB,ħ,𝘤,μ₀} = sqrt(coupling(C)/finestructure(C)) +@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,1/μₚₑ},C::Coupling) where {kB,ħ,𝘤,μ₀} = 1/protonelectron(C) +@pure permeability(U::UnitSystem{kB,ħ,𝘤,4π/αinv^2},C::Coupling) where {kB,ħ,𝘤} = 4π*finestructure(C)^2 +@pure permeability(U::UnitSystem{kB,ħ,𝘤,π/αinv^2},C::Coupling) where {kB,ħ,𝘤} = π*finestructure(C)^2 +@pure lightspeed(U::UnitSystem{kB,ħ,αinv},C::Coupling) where {kB,ħ} = 1/finestructure(C) +@pure lightspeed(U::UnitSystem{kB,ħ,2αinv},C::Coupling) where {kB,ħ} = 2/finestructure(C) +@pure planckreduced(U::UnitSystem{kB,αinv},C::Coupling) where kB = 1/finestructure(C) + +@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,mₑ},C::Coupling) where {kB,ħ,μ₀} = electronmass(planck(U),C) +@pure electronmass(U::UnitSystem{kB,ħ,100𝘤,μ₀,1000mₑ},C::Coupling) where {kB,ħ,μ₀} = 1000electronmass(SI,C) +@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,mₑ/1000},C::Coupling) where {kB,ħ,μ₀} = electronmass(SI,C)/1000 +@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,mₑ2014},C::Coupling) where {kB,ħ,μ₀} = electronmass(planck(U),C) +@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,mₑ1990},C::Coupling) where {kB,ħ,μ₀} = electronmass(planck(U),C) +@pure electronmass(U::UnitSystem{kB,ħ,𝘤/ftUS,μ₀,mₑ/slug},C::Coupling) where {kB,ħ,μ₀} = electronmass(SI,C)/slug +@pure permeability(U::UnitSystem{kB,ħ,𝘤,μ₀},C::Coupling) where {kB,ħ,𝘤} = finestructure(C)*2𝘩/𝘤/𝘦^2 +@pure permeability(U::typeof(ESU2019),C::Coupling) = 1e3*permeability(SI,C)/𝘤^2 +@pure permeability(U::typeof(EMU2019),C::Coupling) = 1e7*permeability(SI,C) +@pure permeability(U::typeof(CODATA),C::Coupling) = 2RK2014*finestructure(C)/𝘤 +@pure permeability(U::typeof(Conventional),C::Coupling) = 2RK1990*finestructure(C)/𝘤 + @pure molarmass(U::UnitSystem{1}) = 1 -@pure molarmass(U::UnitSystem{kB}) = electronmass(U)*NA/μₑᵤ -@pure molarmass(U::UnitSystem{1e7*kB}) = 1000molarmass(SI2019) -@pure molarmass(U::UnitSystem{1e3*kB}) = molarmass(SI2019)/1000 +@pure molarmass(U::UnitSystem{kB},C::Coupling=universe(U)) = NA*electronmass(U,C)/electronunit(C) +@pure molarmass(U::UnitSystem{1e7*kB},C::Coupling=universe(U)) = 1000molarmass(SI2019,C) +@pure molarmass(U::UnitSystem{1e3*kB},C::Coupling=universe(U)) = molarmass(SI2019,C)/1000 @pure molarmass(U::UnitSystem{kB}) where kB = molarmass(CGS)/1000 @pure molarmass(U::UnitSystem{boltzmann(MTS)}) = molarmass(CGS)/1e6 @pure molarmass(U::UnitSystem{boltzmann(CGS)}) = molarmass(Natural) @pure molarmass(U::UnitSystem{boltzmann(FFF)}) = molarmass(Natural) -@pure molarmass(U::UnitSystem{boltzmann(English)}) = 1000molarmass(SI2019) +@pure molarmass(U::UnitSystem{boltzmann(English)},C::Coupling=universe(U)) = 1000molarmass(SI2019,C) @pure molarmass(U::UnitSystem{boltzmann(EnglishUS)}) = molarmass(Natural) @pure molarmass(U::UnitSystem{boltzmann(IAU)}) = 1/1000mₛ @@ -187,643 +232,6 @@ include("kinematic.jl") include("electromagnetic.jl") include("thermodynamic.jl") include("physics.jl") - -# == Metric is different -const κ = einstein(SI2019) -const σ = stefan(SI2019) # -const μB = magneton(SI2019) # -const ε₀ = permittivity(SI2019) # -const kₑ = coulomb(SI2019) # -const mₚ = protonmass(SI2019) -const mᵤ = atomicmass(SI2019) -const Mᵤ = molarmass(SI2019) -const 𝔉 = faraday(SI2019) # -const Φ₀ = magneticflux(SI2019) # -const Z₀ = impedance(SI2019) # -const G₀ = conductance(SI2019) # -const Eₕ = hartree(SI2019) -const a₀ = bohr(SI2019) -const rₑ = electronradius(SI2019) -const RK = klitzing(SI2019) # -const KJ = josephson(SI2019) # -const RH,Ry = R∞*mₚ/(mₑ+mₚ),𝘩*𝘤*R∞ - -const ℓP = length(PlanckGauss,SI2019) -const tP = time(PlanckGauss,SI2019) -const TP = temperature(PlanckGauss,SI2019) - -const lS = length(Stoney,SI2019) -const tS = time(Stoney,SI2019) -const mS = mass(Stoney,SI2019) -const qS = charge(Stoney,SI2019) - -const lA = length(Hartree,SI2019) -const tA = time(Hartree,SI2019) -const mA = mass(Hartree,SI2019) -const qA = charge(Hartree,SI2019) - -const lQCD = length(QCD,SI2019) -const tQCD = time(QCD,SI2019) -const mQCD = mass(QCD,SI2019) - -# non standard units - -const BTUftlb = 3600/0.5778thermalconductivity(English) # BTU⋅ft⁻¹⋅lb⁻¹ -const BTUJ = energy(English)*BTUftlb # BTU⋅J⁻¹ - -# constant aliases - -const mpe, meu, mpu, ainv, aG = μₚₑ, μₑᵤ, μₚᵤ, αinv, αG -const Mu,Ru,SB,hh,cc,m0,e0,ke,me,mp,mu,ee,FF,Z0,G0,Eh,a0,re,g0,lP,aL,ϵ₀ = Mᵤ,Rᵤ,σ,𝘩,𝘤,μ₀,ε₀,kₑ,mₑ,mₚ,mᵤ,𝘦,𝔉,Z₀,G₀,Eₕ,a₀,rₑ,g₀,ℓP,αL,ε₀ -export κ, GG, NA, kB, Rᵤ, σ, 𝘩, ħ, 𝘤, μ₀, ε₀, kₑ, mₑ, mₚ, mᵤ, 𝘦, 𝔉, Φ₀, Z₀, G₀, Eₕ, R∞, a₀, rₑ, KJ, RK, Ru, SB, hh, cc, m0, e0, ke, me, mp, mu, ee, FF, Z0, G0, Eh, a0, re, μB -export αG, αinv, μₚₑ, μₑᵤ, μₚᵤ, mpe, meu, mpu, mP, δμ₀, Mᵤ, Mu, RH, Ry, ΔνCs, Kcd, ainv -export cal, kcal, calₜₕ, kcalₜₕ, calᵢₜ, kcalᵢₜ, ℓP, g₀, g0, atm, lbm, BTUJ, BTUftlb, aG -export lP, tP, TP, lS, tS, mS, qS, lA, tA, mA, qA, lQCD, tQCD, mQCD, ϵ₀, αL, aL - -# engineering unit systems docs - -cgstext(US,AMP,cgs=eval(US)) = """ -```Julia -julia> boltzmann($US) # erg⋅K⁻¹ -$(boltzmann(cgs)) - -julia> planckreduced($US) # erg⋅s⋅rad⁻¹ -$(planckreduced(cgs)) - -julia> lightspeed($US) # cm⋅s⁻¹ -$(lightspeed(cgs)) - -julia> permeability($US) # statH⋅cm⁻¹ -$(permeability(cgs)) - -julia> electronmass($US) # g -$(electronmass(cgs)) - -julia> rationalization($US) -$(rationalization(cgs)) -``` -""" - -for U ∈ (:CGSm,:CGSe,:EMU,:ESU) - (EU,AMP) = QuoteNode.(U ∉ (:CGSe,:ESU) ? (:EMU,:Bi) : (:ESU,:statA)) -@eval @doc """ - $($(QuoteNode(U)))::UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,$($EU≠:EMU ? "(100𝘤)^-2" : 1),1000mₑ,4π} - -Centimetre-gram-second `UnitSystem` variant based on `$($EU)` (non-rationalized). - -$(cgstext($(QuoteNode(U)),$AMP)) -""" $U - -U ∉ (:CGSm,:CGSe) && @eval @doc """ - $(Symbol($(QuoteNode(U)),:2019))::UnitSystem{1e7*kB,1e7*ħ,100𝘤,$($EU≠:EMU ? "1e3*μ₀/𝘤^2" : "1e7*μ₀"),1000mₑ} - -Centimetre-gram-second `UnitSystem` variant of tuned `SI2019` based on `$($EU)` (rationalized). - -$(cgstext(Symbol($(QuoteNode(U)),:2019),$AMP)) -""" $(Symbol(U,:2019)) -end - -@doc """ - Thomson::UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,4π,1/2} - -Centimetre-gram-second `UnitSystem` variant `Thomson` (EMU-Lorentz, non-rationalized). - -```Julia -julia> boltzmann(Thomson) # erg⋅K⁻¹ -$(boltzmann(Thomson)) - -julia> planckreduced(Thomson) # erg⋅s⋅rad⁻¹ -$(planckreduced(Thomson)) - -julia> lightspeed(Thomson) # cm⋅s⁻¹ -$(lightspeed(Thomson)) - -julia> permeability(Thomson) # abH⋅cm⁻¹ -$(permeability(Thomson)) - -julia> electronmass(Thomson) # g -$(electronmass(Thomson)) - -julia> rationalization(Thomson) -$(rationalization(Thomson)) - -julia> lorentz(Thomson) -$(lorentz(Thomson)) -``` -""" Thomson - -@doc """ - Gauss::UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,4π,0.01/𝘤} - -Centimetre-gram-second `UnitSystem` variant `CGS` (Gauss-Lorentz, non-rationalized). - -```Julia -julia> boltzmann(Gauss) # erg⋅K⁻¹ -$(boltzmann(Gauss)) - -julia> planckreduced(Gauss) # erg⋅s⋅rad⁻¹ -$(planckreduced(Gauss)) - -julia> lightspeed(Gauss) # cm⋅s⁻¹ -$(lightspeed(Gauss)) - -julia> permeability(Gauss) # statH⋅cm⁻¹ -$(permeability(Gauss)) - -julia> electronmass(Gauss) # g -$(electronmass(Gauss)) - -julia> rationalization(Gauss) -$(rationalization(Gauss)) - -julia> lorentz(Gauss) -$(lorentz(Gauss)) -``` -""" Gauss, CGS - -@doc """ - LorentzHeaviside::UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,1,0.01/𝘤} - -Centimetre-gram-second `UnitSystem` variant `HLU` (Heaviside-Lorentz, rationalized). - -```Julia -julia> boltzmann(LorentzHeaviside) # erg⋅K⁻¹ -$(boltzmann(LorentzHeaviside)) - -julia> planckreduced(LorentzHeaviside) # erg⋅s⋅rad⁻¹ -$(planckreduced(LorentzHeaviside)) - -julia> lightspeed(LorentzHeaviside) # cm⋅s⁻¹ -$(lightspeed(LorentzHeaviside)) - -julia> permeability(HLU) # hlH⋅cm⁻¹ -$(permeability(LorentzHeaviside)) - -julia> electronmass(LorentzHeaviside) # g -$(electronmass(LorentzHeaviside)) - -julia> rationalization(LorentzHeaviside) -$(rationalization(LorentzHeaviside)) - -julia> lorentz(LorentzHeaviside) -$(lorentz(LorentzHeaviside)) -``` -""" LorentzHeaviside, HLU - -@doc """ - MTS::UnitSystem{1e6*Rᵤ*mₑ/μₑᵤ,1000ħ,𝘤,4π/1e4,mₑ/1000} - -Metre-tonne-second `UnitSystem` variant of `Metric` system. - -```Julia -julia> boltzmann(MTS) # kJ⋅K⁻¹ -$(boltzmann(MTS)) - -julia> planckreduced(MTS) # kJ⋅s⋅rad⁻¹ -$(planckreduced(MTS)) - -julia> lightspeed(MTS) # m⋅s⁻¹ -$(lightspeed(MTS)) - -julia> permeability(MTS) # kH⋅m⁻¹ -$(permeability(MTS)) - -julia> electronmass(MTS) # t -$(electronmass(MTS)) -``` -""" MTS - -@doc """ - Metric::UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001,ħ,𝘤,4π*1e-7,mₑ} - -Systeme International d'Unites (the SI units) adopted as the preferred `UnitSystem`. - -```Julia -julia> boltzmann(Metric) # J⋅K⁻¹ -$(boltzmann(Metric)) - -julia> planckreduced(Metric) # J⋅s⋅rad⁻¹ -$(planckreduced(Metric)) - -julia> lightspeed(Metric) # m⋅s⁻¹ -$(lightspeed(Metric)) - -julia> permeability(Metric) # H⋅m⁻¹ -$(permeability(Metric)) - -julia> electronmass(Metric) # kg -$(electronmass(Metric)) -``` -""" Metric - -@doc """ - SI2019::UnitSystem{kB,ħ,𝘤,μ₀,mₑ} - -Systeme International d'Unites (the SI units) with `μ₀` for a tuned `charge` exactly. - -```Julia -julia> boltzmann(SI2019) # J⋅K⁻¹ -$(boltzmann(SI2019)) - -julia> planckreduced(SI2019) # J⋅s⋅rad⁻¹ -$(planckreduced(SI2019)) - -julia> lightspeed(SI2019) # m⋅s⁻¹ -$(lightspeed(SI2019)) - -julia> permeability(SI2019) # H⋅m⁻¹ -$(permeability(SI2019)) - -julia> electronmass(SI2019) # kg -$(electronmass(SI2019)) -``` -""" SI2019, SI - -@doc """ - CODATA::UnitSystem{Rᵤ*mₑ2014/μₑᵤ/0.001,2/RK2014/KJ2014^2/π,𝘤,2RK2014/𝘤/αinv,mₑ2014} - -Metric `UnitSystem` based on Committee on Data of the International Science Council. - -```Julia -julia> boltzmann(CODATA) # J⋅K⁻¹ -$(boltzmann(CODATA)) - -julia> planckreduced(CODATA) # J⋅s⋅rad⁻¹ -$(planckreduced(CODATA)) - -julia> lightspeed(CODATA) # m⋅s⁻¹ -$(lightspeed(CODATA)) - -julia> permeability(CODATA) # H⋅m⁻¹ -$(permeability(CODATA)) - -julia> electronmass(CODATA) # kg -$(electronmass(CODATA)) -``` -""" CODATA - -@doc """ - Conventional::UnitSystem{Rᵤ*mₑ1990/μₑᵤ/0.001,2/RK1990/KJ1990^2/π,𝘤,2RK1990/𝘤/αinv,mₑ1990} - -Conventional electronic `UnitSystem` with 1990 tuned `josephson` and `klitzing` constants. - -```Julia -julia> boltzmann(Conventional) # J⋅K⁻¹ -$(boltzmann(Conventional)) - -julia> planckreduced(Conventional) # J⋅s⋅rad⁻¹ -$(planckreduced(Conventional)) - -julia> lightspeed(Conventional) # m⋅s⁻¹ -$(lightspeed(Conventional)) - -julia> permeability(Conventional) # H⋅m⁻¹ -$(permeability(Conventional)) - -julia> electronmass(Conventional) # kg -$(electronmass(Conventional)) -``` -""" Conventional - -@doc """ - IAU::UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001/Jₛ,ħ*day/Jₛ,day*𝘤/au,4π*1e-7*day^2/Jₛ,mₑ/mₛ} - -Astronomical (solar) `UnitSystem` defined by International Astronomical Union. - -```Julia -julia> boltzmann(IAU) # M⊙⋅au²⋅D⁻²⋅K⁻¹ -$(boltzmann(IAU)) - -julia> planckreduced(IAU) # M⊙⋅au²⋅D⁻¹⋅rad⁻¹ -$(planckreduced(IAU)) - -julia> lightspeed(IAU) # au⋅D⁻¹ -$(lightspeed(IAU)) - -julia> permeability(IAU) # M⊙⋅au²⋅C⁻² -$(permeability(IAU)) - -julia> electronmass(IAU) # M⊙ -$(electronmass(IAU)) -``` -""" IAU - -@doc """ - English::UnitSystem{kB*rankine/slug/ft^2,ħ/slug/ft^2,𝘤/ft,4π,mₑ/slug} - -Engineering `UnitSystem` historically used by Britain and United States. - -```Julia -julia> boltzmann(English) # ft⋅lb⋅°R⁻¹ -$(boltzmann(English)) - -julia> planckreduced(English) # ft⋅lb⋅s⋅rad⁻¹ -$(planckreduced(English)) - -julia> lightspeed(English) # ft⋅s⁻¹ -$(lightspeed(English)) - -julia> permeability(English) # slug⋅ft²⋅?⁻² -$(permeability(English)) - -julia> electronmass(English) # slugs -$(electronmass(English)) -``` -""" English - -@doc """ - EnglishUS::UnitSystem{1000Rᵤ*mₑ/μₑᵤ*rankine/slug/ftUS^2,ħ/slug/ftUS^2,𝘤/ftUS,4π,mₑ/slug} - -Engineering `UnitSystem` based on the geophysical US survey foot (1200/3937). - -```Julia -julia> boltzmann(EnglishUS) # ftUS⋅lb⋅°R⁻¹ -$(boltzmann(EnglishUS)) - -julia> planckreduced(EnglishUS) # ftUS⋅lb⋅s⋅rad⁻¹ -$(planckreduced(EnglishUS)) - -julia> lightspeed(EnglishUS) # ftUS⋅s⁻¹ -$(lightspeed(EnglishUS)) - -julia> permeability(EnglishUS) # slug⋅ftUS²⋅?⁻² -$(permeability(EnglishUS)) - -julia> electronmass(EnglishUS) # slugs -$(electronmass(EnglishUS)) -``` -""" EnglishUS - -@doc """ - FFF::UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001*rankine/Jf,ħ/14day/Jf,14day*𝘤/201.168,0,mₑ/mf} - -Furlong–firkin–fortnight `FFF` is a humorous `UnitSystem` based on unusal impractical units. - -```Julia -julia> boltzmann(FFF) # fir⋅fur²⋅ftn⁻²⋅F⁻¹ -$(boltzmann(FFF)) - -julia> planckreduced(FFF) # fir⋅fur²⋅ftn⁻¹⋅rad⁻¹ -$(planckreduced(FFF)) - -julia> lightspeed(FFF) # fur⋅ftn⁻¹ -$(lightspeed(FFF)) - -julia> permeability(FFF) # fir⋅fur²⋅Inf⁻² -$(permeability(FFF)) - -julia> electronmass(FFF) # fir -$(electronmass(FFF)) -``` -""" FFF - -@doc """ - Kennelly::UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001,ħ,𝘤,1e-7,mₑ,4π} - -Kennelly ? variant `UnitSystem` of the standard `Metric` units ??? - -```Julia -julia> boltzmann(Kennelly) # J⋅K⁻¹ -$(boltzmann(Kennelly)) - -julia> planckreduced(Kennelly) # J⋅s⋅rad⁻¹ -$(planckreduced(Kennelly)) - -julia> lightspeed(Kennelly) # m⋅s⁻¹ -$(lightspeed(Kennelly)) - -julia> permeability(Kennelly) # H⋅m⁻¹ -$(permeability(Kennelly)) - -julia> electronmass(Kennelly) # kg -$(electronmass(Kennelly)) - -julia> rationalization(Kennelly) -$(rationalization(Kennelly)) -``` -""" Kennelly - -# natural unit system docs - -textunits(U,S) = """ -```Julia -julia> boltzmann($S) -$(boltzmann(U)) - -julia> planckreduced($S) -$(planckreduced(U)) - -julia> lightspeed($S) -$(lightspeed(U)) - -julia> permeability($S) -$(permeability(U)) - -julia> electronmass($S) -$(electronmass(U)) -``` -""" - -@doc """ - Planck::UnitSystem{1,1,1,1,√(4π*αG)} - -Planck `UnitSystem` with the `electronmass` value `√(4π*αG)` using gravitational coupling. - -$(textunits(Planck,:Planck)) -""" Planck - -@doc """ - PlanckGauss::UnitSystem{1,1,1,4π,√αG} - -Planck (Gauss) `UnitSystem` with `permeability` of `4π` and `electronmass` coupling `√αG`. - -$(textunits(PlanckGauss,:PlanckGauss)) - -The well known `PlanckGauss` values for `length`, `time`, `mass`, and `temperature` are: -```Julia -julia> length(PlanckGauss,Metric) # ℓP -$(length(PlanckGauss,Metric)) - -julia> time(PlanckGauss,Metric) # tP -$(time(PlanckGauss,Metric)) - -julia> mass(PlanckGauss,Metric) # mP -$(mass(PlanckGauss,Metric)) - -julia> temperature(PlanckGauss,Metric) # TP -$(temperature(PlanckGauss,Metric)) -``` -""" PlanckGauss - -@doc """ - Stoney::UnitSystem{1,αinv,1,4π,√(αG*αinv)} - -Stoney `UnitSystem` with `permeability` of `4π` and `electronmass` coupling `√(αG*αinv)`. - -$(textunits(Stoney,:Stoney)) - -The well known `Stoney` values for `length`, `time`, `mass`, and `charge` are: -```Julia -julia> length(Stoney,Metric) # lS -$(length(Stoney,Metric)) - -julia> time(Stoney,Metric) # tS -$(time(Stoney,Metric)) - -julia> mass(Stoney,Metric) # mS -$(mass(Stoney,Metric)) - -julia> charge(Stoney,Metric) # qS -$(charge(Stoney,Metric)) -``` -""" Stoney - -@doc """ - Hartree::UnitSystem{1,1,αinv,4π/αinv^2,1} - -Hartree atomic `UnitSystem` with `lightspeed` of `αinv` and `permeability` of `4π/αinv^2`. - -$(textunits(Hartree,:Hartree)) - -The well known `Hartree` atomic unit values for `length`, `time`, `mass`, and `charge` are: -```Julia -julia> length(Hartree,Metric) # lA -$(length(Hartree,Metric)) - -julia> time(Hartree,Metric) # tA -$(time(Hartree,Metric)) - -julia> mass(Hartree,Metric) # mA -$(mass(Hartree,Metric)) - -julia> charge(Hartree,Metric) # qA -$(charge(Hartree,Metric)) -``` -""" Hartree - -@doc """ - Rydberg::UnitSystem{1,1,2αinv,π/αinv^2,1/2} - -Rydberg `UnitSystem` with `lightspeed` of `2αinv` and `permeability` of `π/αinv^2`. - -$(textunits(Rydberg,:Rydberg)) -""" Rydberg - -@doc """ - Schrodinger::UnitSystem{1,1,αinv,4π/αinv^2,√(αG*αinv)} - -Schrodinger `UnitSystem` with `permeability` of `4π/αinv^2` and `electronmass` of `√(αG*αinv)`. - -$(textunits(Schrodinger,:Schrodinger)) -""" Schrodinger - -const Electronic = UnitSystem{1,αinv,1,4π,1}() -@doc """ - Electronic::UnitSystem{1,αinv,1,4π,1} - -Electronic `UnitSystem` with `planckreduced` of `αinv` and `permeability` of `4π`. - -$(textunits(Electronic,:Electronic)) -""" Electronic - -@doc """ - Natural::UnitSystem{1,1,1,1,1} - -Natural `UnitSystem` with all primary constants having unit value. - -$(textunits(Natural,:Natural)) - -The well known `Natural` values for `length`, `time`, `mass`, and `charge` are: -```Julia -julia> length(Natural,Metric) -$(length(Natural,Metric)) - -julia> time(Natural,Metric) -$(time(Natural,Metric)) - -julia> mass(Natural,Metric) -$(mass(Natural,Metric)) - -julia> charge(Natural,Metric) -$(charge(Natural,Metric)) -``` -""" Natural - -@doc """ - NaturalGauss::UnitSystem{1,1,1,4π,1} - -Natural (Gauss) `UnitSystem` with the Gaussian `permeability` value of `4π`. - -$(textunits(NaturalGauss,:NaturalGauss)) -""" NaturalGauss - -@doc """ - QCD::UnitSystem{1,1,1,1,1/μₚₑ} - -Qunatum chromodynamics `UnitSystem` with `electronmass` of `1/μₚₑ` or `1/$μₚₑ`. - -$(textunits(QCD,:QCD)) - -The well known `QCD` values for `length`, `time`, `mass`, and `charge` are: -```Julia -julia> length(QCD,Metric) # lQCD -$(length(QCD,Metric)) - -julia> time(QCD,Metric) # tQCD -$(time(QCD,Metric)) - -julia> mass(QCD,Metric) # mQCD -$(mass(QCD,Metric)) - -julia> charge(QCD,Metric) -$(charge(QCD,Metric)) -``` -""" QCD - -@doc """ - QCDGauss::UnitSystem{1,1,1,4π,1/μₚₑ} - -Qunatum chromodynamics (Gauss) `UnitSystem` with `electronmass` of `1/μₚₑ`. - -$(textunits(QCDGauss,:QCDGauss)) - -The well known `QCDGauss` values for `length`, `time`, `mass`, and `charge` are: -```Julia -julia> length(QCDGauss,Metric) # lQCD -$(length(QCDGauss,Metric)) - -julia> time(QCDGauss,Metric) # tQCD -$(time(QCDGauss,Metric)) - -julia> mass(QCDGauss,Metric) # mQCD -$(mass(QCDGauss,Metric)) - -julia> charge(QCDGauss,Metric) -$(charge(QCDGauss,Metric)) -``` -""" QCDGauss - -@doc """ - QCDoriginal::UnitSystem{1,1,1,4π/αinv,1/μₚₑ} - -Qunatum chromodynamics (original) `UnitSystem` with `permeability` of `4π/αinv`. - -$(textunits(QCDoriginal,:QCDoriginal)) - -The well known `QCDoriginal` values for `length`, `time`, `mass`, and `charge` are: -```Julia -julia> length(QCDoriginal,Metric) # lQCD -$(length(QCDoriginal,Metric)) - -julia> time(QCDoriginal,Metric) # tQCD -$(time(QCDoriginal,Metric)) - -julia> mass(QCDoriginal,Metric) # mQCD -$(mass(QCDoriginal,Metric)) - -julia> charge(QCDoriginal,Metric) -$(charge(QCDoriginal,Metric)) -``` -""" QCDoriginal +include("systems.jl") end # module diff --git a/src/physics.jl b/src/physics.jl index 4c6c545..6e58e9e 100644 --- a/src/physics.jl +++ b/src/physics.jl @@ -5,25 +5,25 @@ @doc """ μₑᵤ, μₚᵤ, μₚₑ, αinv, αG -Physical measured dimensionless values with uncertainty are the electron to proton mass ratio `μₑᵤ`, proton to atomic mass ratio `μₚᵤ`, proton to electron mass ratio `μₚₑ`, inverted fine structure constant `αinv`, and the gravitaional coupling constant `αG`. +Physical measured dimensionless `Coupling` values with uncertainty are the electron to proton mass ratio `μₑᵤ`, proton to atomic mass ratio `μₚᵤ`, proton to electron mass ratio `μₚₑ`, inverted fine structure constant `αinv`, and the gravitaional coupling constant `αG`. ```Julia -julia> μₑᵤ +julia> μₑᵤ # electronunit(Universe) $μₑᵤ -julia> μₚᵤ +julia> μₚᵤ # protonunit(Universe) $μₚᵤ -julia> μₚₑ +julia> μₚₑ # protonelectron(Universe) $μₚₑ -julia> αinv +julia> αinv # 1/finestructure(Universe) $αinv -julia> αG +julia> αG # coupling(Universe) $αG ``` -""" μₑᵤ, μₚᵤ, μₚₑ, αinv, αG, meu, mpu, mpe, ainv, aG +""" Universe, μₑᵤ, μₚᵤ, μₚₑ, αinv, αG, meu, mpu, mpe, ainv, aG, electronunit, protonunit, protonelectron, finestructure, coupling @pure hyperfine(U::UnitSystem) = frequency(ΔνCs,U) @doc """ @@ -62,7 +62,7 @@ $(luminousefficacy(English)) """ luminousefficacy, Kcd @doc """ - molarmass(U::UnitSystem) = avogadro(U)*electronmass(U)/μₑᵤ # 1/μₑᵤ = $(1/μₑᵤ-2e-13) + molarmass(U::UnitSystem) = avogadro(U)*electronmass(U)/electronunit(U) Molar mass constant `Mᵤ` is the ratio of the `molarmass` and `relativemass` of a chemical. ```Julia @@ -80,7 +80,7 @@ $(molarmass(SI2019)) ``` """ molarmass, Mᵤ, Mu -@pure avogadro(U::UnitSystem) = μₑᵤ*molarmass(U)/electronmass(U) +@pure avogadro(U::UnitSystem,C::Coupling=universe(U)) = molarmass(U,C)*electronunit(C)/electronmass(U,C) @doc """ avogadro(x) = universal(x)/boltzmann(x) # Mᵤ/atomicmass(x), Mᵤ ≈ 0.001-3.5e-13 @@ -272,7 +272,7 @@ $(rationalization(Gauss)) """ rationalization @doc """ - electronmass(U::UnitSystem) = protonmass(U)/$μₚₑ # αinv^2*R∞*2𝘩/𝘤 + electronmass(U::UnitSystem) = protonmass(U)/protonelectron(U) # αinv^2*R∞*2𝘩/𝘤 Electron rest mass `mₑ` of subatomic particle with `-𝘦` elementary charge (kg or slugs). ```Julia @@ -293,7 +293,7 @@ $(electronmass(English)) ``` """ electronmass, mₑ, me -@pure atomicmass(U::UnitSystem) = electronmass(U)/μₑᵤ +@pure atomicmass(U::UnitSystem,C::Coupling=universe(U)) = electronmass(U,C)/electronunit(C) @doc """ atomicmass(U::UnitSystem) = Mᵤ/avogadro(U) # $(molarmass(SI2019)) ≈ 0.001-3.5e-13 @@ -316,9 +316,9 @@ $(atomicmass(English)) ``` """ atomicmass, mᵤ, mu -@pure protonmass(U::UnitSystem) = μₚₑ*electronmass(U) +@pure protonmass(U::UnitSystem,C::Coupling=universe(U)) = protonelectron(C)*electronmass(U,C) @doc """ - protonmass(U::UnitSystem) = $(μₚᵤ)atomicmass(U) + protonmass(U::UnitSystem) = protonunit(U)*atomicmass(U) Proton mass `mₚ` of subatomic particle with `+𝘦` elementary charge (kg or mass). ```Julia @@ -337,7 +337,7 @@ $(protonmass(Metric)/electronmass(Metric)) """ protonmass, mₚ, mp @doc """ - planckmass(U::UnitSystem) = sqrt(planckreduced(U)*lightspeed(U)/newton(U)) + planckmass(U::UnitSystem) = electronmass(U)/sqrt(coupling(U)) Planck mass factor `mP` from the gravitational coupling constant `αG` (kg or slugs). ```Julia @@ -371,7 +371,7 @@ $(newton(English)) ``` """ newton, GG -@pure einstein(U::UnitSystem) = 8π*newton(U)/lightspeed(U)^4 +@pure einstein(U::UnitSystem,C::Coupling=universe(U)) = 8π*newton(U,C)/lightspeed(U,C)^4 @doc """ einstein(U::UnitSystem) = 8π*newton(U)/lightspeed(U)^4 @@ -382,7 +382,7 @@ $(einstein(Metric)) ``` """ einstein, κ -@pure universal(U::UnitSystem) = boltzmann(U)*avogadro(U) +@pure universal(U::UnitSystem,C::Coupling=universe(U)) = boltzmann(U,C)*avogadro(U,C) @doc """ universal(x) = boltzmann(x)*avogadro(x) @@ -414,7 +414,7 @@ $(universal(English)) The 1976 United States Standard Atmosphere used R* = 8.31432 exactly. """ universal, Rᵤ, Ru -@pure stefan(U::UnitSystem) = 2π^5*boltzmann(U)^4/(15planck(U)^3*lightspeed(U)^2) +@pure stefan(U::UnitSystem,C::Coupling=universe(U)) = 2π^5*boltzmann(U,C)^4/(15planck(U,C)^3*lightspeed(U,C)^2) @doc """ stefan(U::UnitSystem) = 2π^5*boltzmann(U)^4/(15planck(U)^3*lightspeed(U)^2) @@ -451,9 +451,9 @@ julia> radiationdensity(English) # lb⋅ft⁻²⋅°R⁻⁴ $(radiationdensity(English)) ``` """ -@pure radiationdensity(U::UnitSystem) = 4stefan(U)/lightspeed(U) +@pure radiationdensity(U::UnitSystem,C::Coupling=universe(U)) = 4stefan(U,C)/lightspeed(U,C) -@pure permittivity(U::UnitSystem) = inv(permeability(U)*(lightspeed(U)*lorentz(U))^2) +@pure permittivity(U::UnitSystem,C::Coupling=universe(U)) = inv(permeability(U,C)*(lightspeed(U,C)*lorentz(U))^2) @doc """ permittivity(U::UnitSystem) = 1/permeability(U)/(lightspeed(U)*lorentz(U))^2 @@ -483,7 +483,7 @@ $(permittivity(SI2019)/charge(SI2019)) ``` """ permittivity, ε₀, ϵ₀, e0 -@pure coulomb(U::UnitSystem) = rationalization(U)/4π/permittivity(U) +@pure coulomb(U::UnitSystem,C::Coupling=universe(U)) = rationalization(U)/4π/permittivity(U,C) @doc """ coulomb(U::UnitSystem) = rationalization(U)/4π/permittivity(U) @@ -513,7 +513,7 @@ $(coulomb(HLU)) ``` """ coulomb, kₑ, ke -@pure biotsavart(U::UnitSystem) = permeability(U)*lorentz(U)*(rationalization(U)/4π) +@pure biotsavart(U::UnitSystem,C::Coupling=universe(U)) = permeability(U,C)*lorentz(U)*(rationalization(U)/4π) @doc """ biotsavart(U::UnitSystem) = permeability(U)*lorentz(U)*rationalization(U)/4π @@ -608,7 +608,7 @@ $(impedance(HLU)) """ impedance, Z₀, Z0 @doc """ - charge(U::UnitSystem) = sqrt(2𝘩/$(αinv)impedance(U)) # faraday(U)/avogadro(U) + charge(U::UnitSystem) = √(2planck(U)*finestructure(U)/impedance(U)) # faraday(U)/avogadro(U) Quantized elementary charge `𝘦` of a proton or electron `2/(klitzing(U)*josephson(U))` (C). ```Julia @@ -635,7 +635,7 @@ $(charge(Planck)) ``` """ charge, 𝘦, ee -@pure faraday(U::UnitSystem) = charge(U)*avogadro(U) +@pure faraday(U::UnitSystem,C::Coupling=universe(U)) = charge(U,C)*avogadro(U,C) @doc """ faraday(U::UnitSystem) = charge(U)*avogadro(U) @@ -667,7 +667,7 @@ $(faraday(Metric)/3600) ``` """ faraday, 𝔉, FF -@pure josephson(U::UnitSystem) = 2charge(U)*lorentz(U)/planck(U) +@pure josephson(U::UnitSystem,C::Coupling=universe(U)) = 2charge(U,C)*lorentz(U)/planck(U,C) @doc """ josephson(U::UnitSystem) = 2charge(U)*lorentz(U)/planck(U) # 1/magneticflux(U) @@ -693,7 +693,7 @@ $(josephson(ESU)) ``` """ josephson, KJ -@pure magneticflux(U::UnitSystem) = inv(josephson(U)) +@pure magneticflux(U::UnitSystem,C::Coupling=universe(U)) = inv(josephson(U,C)) @doc """ magneticflux(U::UnitSystem) = planck(U)/2charge(U)/lorentz(U) @@ -716,7 +716,7 @@ $(magneticflux(ESU)) ``` """ magneticflux, Φ₀ -@pure klitzing(U::UnitSystem) = planck(U)/charge(U)^2 +@pure klitzing(U::UnitSystem,C::Coupling=universe(U)) = planck(U,C)/charge(U,C)^2 @doc """ klitzing(U::UnitSystem) = planck(U)/charge(U)^2 @@ -742,7 +742,7 @@ $(klitzing(ESU)) ``` """ klitzing, RK -@pure conductance(U::UnitSystem) = 2charge(U)^2/planck(U) +@pure conductance(U::UnitSystem,C::Coupling=universe(U)) = 2charge(U,C)^2/planck(U,C) @doc """ conductance(U::UnitSystem) = 2charge(U)^2/planck(U) # 2/klitzing(U) @@ -768,9 +768,9 @@ $(conductance(ESU)) ``` """ conductance, G₀, G0 -@pure hartree(U::UnitSystem) = electronmass(U)*(lightspeed(U)/αinv)^2 +@pure hartree(U::UnitSystem,C::Coupling=universe(U)) = electronmass(U,C)*(lightspeed(U,C)*finestructure(C))^2 @doc """ - hartree(U::UnitSystem) = electronmass(U)*(lightspeed(U)/$αinv)^2 # mₑ*(𝘤/αinv)^2 + hartree(U::UnitSystem) = electronmass(U)*(lightspeed(U)*finestructure(U))^2 # mₑ*(𝘤/αinv)^2 Hartree electric potential energy `Eₕ` of the hydrogen atom at ground state is `2R∞*𝘩*𝘤` (J). ```Julia @@ -801,7 +801,7 @@ $(hartree(Metric)/boltzmann(Metric)) In a Gaussian unit system where `4π*ε₀ == 1` the Hartree energy is `𝘦^2/a₀`. """ hartree, Eₕ, Eh -@pure rydberg(U::UnitSystem) = hartree(U)/2planck(U)/lightspeed(U) +@pure rydberg(U::UnitSystem,C::Coupling=universe(U)) = hartree(U,C)/2planck(U,C)/lightspeed(U,C) @doc """ rydberg(U::UnitSystem) = hartree(U)/2planck(U)/lightspeed(U) # Eₕ/2𝘩/𝘤 @@ -839,9 +839,9 @@ $(1/rydberg(Metric)/2π) Precision measurements of the Rydberg constants are within a relative standard uncertainty of under 2 parts in 10¹², and is chosen to constrain values of other physical constants. """ rydberg, R∞, RH, Ry -@pure bohr(U::UnitSystem) = αinv*planckreduced(U)/electronmass(U)/lightspeed(U) +@pure bohr(U::UnitSystem,C::Coupling=universe(U)) = planckreduced(U,C)/electronmass(U,C)/lightspeed(U,C)/finestructure(C) @doc """ - bohr(U) = $αinv*planckreduced(U)/electronmass(U)/lightspeed(U) + bohr(U) = planckreduced(U)/electronmass(U)/lightspeed(U)/finestructure(U) Bohr radius of the hydrogen atom in its ground state `a₀` (m). ```Julia @@ -857,7 +857,7 @@ $(bohr(Metric)/length(PlanckGauss)) """ bohr, a₀, a0 """ - bohrreduced(U::UnitSystem) = bohr(U)*(1+1/$μₚₑ) + bohrreduced(U::UnitSystem) = bohr(U)*(1+1/protonelectron(U)) Reduced Bohr radius including the effect of reduced mass in hydrogen atom (m). ```Julia @@ -868,11 +868,11 @@ julia> bohrreduced(Metric) # a₀ $(bohrreduced(Metric)/bohr(Metric)) ``` """ -@pure bohrreduced(U::UnitSystem) = bohr(U)*(1+1/μₚₑ) +@pure bohrreduced(U::UnitSystem,C::Coupling=universe(U)) = bohr(U,C)*(1+1/protonelectron(C)) -@pure electronradius(U::UnitSystem) = planckreduced(U)/electronmass(U)/lightspeed(U)/αinv +@pure electronradius(U::UnitSystem,C::Coupling=universe(U)) = finestructure(C)*planckreduced(U,C)/electronmass(U,C)/lightspeed(U,C) @doc """ - electronradius(U) = planckreduced(U)/electronmass(U)/lightspeed(U)/$αinv + electronradius(U) = finestructure(U)*planckreduced(U)/electronmass(U)/lightspeed(U) Classical electron radius or Lorentz radius or Thomson scattering length (m). ```Julia @@ -887,7 +887,7 @@ $(electronradius(Conventional)) ``` """ electronradius, rₑ, re -@pure magneton(U::UnitSystem) = charge(U)*planckreduced(U)*lorentz(U)/2electronmass(U) +@pure magneton(U::UnitSystem,C::Coupling=universe(U)) = charge(U,C)*planckreduced(U,C)*lorentz(U)/2electronmass(U,C) """ magneton(U::UnitSystem) = charge(U)*planckreduced(U)*lorentz(U)/2electronmass(U) diff --git a/src/systems.jl b/src/systems.jl new file mode 100644 index 0000000..28eb503 --- /dev/null +++ b/src/systems.jl @@ -0,0 +1,646 @@ + +# This file is part of UnitSystems.jl. It is licensed under the MIT license +# UnitSystems Copyright (C) 2021 Michael Reed + +export Universe, coupling, finestructure, electronunit, protonunit, protonelectron +#const Mu,Ru,SB,hh,cc,m0,e0,ke,me,mp,mu,ee,FF,Z0,G0,Eh,a0,re,g0,lP,ϵ₀,mB = Mᵤ,Rᵤ,σ,𝘩,𝘤,μ₀,ε₀,kₑ,mₑ,mₚ,mᵤ,𝘦,𝔉,Z₀,G₀,Eₕ,a₀,rₑ,g₀,ℓP,ε₀,μB +export slug, ft, KJ1990, KJ2014, RK1990, RK2014, mₑ1990, mₑ2014, temp, units +export slugs, kilograms, lbm, meters, feet, rankine, kelvin, moles, molecules +export UnitSystem, US, SI, MKS, CGS, CGS2019, CGSm, CGSe, HLU, FFF + +# == Metric is different +const κ = einstein(SI2019) +const σ = stefan(SI2019) # +const μB = magneton(SI2019) # +const ε₀ = permittivity(SI2019) # +const kₑ = coulomb(SI2019) # +const mₚ = protonmass(SI2019) +const mᵤ = atomicmass(SI2019) +const Mᵤ = molarmass(SI2019) +const 𝔉 = faraday(SI2019) # +const Φ₀ = magneticflux(SI2019) # +const Z₀ = impedance(SI2019) # +const G₀ = conductance(SI2019) # +const Eₕ = hartree(SI2019) +const a₀ = bohr(SI2019) +const rₑ = electronradius(SI2019) +const RK = klitzing(SI2019) # +const KJ = josephson(SI2019) # +const RH,Ry = R∞*mₚ/(mₑ+mₚ),𝘩*𝘤*R∞ + +const ℓP = length(PlanckGauss,SI2019) +const tP = time(PlanckGauss,SI2019) +const TP = temperature(PlanckGauss,SI2019) + +const lS = length(Stoney,SI2019) +const tS = time(Stoney,SI2019) +const mS = mass(Stoney,SI2019) +const qS = charge(Stoney,SI2019) + +const lA = length(Hartree,SI2019) +const tA = time(Hartree,SI2019) +const mA = mass(Hartree,SI2019) +const qA = charge(Hartree,SI2019) + +const lQCD = length(QCD,SI2019) +const tQCD = time(QCD,SI2019) +const mQCD = mass(QCD,SI2019) + +# non standard units + +const BTUftlb = 3600/0.5778thermalconductivity(English) # BTU⋅ft⁻¹⋅lb⁻¹ +const BTUJ = energy(English)*BTUftlb # BTU⋅J⁻¹ + +# constant aliases + +const mpe, meu, mpu, ainv, aG = μₚₑ, μₑᵤ, μₚᵤ, αinv, αG +const Mu,Ru,SB,hh,cc,m0,e0,ke,me,mp,mu,ee,FF,Z0,G0,Eh,a0,re,g0,lP,aL,ϵ₀ = Mᵤ,Rᵤ,σ,𝘩,𝘤,μ₀,ε₀,kₑ,mₑ,mₚ,mᵤ,𝘦,𝔉,Z₀,G₀,Eₕ,a₀,rₑ,g₀,ℓP,αL,ε₀ +export κ, GG, NA, kB, Rᵤ, σ, 𝘩, ħ, 𝘤, μ₀, ε₀, kₑ, mₑ, mₚ, mᵤ, 𝘦, 𝔉, Φ₀, Z₀, G₀, Eₕ, R∞, a₀, rₑ, KJ, RK, Ru, SB, hh, cc, m0, e0, ke, me, mp, mu, ee, FF, Z0, G0, Eh, a0, re, μB +export αG, αinv, μₚₑ, μₑᵤ, μₚᵤ, mpe, meu, mpu, mP, δμ₀, Mᵤ, Mu, RH, Ry, ΔνCs, Kcd, ainv +export cal, kcal, calₜₕ, kcalₜₕ, calᵢₜ, kcalᵢₜ, ℓP, g₀, g0, atm, lbm, BTUJ, BTUftlb, aG +export lP, tP, TP, lS, tS, mS, qS, lA, tA, mA, qA, lQCD, tQCD, mQCD, ϵ₀, αL, aL + +# engineering unit systems docs + +cgstext(US,AMP,cgs=eval(US)) = """ +```Julia +julia> boltzmann($US) # erg⋅K⁻¹ +$(boltzmann(cgs)) + +julia> planckreduced($US) # erg⋅s⋅rad⁻¹ +$(planckreduced(cgs)) + +julia> lightspeed($US) # cm⋅s⁻¹ +$(lightspeed(cgs)) + +julia> permeability($US) # statH⋅cm⁻¹ +$(permeability(cgs)) + +julia> electronmass($US) # g +$(electronmass(cgs)) + +julia> rationalization($US) +$(rationalization(cgs)) +``` +""" + +for U ∈ (:CGSm,:CGSe,:EMU,:ESU) + (EU,AMP) = QuoteNode.(U ∉ (:CGSe,:ESU) ? (:EMU,:Bi) : (:ESU,:statA)) +@eval @doc """ + $($(QuoteNode(U)))::UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,$($EU≠:EMU ? "(100𝘤)^-2" : 1),1000mₑ,4π} + +Centimetre-gram-second `UnitSystem` variant based on `$($EU)` (non-rationalized). + +$(cgstext($(QuoteNode(U)),$AMP)) +""" $U + +U ∉ (:CGSm,:CGSe) && @eval @doc """ + $(Symbol($(QuoteNode(U)),:2019))::UnitSystem{1e7*kB,1e7*ħ,100𝘤,$($EU≠:EMU ? "1e3*μ₀/𝘤^2" : "1e7*μ₀"),1000mₑ} + +Centimetre-gram-second `UnitSystem` variant of tuned `SI2019` based on `$($EU)` (rationalized). + +$(cgstext(Symbol($(QuoteNode(U)),:2019),$AMP)) +""" $(Symbol(U,:2019)) +end + +@doc """ + Thomson::UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,4π,1/2} + +Centimetre-gram-second `UnitSystem` variant `Thomson` (EMU-Lorentz, non-rationalized). + +```Julia +julia> boltzmann(Thomson) # erg⋅K⁻¹ +$(boltzmann(Thomson)) + +julia> planckreduced(Thomson) # erg⋅s⋅rad⁻¹ +$(planckreduced(Thomson)) + +julia> lightspeed(Thomson) # cm⋅s⁻¹ +$(lightspeed(Thomson)) + +julia> permeability(Thomson) # abH⋅cm⁻¹ +$(permeability(Thomson)) + +julia> electronmass(Thomson) # g +$(electronmass(Thomson)) + +julia> rationalization(Thomson) +$(rationalization(Thomson)) + +julia> lorentz(Thomson) +$(lorentz(Thomson)) +``` +""" Thomson + +@doc """ + Gauss::UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,4π,0.01/𝘤} + +Centimetre-gram-second `UnitSystem` variant `CGS` (Gauss-Lorentz, non-rationalized). + +```Julia +julia> boltzmann(Gauss) # erg⋅K⁻¹ +$(boltzmann(Gauss)) + +julia> planckreduced(Gauss) # erg⋅s⋅rad⁻¹ +$(planckreduced(Gauss)) + +julia> lightspeed(Gauss) # cm⋅s⁻¹ +$(lightspeed(Gauss)) + +julia> permeability(Gauss) # statH⋅cm⁻¹ +$(permeability(Gauss)) + +julia> electronmass(Gauss) # g +$(electronmass(Gauss)) + +julia> rationalization(Gauss) +$(rationalization(Gauss)) + +julia> lorentz(Gauss) +$(lorentz(Gauss)) +``` +""" Gauss, CGS + +@doc """ + LorentzHeaviside::UnitSystem{1e10*Rᵤ*mₑ/μₑᵤ,1e7*ħ,100𝘤,1,1000mₑ,1,0.01/𝘤} + +Centimetre-gram-second `UnitSystem` variant `HLU` (Heaviside-Lorentz, rationalized). + +```Julia +julia> boltzmann(LorentzHeaviside) # erg⋅K⁻¹ +$(boltzmann(LorentzHeaviside)) + +julia> planckreduced(LorentzHeaviside) # erg⋅s⋅rad⁻¹ +$(planckreduced(LorentzHeaviside)) + +julia> lightspeed(LorentzHeaviside) # cm⋅s⁻¹ +$(lightspeed(LorentzHeaviside)) + +julia> permeability(HLU) # hlH⋅cm⁻¹ +$(permeability(LorentzHeaviside)) + +julia> electronmass(LorentzHeaviside) # g +$(electronmass(LorentzHeaviside)) + +julia> rationalization(LorentzHeaviside) +$(rationalization(LorentzHeaviside)) + +julia> lorentz(LorentzHeaviside) +$(lorentz(LorentzHeaviside)) +``` +""" LorentzHeaviside, HLU + +@doc """ + MTS::UnitSystem{1e6*Rᵤ*mₑ/μₑᵤ,1000ħ,𝘤,4π/1e4,mₑ/1000} + +Metre-tonne-second `UnitSystem` variant of `Metric` system. + +```Julia +julia> boltzmann(MTS) # kJ⋅K⁻¹ +$(boltzmann(MTS)) + +julia> planckreduced(MTS) # kJ⋅s⋅rad⁻¹ +$(planckreduced(MTS)) + +julia> lightspeed(MTS) # m⋅s⁻¹ +$(lightspeed(MTS)) + +julia> permeability(MTS) # kH⋅m⁻¹ +$(permeability(MTS)) + +julia> electronmass(MTS) # t +$(electronmass(MTS)) +``` +""" MTS + +@doc """ + Metric::UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001,ħ,𝘤,4π*1e-7,mₑ} + +Systeme International d'Unites (the SI units) adopted as the preferred `UnitSystem`. + +```Julia +julia> boltzmann(Metric) # J⋅K⁻¹ +$(boltzmann(Metric)) + +julia> planckreduced(Metric) # J⋅s⋅rad⁻¹ +$(planckreduced(Metric)) + +julia> lightspeed(Metric) # m⋅s⁻¹ +$(lightspeed(Metric)) + +julia> permeability(Metric) # H⋅m⁻¹ +$(permeability(Metric)) + +julia> electronmass(Metric) # kg +$(electronmass(Metric)) +``` +""" Metric + +@doc """ + SI2019::UnitSystem{kB,ħ,𝘤,μ₀,mₑ} + +Systeme International d'Unites (the SI units) with `μ₀` for a tuned `charge` exactly. + +```Julia +julia> boltzmann(SI2019) # J⋅K⁻¹ +$(boltzmann(SI2019)) + +julia> planckreduced(SI2019) # J⋅s⋅rad⁻¹ +$(planckreduced(SI2019)) + +julia> lightspeed(SI2019) # m⋅s⁻¹ +$(lightspeed(SI2019)) + +julia> permeability(SI2019) # H⋅m⁻¹ +$(permeability(SI2019)) + +julia> electronmass(SI2019) # kg +$(electronmass(SI2019)) +``` +""" SI2019, SI + +@doc """ + CODATA::UnitSystem{Rᵤ*mₑ2014/μₑᵤ/0.001,2/RK2014/KJ2014^2/π,𝘤,2RK2014/𝘤/αinv,mₑ2014} + +Metric `UnitSystem` based on Committee on Data of the International Science Council. + +```Julia +julia> boltzmann(CODATA) # J⋅K⁻¹ +$(boltzmann(CODATA)) + +julia> planckreduced(CODATA) # J⋅s⋅rad⁻¹ +$(planckreduced(CODATA)) + +julia> lightspeed(CODATA) # m⋅s⁻¹ +$(lightspeed(CODATA)) + +julia> permeability(CODATA) # H⋅m⁻¹ +$(permeability(CODATA)) + +julia> electronmass(CODATA) # kg +$(electronmass(CODATA)) +``` +""" CODATA + +@doc """ + Conventional::UnitSystem{Rᵤ*mₑ1990/μₑᵤ/0.001,2/RK1990/KJ1990^2/π,𝘤,2RK1990/𝘤/αinv,mₑ1990} + +Conventional electronic `UnitSystem` with 1990 tuned `josephson` and `klitzing` constants. + +```Julia +julia> boltzmann(Conventional) # J⋅K⁻¹ +$(boltzmann(Conventional)) + +julia> planckreduced(Conventional) # J⋅s⋅rad⁻¹ +$(planckreduced(Conventional)) + +julia> lightspeed(Conventional) # m⋅s⁻¹ +$(lightspeed(Conventional)) + +julia> permeability(Conventional) # H⋅m⁻¹ +$(permeability(Conventional)) + +julia> electronmass(Conventional) # kg +$(electronmass(Conventional)) +``` +""" Conventional + +@doc """ + IAU::UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001/Jₛ,ħ*day/Jₛ,day*𝘤/au,4π*1e-7*day^2/Jₛ,mₑ/mₛ} + +Astronomical (solar) `UnitSystem` defined by International Astronomical Union. + +```Julia +julia> boltzmann(IAU) # M⊙⋅au²⋅D⁻²⋅K⁻¹ +$(boltzmann(IAU)) + +julia> planckreduced(IAU) # M⊙⋅au²⋅D⁻¹⋅rad⁻¹ +$(planckreduced(IAU)) + +julia> lightspeed(IAU) # au⋅D⁻¹ +$(lightspeed(IAU)) + +julia> permeability(IAU) # M⊙⋅au²⋅C⁻² +$(permeability(IAU)) + +julia> electronmass(IAU) # M⊙ +$(electronmass(IAU)) +``` +""" IAU + +@doc """ + English::UnitSystem{kB*rankine/slug/ft^2,ħ/slug/ft^2,𝘤/ft,4π,mₑ/slug} + +Engineering `UnitSystem` historically used by Britain and United States. + +```Julia +julia> boltzmann(English) # ft⋅lb⋅°R⁻¹ +$(boltzmann(English)) + +julia> planckreduced(English) # ft⋅lb⋅s⋅rad⁻¹ +$(planckreduced(English)) + +julia> lightspeed(English) # ft⋅s⁻¹ +$(lightspeed(English)) + +julia> permeability(English) # slug⋅ft²⋅?⁻² +$(permeability(English)) + +julia> electronmass(English) # slugs +$(electronmass(English)) +``` +""" English + +@doc """ + EnglishUS::UnitSystem{1000Rᵤ*mₑ/μₑᵤ*rankine/slug/ftUS^2,ħ/slug/ftUS^2,𝘤/ftUS,4π,mₑ/slug} + +Engineering `UnitSystem` based on the geophysical US survey foot (1200/3937). + +```Julia +julia> boltzmann(EnglishUS) # ftUS⋅lb⋅°R⁻¹ +$(boltzmann(EnglishUS)) + +julia> planckreduced(EnglishUS) # ftUS⋅lb⋅s⋅rad⁻¹ +$(planckreduced(EnglishUS)) + +julia> lightspeed(EnglishUS) # ftUS⋅s⁻¹ +$(lightspeed(EnglishUS)) + +julia> permeability(EnglishUS) # slug⋅ftUS²⋅?⁻² +$(permeability(EnglishUS)) + +julia> electronmass(EnglishUS) # slugs +$(electronmass(EnglishUS)) +``` +""" EnglishUS + +@doc """ + FFF::UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001*rankine/Jf,ħ/14day/Jf,14day*𝘤/201.168,0,mₑ/mf} + +Furlong–firkin–fortnight `FFF` is a humorous `UnitSystem` based on unusal impractical units. + +```Julia +julia> boltzmann(FFF) # fir⋅fur²⋅ftn⁻²⋅F⁻¹ +$(boltzmann(FFF)) + +julia> planckreduced(FFF) # fir⋅fur²⋅ftn⁻¹⋅rad⁻¹ +$(planckreduced(FFF)) + +julia> lightspeed(FFF) # fur⋅ftn⁻¹ +$(lightspeed(FFF)) + +julia> permeability(FFF) # fir⋅fur²⋅Inf⁻² +$(permeability(FFF)) + +julia> electronmass(FFF) # fir +$(electronmass(FFF)) +``` +""" FFF + +@doc """ + Kennelly::UnitSystem{Rᵤ*mₑ/μₑᵤ/0.001,ħ,𝘤,1e-7,mₑ,4π} + +Kennelly ? variant `UnitSystem` of the standard `Metric` units ??? + +```Julia +julia> boltzmann(Kennelly) # J⋅K⁻¹ +$(boltzmann(Kennelly)) + +julia> planckreduced(Kennelly) # J⋅s⋅rad⁻¹ +$(planckreduced(Kennelly)) + +julia> lightspeed(Kennelly) # m⋅s⁻¹ +$(lightspeed(Kennelly)) + +julia> permeability(Kennelly) # H⋅m⁻¹ +$(permeability(Kennelly)) + +julia> electronmass(Kennelly) # kg +$(electronmass(Kennelly)) + +julia> rationalization(Kennelly) +$(rationalization(Kennelly)) +``` +""" Kennelly + +# natural unit system docs + +textunits(U,S) = """ +```Julia +julia> boltzmann($S) +$(boltzmann(U)) + +julia> planckreduced($S) +$(planckreduced(U)) + +julia> lightspeed($S) +$(lightspeed(U)) + +julia> permeability($S) +$(permeability(U)) + +julia> electronmass($S) +$(electronmass(U)) +``` +""" + +@doc """ + Planck::UnitSystem{1,1,1,1,√(4π*αG)} + +Planck `UnitSystem` with the `electronmass` value `√(4π*αG)` using gravitational coupling. + +$(textunits(Planck,:Planck)) +""" Planck + +@doc """ + PlanckGauss::UnitSystem{1,1,1,4π,√αG} + +Planck (Gauss) `UnitSystem` with `permeability` of `4π` and `electronmass` coupling `√αG`. + +$(textunits(PlanckGauss,:PlanckGauss)) + +The well known `PlanckGauss` values for `length`, `time`, `mass`, and `temperature` are: +```Julia +julia> length(PlanckGauss,Metric) # ℓP +$(length(PlanckGauss,Metric)) + +julia> time(PlanckGauss,Metric) # tP +$(time(PlanckGauss,Metric)) + +julia> mass(PlanckGauss,Metric) # mP +$(mass(PlanckGauss,Metric)) + +julia> temperature(PlanckGauss,Metric) # TP +$(temperature(PlanckGauss,Metric)) +``` +""" PlanckGauss + +@doc """ + Stoney::UnitSystem{1,αinv,1,4π,√(αG*αinv)} + +Stoney `UnitSystem` with `permeability` of `4π` and `electronmass` coupling `√(αG*αinv)`. + +$(textunits(Stoney,:Stoney)) + +The well known `Stoney` values for `length`, `time`, `mass`, and `charge` are: +```Julia +julia> length(Stoney,Metric) # lS +$(length(Stoney,Metric)) + +julia> time(Stoney,Metric) # tS +$(time(Stoney,Metric)) + +julia> mass(Stoney,Metric) # mS +$(mass(Stoney,Metric)) + +julia> charge(Stoney,Metric) # qS +$(charge(Stoney,Metric)) +``` +""" Stoney + +@doc """ + Hartree::UnitSystem{1,1,αinv,4π/αinv^2,1} + +Hartree atomic `UnitSystem` with `lightspeed` of `αinv` and `permeability` of `4π/αinv^2`. + +$(textunits(Hartree,:Hartree)) + +The well known `Hartree` atomic unit values for `length`, `time`, `mass`, and `charge` are: +```Julia +julia> length(Hartree,Metric) # lA +$(length(Hartree,Metric)) + +julia> time(Hartree,Metric) # tA +$(time(Hartree,Metric)) + +julia> mass(Hartree,Metric) # mA +$(mass(Hartree,Metric)) + +julia> charge(Hartree,Metric) # qA +$(charge(Hartree,Metric)) +``` +""" Hartree + +@doc """ + Rydberg::UnitSystem{1,1,2αinv,π/αinv^2,1/2} + +Rydberg `UnitSystem` with `lightspeed` of `2αinv` and `permeability` of `π/αinv^2`. + +$(textunits(Rydberg,:Rydberg)) +""" Rydberg + +@doc """ + Schrodinger::UnitSystem{1,1,αinv,4π/αinv^2,√(αG*αinv)} + +Schrodinger `UnitSystem` with `permeability` of `4π/αinv^2` and `electronmass` of `√(αG*αinv)`. + +$(textunits(Schrodinger,:Schrodinger)) +""" Schrodinger + +@doc """ + Electronic::UnitSystem{1,αinv,1,4π,1} + +Electronic `UnitSystem` with `planckreduced` of `αinv` and `permeability` of `4π`. + +$(textunits(Electronic,:Electronic)) +""" Electronic + +@doc """ + Natural::UnitSystem{1,1,1,1,1} + +Natural `UnitSystem` with all primary constants having unit value. + +$(textunits(Natural,:Natural)) + +The well known `Natural` values for `length`, `time`, `mass`, and `charge` are: +```Julia +julia> length(Natural,Metric) +$(length(Natural,Metric)) + +julia> time(Natural,Metric) +$(time(Natural,Metric)) + +julia> mass(Natural,Metric) +$(mass(Natural,Metric)) + +julia> charge(Natural,Metric) +$(charge(Natural,Metric)) +``` +""" Natural + +@doc """ + NaturalGauss::UnitSystem{1,1,1,4π,1} + +Natural (Gauss) `UnitSystem` with the Gaussian `permeability` value of `4π`. + +$(textunits(NaturalGauss,:NaturalGauss)) +""" NaturalGauss + +@doc """ + QCD::UnitSystem{1,1,1,1,1/μₚₑ} + +Qunatum chromodynamics `UnitSystem` with `electronmass` of `1/μₚₑ` or `1/$μₚₑ`. + +$(textunits(QCD,:QCD)) + +The well known `QCD` values for `length`, `time`, `mass`, and `charge` are: +```Julia +julia> length(QCD,Metric) # lQCD +$(length(QCD,Metric)) + +julia> time(QCD,Metric) # tQCD +$(time(QCD,Metric)) + +julia> mass(QCD,Metric) # mQCD +$(mass(QCD,Metric)) + +julia> charge(QCD,Metric) +$(charge(QCD,Metric)) +``` +""" QCD + +@doc """ + QCDGauss::UnitSystem{1,1,1,4π,1/μₚₑ} + +Qunatum chromodynamics (Gauss) `UnitSystem` with `electronmass` of `1/μₚₑ`. + +$(textunits(QCDGauss,:QCDGauss)) + +The well known `QCDGauss` values for `length`, `time`, `mass`, and `charge` are: +```Julia +julia> length(QCDGauss,Metric) # lQCD +$(length(QCDGauss,Metric)) + +julia> time(QCDGauss,Metric) # tQCD +$(time(QCDGauss,Metric)) + +julia> mass(QCDGauss,Metric) # mQCD +$(mass(QCDGauss,Metric)) + +julia> charge(QCDGauss,Metric) +$(charge(QCDGauss,Metric)) +``` +""" QCDGauss + +@doc """ + QCDoriginal::UnitSystem{1,1,1,4π/αinv,1/μₚₑ} + +Qunatum chromodynamics (original) `UnitSystem` with `permeability` of `4π/αinv`. + +$(textunits(QCDoriginal,:QCDoriginal)) + +The well known `QCDoriginal` values for `length`, `time`, `mass`, and `charge` are: +```Julia +julia> length(QCDoriginal,Metric) # lQCD +$(length(QCDoriginal,Metric)) + +julia> time(QCDoriginal,Metric) # tQCD +$(time(QCDoriginal,Metric)) + +julia> mass(QCDoriginal,Metric) # mQCD +$(mass(QCDoriginal,Metric)) + +julia> charge(QCDoriginal,Metric) +$(charge(QCDoriginal,Metric)) +``` +""" QCDoriginal diff --git a/test/runtests.jl b/test/runtests.jl index 66ddee4..8e0a8c5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -71,7 +71,7 @@ for S ∈ UnitSystems.Systems @test electronmass(U) ≈ planckmass(U)*sqrt(αG) end @testset "hartree" begin - @test hartree(U) == electronmass(U)*(lightspeed(U)/αinv)^2 + @test hartree(U) ≈ electronmass(U)*(lightspeed(U)/αinv)^2 @test hartree(U) ≈ planckreduced(U)*lightspeed(U)/αinv/bohr(U) @test hartree(U) ≈ planckreduced(U)^2/electronmass(U)/bohr(U)^2 @test hartree(U) ≈ 2rydberg(U)*planck(U)*lightspeed(U) @@ -161,7 +161,7 @@ for S ∈ UnitSystems.Systems @test coulomb(U) ≈ permeability(U)*rationalization(U)*(lorentz(U)*lightspeed(U))^2/4π @test coulomb(U) ≈ planckreduced(U)*lightspeed(U)/αinv/charge(U)^2 @test coulomb(U) ≈ klitzing(U)*lightspeed(U)/αinv/2π - @test coulomb(U) == biotsavart(U)/lorentz(U)/permeability(U)/permittivity(U) + @test coulomb(U) ≈ biotsavart(U)/lorentz(U)/permeability(U)/permittivity(U) @test coulomb(U) ≈ ampere(U)*lightspeed(U)^2 end @testset "ampere" begin @@ -173,7 +173,7 @@ for S ∈ UnitSystems.Systems end @testset "lorentz" begin @test lorentz(U) ≈ 1/lightspeed(U)/sqrt(permeability(U)*permittivity(U)) - @test lorentz(U) == biotsavart(U)/permeability(U)/permittivity(U)/coulomb(U) + @test lorentz(U) ≈ biotsavart(U)/permeability(U)/permittivity(U)/coulomb(U) @test lorentz(U) ≈ 4π*biotsavart(U)/rationalization(U)/permeability(U) @test lorentz(U) == ampere(U)/biotsavart(U) end