entanglement_entropy_segment doubt

How do I use this algorithm? What does that parameter do?
Post Reply
amankumar
Posts: 19
Joined: 17 Apr 2020, 11:14

entanglement_entropy_segment doubt

Post by amankumar »

Hey
I wanted to evaluate entanglement entropy for a subsystem given by sites in segment parameter in entanglement_entropy_segment function. It should give entropy of this subsystem meaning just one numeric number. But in return I am getting array of entropies. I completely don't understand what each element this array constitutes. Please make me clear about this.

Code: Select all

[print("Entanglement Entropy: ", psi.entanglement_entropy_segment(segment=[0,1,2,3,4,5,6,7,8]))]
User avatar
Johannes
Site Admin
Posts: 209
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

Re: entanglement_entropy_segment doubt

Post by Johannes »

Read the documentation at entanglement_entropy_segment.
There is another parameter first_site, where this segment starts.
If you use segment=[0, 1, 2] and don't specify first_site,
it will default to the segments on sites

Code: Select all

[0, 1, 2]
[1, 2, 3]
[2, 3, 4]
...
Each of them gives you one number, resulting in a 1D array returned.

If you want only the entropy of the segment say 10, 11, 14, 15, you should use

Code: Select all

psi.entanglement_entropy_segment(segment=[0, 1, 4, 5], first_site=[10])
Note that this function is exponentially expensive with len(segment)...

If you aim at calculating the entanglement of the "segment" [0, 1, ..., x-2, x-1] for some large x and finite boundary conditions, just use entanglement_entropy at bond x.
amankumar
Posts: 19
Joined: 17 Apr 2020, 11:14

Re: entanglement_entropy_segment doubt

Post by amankumar »

Thank you for your clarification. But I am concerned about one point, that whether these two operations of entanglement entropy gives the same answer or not for a same subsystem. So I did a check for a given example of Toric Code Model.
Here I took Lx=2,Ly=3 and evaluated ent. entropy for same subsystem.
Here is my result for the below code:

Entanglement Entropy_1:

Code: Select all

[3.4657359  3.4657359  4.15888308 4.15888308 4.15888308 4.15888308 3.4657359  3.4657359  4.15888308 4.15888308 4.15888308 4.15888308]
Where the first element is 3.4657359 =5*Log[2]

Entanglement Entropy_2:

Code: Select all

[4.15888308 4.15888308 4.85203026 4.85203026 4.85203026 4.15888308 4.15888308 4.15888308 4.85203026 4.85203026 4.85203026 4.15888308]
Where the first element is 4.15888308 =6*Log[2]

Entanglement Entropy_3:

Code: Select all

[2.07944154]
which is nearly equal to 3Log[2]

For Toric code model Entanglement entropy scales as (L_y-1)Log[2] for a cut on cylinder along y axis.
So I supposed answer should be 2Log[2] for psi.entanglement_entropy(bonds=[6])). But I got 3Log[2].

Another querry: psi.entanglement_entropy_segment(segment=[0,1,2,3,4,5])[0] should equal to psi.entanglement_entropy(bonds=[6])). But I am not getting the same answer (5Log[2] for first and 3Log[2] for second).
Please clarify me regarding this big confusion. If you do not understand my question let me know, I will more clarify my question.
Thank You.

Code: Select all

model_params = dict(Lx=2, Ly=3, Jv=1, Jp=1, bc_MPS="infinite", verbose= 1)
    print("Entanglement Entropy_1: ", psi.entanglement_entropy_segment(segment=[0,1,2,3,4,5]))
    print("Entanglement Entropy_2: ", psi.entanglement_entropy_segment(segment=[0,1,2,3,4,5,6]))
    print("Entanglement Entropy_3: ", psi.entanglement_entropy(bonds=[6]))
User avatar
Johannes
Site Admin
Posts: 209
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

Re: entanglement_entropy_segment doubt

Post by Johannes »

First of all: the segment [0, 1, 2, 3, 4, 5] is only equivalent to psi.entanglement_entropy()[6] on a finite system.
In an infinite system, psi.entanglement_entropy()[6] takes region A to be [..., -4, -3, -2, -1, 0, 1, 2, 3, 4, 5], which is a single cut dividing the system into left and right halfs, whereas psi.entanglement_entropy_segment([0, 1, 2, 3, 4, 5], [0]) takes the segment [0, 1, 2, 3, 4, 5], not including the sites left of 0, cutting out a "segment" of sites in the center of the chain. The segment basically makes *two* cuts, one to the left and one to the right of the "cylinder ring" of sites [0, 1, 2, 3, 4, 5] with x=0. Hence, it is also expected that it has a larger entanglement entropy.

