Possible bug to implement vanishing coupling strength?

How do I use this algorithm? What does that parameter do?
Post Reply
nervxxx
Posts: 5
Joined: 20 Aug 2020, 04:16

Possible bug to implement vanishing coupling strength?

Post by nervxxx »

I'm trying to produce a model with spatially-dependent on-site terms and was having some difficulty.
For example to produce a dimerized pattern of Zeeman fields I use the on-site functionality

Code: Select all

self.add_onsite(np.array([t1, t2]), 0, 'Sz')
If amplitudes t1, t2 are non-zero, everything is fine. I can create a CouplingMPOModel, and from there I can create a NearestNeighborModel using fromMPOModel().

But there are times when I actually want the field on a given site to be exactly zero. If either t1 or t2 are zero, creating CouplingMPOMOdel is fine, but creating NearestNeighborModel throws up an exception:

Code: Select all

Traceback (most recent call last):
  File "/Users/physics2/anaconda3/envs/tenpy/lib/python3.8/site-packages/tenpy/linalg/np_conserved.py", line 2483, in _advanced_getitem
    iter(i)
TypeError: 'NoneType' object is not iterable

I could hack it by setting the desired zero entry to be very small but non-vanishing, e.g. 0.0000000000001, and the code runs OK, and the physics should be unchanged. But this feels a bit unsatisfactory than actually literally setting the coupling to 0. So, is this a bug?


A minimal working code to showcase the error is as follows:

Code: Select all

import numpy as np

from tenpy.models.model import CouplingMPOModel, NearestNeighborModel
from tenpy.tools.params import asConfig
from tenpy.networks.site import SpinSite 

__all__ = ['minimal_example']

class minimal_example(CouplingMPOModel):
    def __init__(self,model_params):
        model_params = asConfig(model_params, self.__class__.__name__)
        model_params.setdefault('lattice',"Chain")
        CouplingMPOModel.__init__(self,model_params)
    def init_sites(self, model_params):
        site = SpinSite(S=0.5,conserve=None)
        return site
    
    def init_terms(self, model_params):
        self.add_onsite(np.array([1, 0]), 0, 'Sz')

L = 10
model_params = dict(L=L,   bc_MPS="finite")
ME = minimal_example(model_params)
ME_TEBD = NearestNeighborModel.from_MPOModel(ME)
Conversely if I do

Code: Select all

self.add_onsite(np.array([1, 0.0000000000001]), 0, 'Sz')
it is OK.
nervxxx
Posts: 5
Joined: 20 Aug 2020, 04:16

Re: Possible bug to implement vanishing coupling strength?

Post by nervxxx »

Relatedly, if I try to create a model that has only 2-body couplings but no 1-body terms, a CouplingMPOModel can be created but NearestNeighborModel from NearestNeighborModel.from_MPOMOdel() complains and fails...
User avatar
Johannes
Site Admin
Posts: 207
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

Re: Possible bug to implement vanishing coupling strength?

Post by Johannes »

While it does not work with the version v0.6.1, it works with the latest version of the master branch.
The fix is about a year old, but wasn't included into the master branch until recently when we merged the MPO evolution with the W_I/W_II approximations...
I guess it's time for a version bump again...
Post Reply