# Exited states of Hubbard model

+1 vote

I am using the sample code provided in ITensor for calculating excited states using DMRG. I am using Hubbard model, but the ConserveQN has been set to "true". I get the following error:

randomMPS(SiteSet) with QN conservation is ambiguous, use randomMPS(InitState) instead.

I have the following code:

#include "itensor/all.h"
#include "itensor/util/print_macro.h"

using namespace itensor;

int main(int argc, char* argv[])
{
//Parse the input file
if(argc != 2) { printfln("Usage: %s inputfile_exthubbard",argv[0]); return 0; }
auto input = InputGroup(argv[1],"input");

auto N = input.getInt("N");
auto Npart = input.getInt("Npart",N); //number of particles, default is N (half filling)

auto nsweeps = input.getInt("nsweeps");
auto t1 = input.getReal("t1",1);
auto t2 = input.getReal("t2",0);
auto U = input.getReal("U",0);
auto V1 = input.getReal("V1",0);
auto quiet = input.getYesNo("quiet",false);

auto table = InputGroup(input,"sweeps");
auto sweeps = Sweeps(nsweeps,table);
println(sweeps);

//
// Initialize the site degrees of freedom.
//
auto sites = Electron(N,{"ConserveQNs=",true});

//
// Create the Hamiltonian using AutoMPO
//
auto ampo = AutoMPO(sites);
for(int i = 1; i <= N; ++i)
{
ampo += U,"Nupdn",i;
}
for(int b = 1; b < N; ++b)
{
ampo += -t1,"Cdagup",b,"Cup",b+1;
ampo += -t1,"Cdagup",b+1,"Cup",b;
ampo += -t1,"Cdagdn",b,"Cdn",b+1;
ampo += -t1,"Cdagdn",b+1,"Cdn",b;
ampo += V1,"Ntot",b,"Ntot",b+1;
}

for(int b = 1; b < N-1; ++b)
{
ampo += -t2,"Cdagup",b,"Cup",b+2;
ampo += -t2,"Cdagup",b+2,"Cup",b;
ampo += -t2,"Cdagdn",b,"Cdn",b+2;
ampo += -t2,"Cdagdn",b+2,"Cdn",b;
}
auto H = toMPO(ampo);
//
// Begin the DMRG calculation
//
auto [en0,psi0] = dmrg(H,randomMPS(sites),sweeps,{"Quiet=",true});

println("\n----------------------\n");

//
// Make a vector of previous wavefunctions;
// code will penalize future wavefunctions
// for having any overlap with these
//
auto wfs = std::vector<MPS>(1);
wfs.at(0) = psi0;
//
// Here the Weight option sets the energy penalty for
// psi1 having any overlap with psi0
//
auto [en1,psi1] = dmrg(H,wfs,randomMPS(sites),sweeps,{"Quiet=",true,"Weight=",20.0});

//
// Print the final energies reported by DMRG
//
printfln("\nGround State Energy = %.10f",en0);
printfln("\nExcited State Energy = %.10f",en1);

return 0;
}


I have gone through the answers to all the previous questions in Itensor Support regarding this issue, and seems like doing "git pull" is solving the issue. In stead of doing that, I installed the latest version of ITensor again, but I get the same error.

Is "git pull" the necessary way to solve this? Or is there something else wrong with the code?

answered by (55.1k points)

Hi, thanks for the question.

So this is not a bug in ITensor, but just a message telling you about incorrect usage of the code for the case you are doing. Therefore a git pull would not fix the problem; rather you need to use the code differently for your case.

The error message is saying that for the case of a quantum number (QN) conserving calculation, such as the one you are doing, it is not enough to initialize an MPS by just giving the site indices. Additionally, you have to provide a specific product state that you want the MPS to be initialized to, which has a well-defined total QN.

Here are some example codes where QN conservation is used, and you will see that the MPS is always initialized with an InitState object passed to the MPS constructor (psi = MPS(state);).

Please let me know if that doens't answer your question or if you have more questions -

Miles

commented by (250 points)
Thank you very much, this works now perfectly!
Apologizing for late reply as there was no email notification this time. I will post if I have some more issues.