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')`

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)
```

Code: Select all

`self.add_onsite(np.array([1, 0.0000000000001]), 0, 'Sz')`