Skip to content

Commit

Permalink
upgraded to LaTeX printing
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Jan 27, 2023
1 parent 80f7ca1 commit 1e94f1a
Show file tree
Hide file tree
Showing 8 changed files with 443 additions and 684 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ environment:
matrix:
- julia_version: 1
- julia_version: 1.6
- julia_version: 1.7
- julia_version: 1.8
- julia_version: nightly

platform:
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ os:
julia:
- 1.0
- 1.6
- 1.7
- 1.8
- nightly
matrix:
allow_failures:
Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Similitude"
uuid = "d70e672a-ff44-4dfc-8031-4cc812d84922"
authors = ["Michael Reed"]
version = "0.2.6"
version = "0.2.7"

[deps]
UnitSystems = "3a241a3c-2137-41aa-af5e-1388e404ca09"
Expand All @@ -13,8 +13,8 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[compat]
AbstractTensors = "0.7"
FieldConstants = "0.1"
FieldAlgebra = "0.1"
UnitSystems = "0.3.3"
FieldAlgebra = "0.1.3"
UnitSystems = "0.3.9"
julia = "1"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Specifications for dimensional units are in the [UnitSystems.jl](https://github.
The three packages are designed so that they can be interchanged with compatibility.
On its own `UnitSystems` is the fastest package, while `Similitude` (provides `Quantity` type) and `MeasureSystems` (introduces [Measurements.jl](https://github.com/JuliaPhysics/Measurements.jl) uncertainty) build additional features on top of `UnitSystems` base defintions.
Additionally, in the `UnitSystems` repository there is an equivalent [Wolfram language paclet](https://reference.wolfram.com/language/guide/Paclets) `Kernel` and also an unmaintained Rust `src` implementation.
Defaults are shared: `Metric`, `SI2019`, `CODATA`, `Conventional`, `International`, `InternationalMean`, `MetricTurn`, `MetricGradian`, `MetricDegree`, `MetricArcminute`, `MetricArcsecond`, `MetricEngineering`, `GravitationalMetric`, `FPS`, `IPS`, `British`, `English`, `Survey`, `Gauss`, `LorentzHeaviside`, `EMU`, `ESU`, `IAU`, `IAUE`, `IAUJ`, `Hubble`, `Cosmological`, `CosmologicalQuantum`, `Meridian`, `Nautical`, `MPH`, `KKH`, `MTS`, `FFF`, `Planck`, `PlanckGauss`, `Stoney`, `Hartree`, `Rydberg`, `Schrodinger`, `Electronic`, `Natural`, `NaturalGauss`, `QCD`, `QCDGauss`, `QCDoriginal`.
Defaults are shared: `Metric`, `SI2019`, `CODATA`, `Conventional`, `International`, `InternationalMean`, `MetricTurn`, `MetricGradian`, `MetricDegree`, `MetricArcminute`, `MetricArcsecond`, `Engineering`, `Gravitational`, `FPS`, `IPS`, `British`, `English`, `Survey`, `Gauss`, `LorentzHeaviside`, `EMU`, `ESU`, `IAU`, `IAUE`, `IAUJ`, `Hubble`, `Cosmological`, `CosmologicalQuantum`, `Meridian`, `Nautical`, `MPH`, `KKH`, `MTS`, `FFF`, `Planck`, `PlanckGauss`, `Stoney`, `Hartree`, `Rydberg`, `Schrodinger`, `Electronic`, `Natural`, `NaturalGauss`, `QCD`, `QCDGauss`, `QCDoriginal`.

```Julia
julia> using Similitude # or UnitSystems or MeasureSystems
Expand Down Expand Up @@ -50,7 +50,7 @@ Standardized unit/derived quantities are `hyperfine`, `loschmidt`, `wienwaveleng

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

Additional reference `UnitSystem` variants: `EMU`, `ESU`, `Gauss`, `LorentzHeaviside`, `SI2019`, `SI1976`, `CODATA`, `Conventional`, `International`, `InternationalMean`, `MetricEngineering`, `GravitationalMetric`, `IAU`, `IAUE`, `IAUJ`, `FPS`, `IPS`, `British`, `Survey`, `Hubble`, `Cosmological`, `CosmologicalQuantum`, `Meridian`, `Nautical`, `MPH`, `KKH`, `MTS`, `FFF`; and natural atomic units based on gravitational `coupling` and `finestructure` constant (`Planck`, `PlanckGauss`, `Stoney`, `Hartree`, `Rydberg`, `Schrodinger`, `Electronic`, `Natural`, `NaturalGauss`, `QCD`, `QCDGauss`, and `QCDoriginal`).
Additional reference `UnitSystem` variants: `EMU`, `ESU`, `Gauss`, `LorentzHeaviside`, `SI2019`, `SI1976`, `CODATA`, `Conventional`, `International`, `InternationalMean`, `Engineering`, `Gravitational`, `IAU`, `IAUE`, `IAUJ`, `FPS`, `IPS`, `British`, `Survey`, `Hubble`, `Cosmological`, `CosmologicalQuantum`, `Meridian`, `Nautical`, `MPH`, `KKH`, `MTS`, `FFF`; and natural atomic units based on gravitational `coupling` and `finestructure` constant (`Planck`, `PlanckGauss`, `Stoney`, `Hartree`, `Rydberg`, `Schrodinger`, `Electronic`, `Natural`, `NaturalGauss`, `QCD`, `QCDGauss`, and `QCDoriginal`).

Unit conversion documentation is at https://geophysics.crucialflow.com/dev/convert

Expand Down
50 changes: 46 additions & 4 deletions src/Similitude.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module Similitude

import Base: @pure
import UnitSystems
import UnitSystems: UnitSystem, universe, Coupling, logdb, expdb, dB
import UnitSystems: UnitSystem, universe, Coupling, logdb, expdb, dB, cache
import UnitSystems: Systems, Dimensionless, Constants, Physics, Convert, Derived
const dir = dirname(pathof(UnitSystems))

Expand Down Expand Up @@ -90,7 +90,7 @@ normal(x::Quantity) = quantity(x)
(q::Quantity{D,U})(s::UnitSystem) where {D,U} = (S=normal(s); Quantity{D,S}(q.v*ratio(D,U,S)))

function Quantity(u::UnitSystem)
U = constant(u); t = isone(normal(UnitSystems.boltzmann(U)))
U = constant(u)
kB = Quantity{F*L/Θ,U}(UnitSystems.boltzmann(U))
ħ = Quantity{F*L*T/A,U}(UnitSystems.planckreduced(U))
c = Quantity{L/T,U}(UnitSystems.lightspeed(U))
Expand All @@ -110,7 +110,7 @@ function Quantity(u::UnitSystem)
v = UnitSystems.eleven(U)
w = UnitSystems.nineteen(U)
q = UnitSystems.fourtythree(U)
UnitSystem(kB,ħ,c,μ0,mₑ,Mᵤ,Kcd,θ,λ,αL,g₀,Universe,τ,x,y,z,u,v,w,q)
unitsystem(kB,ħ,c,μ0,mₑ,Mᵤ,Kcd,θ,λ,αL,g₀,Universe,τ,x,y,z,u,v,w,q)
end

const LD,JD = Constant(384399)*(𝟐*𝟓)^3,Constant(778479)*(𝟐*𝟓)^6
Expand All @@ -121,14 +121,15 @@ include("$dir/initdata.jl")

const Unified = Quantity(UnitSystem(F*L/Θ,F*L*T/A,L/T,F*T*T*C*C/(Q*Q)/R,M,M/N,J*T/F/L,A,R,inv(C),M*L/(F*T*T),Universe,τ,𝟐,𝟑,𝟓,𝟕,𝟏𝟏,𝟏𝟗,𝟒𝟑))
dimtext(::typeof(normal(Unified))) = Values("kB","ħ","𝘤","μ₀","mₑ","Mᵤ","Kcd","ϕ","λ","αL","g₀")
dimlatex(::typeof(normal(Unified))) = Values("\\text{k}_\\text{B}","\\hbar","\\text{c}","\\mu_0","\\text{m}_\\text{e}","\\text{M}_\\text{u}","\\text{K}_\\text{cd}","\\phi","\\lambda","\\alpha_\\text{L}","\\text{g}_0")

export Unified
unitname(::typeof(normal(Unified))) = "Unified"
(u::typeof(normal(Unified)))(d::Group) = UnitSystem(d)
(u::UnitSystem)(d::Group) = normal(Metric)(d)

for unit Convert
if unit (:length,:time,:angle,:molarmass,:luminousefficacy)
if unit (:dimensionless,:length,:time,:angle,:molarmass,:luminousefficacy)
@eval const $unit = dimensions(UnitSystems.$unit(UnitSystems.Natural,Natural))
end
end
Expand Down Expand Up @@ -163,6 +164,8 @@ An alternate syntax `Quantity(D::Constant, U::UnitSystem, v::Number)` is also av
When `using UnitSystems` instead of `using Similitude`, this same syntax can be written so that code doesn't need to be changed while the output is generated.
""" Quantity

dimlatex(U) = Values("\\text{F}","\\text{M}","\\text{L}","\\text{T}","\\text{Q}","\\Theta","\\text{N}","\\text{J}","\\text{A}","\\text{R}","\\text{C}")

include("derived.jl")

(u::typeof(normal(UnitSystems.QCD)))(d::Group) = normal(Planck)(d)
Expand Down Expand Up @@ -200,6 +203,45 @@ for dim ∈ (:angle, :length, :time)
end
end

param1(x::Constant) = param(x)
param1(x) = x
compare(a::Symbol,b::Symbol,U) = param1(evaldim(a,U)) == param1(evaldim(b,U))
Base.:/(U::UnitSystem,::typeof(~)) = quotient(U)

export quotient
function quotient(U)
len = length(Convert)
out = [:x=>Symbol[] for i 1:len]
for i 1:len
x = Convert[i]
out[i] = x=>Convert[findall(compare.(Ref(x),Convert,Ref(U)))]
end
i,num = 1,length(out)
while i num
for x out[i].second[2:end]
j = findfirst(z->z==x,getproperty.(out,:first))
if !isnothing(j) && j>i
deleteat!(out,j)
num -= 1
end
end
i += 1
end
[evaldim(x.first,U)=>x.second for x out]
end

function printquotient(U)
for x quotient(U)
print(" $(x.first) => ")
for j 1:length(x.second)
y = x.second[j]
print("$y ($(evaldim(y)))")
j<length(x.second) && print(", ")
end
println()
end
end

if haskey(ENV,"UNITDOCS")
include("$dir/kinematicdocs.jl")
include("$dir/electromagneticdocs.jl")
Expand Down
Loading

2 comments on commit 1e94f1a

@chakravala
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/76478

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.7 -m "<description of version>" 1e94f1a91e813c93f79ef35c2cb76d9a5a5da934
git push origin v0.2.7

Please sign in to comment.