From 0c44f67c99f49270e1df6acd7d5557c247f312d1 Mon Sep 17 00:00:00 2001 From: Lukas <37111893+lkdvos@users.noreply.github.com> Date: Mon, 12 Aug 2024 18:50:06 +0200 Subject: [PATCH] Fix issue where SVDCut produces InfiniteMPS that is not full rank (#174) * Avoid using constructor that expects full-rank matrix in SVDCut algorithm * Add warning in InfiniteMPS constructor --- src/algorithms/changebonds/svdcut.jl | 11 ++++++++++- src/states/infinitemps.jl | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/algorithms/changebonds/svdcut.jl b/src/algorithms/changebonds/svdcut.jl index 95ddff4c5..9ab311c96 100644 --- a/src/algorithms/changebonds/svdcut.jl +++ b/src/algorithms/changebonds/svdcut.jl @@ -83,7 +83,16 @@ function changebonds(ψ::InfiniteMPS, alg::SvdCut) copied[i + 1] = _transpose_front(U' * _transpose_tail(copied[i + 1])) end - return normalize!(InfiniteMPS(copied, complex(ncr))) + # make sure everything is full rank: + makefullrank!(copied) + + # if the bond dimension is not changed, we can keep the same center, otherwise recompute + ψ = if space(ncr, 1) != space(copied[1], 1) + InfiniteMPS(copied) + else + InfiniteMPS(copied, complex(ncr)) + end + return normalize!(ψ) end function changebonds(ψ, H, alg::SvdCut, envs=environments(ψ, H)) diff --git a/src/states/infinitemps.jl b/src/states/infinitemps.jl index 93fbd5a24..d1f5d7276 100644 --- a/src/states/infinitemps.jl +++ b/src/states/infinitemps.jl @@ -176,6 +176,9 @@ end function InfiniteMPS(AL::AbstractVector{<:GenericMPSTensor}, C₀::MPSBondTensor; kwargs...) AL = PeriodicArray(copy.(AL)) + all(isfullrank, AL) || + @warn "Constructing an MPS from tensors that are not full rank" + # initialize tensor storage AC = similar.(AL) AR = similar.(AL)