Hello, I am new to DMRG and ITensor package. Currently I am very interested to calculate the spectral function based on Lanzcos method as described in this article.(https://www.cond-mat.de/events/correl11/manuscript/Koch.pdf) . However, when I run the following program.I found that the summation of H\ket{\psi} and \ket\psi are incompatibal with quantum number conserved. I print out the MPS and found H acting on the state actually doesn’t change the index structure but an error was reported.
int main()
{
int L = 4;
double U = 1.0;
double J = 1.0;
double g = 3.0;
double K = 5.0;
auto sites = SpinHalf(L,{"ConserveQNs=",true});
auto ampo = AutoMPO(sites);
for(int j = 1; j <L; ++j)
{
ampo += 0.5,"S+",j,"S-",j+1;
ampo += 0.5,"S-",j,"S+",j+1;
ampo += "Sz",j,"Sz",j+1;
}
auto H = toMPO(ampo);
auto sweeps = Sweeps(30); //number of sweeps is 5
sweeps.maxdim() = 10,20,100,100,200;
sweeps.cutoff() = 1E-10;
auto state = InitState(sites);
for(auto i : range1(L))
{
if(i%2 == 1) state.set(i,"Up");
else state.set(i,"Dn");
}
itensor::MPS psi0 = MPS(state);
auto [energy,psi] = dmrg(H,psi0,sweeps,{"Quite",true});
itensor::MPS tmp=itensor::applyMPO(H,psi);
std::cout<<"++++++++++++++++++++++++++++++++++++++++++++++++"<<std::endl;
println(tmp);
std::cout<<"++++++++++++++++++++++++++++++++++++++++++++++++"<<std::endl;
println(psi);
std::cout<<"++++++++++++++++++++++++++++++++++++++++++++++++"<<std::endl;
tmp=itensor::sum(tmp,psi);
println(tmp);
std::cout<<"++++++++++++++++++++++++++++++++++++++++++++++++"<<std::endl;
}
And after I turn off the QN conservation, the error was not reported. I can’t find where the mistake is. Please help me . Plus, I an really looking forward to calculate spectrum of some quantum systems, I am grateful if any suggestions can be provided on the possible algoirthm and C++ implementation.