Segmentation Fault in Calculation of Excited States?

+1 vote
asked Mar 24 by hermit0308 (470 points)

Hi Miles,

I had a error when running the following code to calculate the exited state of a spin-1 chain,

int N = 24;
auto sites = SpinOne(N);
Real J = 0.05;
auto ampo = AutoMPO(sites);
for(int j = 1; j <= N; ++j)
    ampo += 0.5,"Sz2",j;
    ampo += -0.5,"Sz",j;
for(int j = 1; j < N; ++j)
    ampo += -J,"S+",j,"S-",j+1;
    ampo += -J,"S+",j+1,"S-",j;
auto H = IQMPO(ampo);

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;

auto state = InitState(sites);

for(int i = 1; i <= N; i++)
    state.set(i, i <= N/2 ? "+" : "0");

auto psi0 = IQMPS(state);

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

auto wfs = std::vector<IQMPS>(1); = psi0;

auto psi1 = IQMPS(state);

auto en1 = dmrg(psi1,H,wfs,sweeps,{"Quiet=",true,"Weight=",20.0});

It always stops after calculating the ground state, with a message "Segmentation fault: 11". When I run it in debug mode, it says

From line 87, file

div(T1)=QN(24) must equal div(T2)=QN() when adding T1+T2

div(T1)=QN(24) must equal div(T2)=QN() when adding T1+T2
Abort trap: 6

This error looks wired for me because the code works for N <=22. I solved this problem by modifying the initial state

for(int i = 1; i <= N; i++)
    state.set(i, i%2 == 1 ? "+" : "0");

My questions,

  1. Why the former initial state would cause this error?

  2. Why this error appear only for N >= 24?

Many thanks for answering all these questions!


1 Answer

0 votes
answered Mar 24 by miles (12,650 points)

Hi Jin,
For an IQMPS to be used it must be fully initialized. The first InitState you made did not specify a state for all of the sites but only the first N/2 of them. So the result is an IQMPS that is not fully defined.

I agree though that this behavior is somewhat confusing and that there should be a clearer error message that happens earlier. I'll see if I can make that happen.


commented Mar 24 by hermit0308 (470 points)
Hi Miles,

Why isn't my first InitState fully initialized? I think the first one is "1...10...0" (the first N/2 sites are "1" and the other N/2 sites are "0"), and the second one is "1010...10". Right? Thanks.

commented Mar 24 by miles (12,650 points)
Oh my fault I misread your code. I had better try this code myself then to see what is going on. It may be a bug. Thanks for correcting -
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
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.