Now to the question how large the entropy should be.
We know that the ground state of the toric code with periodic boundary conditions (PBC) is an equal super position of all closed "loops", if we identify say up-spins with "activated" bonds (contained in a loop) and down spins with deactivated bonds (not in any loop).

Correct me, if I'm wrong, but my guess is that the result of \((L_y-1)*log(2)\) on a cylinder only holds for even Ly (for which I find that result), where you can ignore boundary effects.
However, even if we do infinite MPS, it's still open boundary conditions in x-direction; infinite DMRG just grows a finite system. If you try to draw the loops on the lattice with odd \(L_y=3,5,7\), you will find that there is always at least one open "loop" which you can't close, going from the left edge of the system to the right.
I'm not completely sure, but I think this loop contributes an additional \(log(2)\) to the entanglement.
This would explain the additional \(log(2)\) in your "entropy 3", and also in entropy 1 (which the standard argument would expect \(2(L_y-1) log(2) = 4 log(2)\) for).
To some extend, the extra loop lifts the restriction of an even number of loops going into to the region, which is the (-1) bit subtracted from the area law entanglement \(L_y log(2)\)

Coming to think about it: the DMRG will also drop the vertex/plaquette terms at the edge of a finite system where one of the operators "leaks" out of the system.
For a finite system, you could explicitly add the corresponding terms.
Alternatively, which should also work for infinite DMRG, I think you can avoid that if you switch off any charge (parity) conservation and adjust the starting left/right environments to be all ones (or more precisely, all ones except for the IdR/IdL index, if you want to avoid adding a global constant).

Also, I've noticed that the order how the MPS winds through the system was not optimal for the toric code.
After the commit 73193b192a3c12e67217a876510cd17d01b3695a I've just made, my tests indicate that you only need a quarter of the bond dimension for the toric code ground state.
amankumar
Posts: 19
Joined: 17 Apr 2020, 11:14

Re: entanglement_entropy_segment doubt

Post by amankumar »

Thank You for the clarification,
1.)Does tenpy also implement toroidal boundary condition ?
2.) I have another question not related to the thread, Suppose I have a model whose ground state is highly entangled, and it requires huge number of chi_max. So can you suggest me some way reduce chi_max, or DMRG is not the right method for the model?
User avatar
Johannes
Site Admin
Posts: 209
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

Re: entanglement_entropy_segment doubt

Post by Johannes »

1) TeNPy only supports "open" MPS, since peridoic MPS don't have a canonical form.
You can make your Model have periodic/toric boundary conditions and still have an open MPS, and TeNPy supports that.
The price you pay is that you need the squared bond dimension due to the (expected) entanglement entropy from one end of the MPS to the other end.
2)
The required bond dimension is dictated by the entanglement, which is a physical quantity, so usually you can't do anything about it.
It is basis dependent, so if you are able to change the basis (e.g. going to momentum space around the cylinder), this can sometimes help. Rearranging the order of sites in your MPS (unit cell), as I did for the toric code is another example of such a basis change.

Appart from that, there is no "magic" trick to to reduce the required bond dimension - it's dictated by physics, after all.
amankumar
Posts: 19
Joined: 17 Apr 2020, 11:14

Re: entanglement_entropy_segment doubt

Post by amankumar »

Can you explain a bit more your second point. Of course entanglement entropy is basis dependent, if you write the Hamiltonian in the basis of exact eigenstate of model, then in that basis ground state would be pure state. But I do not understand how the bond dimension is reduced in Dual Square lattice instead of usual Square lattice as computed by Leon Balents in there nature paper. I mean by just changing the order of lattice sites or unit cell ,how bond dimension is reduced. You can suggest me good reference for this.

(2.) You also suggested me to go to momentum space, and try evaluated entanglement entropy, but while integrated out the space degree of freedom, I need to go back to the space basis. How this will be helpful?
User avatar
Johannes
Site Admin
Posts: 209
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

Re: entanglement_entropy_segment doubt

Post by Johannes »

The square lattice of Leon Balents' paper is a 45-degree rotation compared to the DualSquareLattice we are using.
This implies a different geometry for the cylinder axis (going in the [1, 1] direction of our DualSquareLattice),
and a different "cut" when you split the MPS between unit cells, so it can require different amounts of entanglement entropy in the MPS.

All I'm trying to say is that the way the MPS winds through the lattice can dictate how much entanglement entropy you need. As an example where this is pretty obvious, consider the model coupled spin dimers, e.g. Appendix D of arXiv:1205.4289.
Let me draw strong bonds with = and weak bonds with -,
and let's even consider the limit where the - bonds are completely zero, such that the physical ground state is singlets on the = bonds.
If you consider this ordering of sites:

