BergEC-jl/test/numerical_V.jl

21 lines
594 B
Julia

using Statistics
include("../ho_basis.jl")
ls = 0:4
ns = 0:15
R = 2
μω_gen = 0.3
V_of_r(r) = exp(-r^2 / R^2)
for l in ls
println("Testing l=", l)
@time "Analytical" V_ana = [V_Gaussian(R, l, n1, n2; μω_gen=μω_gen) for (n1, n2) in Iterators.product(ns, ns)]
@time "Numerical" V_num = [V_numerical(V_of_r, l, n1, n2; μω_gen=μω_gen) for (n1, n2) in Iterators.product(ns, ns)]
mean_diff = Statistics.mean(abs.((V_num .- V_ana) ./ V_ana))
@assert mean_diff < 1e-5 "Mean absoute difference of $(mean_diff * 100)% between analytical and numerical calculations"
end