How Do I Define New Operators in TenPy
Posted: 11 Mar 2022, 00:08
I am currently studying the Bose Hubbard model that has been implemented in TenPy. Here the specific part of the code that I am studying:
For instance the code basically implements the term \(-t\sum_{\langle i, j \rangle}b^\dagger_i b_j\). Now suppose I want to implement the term \(-t\sum_{\langle i, j \rangle}k^\dagger_i k_j\) where \(k_i^\dagger = b_i^\dagger \sigma_i^-\). I want to replace the line with .
Question: Is there a way to implement the operator \(k_i^\dagger = b_i^\dagger \sigma_i^-\) such that TenPy understand the string "Kd"? I was initially thinking to use, but that would not return a string. How do I incorporate this operator.
Code: Select all
def init_terms(self, model_params):
# 0) Read and set parameters.
t = get_parameter(model_params, 't', 1., self.name, True)
U = get_parameter(model_params, 'U', 0., self.name, True)
V = get_parameter(model_params, 'V', 0., self.name, True)
mu = get_parameter(model_params, 'mu', 0, self.name, True)
for u in range(len(self.lat.unit_cell)):
self.add_onsite(-mu - U / 2., u, 'N')
self.add_onsite(U / 2., u, 'NN')
for u1, u2, dx in self.lat.pairs['nearest_neighbors']:
self.add_coupling(-t, u1, 'Bd', u2, 'B', dx)
self.add_coupling(-np.conj(t), u2, 'Bd', u1, 'B', -dx) # h.c.
self.add_coupling(V, u1, 'N', u2, 'N', dx)
Code: Select all
self.add_coupling(-t, u1, 'Bd', u2, 'B', dx)
Code: Select all
self.add_coupling(-t, u1, 'Bd', u2, 'B', dx)
Code: Select all
self.add_coupling(-t, u1, 'Kd', u2, 'K', dx)
Question: Is there a way to implement the operator \(k_i^\dagger = b_i^\dagger \sigma_i^-\) such that TenPy understand the string "Kd"? I was initially thinking to use
Code: Select all
kron("Bd", "Sp")