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

3D harmonic oscillator #50

Open
ohno opened this issue Apr 20, 2024 · 0 comments
Open

3D harmonic oscillator #50

ohno opened this issue Apr 20, 2024 · 0 comments
Labels

Comments

@ohno
Copy link
Owner

ohno commented Apr 20, 2024

3D isotropic harmonic oscillator on spherical coordinate system is already implemented as SphericalOscillator #7.

HarmonicOscillator3D is reserved for the name of this model. Please implement the anisotropic (general) 3D harmonic oscillator on Cartesian coordinate system. The spherical harmonics will not be used and a product of three Hermitian polynomials should be used for wavefunction. Refer to the well tested 1D harmonic oscillator:

export HarmonicOscillator, V, E, ψ, H
@kwdef struct HarmonicOscillator
k = 1.0
m = 1.0
= 1.0
end
function V(model::HarmonicOscillator, x)
k = model.k
return 1//2 * k * x^2
end
function E(model::HarmonicOscillator; n=0)
k = model.k
m = model.m
= model.
ω = sqrt(k/m)
return* ω * (n+1//2)
end
function ψ(model::HarmonicOscillator, x; n=0)
k = model.k
m = model.m
= model.
ω = sqrt(k/m)
A = sqrt(1//(factorial(n)*2^n)*sqrt(m*ω/*ℏ)))
ξ = sqrt(m*ω/ℏ) * x
return A * H(model,ξ,n=n) * exp(-ξ^2/2)
end
function H(model::HarmonicOscillator, x; n=0)
return factorial(n) * sum(i -> (-1)^i // (factorial(i) * factorial(n-2*i)) * (2*x)^(n-2*i), 0:Int(floor(n/2)))
end

@ohno ohno added good first issue Good for newcomers new model labels Apr 20, 2024
@ohno ohno added enhancement New feature or request new model and removed new model enhancement New feature or request labels Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant