0 votes
asked by (140 points)

Hi Miles,

I've attempted to calculate the ground-state fidelity
for the transverse Ising model using DMRG. I'm getting
incorrect results. Below is my code (adapted from
excited_dmrg.cc). Can you help me with this?
(Another question: How do you suppress in the code
intermediate outputs?)

Thanks in advance.
Oz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

include "itensor/all.h"

using namespace itensor;

define N 100

define NP 11

define J -1.0

define DL 0.1

double h,h1;
double fid[NP];
double E0[NP],E1[NP];
int main()
{
for(int k = 0; k < NP-1; ++k)
{
h= 0.5 + 0.1*k;
h1= h + DL;

//creates_chain()

  auto sites = SpinHalf(N); //make a chain of N spin 1/2's

// creates_hamiltonian() transvese field - h

  auto ampo = AutoMPO(sites);
  for(int j = 1; j < N; ++j)
  {
     ampo += -4*J,"Sz",j,"Sz",j+1;
  }
  for(int j = 1; j <= N; ++j)
  {
     ampo += -2*h,"Sx",j;
  }
  auto H = MPO(ampo);

//// creates_hamiltonian() transvese field - h1= h + DL

  auto ampo1 = AutoMPO(sites);
  for(int j = 1; j < N; ++j)
  {
     ampo1 += -4*J,"Sz",j,"Sz",j+1;
  }
  for(int j = 1; j <= N; ++j)
  {
    ampo1 += -2*h1,"Sx",j;
  } 
  auto H1 = MPO(ampo1);

// init_wavefunction()

  auto state = InitState(sites);
  for(int i = 1; i <= N; ++i)
  {
     if(i%2 == 1)
        state.set(i,"Up");
    else
        state.set(i,"Dn");
  }
  auto psi = MPS(state);

//setssweepingparameters()

  auto sweeps = Sweeps(30);
  sweeps.maxm() = 10,20,100,100,200;
  sweeps.cutoff() = 1E-10;
  sweeps.niter() = 2;
  sweeps.noise() = 1E-7,1E-8,0.0;

// println(sweeps);

  auto psi0 = MPS(sites);
  auto psi1 = MPS(sites);

//finds_groundstate()

  auto en0 = dmrg(psi0,H,sweeps,{"Quiet=",true});
  auto en1 = dmrg(psi1,H1,sweeps,{"Quiet=",true});

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

  fid[k]= overlap(psi0,psi1);
  E0[k] = en0;
  E1[k] = en1;

}
printfln(" h fidelity");
for(int k = 0; k < NP-1; ++k)
{
h= 0.5 + 0.1*k;
printfln("%.2f %.5E",h,fid[k]);
}
return 0;
}

1 Answer

0 votes
answered by (70.1k points)

Hi, so yes you can calculate the fidelity and the way you are doing it (using overlap between two MPS) is correct.

I'm not sure why you are getting incorrect results. It could be due to many various reasons including an error in constructing your Hamiltonian; insufficient convergence of DMRG; poor selection of initial states; finite size effects; etc.

I'd recommend studying a particular set of Hamiltonian parameters in detail, trying out different numbers of sweeps and looking at the convergence of the MPS by looking closely at the reported truncation error, for example. Then if you are still getting an incorrect fidelity for that particular Hamiltonian you will be in a better position to assess why it's happening.

Please let me know if I can be of more help, like if you suspect there is an issue with one of the ITensor routines.

Best regards,
Miles

commented by (140 points)
Hi Miles,

Thanks, I will do it.

PS: Another question: How do you suppress in the code the intermediate printouts? like:
 vN Entropy at center bond b=500 = 0.295190192552
    Eigs at center bond b=500: 0.9142 0.0855
    Largest m during sweep 1/20 was 10
    Largest truncation error: 2.49966e-08
    Energy after sweep 1/20 is -1262.873018602332
    Sweep 1/20 CPU time = 4.048s (Wall time = 0.756s)
commented by (70.1k points)
Great!

So to suppress the printouts, we should try to make this easier but the technical way is you need to make an "Observer" object which is a class that inherits from Observer and (optionally) implements the measure and checkDone methods. You could just make an empty "do-nothing" class and plug this into the versions of DMRG that take a custom Observer.

Alternatively, you can modify the code in itensor/mps/DMRGObserver.h to turn off the printouts there and recompile your code. The downside of this is that you won't be able to pull new versions of ITensor without stashing or committing your changes to that file.
commented by (140 points)
That is very helpful.

Thanks a lot.
Oz
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...