Hi, I am trying to execute the following code:
using ITensors, ITensorMPS
function main(; Nx=2, Ny=2, U=4.0, t=1.0)
N = Nx * Ny
cutoff = [1E-8]
sites = siteinds("Electron", N; conserve_qns=true)
# Half filling
state = [isodd(n) ? "Up" : "Dn" for n in 1:N]
# Initialize wavefunction to a random MPS
# of bond-dimension 10 with same quantum
# numbers as `state`
psi = random_mps(sites, state)
Sz1 = op("Cup", sites[1])
Sz2 = op("Cdagup", sites[1])
Stot = Sz1 * Sz2
psi = apply(Sz1, psi; cutoff)
psi0 = apply(Sz2, psi; cutoff)
Sz = inner(psi, psi0)
println(Sz)
return nothing
end
main()
But I am getting the following error:
ERROR: LoadError: Attempting to contract IndexSet:
((dim=4|id=868|“Electron,Site,n=1”)’
1: QN((“Nf”,0,-1),(“Sz”,0)) => 1
2: QN((“Nf”,1,-1),(“Sz”,1)) => 1
3: QN((“Nf”,1,-1),(“Sz”,-1)) => 1
4: QN((“Nf”,2,-1),(“Sz”,0)) => 1, (dim=4|id=868|“Electron,Site,n=1”)
1: QN((“Nf”,0,-1),(“Sz”,0)) => 1
2: QN((“Nf”,1,-1),(“Sz”,1)) => 1
3: QN((“Nf”,1,-1),(“Sz”,-1)) => 1
4: QN((“Nf”,2,-1),(“Sz”,0)) => 1)
with IndexSet:
((dim=4|id=868|“Electron,Site,n=1”)’
1: QN((“Nf”,0,-1),(“Sz”,0)) => 1
2: QN((“Nf”,1,-1),(“Sz”,1)) => 1
3: QN((“Nf”,1,-1),(“Sz”,-1)) => 1
4: QN((“Nf”,2,-1),(“Sz”,0)) => 1, (dim=4|id=868|“Electron,Site,n=1”)
1: QN((“Nf”,0,-1),(“Sz”,0)) => 1
2: QN((“Nf”,1,-1),(“Sz”,1)) => 1
3: QN((“Nf”,1,-1),(“Sz”,-1)) => 1
4: QN((“Nf”,2,-1),(“Sz”,0)) => 1)
QN indices must have opposite direction to contract, but indices:
(dim=4|id=868|“Electron,Site,n=1”)’
1: QN((“Nf”,0,-1),(“Sz”,0)) => 1
2: QN((“Nf”,1,-1),(“Sz”,1)) => 1
3: QN((“Nf”,1,-1),(“Sz”,-1)) => 1
4: QN((“Nf”,2,-1),(“Sz”,0)) => 1
and:
(dim=4|id=868|“Electron,Site,n=1”)’
1: QN((“Nf”,0,-1),(“Sz”,0)) => 1
2: QN((“Nf”,1,-1),(“Sz”,1)) => 1
3: QN((“Nf”,1,-1),(“Sz”,-1)) => 1
4: QN((“Nf”,2,-1),(“Sz”,0)) => 1
do not have opposite directions.
On a related note, I am littile bit confused what this and mean?