Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* splitting MPS function into MPS and _compress_MPS * Renaming _compress_MPS to _apply_layer_of_gates, adding multiply_purifications * MPS2 does not work * some changes in MPS2 - working * add empty MPS into multiply_purifications * start splitting test files, corrections in MPS2 * correct holes in _apply_layer_of_gates, correct MPS2, add some tests * unification of notation * changes after pulling request * unification of MPS and MPS2, change type from String to Symbol, add some tests * some changes in tests * Update Project.toml * Update Project.toml * remove Infiltrator * corrections in full_spectrum * add more tests
- Loading branch information
1 parent
bff3c4f
commit ec6beef
Showing
4 changed files
with
224 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
using MetaGraphs | ||
using LightGraphs | ||
using GraphPlot | ||
|
||
L = 4 | ||
N = L^2 | ||
|
||
instance = "$(@__DIR__)/instances/$(N)_001.txt" | ||
|
||
ig = ising_graph(instance, N) | ||
set_prop!(ig, :β, 1.) #rand(Float64)) | ||
r = fill(2, N) | ||
set_prop!(ig, :rank, r) | ||
set_prop!(ig, :dβ, 0.001) | ||
|
||
ϵ = 1E-5 | ||
D = 16 | ||
var_ϵ = 1E-8 | ||
sweeps = 40 | ||
type1 = :log | ||
type2 = :lin | ||
β = [get_prop(ig, :β)] | ||
dβ = [get_prop(ig, :dβ)] | ||
control = MPSControl(D, var_ϵ, sweeps, β, dβ) | ||
|
||
states = all_states(get_prop(ig, :rank)) | ||
ϱ = gibbs_tensor(ig) | ||
@test sum(ϱ) ≈ 1 | ||
|
||
@testset "Verifying gate operations 2" begin | ||
rank = get_prop(ig, :rank) | ||
@info "Testing MPS" | ||
|
||
rψ1 = MPS(ig, control, type1) | ||
rψ2 = MPS(ig, control, type2) | ||
rψ3 = MPS(ig, control) | ||
overlap12 = dot(rψ1, rψ2) | ||
@test abs(1 - overlap12) < ϵ | ||
overlap13 = dot(rψ1, rψ3) | ||
@test abs(1 - overlap13) < ϵ | ||
overlap23 = dot(rψ2, rψ3) | ||
@test abs(1 - overlap23) < ϵ | ||
|
||
for max_states ∈ [1, N, 2*N, N^2] | ||
@info "Testing spectrum_new" | ||
states_new1, prob_new1, pCut_new1 = solve_new(rψ1, max_states) | ||
states_new2, prob_new2, pCut_new2 = solve_new(rψ2, max_states) | ||
states_new3, prob_new3, pCut_new3 = solve_new(rψ3, max_states) | ||
|
||
for st ∈ states_new1 | ||
@test st ∈ states_new2 | ||
end | ||
eng_new1 = zeros(length(prob_new1)) | ||
eng_new2 = zeros(length(prob_new2)) | ||
eng_new3 = zeros(length(prob_new3)) | ||
for (j, p) ∈ enumerate(prob_new1) | ||
σ = states_new1[j, :] | ||
eng_new1[j] = energy(σ, ig) | ||
end | ||
for (j, p) ∈ enumerate(prob_new2) | ||
σ = states_new2[j, :] | ||
eng_new2[j] = energy(σ, ig) | ||
end | ||
for (j, p) ∈ enumerate(prob_new3) | ||
σ = states_new3[j, :] | ||
eng_new3[j] = energy(σ, ig) | ||
end | ||
|
||
perm1 = partialsortperm(eng_new1, 1:max_states) | ||
eng_new1 = eng_new1[perm1] | ||
states_new1 = states_new1[perm1, :] | ||
prob_new1 = prob_new1[perm1] | ||
state1 = states_new1[1, :] | ||
@info "Testing MPS2 - logarithmic" | ||
@info "The largest discarded probability" pCut_new1 | ||
@info "State with the lowest energy" state1 | ||
@info "Probability of the state with the lowest energy" prob_new1[1] | ||
@info "The lowest energy" eng_new1[1] | ||
|
||
perm2 = partialsortperm(eng_new2, 1:max_states) | ||
eng_new2 = eng_new2[perm2] | ||
states_new2 = states_new2[perm2, :] | ||
prob_new2 = prob_new2[perm2] | ||
state2 = states_new2[1, :] | ||
@info "Testing MPS2 - linear" | ||
@info "The largest discarded probability" pCut_new2 | ||
@info "State with the lowest energy" state2 | ||
@info "Probability of the state with the lowest energy" prob_new2[1] | ||
@info "The lowest energy" eng_new2[1] | ||
|
||
perm3 = partialsortperm(eng_new3, 1:max_states) | ||
eng_new3 = eng_new3[perm3] | ||
states_new3 = states_new3[perm3, :] | ||
prob_new3 = prob_new3[perm3] | ||
state3 = states_new3[1, :] | ||
@info "Testing MPS" | ||
@info "The largest discarded probability" pCut_new3 | ||
@info "State with the lowest energy" state3 | ||
@info "Probability of the state with the lowest energy" prob_new3[1] | ||
@info "The lowest energy" eng_new3[1] | ||
|
||
if state1 == state2 | ||
@test eng_new1[1] == eng_new2[1] | ||
elseif state2 == state3 | ||
@test eng_new2[1] == eng_new3[1] | ||
elseif state1 == state3 | ||
@test eng_new1[1] == eng_new3[1] | ||
end | ||
|
||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters