Skip to content

Commit

Permalink
feat: add hollow site builder
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Nov 7, 2024
1 parent 27fe6ff commit 00a6bed
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/py/mat3ra/made/tools/build/defect/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
PointDefectPairConfiguration,
)
from .factories import DefectBuilderFactory
from pymatgen.analysis.adsorption import AdsorbateSiteFinder


class PointDefectBuilderParameters(BaseModel):
Expand Down Expand Up @@ -434,6 +435,35 @@ def create_adatom(
return self.merge_slab_and_defect(new_material, only_adatom_material)


class HollowSiteAdatomSlabDefectBuilder(AdatomSlabDefectBuilder):
"""
Builder class for generating adatoms at hollow sites.
The adatom is placed at the hollow site closest to the specified position on the surface of the material.
"""

def _calculate_coordinate_from_position_and_distance(
self, material: Material, position_on_surface: List[float], distance_z: float
) -> List[float]:
coordinate = super()._calculate_coordinate_from_position_and_distance(material, position_on_surface, distance_z)
pymatgen_structure = to_pymatgen(material)
asf = AdsorbateSiteFinder(pymatgen_structure)

sites = asf.find_adsorption_sites(
positions=[
"hollow",
],
no_obtuse_hollow=False,
)
hollow_coordinates = [array.tolist() for array in sites["hollow"]]
print("Hollow site coordinates:\n", hollow_coordinates)
closest_hollow_site_coordinate = min(
hollow_coordinates, key=lambda x: np.linalg.norm(np.array(x) - np.array(coordinate))
)
return closest_hollow_site_coordinate[0:2] + [coordinate[2]]


class DefectPairBuilder(DefectBuilder):
def create_defect_pair(
self,
Expand Down

0 comments on commit 00a6bed

Please sign in to comment.