how to write HofstadterModel with mixed_xk in infinite dmrg

How do I use this algorithm? What does that parameter do?
Post Reply
kevln
Posts: 18
Joined: 12 May 2022, 07:02

how to write HofstadterModel with mixed_xk in infinite dmrg

Post by kevln »

Hi,tenpy forum

I'm trying to use the mixed model in tenpy to write the idmrg code of the hofstadter model, just like arxiv:1512.03318.

According to the form provided MPO in the article, the form of our Hamiltonian is .

Image

Obviously there is a coefficient cos(k+phi*x) related to x here. I'm not particularly familiar with idmrg's algorithm, so l do not know how I should do in the HofstadterModel Class to describe this coefficient. Because the x direction of idmrg is continuously expanding, but I can only write a limited x when coding the model Class.That is, how to specify the coefficients of the model in "infinite" x direction.

I noticed that the hofstadter model is provided in tenpy, but it seems to be a square lattcie with no magnetic field, and also I have not found any relevant answers in the community.
User avatar
Johannes
Site Admin
Posts: 428
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: how to write HofstadterModel with mixed_xk in infinite dmrg

Post by Johannes »

The Hofstadter models in TeNPy are implemented in real-space (both along and around the cylinder).
To switch to momentum space, you might want to take a look at the tenpy.models.mixed_xk.MixedXKModel, and the subclass examples tenpy.models.mixed_xk.SpinlessMixedXKSquare and tenpy.models.mixed_xk.HubbardMixedXKSquare.
Take a look at the actual source of those example models.

Regarding the kinetic term: since \(phi=2 \pi p /q\), the cosine is periodic under x -> x+q (or maybe even less).
So the trick is to have the full iDMRG unit cell up to x=q, i.e. with Lx * Ly * N_orbitals sites, which repeats.
kevln
Posts: 18
Joined: 12 May 2022, 07:02

Re: how to write HofstadterModel with mixed_xk in infinite dmrg

Post by kevln »

Hi, Johannes
After reading the relevant code of tenpy.mixed_xk, I found that the mixed_xk model provided in tenpy, like SpinlessMixedSquare, etc., seems to use one ring as a unit cell, which is true in a square lattice that does not consider the magnetic field.

But after considering the magnetic field, as you said above, for a model whose flux density is 1/4 and Ly=4, It seem that need to consider a 4*4 unit cell.

If what I said above is correct, does that mean I need to modify the size of the unit cell from 1*4 to 4*4 ,so that code

Code: Select all

self. add_onsite(strength, u1, 'N')
self.add_coupling(strength, u1, 'Cd', u2, 'C', dx, op_string='JW', plus_hc=True)
can be traversed correctly in new unit cell? This seems to be a bit difficult, is there a good template or method in tenpy to achieve such operation? I also made some modifications before, but essentially did not know how to change the size of unit cell.Use the code above,l only can change the terms in each ring. l think this problem can be solved by enlarge unit cell.
kevln
Posts: 18
Joined: 12 May 2022, 07:02

Re: how to write HofstadterModel with mixed_xk in infinite dmrg

Post by kevln »

kevln wrote: 09 May 2023, 14:41 Hi, Johannes
After reading the relevant code of tenpy.mixed_xk, I found that the mixed_xk model provided in tenpy, like SpinlessMixedSquare, etc., seems to use one ring as a unit cell, which is true in a square lattice that does not consider the magnetic field.

But after considering the magnetic field, as you said above, for a model whose flux density is 1/4 and Ly=4, It seem that need to consider a 4*4 unit cell.

If what I said above is correct, does that mean I need to modify the size of the unit cell from 1*4 to 4*4 ,so that code

Code: Select all

self. add_onsite(strength, u1, 'N')
self.add_coupling(strength, u1, 'Cd', u2, 'C', dx, op_string='JW', plus_hc=True)
can be traversed correctly in new unit cell? This seems to be a bit difficult, is there a good template or method in tenpy to achieve such operation? I also made some modifications before, but essentially did not know how to change the size of unit cell.Use the code above,l only can change the terms in each ring. l think this problem can be solved by enlarge unit cell.
By reading some tenpy documents, I found that add_onsite_term and add_coupling_term can be used to add Hamiltonian item by item. Now I seem to be able to get the hamiltonian ground state energy and wave function.

But, as stated in 1512.03318, "Whereas the calculation of the momentum labels of the Schmidt states require additional computational steps
in the real space basis, it is a trivial by-product of the algorithm in the mixed basis.”

It seems that getting the momentum quantum number of the wave function under the mixed basis is not a very difficult operation, but this is not specifically introduced in the documentation and introduction of tenpy.

I really hope to get some help from the community, any help and advice will be very useful to me!!!
User avatar
Johannes
Site Admin
Posts: 428
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: how to write HofstadterModel with mixed_xk in infinite dmrg

Post by Johannes »

Hi Kevin,
just like the other 2D models in TeNPy, the `MixedXK` model reads out the Lx parameter to define the number of "rings" in the iMPS unit cell, similar as Ly defines the number of sites / lattice unit cells around the cylinder.

