Hi,
I was trying to define a new SiteType "MyFermion", following the documentation for "Electron". Basically, I have two flavors of fermions f3 and f4, carrying charges 3 and 4 respectively. But somehow I got the "String is too long" error. So what string is this referring to? Below is my code for your reference. I try to conserve total charge and fermion parity.
Thanks a lot,
Mason
using ITensors
ITensors.space(::SiteType"MyFermion") = 4
function space(
::SiteType"MyFermion";
conserveqns=false,
conserveQ1=conserveqns,
conservenfparity=conserveqns,
qnnamenf="Q1",
qnnamenfparity="NfParity",
)
if conservenfparity && conserveQ1
return [
QN((qnnamenfparity, 0, -2), (qnnameQ1, 0)) => 1,
QN((qnnamenfparity, 1, -2), (qnnameQ1, +3)) => 1,
QN((qnnamenfparity, 1, -2), (qnnameQ1, +4)) => 1,
QN((qnnamenfparity, 0, -2), (qnname_Q1, +7)) => 1
]
end
return 4
end
val(::ValName"Emp", ::SiteType"MyFermion") = 1
val(::ValName"f3", ::SiteType"MyFermion") = 2
val(::ValName"f4", ::SiteType"MyFermion") = 3
val(::ValName"f3f4", ::SiteType"MyFermion") = 4
state(::StateName"Emp", ::SiteType"MyFermion") = [1.0, 0, 0, 0]
state(::StateName"f3", ::SiteType"MyFermion") = [0.0, 1, 0, 0]
state(::StateName"f4", ::SiteType"MyFermion") = [0.0, 0, 1, 0]
state(::StateName"f3f4", ::SiteType"MyFermion") = [0.0, 0, 0, 1]
function op!(Op::ITensor, ::OpName"C3", ::SiteType"MyFermion", s::Index)
Op[s' => 1, s => 2] = 1.0
return Op[s' => 3, s => 4] = 1.0
end
function op!(Op::ITensor, ::OpName"C3d", ::SiteType"MyFermion", s::Index)
Op[s' => 2, s => 1] = 1.0
return Op[s' => 4, s => 3] = 1.0
end
function op!(Op::ITensor, ::OpName"C4", ::SiteType"MyFermion", s::Index)
Op[s' => 1, s => 3] = 1.0
return Op[s' => 2, s => 4] = 1.0
end
function op!(Op::ITensor, ::OpName"C4d", ::SiteType"MyFermion", s::Index)
Op[s' => 3, s => 1] = 1.0
return Op[s' => 4, s => 2] = 1.0
end
function op!(Op::ITensor, ::OpName"N3", ::SiteType"MyFermion", s::Index)
Op[s' => 2, s => 2] = 1.0
return Op[s' => 4, s => 4] = 1.0
end
function op!(Op::ITensor, ::OpName"N4", ::SiteType"MyFermion", s::Index)
Op[s' => 3, s => 3] = 1.0
return Op[s' => 4, s => 4] = 1.0
end
hasfermionstring(::OpName"C3", ::SiteType"MyFermion") = true
hasfermionstring(::OpName"C3d", ::SiteType"MyFermion") = true
hasfermionstring(::OpName"C4", ::SiteType"MyFermion") = true
hasfermionstring(::OpName"C4d", ::SiteType"MyFermion") = true