diff --git a/Project.toml b/Project.toml index bd42530..798667a 100644 --- a/Project.toml +++ b/Project.toml @@ -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] diff --git a/src/constructors.jl b/src/constructors.jl index 6a03b3b..ae87d44 100644 --- a/src/constructors.jl +++ b/src/constructors.jl @@ -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) @@ -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]); diff --git a/src/particle_functions.jl b/src/particle_functions.jl index cff266d..9bbbdee 100644 --- a/src/particle_functions.jl +++ b/src/particle_functions.jl @@ -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 \ No newline at end of file +export full_name + \ No newline at end of file