Obtain elements of a tensor represented by an MPS when the quantum number is conserved

Hi, I want to obtain elements of a tensor represented by an MPS when the quantum number is conserved.

using ITensors

sites3=siteinds("S=1/2",3; conserve_qns=true)
state3 = ["Dn" for i in 1:3]
state3[2] = "Up"
state3
psi4 = productMPS(sites3,state3)

for i in 1:2
    for j in 1:2
        for k in 1:2
            el3 = [i,j,k]
            V3 = ITensor(1.)
            for l=1:3
            V3 *= (psi4[l]*state(sites3[l],el3[l]))
            end
            v3 = scalar(V3)
            print(i,j,k)
            # v is the element we wanted to obtain:
            @show v3
        end
    end
end

It works well without conserve_qns=true in siteinds function.

1 Like

This problem have been solved.

Reason of problem:
A pair of QN indices must have opposite arrow directions to be contracted. A physicist might view an Out arrow as denoting a “ket” index and an In arrow as a “bra” index[1].

[1] Matthew Fishman et al. The ITensor Software Library for Tensor Network Calculations. SciPost Physics Codebases. 2021

psi4[l] and state(sites3[l],el3[l]) have the same arrow directions.
Solving of problem:
The function dag() is defined to reverse all of the arrows of tensor’s indices. So the psi4[l]*state(sites3[l],el3[l]) need to be changed to psi4[l]*dag(state(sites3[l],el3[l])).
Then it works well.

2 Likes

Glad you caught it! Thanks for posting your question.