Dear Jared,
Thank you so much for your answer.
I tried your way carefully but it still replied that "Index does not contain given QN block.". I though it may came from the maximum occupancy because the default maximum occupancy is 1, so I set the maximum occupancy more than two, but it have the same errors...
The terminal told me that QN index only have Nb = +1/-1 while my QN index with this Hamiltonian term have Nb=-2. Maybe I need to change my QN index to fixed it?
My code is as follow
#include "itensor/all.h"
using namespace itensor;
using std::vector;
int main()
{
int L = 8;
auto sites = Boson(L,{"MaxOcc=",4,"ConserveQNs",true});
auto sweeps = Sweeps(5);
sweeps.maxdim() = 40, 80, 400, 400, 800;
sweeps.cutoff() = 1E-16;
Real miu = 1.0;
Real U = 1.0;
Real J = 1.0;
Real V = 1.0;
Real em = 1.0;
auto ampo = AutoMPO(sites);
for (int i = 1; i < L; i += 1)
{
ampo += -miu-U/2, "N", i;
ampo += U/2, "N", i, "N", i;
ampo += -J, "A", i, "Adag", i+1;
ampo += -J, "Adag", i, "A", i+1;
ampo += V, "N", i, "N", i+1;
ampo += -em/2, "ADagsq", i;
ampo += -em/2, "Asq", i;
}
ampo += -J, "A", 1, "Adag", L;
ampo += -J, "Adag", 1, "A", L;
ampo += V, "N", 1, "N", L;
auto H = toMPO(ampo);
auto state = InitState(sites);
for (int i : range1(L))
{
if (i%2 == 1) state.set(i,"2");
else state.set(i,"2");
}
auto psi = randomMPS(state);
auto [energy,psi0] = dmrg(H,psi,sweeps,"Quiet");
printfln("-----Energy = %.2f-----", energy/L);
return 0;
}
And the error report is as follow
I = (dim=5|id=69|"l=1,Link") <Out>
1: 3 QN()
2: 1 QN({"Nb",-1})
3: 1 QN({"Nb",1})
Q = QN({"Nb",-2})
From line 683, file index.cc
Index does not contain given QN block.
Index does not contain given QN block.
Aborted (core dumped)