From 8dc209be9cf4c55881fecb58fa31de41028b2282 Mon Sep 17 00:00:00 2001 From: Daniel Pozsar Date: Tue, 12 Nov 2024 16:15:43 +0100 Subject: [PATCH] added hh, ss symmetry test --- src/grogupy/grogu.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/grogupy/grogu.py b/src/grogupy/grogu.py index 2aac3fb..dbddcb7 100644 --- a/src/grogupy/grogu.py +++ b/src/grogupy/grogu.py @@ -219,6 +219,10 @@ def main(simulation_parameters: dict, magnetic_entities: list, pairs: list) -> N # reformat Hamiltonian and Overlap matrix for manipulations hh, ss = build_hh_ss(dh) + # copy arrays for tests + if rank == root_node: + hh_test, ss_test = hh.copy(), ss.copy() + # symmetrizing Hamiltonian and Overlap matrix to make them hermitian for i in range(dh.lattice.sc_off.shape[0]): j = dh.lattice.sc_index(-dh.lattice.sc_off[i]) @@ -227,6 +231,19 @@ def main(simulation_parameters: dict, magnetic_entities: list, pairs: list) -> N s1, s1d = ss[i], ss[j] ss[i], ss[j] = (s1 + s1d.T.conj()) / 2, (s1d + s1.T.conj()) / 2 + # test symmetrization + if rank == root_node: + diff_hh = abs(hh - hh_test).max() + diff_ss = abs(ss - ss_test).max() + if diff_hh > 1e-12: + warnings.warn( + f"Hamiltonian changed after symmetrization. Largest change is {diff_hh}" + ) + if diff_ss > 1e-12: + warnings.warn( + f"Overlap matrix changed after symmetrization. Largest change is {diff_hh}" + ) + # identifying TRS and TRB parts of the Hamiltonian TAUY: np.array = np.kron(np.eye(NO), TAU_Y) hTR: np.array = np.array(