Skip to content

Commit 19a24aa

Browse files
committed
upgraded to UnitSystems v0.3.4
1 parent d82c1c1 commit 19a24aa

File tree

4 files changed

+21
-19
lines changed

4 files changed

+21
-19
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MeasureSystems"
22
uuid = "ea45d09e-59d0-491b-a101-09823c6a9fd4"
33
authors = ["Michael Reed"]
4-
version = "0.1.2"
4+
version = "0.1.3"
55

66
[deps]
77
Similitude = "d70e672a-ff44-4dfc-8031-4cc812d84922"
@@ -11,7 +11,7 @@ Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
1111

1212
[compat]
1313
Measurements = "2"
14-
UnitSystems = "0.3.3"
14+
UnitSystems = "0.3.4"
1515
Similitude = "0.2"
1616
julia = "1"
1717

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Defaults are shared: `Metric`, `SI2019`, `CODATA`, `Conventional`, `Internationa
2222
julia> using MeasureSystems # or UnitSystems or Similitude
2323
```
2424

25+
An optional environment variable `ENV["SIMILITUDE"]` induces `UnitSystems.similitude()` to return `true`, giving flexibility for building dependencies whenever it is desirable to toggle usage between `UnitSystems` (default) and `Similitude` (requires environment variable specification). For example, in `MeasureSystems` and `Geophysics` this option is used to increase flexibility with variety in local compilation workflow.
26+
2527
A `UnitSystem` is a consistent set of dimensional values selected to accomodate a particular use case or standardization.
2628
It is possible to convert derived physical quantities from any `UnitSystem` specification into any other using accurate values.
2729
Eleven fundamental constants `kB`, `ħ`, `𝘤`, `μ₀`, `mₑ`, `Mᵤ`, `Kcd`, `θ`, `λ`, `αL`, `g₀` are used to govern a specific unit system consistent scaling.
@@ -44,7 +46,7 @@ additional constants `molarmass`, `luminousefficacy`, `gravity`, `angle`, `turn`
4446

4547
Physics constant documentation is at https://geophysics.crucialflow.com/dev/constants
4648

