From 7adf4a9efc3d249f3d921fa428c578897d8bc991 Mon Sep 17 00:00:00 2001 From: Johanna <johanna@zijderveld.de> Date: Fri, 12 Apr 2024 14:04:35 +0200 Subject: [PATCH] delete file which is not actually used and is a throwaway --- examples/dict_to_flat.py | 41 ---------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 examples/dict_to_flat.py diff --git a/examples/dict_to_flat.py b/examples/dict_to_flat.py deleted file mode 100644 index 35c7c58..0000000 --- a/examples/dict_to_flat.py +++ /dev/null @@ -1,41 +0,0 @@ -# %% -import numpy as np -from codes.kwant_helper import utils -from codes import kwant_examples - -# %% -# Example hopping dictionary to use: -graphene_builder, int_builder = kwant_examples.graphene_extended_hubbard() -h_0 = utils.builder2h_0(graphene_builder) - - -# %% -def hop_dict_to_flat(hop_dict): - sorted_vals = np.array(list(hop_dict.values()))[ - np.lexsort(np.array(list(hop_dict.keys())).T) - ] - flat = sorted_vals[..., *np.triu_indices(sorted_vals.shape[-1])].flatten() - return flat - - -def flat_to_hop_dict(flat, shape, hop_dict_keys): - - matrix = np.zeros(shape, dtype=complex) - matrix[..., *np.triu_indices(shape[-1])] = flat.reshape(*shape[:-2], -1) - indices = np.arange(shape[-1]) - diagonal = matrix[..., indices, indices] - matrix += np.moveaxis(matrix[-1::-1], -1, -2).conj() - matrix[..., indices, indices] -= diagonal - - hop_dict_keys = np.array(list(hop_dict_keys)) - sorted_keys = hop_dict_keys[np.lexsort(hop_dict_keys.T)] - hop_dict = dict(zip(map(tuple, sorted_keys), matrix)) - return hop_dict - - -# %% -flat = hop_dict_to_flat(h_0) -shape = (len(h_0.keys()), *list(h_0.values())[0].shape) -hop_dict = flat_to_hop_dict(flat, shape, h_0.keys()) - -# %% -- GitLab