Hi Matt,
Thanks and this works! Now I try to build on this and make an MPO for a sum of two CdagupCdagdn terms:
using ITensors
function single_site_op(sites, which_op, j)
left_ops = "Id"
right_ops = "Id"
if has_fermion_string(which_op, sites[j])
left_ops = "F"
end
ops = [n < j ? left_ops : (n > j ? right_ops : which_op) for n in 1:length(sites)]
return [op(ops[n], sites[n]) for n in 1:length(sites)]
end
s = siteinds("Electron", 4; conserve_qns=true)
Cdagup1 = single_site_op(s, "Cdagup", 1)
Cdagdn2 = single_site_op(s, "Cdagdn", 2)
Cdagup3 = single_site_op(s, "Cdagup", 3)
Cdagdn4 = single_site_op(s, "Cdagdn", 4)
Cdagpt1 = MPO([apply(o1, o2) for (o1, o2) in zip(Cdagup1, Cdagdn2)])
Cdagpt2 = MPO([apply(o1, o2) for (o1, o2) in zip(Cdagup3, Cdagdn4)])
Cdag=Cdagpt1+Cdagpt2
The two individual MPOs were created successfully. However on the last line it reports:
In `svd`, the left or right indices are empty (the indices of `A` are (((dim=16|id=880|"Electron,Site,n=1") <Out>
1: QN(("Nf",-2,-1),("Sz",0)) => 1
2: QN(("Nf",-1,-1),("Sz",-1)) => 2
3: QN(("Nf",-1,-1),("Sz",1)) => 2
4: QN(("Nf",0,-1),("Sz",-2)) => 1
5: QN(("Nf",0,-1),("Sz",0)) => 4
6: QN(("Nf",0,-1),("Sz",2)) => 1
7: QN(("Nf",1,-1),("Sz",-1)) => 2
8: QN(("Nf",1,-1),("Sz",1)) => 2
9: QN(("Nf",2,-1),("Sz",0)) => 1,)), but the input indices are (Index{Vector{Pair{QN, Int64}}}[(dim=16|id=880|"Electron,Site,n=1") <Out>
1: QN(("Nf",-2,-1),("Sz",0)) => 1
2: QN(("Nf",-1,-1),("Sz",-1)) => 2
3: QN(("Nf",-1,-1),("Sz",1)) => 2
4: QN(("Nf",0,-1),("Sz",-2)) => 1
5: QN(("Nf",0,-1),("Sz",0)) => 4
6: QN(("Nf",0,-1),("Sz",2)) => 1
7: QN(("Nf",1,-1),("Sz",-1)) => 2
8: QN(("Nf",1,-1),("Sz",1)) => 2
9: QN(("Nf",2,-1),("Sz",0)) => 1])). For now, this is not supported. You may have accidentally input the wrong indices.
If I change conserve_qn to false then the addition of MPO works. Am I doing this correctly?
Best,
Shengtao