0 votes
asked by (140 points)
edited by


I was trying to measure the momenta of some MPSs in the Electron site class. Here is my attempt:

I got the desired results when I measure the momentum @@P@@ using toMPO. However, when I used the function toExpH to exponentiate the momentum operator and get the usual translation operator @@T@@, I got the following error message:

From line 885, file itensor.cc   

div(T1)=QN({"Nf",0,-1},{"Sz",0}) must equal div(T2)=QN({"Nf",1,-1},{"Sz",-1}) when adding T1+T2

div(T1)=QN({"Nf",0,-1},{"Sz",0}) must equal div(T2)=QN({"Nf",1,-1},{"Sz",-1}) when adding T1+T2
Aborted (core dumped)

I wasn't able to figure out what this message is saying? Also is this the right way to measure the momenta of some MPSs, and is this the best way to exponentiate some MPO? Below is the code for obtaining the MPOs for the operators @@P@@ and @@T@@.

# define PI 3.1415926535897932
MPO Momentum(Electron const& sites)
  auto N = length(sites);

  auto ampo = AutoMPO(sites);

  for(int k = 1; k <= N; ++k)
      for(int i = 1; i <= N; ++i)
          for(int j = 1; j <= N; ++j)
              ampo += 2.0*PI/(N*N)*k*std::exp(Cplx_i*2.0*PI/N*k*(i-j)),"Cdagup",j,"Cup",i;
              ampo += 2.0*PI/(N*N)*k*std::exp(Cplx_i*2.0*PI/N*k*(i-j)),"Cdagdn",j,"Cdn",i;

  auto T = toExpH(ampo,1.0,{"Cutoff=",1E-20});
  auto P = toMPO(ampo,{"Cutoff=",1E-20});

  return T; //or P


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.