From bb29b5103bc9977441b44614959c1c997b730e71 Mon Sep 17 00:00:00 2001 From: Alexander Coxe Date: Thu, 12 Dec 2024 13:41:06 -0500 Subject: [PATCH 1/6] fixed the full_name function to handle unitful quantities, etc --- src/particle_functions.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/particle_functions.jl b/src/particle_functions.jl index cff266d..df66fc2 100644 --- a/src/particle_functions.jl +++ b/src/particle_functions.jl @@ -91,19 +91,19 @@ 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 From fd41bc91be89f727a59e8ccd95feb7329e27857a Mon Sep 17 00:00:00 2001 From: Alexander Coxe Date: Thu, 12 Dec 2024 14:37:53 -0500 Subject: [PATCH 2/6] checking the fix --- src/constructors.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/constructors.jl b/src/constructors.jl index 19a9f63..fee4eab 100644 --- a/src/constructors.jl +++ b/src/constructors.jl @@ -169,6 +169,9 @@ function Species(name::String, charge::Int=0, iso::Int=-1) 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]); From f123de46d9f01c1296e17b9d2ef2a4a7e6582001 Mon Sep 17 00:00:00 2001 From: Alexander Coxe Date: Thu, 12 Dec 2024 13:41:06 -0500 Subject: [PATCH 3/6] fixed the full_name function to handle unitful quantities, etc --- src/particle_functions.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/particle_functions.jl b/src/particle_functions.jl index cff266d..df66fc2 100644 --- a/src/particle_functions.jl +++ b/src/particle_functions.jl @@ -91,19 +91,19 @@ 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 From 19c8b360847aa3224aabf2460a8425d40da9f8b5 Mon Sep 17 00:00:00 2001 From: Alexander Coxe Date: Thu, 12 Dec 2024 14:37:53 -0500 Subject: [PATCH 4/6] checking the fix --- src/constructors.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/constructors.jl b/src/constructors.jl index 6a03b3b..b61e363 100644 --- a/src/constructors.jl +++ b/src/constructors.jl @@ -169,6 +169,9 @@ function Species(name::String, charge::Int=0, iso::Int=-1) 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]); From ea1c2e69167cf19974cf86e548dbf429a29d5021 Mon Sep 17 00:00:00 2001 From: Alexander Coxe Date: Thu, 12 Dec 2024 15:15:59 -0500 Subject: [PATCH 5/6] logistics cleanup --- Project.toml | 1 + 1 file changed, 1 insertion(+) 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] From b4ff5af700a9ca585722e1064c72ef3ee39a9e3e Mon Sep 17 00:00:00 2001 From: Alexander Coxe Date: Thu, 12 Dec 2024 15:27:33 -0500 Subject: [PATCH 6/6] constructor fix --- src/constructors.jl | 6 +++--- src/particle_functions.jl | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/constructors.jl b/src/constructors.jl index b61e363..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,12 +161,12 @@ 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 diff --git a/src/particle_functions.jl b/src/particle_functions.jl index df66fc2..9bbbdee 100644 --- a/src/particle_functions.jl +++ b/src/particle_functions.jl @@ -109,4 +109,5 @@ function full_name(species::Species) 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