Skip to content

Commit

Permalink
a low energy spectrum tester
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomino committed Dec 21, 2020
1 parent 43aaf19 commit ef7f9d9
Showing 1 changed file with 38 additions and 11 deletions.
49 changes: 38 additions & 11 deletions test/low_energy_approx_chimera.jl
Expand Up @@ -2,6 +2,7 @@ using LinearAlgebra
using LightGraphs
using MetaGraphs
using NPZ
using Plots

using SpinGlassPEPS

Expand Down Expand Up @@ -45,7 +46,7 @@ s = ArgParseSettings("description")
"--n_sols", "-n"
default = 10
arg_type = Int
help = "number of solutions"
help = "maximal number of solutions"
"--node_size1", "-r"
default = 1
arg_type = Int
Expand All @@ -54,10 +55,10 @@ s = ArgParseSettings("description")
default = 1
arg_type = Int
help = "chimera node size in columns"
"--spectrum_cutoff max", "-u"
"--spectrum_cutoff", "-u"
default = 256
arg_type = Int
help = "size of the lower spectrum"
help = "maximal size of the lower spectrum"
end

fi = parse_args(s)["file"]
Expand Down Expand Up @@ -87,19 +88,45 @@ energy_ref = energy(ground_spins, ig)

spectrum_cutoff = parse_args(s)["spectrum_cutoff"]

for s in spectrum_cutoff:-10:70
ses = collect(spectrum_cutoff:-10:1)
step = 9
#step = 100
n_s = collect(n_sols:-step:1)

@time _, objective = solve(ig, n_sols; β=β, χ = χ, threshold = 1e-8, node_size = node_size, spectrum_cutoff = s)
delta_e = ones(length(ses), length(n_s))
cut = ones(Int, length(ses), length(n_s))

energy= minimum([energy(s, ig) for s in spins])
function proceed()
j = 1
for n_sol in n_s
i = 1
for s in ses

println("spectrum cutoff = ", s)
println("delta E = ", energy_ref-energy)
end
@time spins, _ = solve(ig, n_sol; β=β, χ = χ, threshold = 1e-8, node_size = node_size, spectrum_cutoff = s)

en = minimum([energy(s, ig) for s in spins])

cut[i,j] = s
delta_e[i,j] = (en-energy_ref)/abs(energy_ref)
i = i+1

println("spectrum cutoff = ", s)
println("no sols = ", n_sol)
println("percentage E = ", (en-energy_ref)/abs(energy_ref))
end
j = j+1
end

d = Dict("percentage_delta_e" => delta_e, "spectrum_size" => cut, "chi" => χ, "beta" => β, "chimera_size" => si, "no_solutions" => n_s)
npzwrite(folder*"low_energy_sols/"*file[1:3]*"approx$(si).npz", d)

p = plot(cut[:,1], delta_e[:,1], title = "low spectr. approx., beta = , chi = , chimera_s. = $(si)", label = "n_sols = $(n_s[1])", lw = 1.5, left_margin = 10Plots.mm, bottom_margin = 10Plots.mm)
xlabel!("size of the low energy spectrum")
ylabel!("percentage delta E")
for j in 2:size(cut,2)
plot!(p, cut[:,j], delta_e[:,j], label = "n_sols = $(n_s[j])", lw = 1.5)
end
savefig(folder*"low_energy_sols/"*file[1:3]*"approx$(si).pdf")
end

#d = Dict("energies" => energies, "energy_ref" => energy_ref, "chi" => χ, "beta" => β)
#npzwrite(folder*file[1:3]*"approx.npz", d)
proceed()

0 comments on commit ef7f9d9

Please sign in to comment.