Skip to content

Commit

Permalink
Merge pull request #111 from bmad-sim/dcs16/02
Browse files Browse the repository at this point in the history
Cleanup of `Kind` enum.
  • Loading branch information
DavidSagan authored Dec 12, 2024
2 parents 791c45c + 574d355 commit 518fd76
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AtomicAndPhysicalConstants"
uuid = "5c0d271c-5419-4163-b387-496237733d8b"
authors = ["David Sagan <david.sagan@cornell.edu> and contributors"]
version = "0.4.0"
version = "0.5.0"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
12 changes: 6 additions & 6 deletions src/constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ function subatomic_particle(name::String)
SUBATOMIC_SPECIES[name].mass,
SUBATOMIC_SPECIES[name].spin,
SUBATOMIC_SPECIES[name].mu,
0., Scale.GBoson)
0., Kind.GBOSON)
elseif lowercase(name) in leptons
return Species(name, SUBATOMIC_SPECIES[name].charge,
SUBATOMIC_SPECIES[name].mass,
SUBATOMIC_SPECIES[name].spin,
SUBATOMIC_SPECIES[name].mu,
0., Scale.Lepton)
0., Kind.LEPTON)
else
return Species(name, SUBATOMIC_SPECIES[name].charge,
SUBATOMIC_SPECIES[name].mass,
SUBATOMIC_SPECIES[name].spin,
SUBATOMIC_SPECIES[name].mu,
0., Scale.Hadron)
0., Kind.HADRON)
end
end

Expand Down Expand Up @@ -96,7 +96,7 @@ If an anti-particle (subatomic or otherwise) prepend "anti-" to the name.
Species


Species() = Species("Null", 0.0u"e", 0.0u"MeV/c^2", 0.0u"h_bar", 0.0u"J/T", 0, Scale.Null)
Species() = Species("Null", 0.0u"e", 0.0u"MeV/c^2", 0.0u"h_bar", 0.0u"J/T", 0, Kind.Null)

function Species(name::String, charge::Int=0, iso::Int=-1)

Expand Down Expand Up @@ -193,9 +193,9 @@ function Species(name::String, charge::Int=0, iso::Int=-1)
spin = 0.5 * iso
end
if anti_atom == false
return Species(AS, charge*u"e", mass*u"MeV/c^2", spin*u"h_bar", 0*u"J/T", iso, Scale.Atom) # return the object to track
return Species(AS, charge*u"e", mass*u"MeV/c^2", spin*u"h_bar", 0*u"J/T", iso, Kind.ATOM) # return the object to track
else
return Species("anti-" * AS, charge*u"e", mass*u"MeV/c^2", spin*u"h_bar", 0u"J/T", iso, Scale.Atom)
return Species("anti-" * AS, charge*u"e", mass*u"MeV/c^2", spin*u"h_bar", 0u"J/T", iso, Kind.ATOM)

end

Expand Down
32 changes: 18 additions & 14 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@



@enumx Scale Atom Hadron Lepton GBoson Null
export Scale


struct Species
name::String # name of the particle to track
charge::typeof(1u"e") # charge of the particle (important to consider ionized atoms) in [e]
mass::typeof(1.0u"MeV/c^2") # mass of the particle in [eV/c^2]
spin::typeof(1.0u"h_bar") # spin of the particle in [ħ]
moment::typeof(1.0u"J/T") # magnetic moment of the particle (for now it's 0 unless we have a recorded value)
iso::Float64 # if the particle is an atomic isotope, this is the mass number, otherwise 0
variety
end;
export Species
@enumx Kind ATOM HADRON LEPTON GBOSON NULL
export Kind

# The docstring for this struct is with its constructor, in the file
# src/constructors.jl

struct Species
name::String # name of the particle to track
charge::typeof(1u"e") # charge of the particle (important to consider ionized atoms) in [e]
mass::typeof(1.0u"MeV/c^2") # mass of the particle in [eV/c^2]
spin::typeof(1.0u"h_bar") # spin of the particle in [ħ]
moment::typeof(1.0u"J/T") # magnetic moment of the particle (for now it's 0 unless we have a recorded value)
iso::Float64 # if the particle is an atomic isotope, this is the mass number, otherwise 0
kind::Kind.T
end

export Species

kindof(species::Species) = species.kind


#####################################################################
#####################################################################

Expand Down

0 comments on commit 518fd76

Please sign in to comment.