Skip to content

Commit

Permalink
Merge pull request #74 from bmad-sim/62-Export_Units
Browse files Browse the repository at this point in the history
re-exported Unitful, updated dependency
  • Loading branch information
lllx125 authored Oct 1, 2024
2 parents ed4eb58 + a69f586 commit ef73b9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
PyFormattedStrings = "5f89f4a4-a228-4886-b223-c468a82ed5b9"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"

[compat]
julia = "1"
Expand Down
3 changes: 2 additions & 1 deletion src/AtomicAndPhysicalConstants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ using PyFormattedStrings
using Dates
using HTTP
using JSON
using Unitful
using Reexport
@reexport using Unitful

include("physical_constants.jl")
include("atomic_isotopes.jl")
Expand Down
38 changes: 12 additions & 26 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,16 @@ end

@testset "set_units.jl" begin

# constants should be undefined when setunits() in not called
@test !@isdefined c_light
@test !@isdefined m_electron
@test !@isdefined m_electron
@test !@isdefined m_proton
@test !@isdefined m_neutron
@test !@isdefined m_muon
@test !@isdefined m_helion
@test !@isdefined m_deuteron
@test !@isdefined m_pion_0
@test !@isdefined m_pion_charged
@test !@isdefined r_e
@test !@isdefined e_charge
@test !@isdefined h_planck
@test !@isdefined mu_0_vac
@test !@isdefined eps_0_vac
@test !@isdefined kg_per_amu
@test !@isdefined eV_per_amu
@test !@isdefined N_avogadro
@test !@isdefined fine_structure
@test !@isdefined classical_radius_factor
@test !@isdefined r_p
@test !@isdefined h_bar_planck
@test !@isdefined kg_per_eV
# units should be available to users, including "amu" and "e"
# if not availble, an error would be thrown and the test would fail.
@test u"kg" == u"kg"
@test u"km" == u"km"
@test u"amu" == u"amu"
@test u"eV/c^2" == u"eV/c^2"
@test u"e" == u"e"
@test u"C" == u"C"
@test u"s" == u"s"


#setunits to default units
setunits()
Expand Down Expand Up @@ -161,11 +147,11 @@ end
H = Species("H", 1, 1, 0, 0, 0)

#mass should be in amu and charge in elementary charge
setunits(mass_unit = u"amu")
setunits(mass_unit=u"amu")

@test massof(H) 1.0
@test chargeof(H) 1
@test massof(H, "kg") 1.6605e-27
@test massof(H, "kg") 1.6605390671738466e-27
@test chargeof(H, "C") 1.602176634e-19


Expand Down

0 comments on commit ef73b9e

Please sign in to comment.