Skip to content

Commit

Permalink
chore: cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Sep 23, 2024
1 parent 4383c76 commit 30f5a4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
20 changes: 13 additions & 7 deletions src/py/mat3ra/made/tools/build/interface/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,16 @@ def _update_material_name(


class CommensurateLatticeInterfaceBuilderParameters(BaseModel):
max_search: int = 10
"""
Parameters for the commensurate lattice interface builder.
Args:
max_repetition_int (int): The maximum search range for commensurate lattices.
angle_tolerance (float): The tolerance for the angle between the commensurate lattice and the target angle.
return_first_match (bool): Whether to return the first match or all matches.
"""

max_repetition_int: int = 10
angle_tolerance: float = 0.1
return_first_match: bool = False

Expand All @@ -260,7 +269,7 @@ class CommensurateLatticeInterfaceBuilder(BaseBuilder):
def _generate(self, configuration: _ConfigurationType) -> List[_GeneratedItemType]:
film = configuration.film
# substrate = configuration.substrate
max_search = self.build_parameters.max_search
max_search = self.build_parameters.max_repetition_int
a = film.lattice.vector_arrays[0][:2]
b = film.lattice.vector_arrays[1][:2]
commensurate_lattice_pairs = self.__generate_commensurate_lattices(
Expand Down Expand Up @@ -332,9 +341,6 @@ def _post_process(
new_film = translate_by_vector(
new_film, [0, 0, item.configuration.distance_z], use_cartesian_coordinates=True
)
try:
interface = merge_materials([new_substrate, new_film])
interfaces.append(interface)
except Exception as e:
print(e)
interface = merge_materials([new_substrate, new_film])
interfaces.append(interface)
return interfaces
6 changes: 5 additions & 1 deletion src/py/mat3ra/made/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def get_overlapping_coordinates(
def create_2d_supercell_matrices(max_search: int) -> List[np.ndarray]:
"""
Create a list of 2D supercell matrices within a maximum search range.
Filtering conditions:
- Non-zero area constraint
- Positive determinant (to exclude mirroring transformations)
Args:
max_search: The maximum search range.
Returns:
Expand All @@ -90,7 +95,6 @@ def create_2d_supercell_matrices(max_search: int) -> List[np.ndarray]:
for s12 in range(-max_search, max_search + 1):
for s21 in range(-max_search, max_search + 1):
for s22 in range(-max_search, max_search + 1):
# Non-zero area constraint
matrix = np.array([[s11, s12], [s21, s22]])
determinant = np.linalg.det(matrix)
if determinant == 0 or determinant < 0:
Expand Down

0 comments on commit 30f5a4c

Please sign in to comment.