Train only on bound states

This commit is contained in:
Nuwan Yapa 2025-04-11 16:28:46 -04:00
parent 56914be36b
commit 75ebbc3247
1 changed files with 16 additions and 4 deletions

View File

@ -8,7 +8,7 @@ training_c = range(1.2, 0.9, 9) # original: range(1.35, 0.9, 5)
extrapolating_c = range(0.78, 0.45, 7) # original: range(0.75, 0.40, 8)
# calculate training data
data_c = vcat(training_c, extrapolating_c)
data_c = training_c
data_E = [quick_pole_E(V_system(c)) for c in data_c]
# hyperparameters
@ -54,6 +54,18 @@ for epoch in 1:epochs
H1 .-= lr .* grad(1) # update H1
end
# plot the results
scatter(real.(data_E), imag.(data_E), label="Target", title="PMM", xlabel="Re E", ylabel="Im E")
scatter!(real.(Es), imag.(Es), label="Predicted")
# evaluate for all points
all_c = vcat(training_c, extrapolating_c)
exact_E = [quick_pole_E(V_system(c)) for c in all_c]
extrapolated_E = ComplexF64[]
for c in all_c
H = H0 + c * H1
evals, evecs = eigen(H)
evals = vcat(evals, conj.(evals)) # include complex conjugates
push!(extrapolated_E, nearest(evals, exact_E[end]))
end
# plot results
scatter(real.(data_E), imag.(data_E), label="training", title="PMM", xlabel="Re E", ylabel="Im E")
scatter!(real.(exact_E), imag.(exact_E), label="exact", m=:+)
scatter!(real.(extrapolated_E), imag.(extrapolated_E), label="predicted", m=:x)