# AutoMPO with products of three/four terms operators

Hi all,

I am trying to implement the AKLT Hamiltonian for the Spin-2 case.
Having computed with Mathematica the power (Si * Sj)^3 and (Si * Sj)^4 (that are contained in the Hamiltonian) as a function of the operators S+ and S-, I have terms of the form

ampo += 1.0, "Sz*S+*S+",indices_prime[i],"Sz*S-*S-",indices_prime[i+1];


and

ampo += 1.0, "S+*S-*Sz*Sz",indices_prime[i],"S-*S+*Sz*Sz",indices_prime[i+1];


with products of three or four operators on each site. I compile the code, but when I try to run it, I obtain the following error:

"Operator S- name not recognized".

Actually, the code seems to recognise the operator "S-", because, if I put only two operators for each site (for instance, "S+S-" and "S-S+"), it works. I think the error it is due to the fact that I am using more than two operators in the product on each site.

Thank you very much.

commented by (70.1k points)
Hi, thanks for the question. One question before I try to find the issue: what is the value type for the array or vector "indices_prime"? Are those integers or ITensor Index types? Thanks -
commented by (270 points)
Hi Miles,

thank you for your precious help. In the array "indices_prime" I have normal integers (1,2,3...N).

Best.
commented by (70.1k points)
Hi, so the following case worked for me:

int N = 10;
auto sites = SpinTwo(N);

auto ampo = AutoMPO(sites);
for(int j = 1; j < N; ++j)
{
ampo += "Sz*S+*S+",j,"Sz*S-*S-",j+1;
ampo += "S+*S-*Sz*Sz",j,"S-*S+*Sz*Sz",j+1;
}
auto H = toMPO(ampo);

so then perhaps the issue you are seeing is because of the specific values of indices_prime[i] and indices_prime[i+1] ? Could you print out or test all of these values and make sure they are between 1 and N, inclusive?

Otherwise I think I will need more information or a minimal example code reproducing the bug in order to investigate it.

Thanks,
Miles
commented by (270 points)
Hi Miles,

thank you very much. In the end, I solved the problem: there was a typo in the string of operators. Now it works for any number of operators.

Thank you very much for your precious help.

Best.
commented by (70.1k points)
Great. Thanks for following up! It’s useful to know so we can catch any potential bugs.

Feel free to ask us if you need any more help

Miles