0 votes
asked by (130 points)
edited by

Hi everyone,

I am trying to get the MPO representation of H^2 from the one of H using the
nmultMPO function but I am unable to get the correct result. (Notice H is long ranged Hamiltonian) Below is the piece of code I am using:

auto sites = SpinHalf(N,{"ConserveQNs=",false}); //make a chain of N spin 1/2's
auto ampo = AutoMPO(sites);

 for(auto i : range1(N-1))
        for(auto j=i+1;j<=N;j++)
            ampo += (i+j),"S+",i,"S-",j;
            ampo += (i+j),"S-",i,"S+",j;
auto H = toMPO(ampo); 
auto res= nmultMPO(H, H,{"Cutoff",1e-8}); 

I get the following error:
libc++abi.dylib: terminating with uncaught exception of type itensor::ITError: doTask not defined for task Mult and storage type Combiner

Your help will be greatly appreciated.


commented by (1.2k points)
How about writing down the form of H^2 and constructing it directly using AutoMPO?
commented by (130 points)
Thank you for your comment hermit0308.
Well, I would prefer not as I want to then compute successive power of H.

1 Answer

+2 votes
answered by (14.1k points)

Hi Yas,

The new version of nmultMPO in V3 works a little bit differently from the one from V2. Now, the input is a little bit more "literal", in that it finds the indices common to the two input MPOs, contracts over those, and returns an MPO with the indices that are not common between the two MPOs.

In short, you should call the function like this:

auto res = nmultMPO(H, prime(H),{"Cutoff",1e-8});

to get the same thing as ITensor V2.

The problem was that the function wasn't working since it was automatically contracting over all of the site indices of the input MPO. However, this should have a better error message, I will add a check for that.

To explain why the behavior changed, the reason is that there are many MPOs you could make (such as in more general tensor networks) that don't have pairs of indices (s1,s1',s2,s2',...), and that wasn't allowed in the previous version. The new behavior makes the code a bit more general (and I personally feel is a bit more intuitive, since now contracting MPOs works more like contracting ITensors).


commented by (130 points)
Hi Matt,

Many thanks for your answer: it is now working.

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.