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?