# Getting "Index does not contain given QN block" error

+1 vote

Hi!
I'm using AutoMPO to implement the following hamiltonian. Here is a snippet of my code

int N = 12;

int Nc = N/2;

auto ampo = AutoMPO(sites);

auto Npart = N;

auto t1 = 1;

auto t2 = 0.5;

auto sites = Electron(N);

for(int b = 1; b < N; ++b)
{
ampo += t1,"Cdagup",b+1,"Cup",b;
ampo += -t1,"Cdagdn",b+1,"Cdn",b;
ampo += -t1,"Cdagup",b,"Cup",b+1;
ampo += t1,"Cdagdn",b,"Cdn",b+1;
}

ampo += t2,"Nup",Nc;
ampo += t2,"Ndn",Nc;
ampo += t2,"Cdagup",Nc,"Cdn",Nc;
ampo += t2,"Cdagdn",Nc,"Cup",Nc;

auto H = toMPO(ampo);


When I run my code I get the following error: "Index does not contain given QN block". When I remove the part containing the terms with 't2' the code runs fine. Is this due to some bug in AutoMPO or am I making some mistake when I do this? Is there anyway to get around this problem?

Best Regards
NIkhil

Hi Nikhil,
Thanks for the question. If I'm not mistaken, the terms you are adding at the end of your code do not conserve total Sz of the electrons. However, by default the site indices produced by the Electron site set do conserve Sz. So you'll have to turn off Sz conservation if you want to add those particular terms to your Hamiltonian.

The way to do this is to change the call to Electron to be Electron(N,{"ConserveSz=",false});.

If you do want to conserve Sz, though, then there may just be an error in how you defined those terms.

Finally, I noticed that your t1 hopping terms don't appear to be Hermitian. You can look at the sample/exthubbard.cc sample code included with the ITensor source to see an example of a Hermitian electron hopping term. There are other ways to define it, some of which do involve minus signs, but I think your definition is not Hermitian at a glance.

Happy to discuss more -

Best,
Miles

commented by (210 points)
Hi Miles,
Thanks for the reply. It works now. I realised that I don't need to conserve Sz. Also I had mistakenly set t1 to be 1 in the question but actually the t1 hopping parameter is imaginary, so my Hamiltonian is Hermitian and now my code works fine. Thanks again.

Best Regards,
Nikhil