+1 vote
asked by (250 points)

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?


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;


commented by (29.7k 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 (29.7k 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!

Please log in or register to answer this question.

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.