Skip to content

Commit

Permalink
chore: add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Sep 6, 2024
1 parent 5a883dc commit f656e46
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions src/py/mat3ra/made/tools/build/interface/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class TwistedInterfaceConfiguration(BaseConfiguration):
substrate: Material
twist_angle: float = Field(..., description="Twist angle in degrees")
distance_z: float = 3.0
supercell_type: SupercellTypes = SupercellTypes.orhogonal
supercell_type: SupercellTypes = SupercellTypes.orthogonal

@property
def _json(self):
Expand Down Expand Up @@ -247,25 +247,37 @@ def _generate(self, configuration: TwistedInterfaceConfiguration) -> List[Materi
return [final_material]

@staticmethod
def _create_hex_supercell(film: Material, angle: float, merged_material_unrotated: Material) -> Material:
def _create_hex_supercell(film: Material, angle: float, merged_material: Material) -> Material:
"""
Creates a hexagonal supercell for the twisted interface by filtering the atoms in the merged material
in the shape of two triangles that form a parallelogram.
Args:
film (Material): The film material.
angle (float): The twist angle in degrees.
merged_material (Material): The merged material.
Returns:
Material: The final material with the hexagonal supercell.
"""
p, q = calculate_moire_periodicity(film.lattice.a, film.lattice.b, angle)

vertex_1 = [0, 0, 0]
vertex_2 = [p / 2, np.sqrt(3) / 2 * q, 0]
vertex_3 = [p, 0, 0]
vertex_4 = [3 / 2 * p, np.sqrt(3) / 2 * q, 0]
height = merged_material_unrotated.lattice.c
height = merged_material.lattice.c

new_atoms_1 = filter_by_triangle_projection(
merged_material_unrotated,
merged_material,
coordinate_1=vertex_1,
coordinate_2=vertex_2,
coordinate_3=vertex_3,
max_z=height,
use_cartesian_coordinates=True,
)
new_atoms_2 = filter_by_triangle_projection(
merged_material_unrotated,
merged_material,
coordinate_1=vertex_2,
coordinate_2=vertex_3,
coordinate_3=vertex_4,
Expand All @@ -281,14 +293,24 @@ def _create_hex_supercell(film: Material, angle: float, merged_material_unrotate
return final_material

@staticmethod
def _create_orthogonal_supercell(
rotated_film: Material, angle: float, merged_material_unrotated: Material
) -> Material:
p, q = calculate_moire_periodicity(rotated_film.lattice.b, rotated_film.lattice.a, angle)
def _create_orthogonal_supercell(film: Material, angle: float, merged_material: Material) -> Material:
"""
Creates an orthogonal supercell for the twisted interface by filtering the atoms in the merged material
in the shape of a rectangular box with the sides equal to the Moire pattern periodicity vectors.
Args:
film (Material): The film material.
angle (float): The twist angle in degrees.
merged_material (Material): The merged material.
Returns:
Material: The final material with the orthogonal supercell.
"""
p, q = calculate_moire_periodicity(film.lattice.b, film.lattice.a, angle)
new_atoms = filter_by_box(
merged_material_unrotated,
merged_material,
[0, 0, 0],
[p, q, merged_material_unrotated.lattice.c],
[p, q, merged_material.lattice.c],
use_cartesian_coordinates=True,
)

Expand Down

0 comments on commit f656e46

Please sign in to comment.