Skip to content
Snippets Groups Projects
Commit 2596791f authored by Kostas Vilkelis's avatar Kostas Vilkelis :flamingo:
Browse files

use ndof instead of shape

parent a807dba9
No related branches found
No related tags found
1 merge request!6Documentation
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
...@@ -27,7 +27,7 @@ def tb_to_flat(tb: tb_type) -> np.ndarray: ...@@ -27,7 +27,7 @@ def tb_to_flat(tb: tb_type) -> np.ndarray:
def flat_to_tb( def flat_to_tb(
tb_param_complex: np.ndarray, tb_param_complex: np.ndarray,
shape: tuple[int, int], ndof: int,
tb_keys: list[tuple[None] | tuple[int, ...]], tb_keys: list[tuple[None] | tuple[int, ...]],
) -> tb_type: ) -> tb_type:
"""Reverse operation to `tb_to_flat`. """Reverse operation to `tb_to_flat`.
...@@ -38,9 +38,8 @@ def flat_to_tb( ...@@ -38,9 +38,8 @@ def flat_to_tb(
---------- ----------
tb_param_complex : tb_param_complex :
1d complex array that parametrises the tb model. 1d complex array that parametrises the tb model.
shape : ndof :
Tuple (n, n) where n is the number of internal degrees of freedom Number internal degrees of freedom within the unit cell.
(e.g. orbitals, spin, sublattice) within the tight-binding model.
tb_keys : tb_keys :
List of keys of the tight-binding dictionary. List of keys of the tight-binding dictionary.
...@@ -49,6 +48,7 @@ def flat_to_tb( ...@@ -49,6 +48,7 @@ def flat_to_tb(
tb : tb :
tight-binding dictionary tight-binding dictionary
""" """
shape = (len(tb_keys), ndof, ndof)
if len(tb_keys[0]) == 0: if len(tb_keys[0]) == 0:
matrix = np.zeros((shape[-1], shape[-2]), dtype=complex) matrix = np.zeros((shape[-1], shape[-2]), dtype=complex)
matrix[np.triu_indices(shape[-1])] = tb_param_complex matrix[np.triu_indices(shape[-1])] = tb_param_complex
......
...@@ -45,4 +45,4 @@ def rparams_to_tb( ...@@ -45,4 +45,4 @@ def rparams_to_tb(
Tight-biding dictionary. Tight-biding dictionary.
""" """
flat_matrix = real_to_complex(tb_params) flat_matrix = real_to_complex(tb_params)
return flat_to_tb(flat_matrix, (len(tb_keys), ndof, ndof), tb_keys) return flat_to_tb(flat_matrix, ndof, tb_keys)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment