Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full name fix #112

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
PyFormattedStrings = "5f89f4a4-a228-4886-b223-c468a82ed5b9"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
Expand Down
9 changes: 6 additions & 3 deletions src/constructors.jl
Original file line number Diff line number Diff line change
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, Kind.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 @@ -161,14 +161,17 @@ function Species(name::String, charge::Int=0, iso::Int=-1)
end
end
if count('+', name) != 0 && count('-', name) != 0
error(f"""You made a typo in "{name}". You have both a + and a - in the name. """)
error(f"""You made a typo in "{name}". You have both + and - in the name. """)
return
end
if haskey(ATOMIC_SPECIES, AS) # is the particle in the Atomic_Particles dictionary?
if iso ∉ keys(ATOMIC_SPECIES[AS].mass) # error handling if the isotope isn't available
error("The isotope you specified is not available: Isotopes are specified by the atomic symbol and integer mass number.")
error("""The isotope you specified is not available: Isotopes are specified by the atomic symbol and integer mass number.""")
return
end
if charge > ATOMIC_SPECIES[AS].Z
error(f"You have specified a larger positive charge than the fully stripped {ATOMIC_SPECIES[AS].species_name} atom has, which is unphysical.")
end
mass = begin
if anti_atom == false
nmass = uconvert(u"MeV/c^2", ATOMIC_SPECIES[AS].mass[iso]);
Expand Down
23 changes: 12 additions & 11 deletions src/particle_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,23 @@ function full_name(species::Species)
if species.iso > 0
isostring = "#" * f"{species.iso}"
end
if species.charge != 0
if species.charge == 1
if species.charge.val != 0
if species.charge.val == 1
chargestring = "+"
elseif species.charge == -1
chargestring == "-"
elseif species.charge == 2
elseif species.charge.val == -1
chargestring = "-"
elseif species.charge.val == 2
chargestring = "++"
elseif species.charge == -2
chargestring == "--"
elseif species.charge > 2
chargestring = f"+{species.charge}"
elseif species.charge.val == -2
chargestring = "--"
elseif species.charge.val > 2
chargestring = f"+{abs(species.charge.val)}"
elseif species.charge < -2
chargestring == f"-{species.charge}"
chargestring = f"-{abs(species.charge.val)}"
end
end
return isostring * species.name * chargestring
end
end;
export full_name
export full_name

Loading