47-
Standardized unit/derived quantities are `hyperfine`, `loschmidt`, `wienwavelength`, `wienfrequency`, `mechanicalheat`, `solarmass`, `jupitermass`, `earthmass`, `lunarmass`, `earthradius`, `greatcircle`, `radarmile`, `hubble`, `cosmological`, `radian`, `steradian`, `degree`, `gradian`, `arcminute`, `arcsecond`, `second`, `minute`, `hour`, `day`, `year`, `gaussianyear`, `siderealyear`, `angstrom`, `inch`, `foot`, `surveyfoot`, `yard`, `meter`, `earthmeter`, `mile`, `statutemile`, `meridianmile`, `admiraltymile`, `nauticalmile`, `lunardistance`, `astronomicalunit`, `lightyear`, `parsec`, `barn`, `hectare`, `acre`, `surveyacre`, `liter`, `gallon`, `quart`, `pint`, `cup`, `fluidounce`, `teaspoon`, `tablespoon`, `grain`, `gram`, `earthgram`, `kilogram`, `tonne`, `ton`, `pound`, `ounce`, `slug`, `slinch`, `hyl`, `dyne`, `newton`, `poundal`, `poundforce`, `kilopond`, `psi`, `pascal`, `bar`, `barye`, `technicalatmosphere`, `atmosphere`, `inchmercury`, `torr`, `electronvolt`, `erg`, `joule`, `footpound`, `calorie`, `kilocalorie`, `meancalorie`, `earthcalorie`, `thermalunit`, `gasgallon`, `tontnt`, `watt`, `horsepower`, `horsepowerwatt`, `horsepowermetric`, `electricalhorsepower`, `tonsrefrigeration`, `boilerhorsepower`, `coulomb`, `earthcoulomb`, `ampere`, `volt`, `henry`, `ohm`, `siemens`, `farad`, `weber`, `tesla`, `abcoulomb`, `abampere`, `abvolt`, `abhenry`, `abohm`, `abmho`, `abfarad`, `maxwell`, `gauss`, `oersted`, `gilbert`, `statcoulomb`, `statampere`, `statvolt`, `stathenry`, `statohm`, `statmho`, `statfarad`, `statweber`, `stattesla`, `kelvin`, `rankine`, `sealevel`, `mole`, `earthmole`, `poundmole`, `slugmole`, `slinchmole`, `katal`, `amagat`, `lumen`, `candela`, `lux`, `phot`, `footcandle`, `nit`, `apostilb`, `stilb`, `lambert`, `footlambert`, `bril`, `neper`, `bel`, `decibel`, `hertz`, `rpm`, `kayser`, `diopter`, `bubnoff`, `gforce`, `galileo`, `eotvos`, `darcy`, `poise`, `reyn`, `stokes`, `rayl`, `mpge`, `langley`, `jansky`, `solarflux`, `curie`, `sievert`, `roentgen`, `rem`.
49+
Standardized unit/derived quantities are `hyperfine`, `loschmidt`, `wienwavelength`, `wienfrequency`, `mechanicalheat`, `solarmass`, `jupitermass`, `earthmass`, `lunarmass`, `earthradius`, `greatcircle`, `radarmile`, `hubble`, `cosmological`, `radian`, `steradian`, `degree`, `gradian`, `arcminute`, `arcsecond`, `second`, `minute`, `hour`, `day`, `year`, `gaussianyear`, `siderealyear`, `angstrom`, `inch`, `foot`, `surveyfoot`, `yard`, `meter`, `earthmeter`, `mile`, `statutemile`, `meridianmile`, `admiraltymile`, `nauticalmile`, `lunardistance`, `astronomicalunit`, `lightyear`, `parsec`, `barn`, `hectare`, `acre`, `surveyacre`, `liter`, `gallon`, `quart`, `pint`, `cup`, `fluidounce`, `teaspoon`, `tablespoon`, `grain`, `gram`, `earthgram`, `kilogram`, `tonne`, `ton`, `pound`, `ounce`, `slug`, `slinch`, `hyl`, `dyne`, `newton`, `poundal`, `poundforce`, `kilopond`, `psi`, `pascal`, `bar`, `barye`, `technicalatmosphere`, `atmosphere`, `inchmercury`, `torr`, `electronvolt`, `erg`, `joule`, `footpound`, `calorie`, `kilocalorie`, `meancalorie`, `earthcalorie`, `thermalunit`, `gasgallon`, `tontnt`, `watt`, `horsepower`, `horsepowerwatt`, `horsepowermetric`, `electricalhorsepower`, `tonsrefrigeration`, `boilerhorsepower`, `coulomb`, `earthcoulomb`, `ampere`, `volt`, `henry`, `ohm`, `siemens`, `farad`, `weber`, `tesla`, `abcoulomb`, `abampere`, `abvolt`, `abhenry`, `abohm`, `abmho`, `abfarad`, `maxwell`, `gauss`, `oersted`, `gilbert`, `statcoulomb`, `statampere`, `statvolt`, `stathenry`, `statohm`, `statmho`, `statfarad`, `statweber`, `stattesla`, `kelvin`, `rankine`, `celsius`, `fahrenheit`, `sealevel`, `boiling`, `mole`, `earthmole`, `poundmole`, `slugmole`, `slinchmole`, `katal`, `amagat`, `lumen`, `candela`, `lux`, `phot`, `footcandle`, `nit`, `apostilb`, `stilb`, `lambert`, `footlambert`, `bril`, `neper`, `bel`, `decibel`, `hertz`, `rpm`, `kayser`, `diopter`, `bubnoff`, `gforce`, `galileo`, `eotvos`, `darcy`, `poise`, `reyn`, `stokes`, `rayl`, `mpge`, `langley`, `jansky`, `solarflux`, `curie`, `sievert`, `roentgen`, `rem`.
4850

4951
Standard physics units are at https://geophysics.crucialflow.com/dev/units
5052

src/MeasureSystems.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@ Base.show(io::IO,M::Measure{N}) where N = show(io,measure(M))
3838

3939
# unit systems
4040

41-
const usingSimilitude = true#UnitSystems.similitude()
41+
const usingSimilitude = UnitSystems.similitude()
4242

