Skip to content

Commit

Permalink
update: fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Nov 6, 2024
1 parent 356e51b commit 75ac321
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/py/mat3ra/made/tools/build/interface/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,12 @@ def __get_initial_guess_for_max_int(self, film, target_angle: float) -> int:
int: The maximum integer for the transformation matrices.
"""
if film.lattice.type == "HEX":
# getting max int of the matrix that has angle closest to target angle
xy_supercell_matrix_for_closest_angle = min(
angle_to_supercell_matrix_values_for_hex, key=lambda x: abs(float(x["angle"]) - target_angle)
angle_to_supercell_matrix_values_for_hex, key=lambda x: abs(x["angle"] - target_angle)
)
return max(**xy_supercell_matrix_for_closest_angle["xy_supercell"])
# Get maximum absolute value from the supercell matrix values
return max(abs(x) for row in xy_supercell_matrix_for_closest_angle["xy_supercell"] for x in row)
return 1

def __generate_commensurate_lattices(
Expand Down
8 changes: 7 additions & 1 deletion src/py/mat3ra/made/tools/build/interface/enums.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum
from typing import TypedDict, List


class StrainModes(str, Enum):
Expand All @@ -12,9 +13,14 @@ class SupercellTypes(str, Enum):
orthogonal = "orthogonal"


class SupercellMatrix(TypedDict):
angle: float
xy_supercell: List[List[int]]


# Tabulation from https://github.com/qtm-iisc/Twister/blob/474156a2a59f2b9d59350b32de56864a9496f848/examples/Homobilayer_hex/hex.table
# Maps twist angle to supercell matrix values for homo-material hexagonal supercells bilayer
angle_to_supercell_matrix_values_for_hex = [
angle_to_supercell_matrix_values_for_hex: List[SupercellMatrix] = [
{"angle": 60.0, "xy_supercell": [[0, 1], [-1, 1]]},
{"angle": 21.7867892983, "xy_supercell": [[1, 2], [-2, 3]]},
{"angle": 13.1735511073, "xy_supercell": [[2, 3], [-3, 5]]},
Expand Down

0 comments on commit 75ac321

Please sign in to comment.