Page 1 of 1

Entanglement Entropy for len(segment)>20

Posted: 28 Oct 2023, 23:50
by phy-jay
Hi,
I am getting an error when I tried to calculate the entropy of a segment whose size is greater than 20 for the TFI model.

Python: Select all

S_Ags=psi.entanglement_entropy_segment(segment=subregion, first_site=[start_site], n=1)
ValueError: too large segment; this is exponentially expensive!

How to over-ride this and calculate the entropy for segment size greater than 20?

Re: Entanglement Entropy for len(segment)>20

Posted: 31 Oct 2023, 14:02
by Johannes
There is a good reason for this, since it's exponentially expensive with the number of sites L in the segment, both in memory \(\mathcal{O}(d^{2L})\) and CPU time \(\mathcal{O}(d^{3L})\)! Each additional site quadruples your computational cost.

If you're reaching that limit, it might be better to use the entanglement_entropy_segment2 method instead, which does the calculation in a slightly different way. Note that this is still very expensive, \(\mathcal{O}(\chi^6 d^{3n_{intern}})\) (compared to usual DMRG/MPS algorithms scaling as \(\mathcal{O}(\chi^3)\), where \(n_{intern}\) is the number of legs between start and end of the segment that are not included.

If you really need to get to larger segments to include just that extra 2 sites, you're of course free to get a local copy of the source code on your machine, modify the corresponding threshold in the source in https://github.com/tenpy/tenpy/blob/a3b ... s.py#L2866 and install TeNPy locally from source.