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";

conserve*qns=false,
conserve*Q1=conserve

*qns,*

conservenfparity=conserve

conserve

*qns,*

qnnamenf="Q1",

qnname

qnname

*nfparity="NfParity",*

)

if conservenfparity && conserve

)

if conserve

*Q1*

return [

QN((qnnamenfparity, 0, -2), (qnname

return [

QN((qnname

*Q1, 0)) => 1,*

QN((qnnamenfparity, 1, -2), (qnname

QN((qnname

*Q1, +3)) => 1,*

QN((qnnamenfparity, 1, -2), (qnname

QN((qnname

*Q1, +4)) => 1,*

QN((qnnamenfparity, 0, -2), (qnname_Q1, +7)) => 1

QN((qnname

]

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

has*fermion*string(::OpName"C3", ::SiteType"MyFermion") = true

has*fermion*string(::OpName"C3d", ::SiteType"MyFermion") = true

has*fermion*string(::OpName"C4", ::SiteType"MyFermion") = true

has*fermion*string(::OpName"C4d", ::SiteType"MyFermion") = true