From c197399843692ded451550668739d43d94be38f7 Mon Sep 17 00:00:00 2001
From: Kostas Vilkelis <kostasvilkelis@gmail.com>
Date: Sun, 24 Mar 2024 19:01:35 +0000
Subject: [PATCH] check hermiticity of tb models

---
 codes/model.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/codes/model.py b/codes/model.py
index cf1f515..8c791da 100644
--- a/codes/model.py
+++ b/codes/model.py
@@ -15,6 +15,16 @@ class Model:
         self._size = tb_model[_firstKey].shape[0]
         self._localKey = tuple(np.zeros((self._ndim,), dtype=int))
 
+
+        def _check_hermiticity(h):
+        # assert hermiticity of the Hamiltonian
+            for vector in h.keys():
+                op_vector = tuple(-1*np.array(vector))
+                assert np.allclose(h[vector], h[op_vector].conj().T)
+
+        _check_hermiticity(tb_model)
+        _check_hermiticity(int_model)
+
     def makeDensityMatrix(self, mf_model, nK=200):
         self.hkfunc = tb2kfunc(addTb(self.tb_model, mf_model))
         self.calculateEF(nK=nK)
-- 
GitLab