Skip to content
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
3 changes: 3 additions & 0 deletions src/Antique.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module Antique

# for Julia 1.1
import Base:@kwdef

# Export public functions
export energy
export potential
Expand Down
46 changes: 12 additions & 34 deletions src/CoulombTwoBody.jl
Original file line number Diff line number Diff line change
@@ -1,45 +1,23 @@
module CoulombTwoBodies

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
import ..energy, ..potential, ..wavefunction, ..radial_function, ..laguerre_polynomial, ..spherical_harmonic, ..legendre_polynomial

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₁=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)
@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
Expand Down
25 changes: 7 additions & 18 deletions src/DeltaPotential.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
module DeltaPotentials

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
import ..energy, ..potential, ..wavefunction

export DeltaPotential, energy, potential, wavefunction

# parameters
struct DeltaPotential <: AbstractModel
alpha::Real
m::Real
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)
@kwdef struct DeltaPotential <: AbstractModel
alpha::Real = 1.0
m::Real = 1.0
hbar::Real = 1.0
end

# potential
Expand Down
24 changes: 7 additions & 17 deletions src/HarmonicOscillator.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
module HarmonicOscillators

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
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=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)
@kwdef struct HarmonicOscillator <: AbstractModel
k::Real = 1.0
m::Real = 1.0
hbar::Real = 1.0
end

# potential
Expand Down
33 changes: 9 additions & 24 deletions src/HydrogenAtom.jl
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
module HydrogenAtoms

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
import ..energy, ..potential, ..wavefunction, ..radial_function, ..laguerre_polynomial, ..spherical_harmonic, ..legendre_polynomial

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=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)
@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
Expand Down
24 changes: 7 additions & 17 deletions src/InfinitePotentialWell.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
module InfinitePotentialWells

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
import ..energy, ..potential, ..wavefunction

export InfinitePotentialWell, energy, potential, wavefunction

# parameters
struct InfinitePotentialWell <: AbstractModel
L::Real
m::Real
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)
@kwdef struct InfinitePotentialWell <: AbstractModel
L::Real = 1.0
m::Real = 1.0
hbar::Real = 1.0
end

# potential
Expand Down
24 changes: 7 additions & 17 deletions src/InfinitePotentialWell3D.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
module InfinitePotentialWell3Ds

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
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=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)
@kwdef struct InfinitePotentialWell3D <: AbstractModel
L::Vector{Real} = [1.0, 1.0, 1.0]
m::Real = 1.0
hbar::Real = 1.0
end

# potential
Expand Down
36 changes: 9 additions & 27 deletions src/MorsePotential.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module MorsePotentials

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
import ..energy, ..potential, ..wavefunction, ..n_max, ..laguerre_polynomial

Expand All @@ -9,33 +12,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(;
# 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)
@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
Expand Down
32 changes: 8 additions & 24 deletions src/PoschlTeller.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module PoschlTellers

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
import ..energy, ..potential, ..wavefunction, ..n_max, ..legendre_polynomial

Expand All @@ -9,30 +12,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=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)
@kwdef struct PoschlTeller <: AbstractModel
lambda::Integer = 1
m::Real = 1.0
hbar::Real = 1.0
x_0::Real = 1.0
end

# potential
Expand Down
29 changes: 8 additions & 21 deletions src/RigidRotor.jl
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
module RigidRotors

# for Julia 1.1
import Base:@kwdef

import ..AbstractModel
import ..energy, ..potential, ..wavefunction, ..spherical_harmonic, ..legendre_polynomial

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=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)
@kwdef struct RigidRotor <: AbstractModel
m_1::Real = 1.0
m_2::Real = 1.0
R::Real = 1.0
hbar::Real = 1.0
end

# potential
Expand Down
Loading
Loading