Code: Select all

5 = 6 - 11= 12
|   |   |   |
3 = 4 - 9 = 10
|   |   |   |
1 = 2 - 7 = 8
you will find the entanglement entropy on the MPS bonds to be [0, 1, 0, 1, 0, 1, ...] (in units of log(2)),
since cutting the MPS into left and right only cuts at most one singlet of the state (e.g. on bond 1-2 or 3-4).

However, if you do the "naive" ordering of going into y-direction first,

Code: Select all

3 = 6 - 9 = 12
|   |   |   |
2 = 5 - 8 = 11
|   |   |   |
1 = 4 - 7 = 10
you will find that your entanglement of the MPS will be [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1] (times log(2)),
the maximum scaling with Ly.


PS:
I did not check which geometry gives you the smaller entanglement entropy.
With TenPy, it should be fairly easily implement another ToricCodeModel using the other geometry, and check that ;)
Ask again, if you want to do that but don't know how.
amankumar
Posts: 19
Joined: 17 Apr 2020, 11:14

Re: entanglement_entropy_segment doubt

Post by amankumar »

Thank you for such a beautiful explanation,
1.) I understand by changing the winding direction, bond dimensions changes depending on the interaction. As you said one can try different geometry(changing the winding) and try to see MPS entropy, Is there another possible geometry possible for square lattice.

3.) I tried to look for Honeycomb lattice also, but I could not able to visualize different winding other than usual. Can you suggest me different winding for this Honeycomb lattice, by defining different dual lattice which I can implement in tenpy.
Attachments
Honeycomb.png
Honeycomb.png (105.2 KiB) Viewed 4527 times
User avatar
Johannes
Site Admin
Posts: 209
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

Re: entanglement_entropy_segment doubt

Post by Johannes »

1) It depends on the physical system, not just the lattice! E.g. in the dimer lattice of my previous post, you should define the ordering such that each dimer is nearest-neighbor in the MPS.

3.) The order you plotted here is different from the default one of the tenpy.models.lattice.Honeycomb lattice! You can change the ordering with the "order" model parameter, I'd recommend trying order="default" and order="Cstyle". Again, it depends on the physical system what order actually is the best.
amankumar
Posts: 19
Joined: 17 Apr 2020, 11:14

Re: entanglement_entropy_segment doubt

Post by amankumar »

I understand that, I deliberately tried to change the lattice basis vector and order in Honeycomb lattice.
1.) How to change the model such that it supports toroidal boundary condition, as you suggested in earlier post. Can you guide me for this your famous toric code example.

2.) I tried to implement kitaev model (bond dependent spin interaction) on a honeycomb(default lattice) in tenpy, since I provided the interaction parameter such that spectrum is gapless and corresponding bond dimension is increased correspondingly. I tried providing different order of lattice also, but this does not help. Can changing initial product state helps in this regard?
Is there other possible way to make the problem computationaly easy?

Code: Select all

psi = MPS.from_product_state(model.lat.mps_sites(), [1]*(2*Ly*Lx), bc = "infinite")
    dmrg_params = {'mixer': True,
                   'chi_list': {0: 200},
                   'trunc_params': {'svd_min': 1.e-10},
                   'verbose': 1}
    results = dmrg.run(psi, model, dmrg_params)
User avatar
Johannes
Site Admin
Posts: 209
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

Re: entanglement_entropy_segment doubt

Post by Johannes »

1.) The toric code model acutally didn't allow for that, you would have had to override the init_lattice method. I've just updated it in 4cc12c0ab9f38cc970da7e5338a1ee3210964997 to allow torus-boundary conditions with bc_MPS="finite", bc_x="periodic", bc_y="periodic".
You can see for Ly=4, that you need bond dimension 64 for the torus compared to bond dimension 8 for the infinite cylinder....

Also, I've now implemented the tenpy.models.lattice.IrregularLattice, in case you want to remove boundary sites not included into couplings for the finite case.

2.) A gapless system formally always requires infinite MPS bond dimension for the ground state, even in 1D!
Start off with small circumferences. Threading a flux through the cylinder can cause a gap opening, where DMRG converges better, but of course that also changes the physics! Same holds for tuning to a different phase by changeing other parameters (e.g., Jz > Jx + Jy in your case, or adding a magnetic field) where there is a gap.

For the Kitaev Honeycomb model, I'd guess that the best order is "Cstyle" (but I didn't try it...).

