Skip to content

Commit

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

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

(L0, R0) = init[cr]

@sync begin
Threads.@spawn begin
E_LL = TransferMatrix($c_above.AL, $O_middle, $c_below.AL)
E_LL = TransferMatrix($c_above.AL, $O[cr], $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_middle, $c_below.AR)
E_RR = TransferMatrix($c_above.AR, $O[cr], $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 @@ -58,7 +57,7 @@ function MPSKit.mixed_fixpoints(
for loc in 2:numcols
lefties[cr, loc] =
lefties[cr, loc - 1] *
TransferMatrix(c_above.AL[loc - 1], O_middle[loc - 1], c_below.AL[loc - 1])
TransferMatrix(c_above.AL[loc - 1], O[cr, 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 @@ -68,9 +67,8 @@ function MPSKit.mixed_fixpoints(

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

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

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

(L0, R0) = init[cr]

@sync begin
Threads.@spawn begin
E_LL = TransferMatrix($c_above.AL, $O_middle, $c_below.AL)
E_LL = TransferMatrix($c_above.AL, $O[cr], $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_middle, $c_below.AR)
E_RR = TransferMatrix($c_above.AR, $O[cr], $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 @@ -60,7 +59,7 @@ function MPSKit.mixed_fixpoints(
for loc in 2:numcols
lefties[cr, loc] =
lefties[cr, loc - 1] *
TransferMatrix(c_above.AL[loc - 1], O_middle[loc - 1], c_below.AL[loc - 1])
TransferMatrix(c_above.AL[loc - 1], O[cr, 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 @@ -70,7 +69,7 @@ function MPSKit.mixed_fixpoints(

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

renormfact = dot(
Expand All @@ -95,12 +94,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 - 1, 0),
left_virtualspace(above, cr, 0),
)
R0::T = TensorMap(
rand,
scalartype(T),
right_virtualspace(above, cr - 1, 0) *
right_virtualspace(above, cr, 0) *
space(O[cr].top[1], 3)' *
space(O[cr].bot[1], 3),
right_virtualspace(below, cr + 1, 0),
Expand Down

0 comments on commit a643644

Please sign in to comment.