Skip to content

Commit

Permalink
Fix row and column indices in mpskit_glue
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrehmer committed Jul 17, 2024
1 parent 40a14ad commit 294726b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
18 changes: 10 additions & 8 deletions src/mpskit_glue/transferpepo_environments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@ function MPSKit.mixed_fixpoints(
righties = PeriodicArray{envtype,2}(undef, numrows, numcols)

@threads for cr in 1:numrows
c_above = above[cr]
c_above = above[cr - 1]
O_middle = O[cr]
c_below = below[cr + 1]

(L0, R0) = init[cr]

@sync begin
Threads.@spawn begin
E_LL = TransferMatrix($c_above.AL, $O[cr], $c_below.AL)
E_LL = TransferMatrix($c_above.AL, $O_middle, $c_below.AL)
(_, Ls, convhist) = eigsolve(flip(E_LL), $L0, 1, :LM, $solver)
convhist.converged < 1 &&
@info "left eigenvalue failed to converge $(convhist.normres)"
L0 = first(Ls)
end

Threads.@spawn begin
E_RR = TransferMatrix($c_above.AR, $O[cr], $c_below.AR)
E_RR = TransferMatrix($c_above.AR, $O_middle, $c_below.AR)
(_, Rs, convhist) = eigsolve(E_RR, $R0, 1, :LM, $solver)
convhist.converged < 1 &&
@info "right eigenvalue failed to converge $(convhist.normres)"
Expand All @@ -57,7 +58,7 @@ function MPSKit.mixed_fixpoints(
for loc in 2:numcols
lefties[cr, loc] =
lefties[cr, loc - 1] *
TransferMatrix(c_above.AL[loc - 1], O[cr, loc - 1], c_below.AL[loc - 1])
TransferMatrix(c_above.AL[loc - 1], O_middle[loc - 1], c_below.AL[loc - 1])
end

renormfact::scalartype(T) = dot(c_below.CR[0], PEPO_∂∂C(L0, R0) * c_above.CR[0])
Expand All @@ -67,8 +68,9 @@ function MPSKit.mixed_fixpoints(

for loc in (numcols - 1):-1:1
righties[cr, loc] =
TransferMatrix(c_above.AR[loc + 1], O[cr, loc + 1], c_below.AR[loc + 1]) *
righties[cr, loc + 1]
TransferMatrix(
c_above.AR[loc + 1], O_middle[loc + 1], c_below.AR[loc + 1]
) * righties[cr, loc + 1]

renormfact = dot(
c_below.CR[loc],
Expand All @@ -90,12 +92,12 @@ function gen_init_fps(above::MPSMultiline, O::TransferPEPOMultiline, below::MPSM
rand,
scalartype(T),
left_virtualspace(below, cr + 1, 0) * prod(adjoint.(west_spaces(O[cr], 1))),
left_virtualspace(above, cr, 0),
left_virtualspace(above, cr - 1, 0),
)
R0::T = TensorMap(
rand,
scalartype(T),
right_virtualspace(above, cr, 0) * prod(adjoint.(east_spaces(O[cr], 1))),
right_virtualspace(above, cr - 1, 0) * prod(adjoint.(east_spaces(O[cr], 1))),
right_virtualspace(below, cr + 1, 0),
)
(L0, R0)
Expand Down
17 changes: 9 additions & 8 deletions src/mpskit_glue/transferpeps_environments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,23 @@ function MPSKit.mixed_fixpoints(
righties = PeriodicArray{envtype,2}(undef, numrows, numcols)

@threads for cr in 1:numrows
c_above = above[cr]
c_above = above[cr - 1]
O_middle = O[cr]
c_below = below[cr + 1]

(L0, R0) = init[cr]

@sync begin
Threads.@spawn begin
E_LL = TransferMatrix($c_above.AL, $O[cr], $c_below.AL)
E_LL = TransferMatrix($c_above.AL, $O_middle, $c_below.AL)
(_, Ls, convhist) = eigsolve(flip(E_LL), $L0, 1, :LM, $solver)
convhist.converged < 1 &&
@info "left eigenvalue failed to converge $(convhist.normres)"
L0 = first(Ls)
end

Threads.@spawn begin
E_RR = TransferMatrix($c_above.AR, $O[cr], $c_below.AR)
E_RR = TransferMatrix($c_above.AR, $O_middle, $c_below.AR)
(_, Rs, convhist) = eigsolve(E_RR, $R0, 1, :LM, $solver)
convhist.converged < 1 &&
@info "right eigenvalue failed to converge $(convhist.normres)"
Expand All @@ -59,7 +60,7 @@ function MPSKit.mixed_fixpoints(
for loc in 2:numcols
lefties[cr, loc] =
lefties[cr, loc - 1] *
TransferMatrix(c_above.AL[loc - 1], O[cr, loc - 1], c_below.AL[loc - 1])
TransferMatrix(c_above.AL[loc - 1], O_middle[loc - 1], c_below.AL[loc - 1])
end

renormfact::scalartype(T) = dot(c_below.CR[0], PEPS_∂∂C(L0, R0) * c_above.CR[0])
Expand All @@ -69,7 +70,7 @@ function MPSKit.mixed_fixpoints(

for loc in (numcols - 1):-1:1
righties[cr, loc] =
TransferMatrix(c_above.AR[loc + 1], O[cr, loc + 1], c_below.AR[loc + 1]) *
TransferMatrix(c_above.AR[loc + 1], O_middle[loc + 1], c_below.AR[loc + 1]) *
righties[cr, loc + 1]

renormfact = dot(
Expand All @@ -94,12 +95,12 @@ function gen_init_fps(above::MPSMultiline, O::TransferPEPSMultiline, below::MPSM
left_virtualspace(below, cr + 1, 0) *
space(O[cr].top[1], 5)' *
space(O[cr].bot[1], 5),
left_virtualspace(above, cr, 0),
left_virtualspace(above, cr - 1, 0),
)
R0::T = TensorMap(
rand,
scalartype(T),
right_virtualspace(above, cr, 0) *
right_virtualspace(above, cr - 1, 0) *
space(O[cr].top[1], 3)' *
space(O[cr].bot[1], 3),
right_virtualspace(below, cr + 1, 0),
Expand All @@ -126,7 +127,7 @@ function MPSKit.transfer_spectrum(
@threads for cr in 1:numrows
L0, = init[cr]

E_LL = TransferMatrix(above[cr].AL, O[cr + 1], below[cr + 2].AL)
E_LL = TransferMatrix(above[cr - 1].AL, O[cr], below[cr + 1].AL)
λ, _, convhist = eigsolve(flip(E_LL), L0, num_vals, :LM, solver)
convhist.converged < num_vals &&
@warn "correlation length failed to converge: normres = $(convhist.normres)"
Expand Down

0 comments on commit 294726b

Please sign in to comment.