Skip to content

Commit

Permalink
Fix space error when CTMRG spaces are changing
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Mar 13, 2024
1 parent 3bca3ec commit b521854
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/algorithms/ctmrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,21 @@ function MPSKit.leading_boundary(state, alg::CTMRG, envinit=CTMRGEnv(state))
normnew = norm(state, env)
Δnorm = abs(normold - normnew) / abs(normold)
CSnew = map(c -> tsvd(c; alg=TensorKit.SVD())[2], env.corners)
ΔCS = maximum(norm.(CSnew - CSold))
ΔCS = maximum(zip(CSold, CSnew)) do (c_old, c_new)
# only compute the difference on the smallest part of the spaces
smallest = infimum(MPSKit._firstspace(c_old), MPSKit._firstspace(c_new))
e_old = isometry(MPSKit._firstspace(c_old), smallest)
e_new = isometry(MPSKit._firstspace(c_new), smallest)
return norm(e_new' * c_new * e_new - e_old' * c_old * e_old)
end
TSnew = map(t -> tsvd(t; alg=TensorKit.SVD())[2], env.edges)
ΔTS = maximum(norm.(TSnew - TSold))

ΔTS = maximum(zip(TSold, TSnew)) do (t_old, t_new)
MPSKit._firstspace(t_old) == MPSKit._firstspace(t_new) ||
return scalartype(t_old)(Inf)
# TODO: implement when spaces aren't the same
return norm(t_new - t_old)
end
(max(Δnorm, ΔCS, ΔTS) < alg.tol && i > alg.miniter) && break # Converge if maximal Δ falls below tolerance

# Print verbose info
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ end

mps = initializeMPS(tpeps, 4)

env = leading_boundary(peps, CTMRG(; tol=1e-10))
env = leading_boundary(peps, CTMRG(; tol=1e-10, trscheme=truncdim(20)))
end

0 comments on commit b521854

Please sign in to comment.