Defining a New Operator when Inheriting CouplingMPOModel
Posted: 17 Jul 2023, 01:17
I'm new at TeNPy and am trying to create a model that is a CouplingMPOModel, with a new operator Nj.
However, when I try to create an object of this class by doing the following:
I keep receiving an error that claims it has no knowledge of the Nj operator. In particular it says:
I don't understand why Nj has not been recognized. Interestingly, I have run a similar code without specifying a particular lattice and it has run without any errors, so I'm assuming something went wrong there. Any help would be much appreciated.
Code: Select all
class myTFLIMModel(CouplingMPOModel):
def init_sites(self, model_params):
site = SpinHalfSite(conserve=None)
Nj = np.array([[1,0],[0,0]])
site.add_op('Nj', Nj)
return site
def init_terms(self, model_params):
U = model_params.get('U',1.)
self.add_coupling(U, 0, 'Nj',1,'Nj',np.array([0]))
Code: Select all
model_params = dict(lattice = Ladder(L = 20, site = SpinHalfSite(conserve=None)), L=20, U=1.,bc_MPS='finite', conserve='None')
M = myTFLIMModel(model_params)
Code: Select all
"ValueError: unknown onsite operator 'Nj' for u=0
SpinHalfSite('None')"