From bb34cb905f8e557d73ff3ed5a4cc0e02d958b9e7 Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:58:03 -0700 Subject: [PATCH] update: use new function --- .../tools/build/grain_boundary/__init__.py | 39 ++++--------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/src/py/mat3ra/made/tools/build/grain_boundary/__init__.py b/src/py/mat3ra/made/tools/build/grain_boundary/__init__.py index a2d34903..f630d9b4 100644 --- a/src/py/mat3ra/made/tools/build/grain_boundary/__init__.py +++ b/src/py/mat3ra/made/tools/build/grain_boundary/__init__.py @@ -1,19 +1,16 @@ from typing import List import numpy as np -from mat3ra.made.tools.build import BaseConfiguration from mat3ra.made.material import Material +from ..interface.configuration import TwistedInterfaceConfiguration from ..interface.builders import ( CommensurateLatticeTwistedInterfaceBuilder, CommensurateLatticeTwistedInterfaceBuilderParameters, ) from ..supercell import create_supercell -from ..utils import merge_materials -from ...modify import filter_by_box, add_vacuum_sides, translate_by_vector - -from ..interface.configuration import TwistedInterfaceConfiguration +from ..utils import merge_two_materials_laterally class SurfaceGrainBoundaryConfiguration(TwistedInterfaceConfiguration): @@ -57,36 +54,14 @@ def _post_process(self, items: List[Material], post_process_parameters=None) -> for item in items: matrix1 = np.dot(np.array(item.configuration.xy_supercell_matrix), item.matrix1) matrix2 = np.dot(np.array(item.configuration.xy_supercell_matrix), item.matrix2) - # TODO: isolate placing side by side with a gap into a separate function (in interface.utils folder?) phase_1_material_initial = create_supercell(item.configuration.film, matrix1.tolist()) - phase_1_material_doubled = create_supercell(phase_1_material_initial, scaling_factor=[2, 1, 1]) - phase_1_material = filter_by_box(phase_1_material_doubled, [0, 0, 0], [0.5, 1, 1]) phase_2_material_initial = create_supercell(item.configuration.film, matrix2.tolist()) - phase_2_material_doubled = create_supercell(phase_2_material_initial, scaling_factor=[2, 1, 1]) - phase_2_material = filter_by_box(phase_2_material_doubled, [0.5, 0, 0], [1, 1, 1]) - - new_lattice_vectors_1 = phase_1_material.lattice.vector_arrays - new_lattice_vectors_1[0][0] += item.configuration.gap - - new_lattice_vectors_2 = phase_2_material.lattice.vector_arrays - new_lattice_vectors_2[0][0] += item.configuration.gap - phase_1_material.set_new_lattice_vectors( - lattice_vector1=new_lattice_vectors_1[0], - lattice_vector2=new_lattice_vectors_1[1], - lattice_vector3=new_lattice_vectors_1[2], - ) - phase_2_material.set_new_lattice_vectors( - lattice_vector1=new_lattice_vectors_2[0], - lattice_vector2=new_lattice_vectors_2[1], - lattice_vector3=new_lattice_vectors_2[2], - ) - - phase_2_material = translate_by_vector( - phase_2_material, [item.configuration.gap / 2, 0, 0], use_cartesian_coordinates=True - ) - interface = merge_materials( - [phase_1_material, phase_2_material], distance_tolerance=self.build_parameters.distance_tolerance + interface = merge_two_materials_laterally( + phase_1_material_initial, + phase_2_material_initial, + gap=item.configuration.gap, + distance_tolerance=post_process_parameters.distance_tolerance, ) grain_boundaries.append(interface)