Skip to content
Snippets Groups Projects

Documentation

Merged Kostas Vilkelis requested to merge documentation into main
2 files
+ 1
50
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 0
48
@@ -62,51 +62,3 @@ def ifftn_to_tb(ifft_array: np.ndarray) -> tb_type:
keys = [np.arange(-size[0] // 2 + 1, size[0] // 2) for i in range(len(size))]
keys = itertools.product(*keys)
return {tuple(k): ifft_array[tuple(k)] for k in keys}
def kham_to_tb(
kham: np.ndarray,
tb_keys: list[tuple[None] | tuple[int, ...]],
ks: ks_type = None,
) -> tb_type:
"""Convert a Hamiltonian evaluated on a k-grid to a tight-binding dictionary.
Parameters
----------
kham :
Hamiltonian sampled on a grid of k-points with shape (nk, nk, ..., ndof, ndof),
where ndof is number of internal degrees of freedom.
tb_keys :
List of keys for which to compute the tight-binding dictionary.
ks :
I have no clue why we need this, so this goes on the chopping board.
Returns
-------
:
Tight-binding model of Hartree-Fock solution.
"""
if ks is not None:
ndim = len(kham.shape) - 2
dk = np.diff(ks)[0]
nk = len(ks)
k_pts = np.tile(ks, ndim).reshape(ndim, nk)
k_grid = np.array(np.meshgrid(*k_pts))
k_grid = k_grid.reshape(k_grid.shape[0], np.prod(k_grid.shape[1:]))
kham = kham.reshape(np.prod(kham.shape[:ndim]), *kham.shape[-2:])
hopps = (
np.einsum(
"ij,jkl->ikl",
np.exp(1j * np.einsum("ij,jk->ik", tb_keys, k_grid)),
kham,
)
* (dk / (2 * np.pi)) ** ndim
)
h = {}
for i, vector in enumerate(tb_keys):
h[tuple(vector)] = hopps[i]
return h
else:
return {(): kham}
Loading