4343
if !usingSimilitude
4444
@pure mass(U::UnitSystem,S::UnitSystem) = electronmass(U,S)
4545
@pure electronmass(𝘩,R∞) = αinv^2*R∞*2𝘩/𝘤
4646
@pure electronmass(𝘩,R∞,C::Coupling) = inv(finestructure(C))^2*R∞*2𝘩/𝘤
4747
@pure planckmass(U::UnitSystem,C::Coupling=universe(U)) = electronmass(U,C)/√coupling(C)
4848
@pure planck(U::UnitSystem,C::Coupling=universe(U)) = 2π*planckreduced(U,C)
49-
@pure newton(U::UnitSystem,C::Coupling=universe(U)) = lightspeed(U,C)*planckreduced(U,C)/planckmass(U,C)^2
50-
@pure elementarycharge(U::UnitSystem,C::Coupling=universe(U)) = sqrt(2planck(U)/(permeability(U)/finestructure(U))/(lightspeed(U)*rationalization(U)*lorentz(U)^2))
49+
@pure gravitation(U::UnitSystem,C::Coupling=universe(U)) = lightspeed(U,C)*planckreduced(U,C)/planckmass(U,C)^2
50+
@pure elementarycharge(U::UnitSystem,C::Coupling=universe(U)) = sqrt(2planck(U)/(vacuumpermeability(U)/finestructure(U))/(lightspeed(U)*rationalization(U)*lorentz(U)^2))
5151

5252
for unit Dimensionless
5353
@eval @pure $unit(C::Coupling) = UnitSystems.$unit(C)
5454
@eval @pure $unit(U::UnitSystem) = UnitSystems.$unit(universe(U))
5555
end
56-
for unit (:boltzmann,:planckreduced,:lightspeed,:permeability,:electronmass,:molarmass)
56+
for unit (:boltzmann,:planckreduced,:lightspeed,:vacuumpermeability,:electronmass,:molarmass)
5757
@eval @pure $unit(U::UnitSystem,C::Coupling) = $unit(U)
5858
end
59-
for unit Constants
59+
for unit (Constants...,:vacuumpermeability)
6060
unit:planck && @eval @pure $unit(U::UnitSystem) = UnitSystems.$unit(U)
6161
unit:angle && (@eval @pure $unit(U::UnitSystem,S::UnitSystem) = unit($unit(S)/$unit(U)))
6262
end
@@ -187,7 +187,7 @@ const ΩΛ = measurement("0.6889(56)")
187187
const α = inv(αinv)
188188
const RK,KJ = RK2014,KJ2014
189189
import UnitSystems: g₀,ft,ftUS,lb,atm,ΔνCs,Kcd,NA,kB,𝘩,𝘤,𝘦,τ,inHg,T₀,aⱼ,Ωᵢₜ,Vᵢₜ,kG,au,seven
190-
import UnitSystems: RK1990,KJ1990,𝟏,𝟐,𝟑,𝟓,𝟕,𝟏𝟎,𝟏𝟏,𝟏𝟗,𝟒𝟑,isquantity,vacuumpermeability,zetta
190+
import UnitSystems: RK1990,KJ1990,𝟏,𝟐,𝟑,𝟓,𝟕,𝟏𝟎,𝟏𝟏,𝟏𝟗,𝟒𝟑,isquantity
191191
const RK90,KJ90 = RK1990,KJ1990
192192
end
193193

