diff --git a/src/PEPS.jl b/src/PEPS.jl index 26127ecb..9f615ab7 100644 --- a/src/PEPS.jl +++ b/src/PEPS.jl @@ -157,7 +157,8 @@ function MPO(::Type{T}, peps::PepsNetwork, i::Int, k::Int) where {T <: Number} en = ones(1, 1) end - @cast A[_, σ, _, η] := en[σ, η] + #@cast A[_, σ, _, η] := en[σ, η] + @cast A[u, _, d, _] := en[u, d] ψ[j] = A end ψ diff --git a/src/graph.jl b/src/graph.jl index 051eb639..52040094 100644 --- a/src/graph.jl +++ b/src/graph.jl @@ -118,7 +118,7 @@ function factor_graph( pl, en = rank_reveal(energy(fg, edg), :PE) en, pr = rank_reveal(en, :EP) - + set_prop!(fg, e, :split, (pl, en, pr)) end end diff --git a/test/PEPS.jl b/test/PEPS.jl index 4463aa8e..6ca26007 100644 --- a/test/PEPS.jl +++ b/test/PEPS.jl @@ -1,3 +1,21 @@ +@testset "LinearIndices" begin +m = 3 +n = 4 +origin_l = [:NW, :NE, :SE, :SW] +origin_r = [:WN, :EN, :ES, :WS] +for i ∈ 1:length(origin_l) + o_l = origin_l[i] + o_r = origin_r[i] + println("origin ", o_l, " ", o_r) + ind_l, i_max_l, j_max_l = LinearIndices(m, n, o_l) + ind_r, i_max_r, j_max_r = LinearIndices(m, n, o_r) + @test i_max_l == m == j_max_r + @test j_max_l == n == i_max_r + for i ∈ 0:m+1, j ∈ 0:n+1 + @test ind_l[i,j] == ind_r[j,i] + end +end +end @testset "PepsTensor correctly builds PEPS network" begin @@ -25,6 +43,7 @@ fg = factor_graph( spectrum=full_spectrum, ) +#= for (bd, e) in zip(bond_dimensions, edges(fg)) pl, en, pr = get_prop(fg, e, :split) println(e) @@ -52,13 +71,11 @@ for (bd, e) in zip(bond_dimensions, edges(fg)) end end - +=# x, y = m, n -#for origin ∈ (:NW, :SW, :WN, :NE, :EN, :SE, :ES, :SW, :WS) -#for origin ∈ (:NW, :SW, :NE, :SE, :WN) # OK -for origin ∈ (:EN, ) #(:EN, :ES, :WS) # NO +for origin ∈ (:NW, :SW, :WN, :NE, :EN, :SE, :ES, :SW, :WS) @info "testing peps" origin println(origin) @@ -72,7 +89,6 @@ for origin ∈ (:EN, ) #(:EN, :ES, :WS) # NO @test A ≈ B end -#= @info "contracting MPOs (up -> down)" ψ = MPO(PEPSRow(peps, 1)) @@ -94,7 +110,7 @@ for origin ∈ (:EN, ) #(:EN, :ES, :WS) # NO for A ∈ ψ @test size(A, 2) == 1 end end -=# + #for A ∈ ψ @test size(A, 4) == 1 end @info "contracting MPOs (down -> up)" @@ -103,8 +119,11 @@ for origin ∈ (:EN, ) #(:EN, :ES, :WS) # NO for A ∈ ψ @test size(A, 4) == 1 end - for i ∈ peps.i_max-1:1 + println("imax -> ", peps.i_max) + + for i ∈ peps.i_max-1:-1:1 println(i) + R = PEPSRow(peps, i) W = MPO(R) M = MPO(peps, i, i+1)