Skip to content

Commit 3bddc13

Browse files
committed
clean up changebonds with Multiline
1 parent fbda480 commit 3bddc13

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/algorithms/changebonds/changebonds.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ See also: [`SvdCut`](@ref), [`RandExpand`](@ref), [`VUMPSSvdCut`](@ref), [`Optim
99
function changebonds end
1010
function changebonds! end
1111

12+
# write in terms of MultilineMPS
13+
function changebonds::InfiniteMPS, operator::InfiniteMPO, alg,
14+
envs=environments(ψ, operator))
15+
ψ′, envs′ = changebonds(convert(MultilineMPS, ψ), convert(MultilineMPO, operator), alg,
16+
Multiline([envs]))
17+
return convert(InfiniteMPS, ψ′), envs
18+
end
19+
1220
_expand(ψ, AL′, AR′) = _expand!(copy(ψ), AL′, AR′)
1321
function _expand!::InfiniteMPS, AL′::PeriodicVector, AR′::PeriodicVector)
1422
for i in 1:length(ψ)

src/algorithms/changebonds/optimalexpand.jl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ original ψ.
1313
trscheme::TruncationScheme = truncdim(1)
1414
end
1515

16-
function changebonds::InfiniteMPS, H, alg::OptimalExpand, envs=environments(ψ, H))
16+
function changebonds::InfiniteMPS, H::InfiniteMPOHamiltonian, alg::OptimalExpand,
17+
envs=environments(ψ, H))
1718
T = eltype.AL)
1819
AL′ = similar.AL)
1920
AR′ = similar.AR, tensormaptype(spacetype(T), 1, numind(T) - 1, storagetype(T)))
@@ -36,12 +37,6 @@ function changebonds(ψ::InfiniteMPS, H, alg::OptimalExpand, envs=environments(
3637
return newψ, envs
3738
end
3839

39-
function changebonds::InfiniteMPS, H::DenseMPO, alg::OptimalExpand,
40-
envs=environments(ψ, H))
41-
(nmψ, envs) = changebonds(convert(MultilineMPS, ψ), convert(MultilineMPO, H), alg, envs)
42-
return (convert(InfiniteMPS, nmψ), envs)
43-
end
44-
4540
function changebonds::MultilineMPS, H, alg::OptimalExpand, envs=environments(ψ, H))
4641
TL = eltype.AL)
4742
AL′ = PeriodicMatrix{TL}(undef, size.AL))

src/algorithms/changebonds/vumpssvd.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ function changebonds_1(state::InfiniteMPS, H, alg::VUMPSSvdCut,
2626

2727
nstate, nenvs = changebonds(nstate, nH, alg)
2828

29-
D1 = space(nstate.AL[1], 1)
30-
D2 = space(nstate.AL[2], 1)
29+
D1 = left_virtualspace(nstate, 1)
30+
D2 = left_virtualspace(nstate, 2)
3131

3232
# collapse back to 1 site
3333
if D2 != D1
@@ -36,6 +36,7 @@ function changebonds_1(state::InfiniteMPS, H, alg::VUMPSSvdCut,
3636
end
3737

3838
collapsed = InfiniteMPS([nstate.AL[1]], nstate.C[1]; tol=alg.tol_gauge)
39+
recalculate!(envs, collapsed, H, collapsed)
3940

4041
return collapsed, envs
4142
end
@@ -72,8 +73,8 @@ function changebonds_n(state::InfiniteMPS, H, alg::VUMPSSvdCut, envs=environment
7273
copied[loc] = AL1
7374
copied[loc + 1] = AL2
7475
state = InfiniteMPS(copied; tol=alg.tol_gauge)
76+
recalculate!(envs, state, H, state)
7577
end
76-
7778
return state, envs
7879
end
7980

0 commit comments

Comments
 (0)