0 votes
asked by (700 points)
edited by

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,
conserve
Q1=conserveqns,
conserve
nfparity=conserveqns,
qnname
nf="Q1",
qnnamenfparity="NfParity",
)
if conserve
nfparity && conserveQ1
return [
QN((qnname
nfparity, 0, -2), (qnnameQ1, 0)) => 1,
QN((qnname
nfparity, 1, -2), (qnnameQ1, +3)) => 1,
QN((qnname
nfparity, 1, -2), (qnnameQ1, +4)) => 1,
QN((qnname
nfparity, 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

commented by (700 points)
I don't why the code shown has all the underscores missing, even though they are there in the preview.

1 Answer

+1 vote
answered by (70.1k points)

Hi Mason, thanks for the question. The string that error is referring to is “MyFermion” (9 characters long). Currently we have imposed a maximum length restriction of 8 characters on Index tags for code performance reasons, but we are looking into possibly lifting this restriction.

Best regards,
Miles

Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...