Refining combined with wave function calculation

This commit is contained in:
Nuwan Yapa 2024-07-16 19:43:46 -04:00
parent f77e5dfed8
commit a17d0813a6
2 changed files with 14 additions and 11 deletions

View File

@ -25,8 +25,20 @@ end
"Solve the Dirac equation and return the wave function u(r)=[g(r), f(r)] where "Solve the Dirac equation and return the wave function u(r)=[g(r), f(r)] where
divs is the number of mesh divisions if the solution should be discretized as a 2×(1+divs) matrix (keep divs=0 to obtain an interpolating function), divs is the number of mesh divisions if the solution should be discretized as a 2×(1+divs) matrix (keep divs=0 to obtain an interpolating function),
refine determines whether to switch to high-precision mode and optimize the energy beforehand (assuming a bound state),
the other parameters are the same from dirac!(...)." the other parameters are the same from dirac!(...)."
function solveWf(κ, p, E, Φ0, W0, B0, A0, r_max, divs::Int=0; dtype=BigFloat, algo=Feagin12()) function solveWf(κ, p, E, Φ0, W0, B0, A0, r_max, divs::Int=0, refine=true)
if refine
dtype = BigFloat
algo = Feagin12()
f(E_) = boundaryValue(κ, p, E_, Φ0, W0, B0, A0, r_max; dtype=dtype, algo=algo)
E = find_zero(f, E)
else
dtype = Float64
algo = RK()
end
prob = ODEProblem(dirac!, convert.(dtype, [0, 1]), (0, r_max)) prob = ODEProblem(dirac!, convert.(dtype, [0, 1]), (0, r_max))
sol = solve(prob, algo, p=(κ, p, E, Φ0, W0, B0, A0), saveat=(divs == 0 ? [] : r_max/divs)) sol = solve(prob, algo, p=(κ, p, E, Φ0, W0, B0, A0), saveat=(divs == 0 ? [] : r_max/divs))
return divs == 0 ? sol : hcat(sol.u...) return divs == 0 ? sol : hcat(sol.u...)
@ -48,13 +60,6 @@ function findEs(κ, p, Φ0, W0, B0, A0, r_max, E_min=0, E_max=(p ? M_p : M_n))
return find_zeros(f, (E_min, E_max)) return find_zeros(f, (E_min, E_max))
end end
"Find more precise bound energies for a given list of Es where
the other parameters are the same from dirac!(...)."
function refineEs(κ, p, Φ0, W0, B0, A0, r_max, Es)
f(E) = boundaryValue(κ, p, E, Φ0, W0, B0, A0, r_max; dtype=BigFloat, algo=Feagin12())
return [find_zero(f, E) for E in Es]
end
"Find all orbitals and return two lists containing κ values and corresponding energies for a single species where "Find all orbitals and return two lists containing κ values and corresponding energies for a single species where
the other parameters are defined above" the other parameters are defined above"
function findAllOrbitals(p, Φ0, W0, B0, A0, r_max, E_min=0, E_max=(p ? M_p : M_n)) function findAllOrbitals(p, Φ0, W0, B0, A0, r_max, E_min=0, E_max=(p ? M_p : M_n))

View File

@ -21,9 +21,7 @@ r_max = maximum(xs)
E_min = 880 E_min = 880
E_max = 939 E_max = 939
approxE = findEs(κ, p, S_interp, V_interp, R_interp, A_interp, r_max, E_min, E_max) |> minimum groundE = findEs(κ, p, S_interp, V_interp, R_interp, A_interp, r_max, E_min, E_max) |> minimum
groundE = refineEs(κ, p, S_interp, V_interp, R_interp, A_interp, r_max, [approxE])[1]
println("ground state E = $groundE") println("ground state E = $groundE")
divs = 50 divs = 50