The add_onsite and add_coupling methods accept the strength to be not only be a number, but also an array with dimensions lattice.Ls (assuming periodic boundary conditions. The MixedXKLattice maps the Ly direction to a single long unit cell of cylinders, so in this case, it just takes 1D arrays giving the x dependence. The MixedXKModel methods add_{inter,intra}_ring_{hopping,interaction} hadn't been able to handle x-dependent couplings, so I've just added that feature in ca0a3c87c252c4e393fe9b28bdc31b2945ddd1a7.

Finally, yes, getting the mometum labels is trivial, if you conserve `ky` around the cylinder (There's a `conserve_ky` parameter in the MixedXKModel, which defaults to True). The ky then appears as the quantum numbers in the charge sectors.
When you get Schmidt values with psi.get_SL(i), you can get the corresponding Charge values e.g. with psi.get_B(i).get_leg('vL').to_qflat(), the last column will be the `ky` charge values (as indicated in psi.chinfo.names)
kevln
Posts: 18
Joined: 12 May 2022, 07:02

Re: how to write HofstadterModel with mixed_xk in infinite dmrg

Post by kevln »

Thank you very much for your help, I tried to use the method you said to calculate the momentum entanglement spectrum , as shown in arxiv:1512.03318. I tried to use

Code: Select all

psi.get_B(i).get_leg('vL').to_qflat()
and found that when conserve_ky=True, the values in the second column are all 0, and I got something like: [-2 0][-1 0][ 0 0] etc., which obviously hardly correspond to the computed entanglement spectrum. Does this have something to do with the initial state I use?

My question is: when we calculate momentum entanglement spectrum in real space, there should be 2 quantum numbers, namely: the number of filled particles N is conserved, and the momentum k corresponding to the singular value. There should still be these two quantum numbers in mixed_xk. I think conserve_ky should correspond to conserve_N in real space, and different momentum quantum numbers should also be available, but I can't get these well with tenpy.

In short, I have tried for a long time, and I can't get the result of how to obtain the momentum entanglement spectrum in arxiv:1512.03318. This seems a bit difficult. The following are some of the native code I tried. What they have in common is that the second column of quantum numbers is 0 and only 0.

Code: Select all

   
E, psi = eng.run()
for i in range(psi.L):
    print(psi.get_SL(i),"  ",psi.get_B(i).get_leg('vL').to_qflat())

Code: Select all

   
E, psi = eng.run()
print(psi.entanglement_spectrum(by_charge=True)[0])
User avatar
Johannes
Site Admin
Posts: 428
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: how to write HofstadterModel with mixed_xk in infinite dmrg

Post by Johannes »

In real space, you can't conserve ky directly, so you don't get that quantum number (although it's still there in principle, yes).
What initial state did you try? You need to put in the correct number of particles, but the total ky is a free parameter which you might need to vary as well (if you don't know a priory, in which sector the ground state should be).
Just to check: did DMRG actually do something, or did you get back the product state you started with?
The only terms changing ky are the interaction terms, so of course you need non-zero interactions for DMRG to work, and since those terms are long-range, you need to enable the mixer as well...
kevln
Posts: 18
Joined: 12 May 2022, 07:02

Re: how to write HofstadterModel with mixed_xk in infinite dmrg

Post by kevln »

Johannes wrote: 23 May 2023, 13:57 In real space, you can't conserve ky directly, so you don't get that quantum number (although it's still there in principle, yes).
What initial state did you try? You need to put in the correct number of particles, but the total ky is a free parameter which you might need to vary as well (if you don't know a priory, in which sector the ground state should be).
Just to check: did DMRG actually do something, or did you get back the product state you started with?
The only terms changing ky are the interaction terms, so of course you need non-zero interactions for DMRG to work, and since those terms are long-range, you need to enable the mixer as well...
Hi,Johannes
I want to find the ground state of the mixed_xk method through the following naive code, and then calculate the momentum entanglement spectrum.

Code: Select all

import numpy as np

from tenpy.tools.params import get_parameter
from headfile import MixedXKLattice, MixedXKModel, SpinlessMixedXKSquare, myMixedXKSquare
from tenpy.networks.mps import MPS
from tenpy.algorithms import dmrg

import matplotlib.pyplot as plt

from tenpy.tools import misc
misc.setup_logging(to_stdout="INFO")
from tenpy.tools import misc
misc.setup_logging(to_stdout="INFO")

import h5py
from tenpy.tools import hdf5_io

def run(model_params):

    dmrg_params = {
        'mixer': True,  # setting this to True helps to escape local minima
        'mixer_params': {
            'amplitude': 1.e-5, 
            'decay': 1.2, 
            'disable_after': 4
        },
        'trunc_params': {
            # 'chi_max': chi_max,
            'svd_min': 1.e-10
        },
        'lanczos_params': {
            'N_min': 5,
            'N_max': 20
        },
        'chi_list': {
            0: 80,
            4: 100,
            8: 200,
            12: 400,
        },
        'max_E_err': 1.e-9,
        'max_S_err': 1.e-6,
        'norm_tol': 1.e-6,
        'max_sweeps': 100,
        'N_sweeps_check': 10,
    }


    product_state = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,]
    print('product_state = ')
    print(product_state)
 
    eng = None
    M = MixedXKSquare(model_params)
    psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS)
    eng = dmrg.TwoSiteDMRGEngine(psi, M, dmrg_params)

    E, psi = eng.run()
    
    print("================================================")
    print("E= ",E)
    print("================================================")

    print(psi.entanglement_spectrum(by_charge=True)[0])
    
    or
    
    #I know this is wrong, but I really don't know how to correspond energy and momentum in the entanglement spectrum
    for i in range(psi.L):
        print(psi.get_SL(i),"  ",psi.get_B(i).get_leg('vL').to_qflat())    
    

if __name__ == "__main__":

    model_params = dict(Lx=4, 
                        Ly=6,
                        # mx=,2 my=1,
                        # filling=(1, 8), 
                        phi=(1, 4),
                        t=1, 
                        V=0,
                        bc_MPS='infinite', 
                        # bc='periodic', 
                        conserve_k=True, 
                        )
Post Reply