Page 1 of 1

Question about poorly conditioned H matrix in KrylovBased

Posted: 27 May 2023, 14:42
by Pr0cess
Hi! I want to use GMRG to calculate the entanglement entropy of the ground state of a 2D Hamiltonian. However, when the tenpy calculates the ground state, the error message came out as "poorly conditioned H matrix in KrylovBased! |psi_0| = 0.337508".

I don't know why...Maybe it depends on the initial state (2D Neel state)?

The second question is what is the difference between psi.entanglement_entropy and psi.entanglement_entropy_segment if I set the segment as the half chain? Dose these two cost the same memory?

Looking forward to your reply.

Re: Question about poorly conditioned H matrix in KrylovBased

Posted: 31 May 2023, 09:20
by Johannes
The "poorly conditioned H" is not an error message, it's a warning - telling you that there might be something wrong in your setup. The poorly conditioned H is often a hint for 1) your Hamiltonian not being hermitian or 2) the initial state/ some intermediate state being such that H |psi> gives 0.
So it's a good reason to 1) double-check that your model is implemented correctly and H is actually hermitian, and 2) that you have chosen a suitable initial state and enabled the mixer, if needed.

As for the entanglement_entropy: check the documentation / source code. entanglement_entropy always divides into left/right, and hence just needs to check the schmidt values, at virtually no extra computational cost.
In contrast, entanglement_entropy_segment uses get_rho_segment, which has exponentially many \(d^{2N}\) entries with the number of sites N in the segment.
Lastly, entanglement_entropy_segment2 is an alternative that works for small enough bond dimension, if you cut out a long, continuous segment.

Re: Question about poorly conditioned H matrix in KrylovBased

Posted: 09 Jun 2023, 14:13
by Pr0cess
Thanks a lot for your reply! My model contains long-range interaction, such as the four corners of a square lattice. If this is the reason, I wonder how to avoid this warning message.

I use the CouplingModel and set the site and lattice as shown below:

site = SpinHalfSite(conserve,sort_charge=True)
N=Lx*Ly
bc_x='periodic'
bc_y='periodic'
lat = Square(Lx,Ly, site, bc=[bc_x, bc_y], bc_MPS='infinite',order='Cstyle')

Re: Question about poorly conditioned H matrix in KrylovBased

Posted: 12 Jun 2023, 10:26
by Pr0cess
Another question is about topological EE. I calculated the topological entanglement entropy of the toric code model following Preskill's method (PRL 96, 110404 (2006)). And the Stopo is always 0(the true value is log(2)).

Code: Select all

a=[9]
b=[13]
c=[14,17]

ab=np.hstack((a,b))
bc=np.hstack((b,c))
ac=np.hstack((a,c))
abc=np.hstack((a,b,c))
Sa=psi.entanglement_entropy_segment(segment=a, first_site=[0], n=1)
Sb=psi.entanglement_entropy_segment(segment=b, first_site=[0], n=1)
Sc=psi.entanglement_entropy_segment(segment=c, first_site=[0], n=1)
Sab=psi.entanglement_entropy_segment(segment=ab, first_site=[0], n=1)
Sac=psi.entanglement_entropy_segment(segment=ac, first_site=[0], n=1)
Sbc=psi.entanglement_entropy_segment(segment=bc, first_site=[0], n=1)
Sabc=psi.entanglement_entropy_segment(segment=abc, first_site=[0], n=1)
print(Sa,Sb,Sc,Sab,Sac,Sbc,Sabc)
I=Sa+Sb+Sc-Sab-Sac-Sbc+Sabc
the system size is 4*4. I don't know what is going wrong.

Re: Question about poorly conditioned H matrix in KrylovBased

Posted: 16 Jun 2023, 08:16
by Johannes
For you model: double-check that your hamiltonian is indeed hermitian assert model.H_MPO.is_equal(model.H_MPO.dagger()) - if you mess up adding the couplings, it might not be.

To fully avoid the warning, you might need to start from a different initial state. In particular, I'd assume you start from a product state. Try to perturb the initial state.

Are your individual entanglement entropies larger than 0 / do you have more than a pure product state?

For the topological entanglement entropy: you use the entanglement_entropy_segment, but include only n=1 site into the segment region. The paper you references assumes that the regions A, B, C are much larger than the correlation length, otherwise all the arguments do not go through.

The usual way to calculate gamma is by scaling the Ly around the cylinder and just considering the bipartite S cutting the cylinder into left and right infinite halfes. In other words, run DMRG for different Ly, and fit the Eq (1) of that paper,
\(S = \alpha L - \gamma + O(1/L)\) for just the entanglement_entropy at bond 0.

Re: Question about poorly conditioned H matrix in KrylovBased

Posted: 16 Jun 2023, 16:55
by Pr0cess
Thanks for your reply!
I used add_multicouplings and add "plus_hc=True" to each term and used "M.H_MPO.is_equal(M.H_MPO.dagger())" to check. My model is hermitian.
Maybe the dmrg_params is too strict? I set the parameters as below:
dmrg_params = {
'mixer': True,
'trunc_params': {'chi_max': chi,
'svd_min': 1.e-10},
'max_E_err': 1.e-10,
'max_S_err': 1.e-10

}

For the topological EE, does "n=1" mean von Neumann entropy? I tried to use regions A, B, and C as shown in arXiv:2104.01180v1. I didn't use a dual square lattice and added multi couplings in a square lattice, the topological EE is correct. I don't know which is correct...

Re: Question about poorly conditioned H matrix in KrylovBased

Posted: 20 Jun 2023, 09:09
by Johannes
1) What model are you actually using? The site you define has Sz conservation, which you can't use in the Toric code.
2) What intitial state are you using? Is H psi = 0 on that initial state?
3) What's the log output during the DMRG run?
4) Again, are your individual entanglement entropies larger than 0? What's the final psi.chi, do you have more than a product state?

Also, take a look at the example notebook to the toric code, which actually calculates the Topological entanglement entropy (by scaling Ly, as I suggested above)!

And again, you defined the regions A, B, C with a single site only. This works for the toric code (considerd in this paper), which has a correlation length of almost zero (quoting from the notebook: Correlation lengths: [0.02917 0.02959 0.0292 0.02962]), but doesn't work for other states/models! As soon as you tune away, you need larger regions to get the correct value of the TE.