Hello there to the community hope all are doing good,
I have done a DMRG calculation of 1d spin 1/2 Heisenberg model and found its ground state as an mps, now I wish to calculate some expectations like Sx, Sy, Sz, S.S . The problem I am facing is I am getting the ket vector and its bra as a 2x2 matrix,
my code reads like this:-
N=2
sites = siteinds(“S=1/2”,N)
psi = psi0; #the ground state called from dmrg
orthogonalize!(psi,j)
psidag_j = dag(prime(psi[j], “Site”))
println(psi[j])
println(psidag_j)
Szjop = op(sites, “Sz” , j)
println(Szjop)
ITensor ord=2
Dim 1: (dim=2|id=575|“S=1/2,Site,n=1”)
Dim 2: (dim=2|id=467|“Link,l=1”)
NDTensors.Dense{Float64, Vector{Float64}}
2×2
-0.029907032140422538 0.40802914179299793
-0.9123808978501717 -0.013374831375957739
ITensor ord=2
Dim 1: (dim=2|id=575|“S=1/2,Site,n=1”)’
Dim 2: (dim=2|id=467|“Link,l=1”)
NDTensors.Dense{Float64, Vector{Float64}}
2×2
-0.029907032140422538 0.40802914179299793
-0.9123808978501717 -0.013374831375957739
ITensor ord=2
Dim 1: (dim=2|id=884|“S=1/2,Site,n=1”)’
Dim 2: (dim=2|id=884|“S=1/2,Site,n=1”)
NDTensors.Dense{Float64, Vector{Float64}}
2×2
0.5 0.0
0.0 -0.5
The problem begins when I print the expectation value of the operator;
Sz_expect = scalar(psidag_j * op(sites, “Sz”, j) * psi[j])
The output shows this error;
DimensionMismatch: In scalar(T) or T, ITensor T is not a scalar (it has indices ((dim=2|id=575|“S=1/2,Site,n=1”)‘, (dim=2|id=884|“S=1/2,Site,n=1”)’, (dim=2|id=884|“S=1/2,Site,n=1”), (dim=2|id=575|“S=1/2,Site,n=1”))).
Please help as I am unable to resolve my problem