# AutoMPO Syntax: Concatenate local terms

Hi everyone and happy new year,

It's just a syntax question but the answer would be very useful for me, in order to simplify my code.

I simulate a model with plaquette-like interactions on a Ladder with terms of
of the type sigma{i,x} \prod{j neighbors of i } Proj_{j,up}.
This means that I have to construct autoMPO terms with variable number of involved operators (due to boundaries)

Is there a way to construct each term of the Hamiltonian via concatenation?

### Pseudo-code:

for (site 1)
term = coeff; //Real number
term = concatenate(term,op1,site1);
if (condition site 2 met)
term = concatenate(term,op2,site2);
if (condition site 3 met)
term = concatenate(term,op3,site3);
ampo += term;


Benoit

commented by (32.2k points)
Hi Benoit, I’d be happy to answer your question, but I’m having a little trouble understanding. What do you mean by concatenate exactly? What sort of conditions are you thinking of to go into your if statements? Could you not just write out the explicit form of each type of term you want to add, then use the if -else statement to select which one is to be added? Or restrict your for loop to go over the correct sites for each type of term?

If you could give a more concrete example or specify the Hamiltonian it would be helpful. Thanks.
commented by (590 points)
Hi Miles, if I may chime in - a feature I'd have like to see was a string operator ~ \prod_i O_i where for instance the number of sites it runs over is not known til runtime. And the local operators are generally diagonal ones so this would be straightforward to form I would think.

Alternatively, I was studying a Hamiltonian that had order parameters which were 4+ body terms which come from basically a (c_up +/- c_dn) basis rotation, and would be easy to read/program in a loop but instead needs to be generated explicitly by python script first.
commented by (32.2k points)
Hi, thanks for the suggestions. So you are asking for other ways to give inputs to AutoMPO that are more flexible at runtime? Yes that's definitely something we could do, no problem.

Since we have a lot of things on our plate right now, we're probably not going to remember to add this. So it would be great if you could either file a feature request with the bug tracker system (or even better see about adding this feature yourself and sending us a pull request) so that we'll have a "ticket" we will remember to look at to eventually add this. Thanks!
commented by (170 points)

Hi - was this ever resolved? I have come across a similar issue and would love a function like what rlevy mentioned.