I try to use tenpy to calculate the entropy of Heisenberg XXZ chain (open boundary) with alternating interaction.

Hailtonian:\(H=\sum_{i=1}^{L} {J ( 1 + \gamma (-1)^{i} ) (S_{i}^{x} S_{i+1}^{x} + S_{i}^{y} S_{i+1}^{y} + J_{z} S_{i}^{z} S_{i+1}^{z})}\)

This is my program.

Code: Select all

```
from tenpy.models.lattice import Site, Chain
from tenpy.models.model import CouplingModel, MPOModel, CouplingMPOModel, NearestNeighborModel
from tenpy.tools.params import asConfig
from tenpy.networks.site import SpinHalfSite
from tenpy.linalg import np_conserved as npc
import numpy as np
from lattice import StaggerLadder
class StaggerLineModel(CouplingMPOModel):
def __init__(self, model_params={}):
model_params = asConfig(model_params, "StaggerLadderModel")
L = model_params.get('L', 4)
bc_MPS = model_params.get('bc_MPS', 'finite')
site = SpinHalfSite(conserve=None)
bc = 'periodic' if bc_MPS == 'infinite' else 'open'
lat = StaggerLadder(L, site, bc=bc, bc_MPS=bc_MPS)
model_params.setdefault('lattice', lat)
self.params = model_params
CouplingMPOModel.__init__(self, model_params)
def init_sites(self, model_params):
return SpinHalfSite(conserve=None)
def init_terms(self, model_params):
J = model_params.get('J', 1.)
Jz = model_params.get('Jz', 1.)
gamma = model_params.get('gamma', 0.2)
h = model_params.get('hz', 0.)
# add terms
for u1, u2, dx in self.lat.pairs['J1']:
self.add_coupling((1 - gamma)*(J) , u1, 'Sx', u2, 'Sx', dx)
self.add_coupling((1 - gamma)*(J) , u1, 'Sy', u2, 'Sy', dx)
self.add_coupling((1 - gamma)*Jz*J, u1, 'Sz', u2, 'Sz', dx)
for u1, u2, dx in self.lat.pairs['J2']:
self.add_coupling((1 + gamma)*(J) , u1, 'Sx', u2, 'Sx', dx)
self.add_coupling((1 + gamma)*(J) , u1, 'Sy', u2, 'Sy', dx)
self.add_coupling((1 + gamma)*Jz*J, u1, 'Sz', u2, 'Sz', dx)
for u in range(len(self.lat.unit_cell)):
self.add_onsite(h, u, 'Sz')
```

Looking forward to your reply.