Skip to content

Commit 56b1308

Browse files
committed
Switched translation in LOBSTER classes to tuple[int, int, int]
1 parent a8ff92d commit 56b1308

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/pymatgen/electronic_structure/cohp.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ def __init__(
946946
atom1: str,
947947
atom2: str,
948948
length: float,
949-
translation: tuple[float, float, float],
949+
translation: tuple[int, int, int],
950950
num: int,
951951
icohp: dict[Spin, float],
952952
are_coops: bool = False,
@@ -959,7 +959,7 @@ def __init__(
959959
atom1 (str): The first atom that contributes to the bond.
960960
atom2 (str): The second atom that contributes to the bond.
961961
length (float): Bond length.
962-
translation (tuple[float, float, float]): cell translation vector, e.g. (0, 0, 0).
962+
translation (tuple[int, int, int]): cell translation vector, e.g. (0, 0, 0).
963963
num (int): The number of equivalent bonds.
964964
icohp (dict[Spin, float]): {Spin.up: ICOHP_up, Spin.down: ICOHP_down}
965965
are_coops (bool): Whether these are COOPs.
@@ -980,7 +980,6 @@ def __init__(
980980
self._atom1 = atom1
981981
self._atom2 = atom2
982982
self._length = length
983-
# TODO switch to integer translation in LOBSTER classes
984983
self._translation = translation
985984
self._num = num
986985
self._icohp = icohp
@@ -1045,13 +1044,13 @@ def is_spin_polarized(self) -> bool:
10451044
return self._is_spin_polarized
10461045

10471046
@property
1048-
def translation(self) -> tuple[float, float, float]:
1047+
def translation(self) -> tuple[int, int, int]:
10491048
"""
10501049
Returns the translation vector with respect to the origin cell
10511050
as defined in LOBSTER.
10521051
10531052
Returns:
1054-
tuple[float, float, float]
1053+
tuple[int, int, int]
10551054
"""
10561055
return self._translation
10571056

@@ -1142,7 +1141,7 @@ def __init__(
11421141
list_atom1: list[str],
11431142
list_atom2: list[str],
11441143
list_length: list[float],
1145-
list_translation: list[tuple[float, float, float]],
1144+
list_translation: list[tuple[int, int, int]],
11461145
list_num: list[int],
11471146
list_icohp: list[dict[Spin, float]],
11481147
is_spin_polarized: bool,
@@ -1156,7 +1155,7 @@ def __init__(
11561155
list_atom1 (list[str]): Atom names, e.g. "O1".
11571156
list_atom2 (list[str]): Atom names, e.g. "O1".
11581157
list_length (list[float]): Bond lengths in Angstrom.
1159-
list_translation (list[tuple[float, float, float]]): Cell translation vectors.
1158+
list_translation (list[tuple[int, int, int]]): Cell translation vectors.
11601159
list_num (list[int]): Numbers of equivalent bonds, usually 1 starting from LOBSTER 3.0.0.
11611160
list_icohp (list[dict]): Dicts as {Spin.up: ICOHP_up, Spin.down: ICOHP_down}.
11621161
is_spin_polarized (bool): Whether the calculation is spin polarized.

src/pymatgen/io/lobster/lobsterenv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ def _find_relevant_atoms_additional_condition(
10651065
site_idx: int,
10661066
icohps: dict[str, IcohpValue],
10671067
additional_condition: Literal[0, 1, 2, 3, 4, 5, 6],
1068-
) -> tuple[list[str], list[float], list[int], list[float], list[tuple[float, float, float]]]:
1068+
) -> tuple[list[str], list[float], list[int], list[float], list[tuple[int, int, int]]]:
10691069
"""Find all relevant atoms that fulfill the additional condition.
10701070
10711071
Args:
@@ -1080,7 +1080,7 @@ def _find_relevant_atoms_additional_condition(
10801080
lengths_from_ICOHPs: list[float] = []
10811081
neighbors_from_ICOHPs: list[int] = []
10821082
icohps_from_ICOHPs: list[float] = []
1083-
translation_from_ICOHPs: list[tuple[float, float, float]] = []
1083+
translation_from_ICOHPs: list[tuple[int, int, int]] = []
10841084

10851085
for key, icohp in icohps.items():
10861086
atomnr1 = self._get_atomnumber(icohp._atom1)
@@ -1587,9 +1587,9 @@ def check_ICOHPs(lengths_from_ICOHPs, selected_ICOHPs, translation, length_thres
15871587
and abs(selected_ICOHPs[i] - selected_ICOHPs[j]) > energy_threshold
15881588
and [int(idx) for idx in translation[i]] != [0.0, 0.0, 0.0]
15891589
and (
1590-
int(translation[i][0]) == -int(translation[j][0])
1591-
and int(translation[i][1]) == -int(translation[j][1])
1592-
and int(translation[i][2]) == -int(translation[j][2])
1590+
translation[i][0] == -translation[j][0]
1591+
and translation[i][1] == -translation[j][1]
1592+
and translation[i][2] == -translation[j][2]
15931593
)
15941594
):
15951595
warnings.warn(

0 commit comments

Comments
 (0)