Page 1 of 1

01_dmrg.ipynb but with periodic boundary conditions

Posted: 21 Sep 2022, 19:09
by nick
I am trying out DMRG for the first time in Google Colab with Tenpy. After adding a cell with

Code: Select all

!pip install physics-tenpy,
I am able to run 01_dmrg.ipynb from ... _dmrg.html. It runs well and it's really nice to see the output!

One thing I noticed is that the central charge fitting, using the default exclude=None to drop 100/4=25 sites from the left and right boundaries, gives a central charge of .508 instead of .5. That's of course a small enough error to confidently know that the central charge is .5, but I've noticed that in exact-diagonalization of the transverse-field ising model in periodic chains, I can get closer to .5 at smaller system sizes.

For example, for L=20 with sparse extraction of the ground state in a periodic TFIM, I get that fitting $c/3 \log(\frac{L}{\pi} \sin(\pi l/L)+\text{const}$ gives me c=.5008 - an order of magnitude better error for a smaller system size. The smallest subsystem size I include has three spins, which is also fractionally smaller than the default exclude of

Since the 01_dmrg code is for an open chain, I want to see whether I can get even closer to c=.5 with a periodic chain and larger system sizes than I access with exact diagonalization. I recognize that Tenpy is primarily designed for open MPS which can be put in canonical form, and so that periodic boundary conditions involve long-range couplings and bond dimensions being squared. Even given this, I would like to try to make a version of 01_dmrg for periodic boundary conditions with the dream of L=100 but maybe more realistically L=40. I read that I will need to put bc_x in the model params to 'periodic', and so I am trying to run the following code:

Code: Select all

L = 100
model_params = {
    'J': 1. , 'g': 1.,  # critical
    'L': L,
    'bc_x': 'periodic',
    'bc_MPS': 'finite',

M = TFIChain(model_params)
However, I receive the error

Code: Select all

ValueError: Can't give nearest neighbor H_bond for long-range 0-99
How can I fix this error? I anticipate I maybe need to set some additional parameters in the model_params or perhaps make my own model.

Re: 01_dmrg.ipynb but with periodic boundary conditions

Posted: 21 Sep 2022, 23:37
by nick
I figured out my confusion. Although there's in principle the option optionCouplingMPOModel.bc_x which takes open or periodic as options, from the inheritance diagram on ... Chain.html, TFIChain is a "NearestNeighborModel". The long-range coupling to do periodic boundary conditions violates the NearestNeighborModel assumptions. Instead, the following code works well:

Code: Select all

class PBC_TI(CouplingModel, MPOModel):
    def __init__(self, L=2,S=.5, over=1, h=1, lam=.1):
        spin = SpinSite(S=S, conserve="None")
        # the lattice defines the geometry
        lattice = Chain(L, spin, bc="periodic", bc_MPS="finite")
        CouplingModel.__init__(self, lattice)
        # add terms of the Hamiltonian
        self.add_multi_coupling((2**2)*over, [("Sx",0,0), ("Sx",1,0)])
        self.add_onsite((2**1)*over*h, 0, "Sz")

        # finish initialization
        # generate MPO for DMRG
        MPOModel.__init__(self, lattice, self.calc_H_MPO())
Running DMRG for L=30, over=-1, h=1, and max bond-dimension of 500, I got a central charge fit (lazily using and dividing the resulting c by two) of .5002, so I'm very happy.

Re: 01_dmrg.ipynb but with periodic boundary conditions

Posted: 22 Sep 2022, 09:09
by Johannes
Indeed, the issue is that the periodic boundary conditions induce a long-range coupling in the model. (The MPS is still open, but I think you already got this.)

You don't even need to define a custom model, since there is also the tenpy.models.tf_ising.TFIModel, which is the same as the TFIChain except that it's not a NearestNeighborModel and works also for other lattices. You just need to add the model parameter 'lattice': 'Chain' to actually select the lattice, and can force the periodic boundary conditions of H with 'bc_x': 'periodic' (but still keep the default 'bc_MPS': 'finite'.