DMRG on a IrregularLattice Transverse Field Ising Model

How do I use this algorithm? What does that parameter do?
Post Reply
quantumbit
Posts: 2
Joined: 13 Feb 2025, 11:05

DMRG on a IrregularLattice Transverse Field Ising Model

Post by quantumbit »

Hello,

I'm currently trying to run a DMRG ground state calculation on a triangular lattice with open boundaries, and with an arbitrarily shaped geometry.
To create the arbitrary geometry, I start with a rhombus shaped triangular lattice, generated with the model.lattice.Triangular class, and modify it by adding and removing sites using the models.lattice.IrregularLattice(reg_lat, remove=lat_idx) function.

This lattice initialisation step is done in an init_lattice(self, model_params) functions in the class SpinModel_triangular_finite(CouplingMPOModel) that generates the model.
The sites are initialised using:

Python: Select all

   
 def init_sites(self, model_params):
        S = model_params.get('S', 0.5)
        conserve = None
        sort_charge = model_params.get('sort_charge', None)
        site = SpinHalfSite(conserve, sort_charge)
        return site
And the one and two-body terms are added using add_coupling_term and add_onsite_term inside the init_terms(self, model_params) function.
I then run DMRG in the following way:

Python: Select all

    myModel = SpinModel_triangular_finite(model_params)
    product_state = ["down"] * N_sites
    psi0 = MPS.from_product_state(myModel.lat.mps_sites(), product_state)
    info = dmrg.run(psi0, myModel, dmrg_params, orthogonal_to = orthogonal_to)
However, I get the following error:

Python: Select all

  File "/Users/emmanuel.gottlob/materials_old/nbs/Examples/clock_phase_rydberg_hexagon.py", line 390, in spin_solver_tenpy_finite_r6_lowest_states
    info = dmrg.run(psi, myModel, dmrg_params)#, orthogonal_to = orthogonal_to)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/emmanuel.gottlob/miniforge3/envs/emu/lib/python3.12/site-packages/tenpy/algorithms/dmrg.py", line 97, in run
    engine = TwoSiteDMRGEngine(psi, model, options, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/emmanuel.gottlob/miniforge3/envs/emu/lib/python3.12/site-packages/tenpy/algorithms/dmrg.py", line 210, in __init__
    super().__init__(psi, model, options, **kwargs)
  File "/Users/emmanuel.gottlob/miniforge3/envs/emu/lib/python3.12/site-packages/tenpy/algorithms/mps_common.py", line 135, in __init__
    super().__init__(psi, model, options, **kwargs)
  File "/Users/emmanuel.gottlob/miniforge3/envs/emu/lib/python3.12/site-packages/tenpy/algorithms/algorithm.py", line 95, in __init__
    consistency_check(N_sites_per_ring, self.options, 'max_N_sites_per_ring', 18,
  File "/Users/emmanuel.gottlob/miniforge3/envs/emu/lib/python3.12/site-packages/tenpy/tools/misc.py", line 978, in consistency_check
    if not compare_func(value, threshold):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<=' not supported between instances of 'NoneType' and 'int'
I suppose I am doing something incorrect in my model initialisation, could you help me figure out what causes the issue?

Many thanks!
Jakob
Posts: 11
Joined: 30 Jan 2023, 22:57

Re: DMRG on a IrregularLattice Transverse Field Ising Model

Post by Jakob »

Hi,
Looks like this is bug in the consistency_check ecosystem, specifically for IrregularLattices.
TeNPy tries to warn users if the lattice has too large N_sites_per_ring.
This check causes an error, because N_sites_per_ring is None for the IrregularLattice.

I will push a fix soon.

In the meantime you can (probably?) do a hacky workaround by setting

Python: Select all

myModel.lat.N_sites_per_ring = 1
before dmrg.run
Jakob
Posts: 11
Joined: 30 Jan 2023, 22:57

Re: DMRG on a IrregularLattice Transverse Field Ising Model

Post by Jakob »

Confirmed that the workaround above works for my quick test.
For the fix see https://github.com/tenpy/tenpy/pull/481
quantumbit
Posts: 2
Joined: 13 Feb 2025, 11:05

Re: DMRG on a IrregularLattice Transverse Field Ising Model

Post by quantumbit »

Thank you for the quick answer and fix ! The hacky workaround did work indeed.
Post Reply