@@ -218,8 +218,10 @@ for CAL ∈ (:calₜₕ,:cal₄,:cal₁₀,:cal₂₀,:calₘ,:calᵢₜ)
218218
KCAL = Symbol(:k,CAL)
219219
@eval import UnitSystems: $CAL, $KCAL
220220
end
221-
import UnitSystems: convertext
221+
import UnitSystems: convertext, unitext
222222
const dir = dirname(pathof(UnitSystems))
223+
const zetta,zepto = Constant(1e21),Constant(1e-21)
224+
const yotta,yocto = Constant(1e24),Constant(1e-24)
223225
include("$dir/kinematic.jl")
224226
include("$dir/electromagnetic.jl")
225227
include("$dir/thermodynamic.jl")
@@ -233,8 +235,8 @@ end
233235
@pure electronmass(U::typeof(PlanckGauss),C::Coupling) = sqrt(coupling(C))
234236
@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,cache(√(αG*αinv))},C::Coupling) where {kB,ħ,𝘤,μ₀} = sqrt(coupling(C)/finestructure(C))
235237
@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,cache(1/μₚₑ)},C::Coupling) where {kB,ħ,𝘤,μ₀} = 1/protonelectron(C)
236-
@pure permeability(U::UnitSystem{kB,ħ,𝘤,cache(4π/αinv^2)},C::Coupling) where {kB,ħ,𝘤} = 4π*finestructure(C)^2
237-
@pure permeability(U::UnitSystem{kB,ħ,𝘤,cache(π/αinv^2)},C::Coupling) where {kB,ħ,𝘤} = π*finestructure(C)^2
238+
@pure vacuumpermeability(U::UnitSystem{kB,ħ,𝘤,cache(4π/αinv^2)},C::Coupling) where {kB,ħ,𝘤} = 4π*finestructure(C)^2
239+
@pure vacuumpermeability(U::UnitSystem{kB,ħ,𝘤,cache(π/αinv^2)},C::Coupling) where {kB,ħ,𝘤} = π*finestructure(C)^2
238240
@pure lightspeed(U::UnitSystem{kB,ħ,cache(αinv)},C::Coupling) where {kB,ħ} = 1/finestructure(C)
239241
@pure lightspeed(U::UnitSystem{kB,ħ,cache(2αinv)},C::Coupling) where {kB,ħ} = 2/finestructure(C)
240242
@pure planckreduced(U::UnitSystem{kB,cache(αinv)},C::Coupling) where kB = 1/finestructure(C)
@@ -245,10 +247,8 @@ end
245247
@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,cache(electronmass(CODATA))},C::Coupling) where {kB,ħ,μ₀} = electronmass(planck(U),R∞,C)
246248
@pure electronmass(U::UnitSystem{kB,ħ,𝘤,μ₀,cache(electronmass(Conventional))},C::Coupling) where {kB,ħ,μ₀} = electronmass(planck(U),R∞,C)
247249
@pure electronmass(U::UnitSystem{kB,ħ,𝘤/ftUS,μ₀,cache(mₑ*ft/lb/g₀)},C::Coupling) where {kB,ħ,μ₀} = electronmass(SI,C)*ft/lb/g₀
248-
@pure permeability(U::UnitSystem{kB,ħ,𝘤,cache(μ₀)},C::Coupling) where {kB,ħ,𝘤} = finestructure(C)*2𝘩/𝘤/𝘦^2
249-
#@pure permeability(U::typeof(ESU2019),C::Coupling) = 1e3*permeability(SI,C)/𝘤^2
250-
#@pure permeability(U::typeof(EMU2019),C::Coupling) = 1e7*permeability(SI,C)
251-
@pure permeability(U::typeof(CODATA),C::Coupling) = 2RK2014*finestructure(C)/𝘤
252-
@pure permeability(U::typeof(Conventional),C::Coupling) = 2RK1990*finestructure(C)/𝘤
250+
@pure vacuumpermeability(U::UnitSystem{kB,ħ,𝘤,cache(μ₀)},C::Coupling) where {kB,ħ,𝘤} = finestructure(C)*2𝘩/𝘤/𝘦^2
251+
@pure vacuumpermeability(U::typeof(CODATA),C::Coupling) = 2RK2014*finestructure(C)/𝘤
252+
@pure vacuumpermeability(U::typeof(Conventional),C::Coupling) = 2RK1990*finestructure(C)/𝘤
253253

254254
end # module

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
using MeasureSystems, Test
22

3-
@test 1000molarmass(SI2019) == molarmass(EMU2019)
4-
@test luminousefficacy(SI2019)/1e7 luminousefficacy(EMU2019)
3+
@test 1000normal(molarmass(Metric)) normal(molarmass(Gauss))
4+
@test normal(luminousefficacy(Metric)) 1e7*normal(luminousefficacy(Gauss))

0 commit comments

Comments
 (0)