-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add tests #43
Comments
It is not clear to me what is meant with "other unit systems". |
Thank you for your efforts. I meant "other parameters". I want to make sure that it is correct not only in atomic unit system but also in other systems of units (e.g. IS unit system). atomic unit system:
IS unit system: a₀ = 5.29177210903e-11 # m # https://physics.nist.gov/cgi-bin/cuu/Value?bohrrada0
Eₕ = 4.3597447222071e-18 # J # https://physics.nist.gov/cgi-bin/cuu/Value?hr
ℏ = 1.054571817e-34 # J s # https://physics.nist.gov/cgi-bin/cuu/Value?hbar
mₑ = 9.1093837015e-31 # kg # https://physics.nist.gov/cgi-bin/cuu/Value?me
HA = HydrogenAtom(Z=1, Eₕ=Eₕ, a₀=a₀, mₑ=mₑ, ℏ=ℏ) |
Thank you, but it is still not 100% clear what you intend to add for it. Let's take your example of the Hydrogen Atom:
Then as of the code
Therefore the users can use any unit system they like. |
Please see this commit 4c96f24 . The parameter dependency of the potential energy was wrong. I means that we want to find such mistakes. julia> using Antique
julia> H = HydrogenAtom(Eₕ=1.0)
julia> V(H,1.0)
-1.0
julia> H = HydrogenAtom(Eₕ=2.0)
julia> V(H,1.0)
-1.0 # wrong!
-2.0 # correct! In general, It is difficult to test energy using only energy. We should calculate the expected value of Hamiltonian to compare with energy. Based on the Virial theorem, I use the expected value of potential energy instead of the Hamiltonian: using Test
using Printf
using QuadGK
using Antique
# https://physics.nist.gov/cgi-bin/cuu/Value?bohrrada0
# https://physics.nist.gov/cgi-bin/cuu/Value?hr
# https://physics.nist.gov/cgi-bin/cuu/Value?hbar
# https://physics.nist.gov/cgi-bin/cuu/Value?me
# https://physics.nist.gov/cgi-bin/cuu/Value?hrev
for HA in [
HydrogenAtom(Z=1, Eₕ=1.0, a₀=1.0, mₑ=1.0, ℏ=1.0),
HydrogenAtom(Z=1, Eₕ=1.0, a₀=2.0, mₑ=1.0, ℏ=1.0),
HydrogenAtom(Z=2, Eₕ=1.0, a₀=1.0, mₑ=1.0, ℏ=1.0),
HydrogenAtom(Z=2, Eₕ=27.211386245988, a₀=1.0, mₑ=1.0, ℏ=1.0),
HydrogenAtom(Z=2, Eₕ=4.3597447222071e-18, a₀=5.29177210903e-11, mₑ=9.1093837015e-31, ℏ=1.054571817e-34),
]
println(HA)
@testset "<ψₙ|V|ψₙ> / 2 = Eₙ" begin
println(" n | analytical | numerical ")
println("-- | ----------------- | ----------------- ")
for n in 1:10
analytical = E(HA, n=n) * 2
numerical = quadgk(r -> 4*π*r^2 * conj(ψ(HA,r,0,0, n=n)) * V(HA,r) * ψ(HA,r,0,0, n=n), 0, HA.a₀*50*n, maxevals=10^3)[1]
acceptance = iszero(analytical) ? isapprox(analytical, numerical, atol=1e-5) : isapprox(analytical, numerical, rtol=1e-5)
@test acceptance
@printf("%2d | %17.12e | %17.12e %s\n", n, analytical, numerical, acceptance ? "✔" : "✗")
end
end
end |
@lhapp27 Please check the dependence not only on λ but also on m, ℏ, and x₀ in |
I will try to check the energy for Deltapotential and Rigidrotor. |
For the delta potential, when I compute the eigenenergy numerically, there is an error or inaccuracy in computing the derivative. This is because there is a cusp at the origin. I can compare the eigenenergy and the expectation value of the Hamiltonian analytically, not numerically. |
Perhaps it is okay like this.
|
Also for Rigidrotor, I computed the expectation value analytically.
|
The normalization and the orthogonality of eigenfunctions have already been tested. We need additional tests for the parameter dependence, the energy, the matching of Hamiltonian and eigenfunctions, etc..
:HydrogenAtom
):CoulombTwoBody
):PoschlTeller
):DeltaPotential
):PoschlTeller
)RigidRotor
)InfinitePotentialWell3D
):SphericalOscillator
):CoulombTwoBody
):MorsePotential
)The text was updated successfully, but these errors were encountered: