# How to measure the momentum of an MPS?

edited

Hi,

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
}


Thanks,
WunderNatur