NuclearRMF/test/Pb208_nucleon_spectrum.jl

44 lines
1.4 KiB
Julia

using DelimitedFiles, Interpolations, Plots
include("../nucleons.jl")
# test data generated from Hartree.f
# format: x S(x) V(x) R(x) A(x)
test_data = readdlm("test/Pb208FldsFSUGarnet.csv")
xs = test_data[:, 1]
Ss = test_data[:, 2]
Vs = test_data[:, 3]
Rs = test_data[:, 4]
As = test_data[:, 5]
S_interp = linear_interpolation(xs, Ss)
V_interp = linear_interpolation(xs, Vs)
R_interp = linear_interpolation(xs, Rs)
A_interp = linear_interpolation(xs, As)
p = true
N = p ? 82 : 126
r_max = maximum(xs)
E_min = 860
E_max = 939
κs, Es = findAllOrbitals(p, S_interp, V_interp, R_interp, A_interp, r_max, E_min, E_max)
Ebinds = (p ? M_p : M_n) .- Es
occ = fillNucleons(N, κs, Es)
# format: proton, kappa, filling, gnodes, fnodes, Ebind
bench_data, _ = readdlm("test/Pb208Spectrum.csv", ','; header=true)
mask = findall(bench_data[:, 1] .== Int(p))
bench_κs = bench_data[mask, 2]
bench_Ebinds = bench_data[mask, 6]
bench_filling = bench_data[mask, 3]
bench_occ = Int.(bench_filling .* (2 .* j_κ.(Int.(bench_κs)) .+ 1))
scatter(κs, Ebinds, label=(p ? "proton" : "neutron") * " spectrum")
annotate!(κs .+ 0.3, Ebinds .+ 1, [(o, 9) for o in occ])
scatter!(bench_κs, bench_Ebinds, label="benchmark"; markershape=:cross, markercolor="red")
annotate!(bench_κs .+ 0.3, bench_Ebinds .- 1, [(o, 9, :red) for o in bench_occ])
xlabel!("κ")
ylabel!("Binding energy (MeV)")
yflip!()