You might want to do a scaling analysis with the MPS bond dimension, i.e. run DMRG multiple times at increasing bond and look how results change. This kind of analysis still allows to infere quite a lot of information, even if you never get the fully converged ground state, c.f. arXiv:0812.2903.
Changing the initial product state will not change what the required MPS bond dimension is (unless you change the charge sector...), the most it can do is converge in less sweeps if the guess is good.

As I said before, there is no general "magic trick" to make it compuationally easy; if there were, we wouldn't need to develop quantum computers....
For this particular model, of course, you can do all calculuations analytically, making the "compuations" trivial :P
amankumar
Posts: 19
Joined: 17 Apr 2020, 11:14

Re: entanglement_entropy_segment doubt

Post by amankumar »

Thank you for the update to allow torus-boundary conditions. And as you pointed I implemented it on Toric Code model and bond dimension is squared as compared to infinite cylinder.
1.) But now I am getting back to my old thread question. I am trying to evaluate entanglement for a system size L_x=L_y=4, by making a circular cut along y-direction. I should get the result (L_y-1)Log[2], but I am not getting the same. Either I am not evaluating the entanglement for a correct subsystem or missing something?
Below I show my result and changes part of code.

Code: Select all

bc_MPS = model_params.get('bc_MPS', 'finite')
        bc_x = 'periodic' if bc_MPS == 'finite' else 'open'
        bc_x = model_params.get('bc_x', bc_x)
        bc_y = model_params.get('bc_y', 'periodic')
Results:

Code: Select all

 print("Entanglement Entropy_1: ", psi.entanglement_entropy())
 Entanglement Entropy_1:  [0.69314718 1.37714441 2.06617149 2.05075731 2.74390449 2.98383923
 3.1347382  3.1347382  3.16274489 3.63043339 3.6498859  3.66792347
 3.66792347 3.66792347 3.66792347 3.66792347 3.66914633 3.66987443
 3.66992567 3.66992567 3.66992567 3.66992567 3.66992567 3.66992567
 3.66992567 2.97677849 2.28363131 1.59048413 1.59048413 1.38629323
 0.69314718]
 print("Entanglement Entropy_2:", psi.entanglement_entropy_segment([0,1,2,3,4,5,6,7]))
 [3.1347382  3.7570416  4.28997528 4.34170791 3.80648073 3.80648073
 3.80648073 3.80648073 3.80648073 3.77859391 4.17482136 4.16271136
 4.15874489 4.15874489 4.15874489 4.15874489 4.15874489 4.15878895
 4.15886452 3.66993139 3.66992567 3.66992567 3.66992567 3.66992567
 3.66992567]
Of course this time psi.entanglement_entropy()[7]=psi.entanglement_entropy_segment([0,1,2,3,4,5,6,7])[0], because of finite MPS. Can you explain the result I got in both cases?
(2.) Since I am considering torus b.c. , I should not get any boundary edge effects in entanglement entropy for odd system size(say L_y=3)?
Please correct my statement if I am missing something.
User avatar
Johannes
Site Admin
Posts: 209
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

Re: entanglement_entropy_segment doubt

Post by Johannes »

So you try to use torus boundary conditions now?

Just to make sure, the correct way to do this is (whith the standard toric code model as in the Repo):

Code: Select all

from tenpy.networks.mps import MPS
from tenpy.algorithms import dmrg
from tenpy.models.toric_code import ToricCode

def example_run_TC():
    model_params = dict(Lx=4, Ly=4, Jv=1, Jp=1,
                        bc_MPS="finite", bc_x="periodic", bc_y='periodic',
                        verbose= 1)
    M = ToricCode(model_params)
    product_state=[0]*M.lat.N_sites
    psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc =M.lat.bc_MPS)
    dmrg_params = {
        'mixer': True,  # setting this to True helps to escape local minima
        'trunc_params': {
            'chi_max': 100,
            'svd_min': 1.e-10,
        },
        'max_E_err': 1.e-10,
        'verbose': 1,
    }
    results = dmrg.run(psi, M, dmrg_params)
    print("Energy per site: ", results['E'])
    print("entanglement_entropy", psi.entanglement_entropy())
    print("entanglement_entropy_segment", psi.entanglement_entropy_segment(list(range(8))))

if __name__ == "__main__":
    example_run_TC()
Away from the boundary of the MPS, this gives an entropy of \(S = 6 \log(2) = 2 (L_y-1) \log(2)\) on bond between sites 7-8, as expected.
The factor of 2 is expected due to the periodic boundary conditions in x-direction, and the reason why you need squared bond dimensions.

For Ly=3, I get \(S=5 \log(2)\), I think it's for the same reason as before.
Post Reply