Skip to content

Commit

Permalink
Reworked to avoid using upreferred
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayeul d'Avezac committed May 6, 2017
1 parent c334ef5 commit 62d15e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/UnitfulHartree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import Unitful

@unit mₑ "mₑ" ElectronMass 9.1093835611e-31*u"kg" false
@unit e₀ "eₒ" ElementaryCharge 1.602176620898e-19*u"C" false
@unit kₑ "kₑ" CoulombForceConstant 8.9875517873681e9*u"kg*m^3*s^-2*C^-2" false
@unit kₑ "kₑ" CoulombForceConstant 1/(4π)u"ϵ0" false
@unit ħ "ħ" ReducedPlanckConstant Unitful.ħ false
@unit a₀ "a₀" BohrRadius uconvert(u"m", 1ħ^2/(1kₑ*mₑ*e₀^2)) false
@unit Eₕ "Eₕ" HartreeEnergy uconvert(u"J", mₑ*e₀^4*kₑ^2/(1ħ^2)) true
@unit Ry "Ry" RydbergEnergy 0.5*Eₕ true
@unit rₑ "rₑ" ClassicalElectronRadius uconvert(u"m", (1e₀^2*kₑ)/(1mₑ*Unitful.c^2)) false
@unit a₀ "a₀" BohrRadius 1ħ^2/(1kₑ*mₑ*e₀^2) false
@unit Eₕ "Eₕ" HartreeEnergy mₑ*e₀^4*kₑ^2/(1ħ^2) true
@unit Ry "Ry" RydbergEnergy 0.5Eₕ true
@unit rₑ "rₑ" ClassicalElectronRadius 1e₀^2*kₑ/(1mₑ*Unitful.c^2) false
const α = 1e₀^2*1kₑ/(1Unitful.c*ħ)
const mₚ = 1836.15mₑ
const μ_b = e₀*ħ/(2mₑ)
const ϵ₀ = Unitful.ϵ0
const ϵ₀ = 1/(4π*kₑ)


# Some gymnastics required here because if we precompile, we cannot add to
Expand Down
10 changes: 9 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ using UnitfulHartree
using Base.Test
using Unitful

@test ustrip(1u"a₀" |> u"m") 5.291772106712e-11
@testset "Check definitions" begin
@test ustrip(1u"a₀" |> u"m") 5.291772106712e-11
@test ustrip(1u"rₑ" |> u"m") 2.8179403227e-15
@test ustrip(1u"kₑ" |> u"N*m^2*C^-2") 8.987_551_787_368_176_4e9
@test ustrip(1u"ϵ₀" |> unit(u"ϵ0")) ustrip(u"ϵ0")
@test ustrip(1u"Eₕ" |> u"Ry") 2
@test ustrip(1u"Eₕ" |> u"J") 4.35974465054e-18
@test ustrip(1u"Eₕ" |> u"eV") 27.2113860217
end

0 comments on commit 62d15e4

Please sign in to comment.