+1 vote
asked by (220 points)
edited by

Working with the Hubbard class, I'm trying to compute the double occupancy
d=\sum{i=1}^{L} \langle n{i \uparrow} n_{i \downarrow} \rangle .
Browsing through the documentation, I found two possible syntaxes for defining the corresponding operator at site i, namely:

ITensor dop1 = sites.op("Nupdn",i);
ITensor dop2 = sites.op("Nup*Ndn",i);

and both give the correct result.
However, after reading the documentation page about local measurements (http://itensor.org/docs.cgi?page=formulas/measure_mps) it is very tempting to try to define the double occupancy operator as:

ITensor dop3 = sites.op("Nup",i)*sites.op("Ndn",i); 

This syntax, however, raises a "Mismatched IQIndex arrows" error.
Any thoughts about this?

1 Answer

0 votes
answered by (70.1k points)
selected by
Best answer

Hi, that's good about the first approaches giving you what you needed to measure.

About the last line of code, if you draw the tensor diagrams (do Print(sites.op(...,i)); to see a printout of the indices), paying close attention to the arrows and prime levels you'll see what the * operation is trying to do, and why it fails. The rule about arrows is that contracted IQIndices must have opposite arrow directions.

To correctly multiply two operator-like tensors, you can use the multSiteOps function. It's actually just a little 3 line function you would probably have no trouble implementing yourself (basically just raise the prime level of the second op by 1 then to mapprime(result, 2,1) at the end).


commented by (220 points)
Got it. Thanks for the answer, Miles.
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.