0 votes
asked by (220 points)
closed by

Hi folks,
I am trying to copy the first 1...L÷2 matrices of an MPS to the last L÷2+1...L matrices (in order to get the symmetric copy of the MPS). the layout is as following:

A - B - C - U λ - V - D - E - F 
|   |   |    |    |   |   |   |     

 => A - B - C - U λ - U - C - B - A
    |   |   |    |    |   |   |   |

The problem I am having right now is that I am not able to link Uλ with U. However, since λ is diagonal, this should be possible in principle. In particular, this works without quantum numbers, but with quantum numbers somehow the order of the blocks is reversed. Do you have an idea how I could go on in that situation? Here some code:

L      = 8
maxdim = 20
sites  = siteinds("S=1/2",L,conserve_szparity=true)
ψ      = randomMPS(sites,[rand(Bool) ? "↑" : "↓" for i in 1:L]);
U, λ, V = svd(ψ[L÷2]*ψ[L÷2+1], uniqueinds(ψ[L÷2],ψ[L÷2+1]))
ψ_new   = copy(ψ)
s_ind1  = siteindex(ψ,L)
s_ind2  = siteindex(ψ,1)
bondL   = commonind(ψ[1],ψ[2])
ψ_new[L] = prime(replaceind(ψ[1],s_ind2,s_ind1),bondL)
for i in 2:L÷2-1
    s_ind1 = siteindex(ψ,L-i+1)
    s_ind2 = siteindex(ψ,i)
    bondL  = commonind(ψ[i],ψ[i+1])
    bondR  = commonind(ψ[i],ψ[i-1])
    ψ_new[L-i+1] = replaceind(ψ[i],s_ind2,s_ind1)
ψ_new[L÷2]   = U*λ
linku = commonind(U,λ)
linkv = commonind(V,λ)
bondL = commonind(ψ[L÷2],ψ[L÷2-1])
s_ind1 = siteindex(ψ,L÷2+1)
s_ind2 = siteindex(ψ,L÷2)
ψ_new[L÷2+1] = replaceind(U,s_ind2,s_ind1)

The error I get in the last line here is

Indices must have the same spaces to be replaced

If we look at linku and linkv, it becomes apparent that they do not coincide (in dimensionality and quantum numbers), even though λ is diagonal. This is something I do not quite understand, does this diagonality somehow change when using quantum numbers?



closed with the note: solved
commented by (14.1k points)

It looks like you've already fixed your problem. To answer the question about the singular value matrix output by ITensors.jl, as you noticed it is diagonal but the indices don't necessarily have the same space if QNs are conserved. This is because the singular value matrix doesn't always have a QN flux of zero, so in general the indices won't have the same QNs. They can be made to have the same QN if the tensor you are SVDing has a QN flux of 0, but that is not guaranteed.

I was going to recommend using a decomposition like the polar decomposition, which would make a non-diagonal center-site matrix that has indices with the same space. Out of curiosity, and in case someone else has a similar issue, what did you do to solve your problem?

commented by (220 points)
Hi Matt, I solved it now as following

    function symmetrize(ψ::MPS)
        L = length(ψ)
        @assert iseven(L)
        sites = siteinds(ψ)
        U, λ, V = svd(ψ[L÷2]*ψ[L÷2+1], uniqueinds(ψ[L÷2],ψ[L÷2+1]))
        ψ_new   = copy(ψ)
        s_ind1  = siteindex(ψ,L)
        s_ind2  = siteindex(ψ,1)
        bondL   = commonind(ψ[1],ψ[2])
        ψ_new[L] = prime(replaceind(ψ[1],s_ind2,s_ind1),bondL)
        for i in 2:L÷2-1
            s_ind1 = siteindex(ψ,L-i+1)
            s_ind2 = siteindex(ψ,i)
            bondL  = commonind(ψ[i],ψ[i+1])
            bondR  = commonind(ψ[i],ψ[i-1])
            ψ_new[L-i+1] = replaceind(ψ[i],s_ind2,s_ind1)
        ψ_new[L÷2]   = U*λ
        u1 = commonind(ψ_new[L÷2],ψ_new[L÷2-1])
        u2 = commonind(U,λ)
        v1 = commonind(V,λ)
        s_ind2 = siteind(ψ_new, L÷2)
        s_ind1 = siteindex(ψ,L÷2+1)
        @assert itensor(store(tensor(U)),(s_ind2,u1,u2)) ≈ U
        ψ_new[L÷2+1] = itensor(store(conj(tensor(U))),(s_ind1,u1',v1))
        return ψ_new

Following from your answer, this should not always work? However, this worked for some tests.
commented by (14.1k points)
It would take me some time to read through your code to see if it is what I had in mind, but if it works for you, that's all that matters.
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.