From 32a3f5f0b636b6efefa785597ad1f11aee5d5fcd Mon Sep 17 00:00:00 2001 From: lhapp27 Date: Wed, 5 Aug 2026 15:16:55 +0200 Subject: [PATCH 1/7] Removed deprecated Unicode arguments --- src/CoulombTwoBody.jl | 25 ------------------------- src/DeltaPotential.jl | 14 -------------- src/HarmonicOscillator.jl | 13 ------------- src/HydrogenAtom.jl | 18 ------------------ src/InfinitePotentialWell.jl | 13 ------------- src/InfinitePotentialWell3D.jl | 13 ------------- src/MorsePotential.jl | 21 --------------------- src/PoschlTeller.jl | 19 ------------------- src/RigidRotor.jl | 16 ---------------- src/SphericalOscillator.jl | 14 -------------- 10 files changed, 166 deletions(-) diff --git a/src/CoulombTwoBody.jl b/src/CoulombTwoBody.jl index 28018f3..df532a6 100644 --- a/src/CoulombTwoBody.jl +++ b/src/CoulombTwoBody.jl @@ -17,31 +17,6 @@ struct CoulombTwoBody <: AbstractModel hbar::Real end -function CoulombTwoBody(; - z_1::Integer=-1, z₁=z_1, - z_2::Integer=1, z₂=z_2, - m_1=1.0, m₁=m_1, - m_2=1.0, m₂=m_2, - m_e=1.0, mₑ=m_e, - a_0=1.0, a₀=a_0, - E_h=1.0, Eₕ=E_h, - hbar=1.0, ℏ=hbar, -) - return CoulombTwoBody(z₁, z₂, m₁, m₂, mₑ, a₀, Eₕ, ℏ) -end - -function Base.getproperty(model::CoulombTwoBody, sym::Symbol) - sym === :z₁ && return getfield(model, :z_1) - sym === :z₂ && return getfield(model, :z_2) - sym === :m₁ && return getfield(model, :m_1) - sym === :m₂ && return getfield(model, :m_2) - sym === :mₑ && return getfield(model, :m_e) - sym === :a₀ && return getfield(model, :a_0) - sym === :Eₕ && return getfield(model, :E_h) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::CoulombTwoBody, r) z_1 = model.z_1 diff --git a/src/DeltaPotential.jl b/src/DeltaPotential.jl index 8d58299..cd09898 100644 --- a/src/DeltaPotential.jl +++ b/src/DeltaPotential.jl @@ -12,20 +12,6 @@ struct DeltaPotential <: AbstractModel hbar::Real end -function DeltaPotential(; - alpha=1.0, α=alpha, - m=1.0, - hbar=1.0, ℏ=hbar, -) - return DeltaPotential(α, m, ℏ) -end - -function Base.getproperty(model::DeltaPotential, sym::Symbol) - sym === :α && return getfield(model, :alpha) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::DeltaPotential, x) return x==0 ? -Inf : 0 diff --git a/src/HarmonicOscillator.jl b/src/HarmonicOscillator.jl index 54fc8e5..4e7356e 100644 --- a/src/HarmonicOscillator.jl +++ b/src/HarmonicOscillator.jl @@ -12,19 +12,6 @@ struct HarmonicOscillator <: AbstractModel hbar::Real end -function HarmonicOscillator(; - k=1.0, - m=1.0, - hbar=1.0, ℏ=hbar, -) - return HarmonicOscillator(k, m, ℏ) -end - -function Base.getproperty(model::HarmonicOscillator, sym::Symbol) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::HarmonicOscillator, x) k = model.k diff --git a/src/HydrogenAtom.jl b/src/HydrogenAtom.jl index 824ea31..d283d2f 100644 --- a/src/HydrogenAtom.jl +++ b/src/HydrogenAtom.jl @@ -14,24 +14,6 @@ struct HydrogenAtom <: AbstractModel hbar::Real end -function HydrogenAtom(; - Z::Integer=1, - m_e=1.0, mₑ=m_e, - a_0=1.0, a₀=a_0, - E_h=1.0, Eₕ=E_h, - hbar=1.0, ℏ=hbar, -) - return HydrogenAtom(Z, mₑ, a₀, Eₕ, ℏ) -end - -function Base.getproperty(model::HydrogenAtom, sym::Symbol) - sym === :mₑ && return getfield(model, :m_e) - sym === :a₀ && return getfield(model, :a_0) - sym === :Eₕ && return getfield(model, :E_h) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::HydrogenAtom, r) if !(0 ≤ r) diff --git a/src/InfinitePotentialWell.jl b/src/InfinitePotentialWell.jl index ebf0ede..e9c0bd8 100644 --- a/src/InfinitePotentialWell.jl +++ b/src/InfinitePotentialWell.jl @@ -12,19 +12,6 @@ struct InfinitePotentialWell <: AbstractModel hbar::Real end -function InfinitePotentialWell(; - L=1.0, - m=1.0, - hbar=1.0, ℏ=hbar, -) - return InfinitePotentialWell(L, m, ℏ) -end - -function Base.getproperty(model::InfinitePotentialWell, sym::Symbol) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::InfinitePotentialWell, x) L = model.L diff --git a/src/InfinitePotentialWell3D.jl b/src/InfinitePotentialWell3D.jl index fa2cf7a..6f582c2 100644 --- a/src/InfinitePotentialWell3D.jl +++ b/src/InfinitePotentialWell3D.jl @@ -12,19 +12,6 @@ struct InfinitePotentialWell3D <: AbstractModel hbar::Real end -function InfinitePotentialWell3D(; - L=[1.0, 1.0, 1.0], - m=1.0, - hbar=1.0, ℏ=hbar, -) - return InfinitePotentialWell3D(Float64.(L), m, ℏ) -end - -function Base.getproperty(model::InfinitePotentialWell3D, sym::Symbol) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::InfinitePotentialWell3D, x) L = model.L diff --git a/src/MorsePotential.jl b/src/MorsePotential.jl index b479223..10edfd5 100644 --- a/src/MorsePotential.jl +++ b/src/MorsePotential.jl @@ -17,27 +17,6 @@ struct MorsePotential <: AbstractModel hbar::Real end -function MorsePotential(; - # The simplified parameters for H2+ - # F. M. Fernandez, J. Garcia, ChemistrySelect, 6, 9527-9534(2021) https://doi.org/10.1002/slct.202102509 - # CODATA recommended values of the fundamental physical constants: 2018 https://physics.nist.gov/cgi-bin/cuu/Value?mpsme - r_e=2.0, rₑ=r_e, - D_e=0.1, Dₑ=D_e, - k=0.1, - mu=918.1, μ=mu, - hbar=1.0, ℏ=hbar, -) - return MorsePotential(rₑ, Dₑ, k, μ, ℏ) -end - -function Base.getproperty(model::MorsePotential, sym::Symbol) - sym === :rₑ && return getfield(model, :r_e) - sym === :Dₑ && return getfield(model, :D_e) - sym === :μ && return getfield(model, :mu) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::MorsePotential, r) if !(0 ≤ r) diff --git a/src/PoschlTeller.jl b/src/PoschlTeller.jl index 26d0646..1664ff5 100644 --- a/src/PoschlTeller.jl +++ b/src/PoschlTeller.jl @@ -16,25 +16,6 @@ struct PoschlTeller <: AbstractModel x_0::Real end -function PoschlTeller(; - lambda=1, λ=lambda, - m=1.0, - hbar=1.0, ℏ=hbar, - x_0=1.0, x₀=x_0, -) - if !isinteger(λ) - throw(DomainError("λ = $λ", "λ must be an integer.")) - end - return PoschlTeller(Int(λ), m, ℏ, x₀) -end - -function Base.getproperty(model::PoschlTeller, sym::Symbol) - sym === :λ && return getfield(model, :lambda) - sym === :x₀ && return getfield(model, :x_0) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::PoschlTeller, x) λ = model.lambda diff --git a/src/RigidRotor.jl b/src/RigidRotor.jl index aec7f48..a8ab1df 100644 --- a/src/RigidRotor.jl +++ b/src/RigidRotor.jl @@ -13,22 +13,6 @@ struct RigidRotor <: AbstractModel hbar::Real end -function RigidRotor(; - m_1=1.0, m₁=m_1, - m_2=1.0, m₂=m_2, - R=1.0, - hbar=1.0, ℏ=hbar, -) - return RigidRotor(m₁, m₂, R, ℏ) -end - -function Base.getproperty(model::RigidRotor, sym::Symbol) - sym === :m₁ && return getfield(model, :m_1) - sym === :m₂ && return getfield(model, :m_2) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::RigidRotor, r) if !(0 ≤ r) diff --git a/src/SphericalOscillator.jl b/src/SphericalOscillator.jl index b9b0c8e..a4f8d11 100644 --- a/src/SphericalOscillator.jl +++ b/src/SphericalOscillator.jl @@ -15,20 +15,6 @@ struct SphericalOscillator <: AbstractModel hbar::Real end -function SphericalOscillator(; - k=1.0, - mu=1.0, μ=mu, - hbar=1.0, ℏ=hbar, -) - return SphericalOscillator(k, μ, ℏ) -end - -function Base.getproperty(model::SphericalOscillator, sym::Symbol) - sym === :μ && return getfield(model, :mu) - sym === :ℏ && return getfield(model, :hbar) - return getfield(model, sym) -end - # potential function potential(model::SphericalOscillator, r) if !(0 ≤ r) From 85e4a8478be510b83486fdb3c4ad665ce61adf16 Mon Sep 17 00:00:00 2001 From: lhapp27 Date: Wed, 5 Aug 2026 17:40:23 +0200 Subject: [PATCH 2/7] restored keyword constructer functions for the modules; removed special characters --- src/CoulombTwoBody.jl | 13 +++++++++++++ src/DeltaPotential.jl | 8 ++++++++ src/HarmonicOscillator.jl | 8 ++++++++ src/HydrogenAtom.jl | 10 ++++++++++ src/InfinitePotentialWell.jl | 8 ++++++++ src/InfinitePotentialWell3D.jl | 8 ++++++++ src/MorsePotential.jl | 10 ++++++++++ src/PoschlTeller.jl | 9 +++++++++ src/RigidRotor.jl | 9 +++++++++ src/SphericalOscillator.jl | 8 ++++++++ 10 files changed, 91 insertions(+) diff --git a/src/CoulombTwoBody.jl b/src/CoulombTwoBody.jl index df532a6..9b69c29 100644 --- a/src/CoulombTwoBody.jl +++ b/src/CoulombTwoBody.jl @@ -17,6 +17,19 @@ struct CoulombTwoBody <: AbstractModel hbar::Real end +function CoulombTwoBody(; + z_1::Integer=-1, + z_2::Integer=1, + m_1::Real=1.0, + m_2::Real=1.0, + m_e::Real=1.0, + a_0::Real=1.0, + E_h::Real=1.0, + hbar::Real=1.0, +) + return CoulombTwoBody(z_1, z_2, m_1, m_2, m_e, a_0, E_h, hbar) +end + # potential function potential(model::CoulombTwoBody, r) z_1 = model.z_1 diff --git a/src/DeltaPotential.jl b/src/DeltaPotential.jl index cd09898..1eb3e30 100644 --- a/src/DeltaPotential.jl +++ b/src/DeltaPotential.jl @@ -12,6 +12,14 @@ struct DeltaPotential <: AbstractModel hbar::Real end +function DeltaPotential(; + alpha::Real=1.0, + m::Real=1.0, + hbar::Real=1.0, +) + return DeltaPotential(alpha, m, hbar) +end + # potential function potential(model::DeltaPotential, x) return x==0 ? -Inf : 0 diff --git a/src/HarmonicOscillator.jl b/src/HarmonicOscillator.jl index 4e7356e..5e177a5 100644 --- a/src/HarmonicOscillator.jl +++ b/src/HarmonicOscillator.jl @@ -12,6 +12,14 @@ struct HarmonicOscillator <: AbstractModel hbar::Real end +function HarmonicOscillator(; + k::Real=1.0, + m::Real=1.0, + hbar::Real=1.0, +) + return HarmonicOscillator(k, m, hbar) +end + # potential function potential(model::HarmonicOscillator, x) k = model.k diff --git a/src/HydrogenAtom.jl b/src/HydrogenAtom.jl index d283d2f..7a4e158 100644 --- a/src/HydrogenAtom.jl +++ b/src/HydrogenAtom.jl @@ -14,6 +14,16 @@ struct HydrogenAtom <: AbstractModel hbar::Real end +function HydrogenAtom(; + Z::Integer=1, + m_e::Real=1.0, + a_0::Real=1.0, + E_h::Real=1.0, + hbar::Real=1.0, +) + return HydrogenAtom(Z, m_e, a_0, E_h, hbar) +end + # potential function potential(model::HydrogenAtom, r) if !(0 ≤ r) diff --git a/src/InfinitePotentialWell.jl b/src/InfinitePotentialWell.jl index e9c0bd8..c95dfc1 100644 --- a/src/InfinitePotentialWell.jl +++ b/src/InfinitePotentialWell.jl @@ -12,6 +12,14 @@ struct InfinitePotentialWell <: AbstractModel hbar::Real end +function InfinitePotentialWell(; + L::Real=1.0, + m::Real=1.0, + hbar::Real=1.0, +) + return InfinitePotentialWell(L, m, hbar) +end + # potential function potential(model::InfinitePotentialWell, x) L = model.L diff --git a/src/InfinitePotentialWell3D.jl b/src/InfinitePotentialWell3D.jl index 6f582c2..ac1c70f 100644 --- a/src/InfinitePotentialWell3D.jl +++ b/src/InfinitePotentialWell3D.jl @@ -12,6 +12,14 @@ struct InfinitePotentialWell3D <: AbstractModel hbar::Real end +function InfinitePotentialWell3D(; + L=[1.0, 1.0, 1.0], + m::Real=1.0, + hbar::Real=1.0, +) + return InfinitePotentialWell3D(L, m, hbar) +end + # potential function potential(model::InfinitePotentialWell3D, x) L = model.L diff --git a/src/MorsePotential.jl b/src/MorsePotential.jl index 10edfd5..fb3cd2c 100644 --- a/src/MorsePotential.jl +++ b/src/MorsePotential.jl @@ -17,6 +17,16 @@ struct MorsePotential <: AbstractModel hbar::Real end +function MorsePotential(; + r_e::Real=2.0, + D_e::Real=0.1, + k::Real=0.1, + mu::Real=918.1, + hbar::Real=1.0, +) + return MorsePotential(r_e, D_e, k, mu, hbar) +end + # potential function potential(model::MorsePotential, r) if !(0 ≤ r) diff --git a/src/PoschlTeller.jl b/src/PoschlTeller.jl index 1664ff5..96574ff 100644 --- a/src/PoschlTeller.jl +++ b/src/PoschlTeller.jl @@ -16,6 +16,15 @@ struct PoschlTeller <: AbstractModel x_0::Real end +function PoschlTeller(; + lambda::Integer=1, + m::Real=1.0, + hbar::Real=1.0, + x_0::Real=1.0, +) + return PoschlTeller(lambda, m, hbar, x_0) +end + # potential function potential(model::PoschlTeller, x) λ = model.lambda diff --git a/src/RigidRotor.jl b/src/RigidRotor.jl index a8ab1df..982c081 100644 --- a/src/RigidRotor.jl +++ b/src/RigidRotor.jl @@ -13,6 +13,15 @@ struct RigidRotor <: AbstractModel hbar::Real end +function RigidRotor(; + m_1::Real=1.0, + m_2::Real=1.0, + R::Real=1.0, + hbar::Real=1.0, +) + return RigidRotor(m_1, m_2, R, hbar) +end + # potential function potential(model::RigidRotor, r) if !(0 ≤ r) diff --git a/src/SphericalOscillator.jl b/src/SphericalOscillator.jl index a4f8d11..d735ef2 100644 --- a/src/SphericalOscillator.jl +++ b/src/SphericalOscillator.jl @@ -15,6 +15,14 @@ struct SphericalOscillator <: AbstractModel hbar::Real end +function SphericalOscillator(; + k::Real=1.0, + mu::Real=1.0, + hbar::Real=1.0, +) + return SphericalOscillator(k, mu, hbar) +end + # potential function potential(model::SphericalOscillator, r) if !(0 ≤ r) From dfe7b40a8258f4cc94d1154edc757419b72c335c Mon Sep 17 00:00:00 2001 From: lhapp27 Date: Thu, 6 Aug 2026 09:13:19 +0200 Subject: [PATCH 3/7] restored keyword constructer functions for the modules --- src/CoulombTwoBody.jl | 31 +++++++++---------------------- src/DeltaPotential.jl | 16 ++++------------ src/HarmonicOscillator.jl | 16 ++++------------ src/HydrogenAtom.jl | 22 ++++++---------------- src/InfinitePotentialWell.jl | 16 ++++------------ src/InfinitePotentialWell3D.jl | 16 ++++------------ src/MorsePotential.jl | 22 ++++++---------------- src/PoschlTeller.jl | 19 +++++-------------- src/RigidRotor.jl | 19 +++++-------------- src/SphericalOscillator.jl | 16 ++++------------ 10 files changed, 51 insertions(+), 142 deletions(-) diff --git a/src/CoulombTwoBody.jl b/src/CoulombTwoBody.jl index 9b69c29..7946f2a 100644 --- a/src/CoulombTwoBody.jl +++ b/src/CoulombTwoBody.jl @@ -6,28 +6,15 @@ import ..energy, ..potential, ..wavefunction, ..radial_function, ..laguerre_poly export CoulombTwoBody, energy, potential, wavefunction, radial_function, laguerre_polynomial, spherical_harmonic, legendre_polynomial # parameters -struct CoulombTwoBody <: AbstractModel - z_1::Integer - z_2::Integer - m_1::Real - m_2::Real - m_e::Real - a_0::Real - E_h::Real - hbar::Real -end - -function CoulombTwoBody(; - z_1::Integer=-1, - z_2::Integer=1, - m_1::Real=1.0, - m_2::Real=1.0, - m_e::Real=1.0, - a_0::Real=1.0, - E_h::Real=1.0, - hbar::Real=1.0, -) - return CoulombTwoBody(z_1, z_2, m_1, m_2, m_e, a_0, E_h, hbar) +@kwdef struct CoulombTwoBody <: AbstractModel + z_1::Integer = -1 + z_2::Integer = 1 + m_1::Real = 1.0 + m_2::Real = 1.0 + m_e::Real = 1.0 + a_0::Real = 1.0 + E_h::Real = 1.0 + hbar::Real = 1.0 end # potential diff --git a/src/DeltaPotential.jl b/src/DeltaPotential.jl index 1eb3e30..a7c6c1c 100644 --- a/src/DeltaPotential.jl +++ b/src/DeltaPotential.jl @@ -6,18 +6,10 @@ import ..energy, ..potential, ..wavefunction export DeltaPotential, energy, potential, wavefunction # parameters -struct DeltaPotential <: AbstractModel - alpha::Real - m::Real - hbar::Real -end - -function DeltaPotential(; - alpha::Real=1.0, - m::Real=1.0, - hbar::Real=1.0, -) - return DeltaPotential(alpha, m, hbar) +@kwdef struct DeltaPotential <: AbstractModel + alpha::Real = 1.0 + m::Real = 1.0 + hbar::Real = 1.0 end # potential diff --git a/src/HarmonicOscillator.jl b/src/HarmonicOscillator.jl index 5e177a5..c37a1c2 100644 --- a/src/HarmonicOscillator.jl +++ b/src/HarmonicOscillator.jl @@ -6,18 +6,10 @@ import ..energy, ..potential, ..wavefunction, ..laguerre_polynomial export HarmonicOscillator, energy, potential, wavefunction, laguerre_polynomial # parameters -struct HarmonicOscillator <: AbstractModel - k::Real - m::Real - hbar::Real -end - -function HarmonicOscillator(; - k::Real=1.0, - m::Real=1.0, - hbar::Real=1.0, -) - return HarmonicOscillator(k, m, hbar) +@kwdef struct HarmonicOscillator <: AbstractModel + k::Real = 1.0 + m::Real = 1.0 + hbar::Real = 1.0 end # potential diff --git a/src/HydrogenAtom.jl b/src/HydrogenAtom.jl index 7a4e158..b01d9cd 100644 --- a/src/HydrogenAtom.jl +++ b/src/HydrogenAtom.jl @@ -6,22 +6,12 @@ import ..energy, ..potential, ..wavefunction, ..radial_function, ..laguerre_poly export HydrogenAtom, energy, potential, wavefunction, radial_function, laguerre_polynomial, spherical_harmonic, legendre_polynomial # parameters -struct HydrogenAtom <: AbstractModel - Z::Integer - m_e::Real - a_0::Real - E_h::Real - hbar::Real -end - -function HydrogenAtom(; - Z::Integer=1, - m_e::Real=1.0, - a_0::Real=1.0, - E_h::Real=1.0, - hbar::Real=1.0, -) - return HydrogenAtom(Z, m_e, a_0, E_h, hbar) +@kwdef struct HydrogenAtom <: AbstractModel + Z::Integer = 1 + m_e::Real = 1.0 + a_0::Real = 1.0 + E_h::Real = 1.0 + hbar::Real = 1.0 end # potential diff --git a/src/InfinitePotentialWell.jl b/src/InfinitePotentialWell.jl index c95dfc1..cc349ab 100644 --- a/src/InfinitePotentialWell.jl +++ b/src/InfinitePotentialWell.jl @@ -6,18 +6,10 @@ import ..energy, ..potential, ..wavefunction export InfinitePotentialWell, energy, potential, wavefunction # parameters -struct InfinitePotentialWell <: AbstractModel - L::Real - m::Real - hbar::Real -end - -function InfinitePotentialWell(; - L::Real=1.0, - m::Real=1.0, - hbar::Real=1.0, -) - return InfinitePotentialWell(L, m, hbar) +@kwdef struct InfinitePotentialWell <: AbstractModel + L::Real = 1.0 + m::Real = 1.0 + hbar::Real = 1.0 end # potential diff --git a/src/InfinitePotentialWell3D.jl b/src/InfinitePotentialWell3D.jl index ac1c70f..d2b3671 100644 --- a/src/InfinitePotentialWell3D.jl +++ b/src/InfinitePotentialWell3D.jl @@ -6,18 +6,10 @@ import ..energy, ..potential, ..wavefunction export InfinitePotentialWell3D, energy, potential, wavefunction # parameters -struct InfinitePotentialWell3D <: AbstractModel - L::Vector{Real} - m::Real - hbar::Real -end - -function InfinitePotentialWell3D(; - L=[1.0, 1.0, 1.0], - m::Real=1.0, - hbar::Real=1.0, -) - return InfinitePotentialWell3D(L, m, hbar) +@kwdef struct InfinitePotentialWell3D <: AbstractModel + L::Vector{Real} = [1.0, 1.0, 1.0] + m::Real = 1.0 + hbar::Real = 1.0 end # potential diff --git a/src/MorsePotential.jl b/src/MorsePotential.jl index fb3cd2c..b4b876b 100644 --- a/src/MorsePotential.jl +++ b/src/MorsePotential.jl @@ -9,22 +9,12 @@ export MorsePotential, energy, potential, wavefunction, n_max, laguerre_polynomi using SpecialFunctions # parameters -struct MorsePotential <: AbstractModel - r_e::Real - D_e::Real - k::Real - mu::Real - hbar::Real -end - -function MorsePotential(; - r_e::Real=2.0, - D_e::Real=0.1, - k::Real=0.1, - mu::Real=918.1, - hbar::Real=1.0, -) - return MorsePotential(r_e, D_e, k, mu, hbar) +@kwdef struct MorsePotential <: AbstractModel + r_e::Real = 2.0 + D_e::Real = 0.1 + k::Real = 0.1 + mu::Real = 918.1 + hbar::Real = 1.0 end # potential diff --git a/src/PoschlTeller.jl b/src/PoschlTeller.jl index 96574ff..d710198 100644 --- a/src/PoschlTeller.jl +++ b/src/PoschlTeller.jl @@ -9,20 +9,11 @@ export PoschlTeller, energy, potential, wavefunction, n_max, legendre_polynomial using SpecialFunctions # parameters -struct PoschlTeller <: AbstractModel - lambda::Integer - m::Real - hbar::Real - x_0::Real -end - -function PoschlTeller(; - lambda::Integer=1, - m::Real=1.0, - hbar::Real=1.0, - x_0::Real=1.0, -) - return PoschlTeller(lambda, m, hbar, x_0) +@kwdef struct PoschlTeller <: AbstractModel + lambda::Integer = 1 + m::Real = 1.0 + hbar::Real = 1.0 + x_0::Real = 1.0 end # potential diff --git a/src/RigidRotor.jl b/src/RigidRotor.jl index 982c081..8eb1b5f 100644 --- a/src/RigidRotor.jl +++ b/src/RigidRotor.jl @@ -6,20 +6,11 @@ import ..energy, ..potential, ..wavefunction, ..spherical_harmonic, ..legendre_p export RigidRotor, energy, potential, wavefunction, spherical_harmonic, legendre_polynomial # parameters -struct RigidRotor <: AbstractModel - m_1::Real - m_2::Real - R::Real - hbar::Real -end - -function RigidRotor(; - m_1::Real=1.0, - m_2::Real=1.0, - R::Real=1.0, - hbar::Real=1.0, -) - return RigidRotor(m_1, m_2, R, hbar) +@kwdef struct RigidRotor <: AbstractModel + m_1::Real = 1.0 + m_2::Real = 1.0 + R::Real = 1.0 + hbar::Real = 1.0 end # potential diff --git a/src/SphericalOscillator.jl b/src/SphericalOscillator.jl index d735ef2..324829d 100644 --- a/src/SphericalOscillator.jl +++ b/src/SphericalOscillator.jl @@ -9,18 +9,10 @@ export SphericalOscillator, energy, potential, wavefunction, radial_function, la using SpecialFunctions # parameters -struct SphericalOscillator <: AbstractModel - k::Real - mu::Real - hbar::Real -end - -function SphericalOscillator(; - k::Real=1.0, - mu::Real=1.0, - hbar::Real=1.0, -) - return SphericalOscillator(k, mu, hbar) +@kwdef struct SphericalOscillator <: AbstractModel + k::Real = 1.0 + mu::Real = 1.0 + hbar::Real = 1.0 end # potential From 7815bbe646ca4bd22480343b8d09d65f624b5664 Mon Sep 17 00:00:00 2001 From: lhapp27 Date: Thu, 6 Aug 2026 09:18:58 +0200 Subject: [PATCH 4/7] restored keyword constructer functions for the modules; removed Field alias compatibility test --- test/runtests.jl | 55 ------------------------------------------------ 1 file changed, 55 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 99fe5b4..e437785 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -12,61 +12,6 @@ using QuadGK using Zygote @testset verbose = true "Antique.jl" begin - @testset "Field alias compatibility" begin - ha_ascii = HydrogenAtom(m_e=2.0, a_0=3.0, E_h=4.0, hbar=5.0) - @test ha_ascii.mₑ == 2.0 - @test ha_ascii.a₀ == 3.0 - @test ha_ascii.Eₕ == 4.0 - @test ha_ascii.ℏ == 5.0 - ha_unicode = HydrogenAtom(mₑ=6.0, a₀=7.0, Eₕ=8.0, ℏ=9.0) - @test ha_unicode.m_e == 6.0 - @test ha_unicode.a_0 == 7.0 - @test ha_unicode.E_h == 8.0 - @test ha_unicode.hbar == 9.0 - - harm = HarmonicOscillator(hbar=2.0) - @test harm.ℏ == 2.0 - - ctb = CoulombTwoBody(z_1=-2, z_2=3, m_1=1.1, m_2=2.2, m_e=3.3, a_0=4.4, E_h=5.5, hbar=6.6) - @test ctb.z₁ == -2 - @test ctb.z₂ == 3 - @test ctb.m₁ == 1.1 - @test ctb.m₂ == 2.2 - @test ctb.mₑ == 3.3 - @test ctb.a₀ == 4.4 - @test ctb.Eₕ == 5.5 - @test ctb.ℏ == 6.6 - - dp = DeltaPotential(alpha=2.5, hbar=3.5) - @test dp.α == 2.5 - @test dp.ℏ == 3.5 - - ipw = InfinitePotentialWell(hbar=2.5) - @test ipw.ℏ == 2.5 - - ipw3d = InfinitePotentialWell3D(hbar=2.5) - @test ipw3d.ℏ == 2.5 - - mp = MorsePotential(r_e=1.1, D_e=2.2, mu=3.3, hbar=4.4) - @test mp.rₑ == 1.1 - @test mp.Dₑ == 2.2 - @test mp.μ == 3.3 - @test mp.ℏ == 4.4 - - pt = PoschlTeller(lambda=4, x_0=2.5, hbar=3.5) - @test pt.λ == 4 - @test pt.x₀ == 2.5 - @test pt.ℏ == 3.5 - - rr = RigidRotor(m_1=1.2, m_2=2.3, hbar=3.4) - @test rr.m₁ == 1.2 - @test rr.m₂ == 2.3 - @test rr.ℏ == 3.4 - - so = SphericalOscillator(mu=2.2, hbar=3.3) - @test so.μ == 2.2 - @test so.ℏ == 3.3 - end for model in Antique.models # [:InfinitePotentialWell3D, :SphericalOscillator, :HydrogenAtom, :CoulombTwoBody] include("./$(model).jl") From fc0c31d0ccb73dfd987d011a8c43ee5273a84daf Mon Sep 17 00:00:00 2001 From: lhapp27 Date: Thu, 6 Aug 2026 09:45:13 +0200 Subject: [PATCH 5/7] fixed @kwdef and tests --- src/Antique.jl | 3 +++ test/result/InfinitePotentialWell3D.md | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Antique.jl b/src/Antique.jl index 528ad23..8d549b8 100644 --- a/src/Antique.jl +++ b/src/Antique.jl @@ -1,5 +1,8 @@ module Antique + # for Julia 1.1 + import Base:@kwdef + # Export public functions export energy export potential diff --git a/test/result/InfinitePotentialWell3D.md b/test/result/InfinitePotentialWell3D.md index f50c4c2..8181fd1 100644 --- a/test/result/InfinitePotentialWell3D.md +++ b/test/result/InfinitePotentialWell3D.md @@ -5,7 +5,7 @@ ``` ``` -IPW3D = Antique.InfinitePotentialWell3D(L=[1.0, 1.0, 1.0], m=1.0, hbar=1.0) +IPW3D = Antique.InfinitePotentialWell3D(L=Real[1.0, 1.0, 1.0], m=1.0, hbar=1.0) ix | iy | iz | jx | jy | jz | analytical | numerical -- | -- | -- | -- | -- | -- | -------------- | -------------- 1 | 1 | 1 | 1 | 1 | 1 | 1.000000000 | 0.999960857 ✔ @@ -73,7 +73,7 @@ ix | iy | iz | jx | jy | jz | analytical | numerical 2 | 2 | 2 | 2 | 2 | 1 | 0.000000000 | -0.000001072 ✔ 2 | 2 | 2 | 2 | 2 | 2 | 1.000000000 | 1.003329100 ✔ -IPW3D = Antique.InfinitePotentialWell3D(L=[1.2, 3.4, 4.5], m=2.0, hbar=3.0) +IPW3D = Antique.InfinitePotentialWell3D(L=Real[1.2, 3.4, 4.5], m=2.0, hbar=3.0) ix | iy | iz | jx | jy | jz | analytical | numerical -- | -- | -- | -- | -- | -- | -------------- | -------------- 1 | 1 | 1 | 1 | 1 | 1 | 1.000000000 | 0.999991924 ✔ @@ -205,7 +205,7 @@ are given by the sum of 2 Taylor series: \end{aligned} ``` ``` -IPW3D = Antique.InfinitePotentialWell3D(L=[1.0, 1.0, 1.0], m=1.0, hbar=1.0) +IPW3D = Antique.InfinitePotentialWell3D(L=Real[1.0, 1.0, 1.0], m=1.0, hbar=1.0) nx | ny | nz | analytical | numerical -- | -- | -- | -------------- | -------------- 1 | 1 | 1 | 14.803827112 | 14.804406602 ✔ @@ -217,7 +217,7 @@ IPW3D = Antique.InfinitePotentialWell3D(L=[1.0, 1.0, 1.0], m=1.0, hbar=1.0) 2 | 2 | 1 | 44.411710033 | 44.413219805 ✔ 2 | 2 | 2 | 59.414767779 | 59.217626407 ✔ -IPW3D = Antique.InfinitePotentialWell3D(L=[1.2, 3.4, 4.5], m=2.0, hbar=3.0) +IPW3D = Antique.InfinitePotentialWell3D(L=Real[1.2, 3.4, 4.5], m=2.0, hbar=3.0) nx | ny | nz | analytical | numerical -- | -- | -- | -------------- | -------------- 1 | 1 | 1 | 18.438717690 | 18.438866604 ✔ From 529161df23c8e8f3c25868ba5f813d25f627165f Mon Sep 17 00:00:00 2001 From: lhapp27 Date: Thu, 6 Aug 2026 11:21:16 +0200 Subject: [PATCH 6/7] resolved conflicts with recent Base.string changes --- src/Antique.jl | 7 ++----- test/runtests.jl | 11 +++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Antique.jl b/src/Antique.jl index 8d549b8..c63423e 100644 --- a/src/Antique.jl +++ b/src/Antique.jl @@ -127,10 +127,7 @@ module Antique using .InfinitePotentialWell3Ds: InfinitePotentialWell3D using .CoulombTwoBodies: CoulombTwoBody - # override Base.string and Base.show - for model in Antique.models - Base.string(t::eval(Symbol(model))) = "Antique.$(typeof(t))(" * join(["$(symbol)=$(getproperty(t,symbol))" for symbol in fieldnames(typeof(t))], ", ") * ")" - Base.show(io::IO, t::eval(Symbol(model))) = print(io, Base.string(t)) - end + # Define the display representation for all models. + Base.show(io::IO, model::AbstractModel) = print(io, "Antique.", nameof(typeof(model)), "(", join(("$(name)=$(getfield(model, name))" for name in fieldnames(typeof(model))), ", "), ")") end diff --git a/test/runtests.jl b/test/runtests.jl index e437785..6ba2c82 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -13,6 +13,17 @@ using Zygote @testset verbose = true "Antique.jl" begin + @testset "Base.string" begin + @test string(HarmonicOscillator(k=2.0, m=3.0, hbar=4.0)) == "Antique.HarmonicOscillator(k=2.0, m=3.0, hbar=4.0)" + for model_name in Antique.models + model = getproperty(Antique, model_name)() + representation = string(model) + @test representation == sprint(show, model) + @test startswith(representation, "Antique.$(model_name)(") + @test which(Base.string, (typeof(model),)).module === Base + end + end + for model in Antique.models # [:InfinitePotentialWell3D, :SphericalOscillator, :HydrogenAtom, :CoulombTwoBody] include("./$(model).jl") end From ee64a2a1241c29923f07f0d5eef388f24ef40e00 Mon Sep 17 00:00:00 2001 From: lhapp27 Date: Thu, 6 Aug 2026 12:20:35 +0200 Subject: [PATCH 7/7] added import of @kwdef to all modules --- src/CoulombTwoBody.jl | 3 +++ src/DeltaPotential.jl | 3 +++ src/HarmonicOscillator.jl | 3 +++ src/HydrogenAtom.jl | 3 +++ src/InfinitePotentialWell.jl | 3 +++ src/InfinitePotentialWell3D.jl | 3 +++ src/MorsePotential.jl | 3 +++ src/PoschlTeller.jl | 3 +++ src/RigidRotor.jl | 3 +++ src/SphericalOscillator.jl | 3 +++ 10 files changed, 30 insertions(+) diff --git a/src/CoulombTwoBody.jl b/src/CoulombTwoBody.jl index 7946f2a..82770c3 100644 --- a/src/CoulombTwoBody.jl +++ b/src/CoulombTwoBody.jl @@ -1,5 +1,8 @@ module CoulombTwoBodies +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction, ..radial_function, ..laguerre_polynomial, ..spherical_harmonic, ..legendre_polynomial diff --git a/src/DeltaPotential.jl b/src/DeltaPotential.jl index a7c6c1c..b589c3b 100644 --- a/src/DeltaPotential.jl +++ b/src/DeltaPotential.jl @@ -1,5 +1,8 @@ module DeltaPotentials +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction diff --git a/src/HarmonicOscillator.jl b/src/HarmonicOscillator.jl index c37a1c2..4fa4b38 100644 --- a/src/HarmonicOscillator.jl +++ b/src/HarmonicOscillator.jl @@ -1,5 +1,8 @@ module HarmonicOscillators +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction, ..laguerre_polynomial diff --git a/src/HydrogenAtom.jl b/src/HydrogenAtom.jl index b01d9cd..ebe522c 100644 --- a/src/HydrogenAtom.jl +++ b/src/HydrogenAtom.jl @@ -1,5 +1,8 @@ module HydrogenAtoms +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction, ..radial_function, ..laguerre_polynomial, ..spherical_harmonic, ..legendre_polynomial diff --git a/src/InfinitePotentialWell.jl b/src/InfinitePotentialWell.jl index cc349ab..5fafdda 100644 --- a/src/InfinitePotentialWell.jl +++ b/src/InfinitePotentialWell.jl @@ -1,5 +1,8 @@ module InfinitePotentialWells +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction diff --git a/src/InfinitePotentialWell3D.jl b/src/InfinitePotentialWell3D.jl index d2b3671..9d97966 100644 --- a/src/InfinitePotentialWell3D.jl +++ b/src/InfinitePotentialWell3D.jl @@ -1,5 +1,8 @@ module InfinitePotentialWell3Ds +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction diff --git a/src/MorsePotential.jl b/src/MorsePotential.jl index b4b876b..0eaf53c 100644 --- a/src/MorsePotential.jl +++ b/src/MorsePotential.jl @@ -1,5 +1,8 @@ module MorsePotentials +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction, ..n_max, ..laguerre_polynomial diff --git a/src/PoschlTeller.jl b/src/PoschlTeller.jl index d710198..7a56ed6 100644 --- a/src/PoschlTeller.jl +++ b/src/PoschlTeller.jl @@ -1,5 +1,8 @@ module PoschlTellers +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction, ..n_max, ..legendre_polynomial diff --git a/src/RigidRotor.jl b/src/RigidRotor.jl index 8eb1b5f..46b784a 100644 --- a/src/RigidRotor.jl +++ b/src/RigidRotor.jl @@ -1,5 +1,8 @@ module RigidRotors +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction, ..spherical_harmonic, ..legendre_polynomial diff --git a/src/SphericalOscillator.jl b/src/SphericalOscillator.jl index 324829d..f86a5fd 100644 --- a/src/SphericalOscillator.jl +++ b/src/SphericalOscillator.jl @@ -1,5 +1,8 @@ module SphericalOscillators +# for Julia 1.1 +import Base:@kwdef + import ..AbstractModel import ..energy, ..potential, ..wavefunction, ..radial_function, ..laguerre_polynomial, ..spherical_harmonic, ..legendre_polynomial