From 30f5a4c4acc00be90ff6788b924d81648ba2ab87 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:03:53 -0700 Subject: [PATCH] chore: cleanups --- .../made/tools/build/interface/builders.py | 20 ++++++++++++------- src/py/mat3ra/made/utils.py | 6 +++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/py/mat3ra/made/tools/build/interface/builders.py b/src/py/mat3ra/made/tools/build/interface/builders.py index 8242fe3c..7f0a0a69 100644 --- a/src/py/mat3ra/made/tools/build/interface/builders.py +++ b/src/py/mat3ra/made/tools/build/interface/builders.py @@ -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 @@ -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( @@ -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 diff --git a/src/py/mat3ra/made/utils.py b/src/py/mat3ra/made/utils.py index bb09ac65..ca3f93db 100644 --- a/src/py/mat3ra/made/utils.py +++ b/src/py/mat3ra/made/utils.py @@ -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: @@ -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: