# Using AutoMPO with toExpH

We have recently tried to do time evolution in the Bose Hubbard model as detailed in http://itensor.org/support/322/time-evolution-in-bose-hubbard?show=322#q322.

We wanted to do time evolution on a five particle superfluid ground state with a Mott Hamiltonian and see the revival of the condensate fraction.
However, we encountered an issue performing time evolution with toExpH.
At first we tried,

auto ampo2ops = AutoMPO(sites);
for (int i = 1; i <= N; ++i) {
ampo2ops += U/2.0,"N",i,"N-1", i;
}

auto expH = toExpH<IQTensor>(ampo2ops,tau*Cplx_i);


And defined the operators "N" and "N-1" accordingly. This did not work. The code runs, but we reach the Mott ground state and get stuck there. On the other hand,

for (int i = 1; i <= N; ++i) {
ampo1op += U/2.0,"N(N-1)",i;
}

auto expH = toExpH<IQTensor>(ampo1op,tau*Cplx_i);


with "N(N-1)" as just one single operator, works just fine. In addition,

for (int i = 1; i <= N; ++i) {
ampo2opagain += U/2.0,"N",i"N",i;
ampo2opagain += -U/2.0, "N",i;
}

auto expH = toExpH<IQTensor>(ampo2opagain,tau*Cplx_i);


didn't work either.

This leads us to believe that toExpH doesn't work for two-operator autompos. Is this a bug? Do you have any workaround for this?

answered by (28.2k points)

Hi, thanks for pointing out this issue. Without diving into the code examples myself yet, my best guess is that yes this is a bug. The toExpH function probably assumes implicitly that if one gives input:
ampo += "Op1",j1,"Op2",j2;
that j1 is not equal to j2.

But this should be simple to fix. In the newer AutoMPO back-end (the one just for making Hamiltonians, not exponentiating) we explicitly check for the case of products of operators acting on the same site and multiply them together before doing the logic to make the MPO.

I wouldn't say that toExpH doesn't work for two operator MPOs, since I have used it often for exactly that case. I think the issue here is that you just can't currently let the two operators act on the exact same site (although you should be able to once I fix it!). So two operators acting on different sites should work just fine.

For now please continue to just define a single-site operator such as "N(N-1)" if that's working correctly for you as a workaround, and I'll work on fixing this bug. Thanks!

commented ago by (110 points)
Hello Miles,

I was wondering whether this issue has been fixed?
I am trying to debug my time evolution code because the results
I am getting are nonsensical and I came upon this thread.  I also defined some terms in the Hamiltonian as two operators acting on a single site and was wondering if this is the cause of my problem.