Skip to content

Commit

Permalink
update: add first implementation of hollow sites
Browse files Browse the repository at this point in the history
  • Loading branch information
VsevolodX committed Nov 5, 2024
1 parent fbade3f commit 50ab92c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
31 changes: 31 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,36 @@ 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_coordinates)
closest_hollow_site_coordinate = min(
hollow_coordinates, key=lambda x: np.linalg.norm(np.array(x) - np.array(coordinate))
)
print(closest_hollow_site_coordinate[0:2] + [coordinate[2]])
return closest_hollow_site_coordinate[0:2] + [coordinate[2]]


class DefectPairBuilder(DefectBuilder):
def create_defect_pair(
self,
Expand Down
6 changes: 6 additions & 0 deletions src/py/mat3ra/made/tools/build/defect/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class AtomPlacementMethodEnum(str, Enum):
EQUIDISTANT = "equidistant"
# Places the atom at the existing or extrapolated crystal site closest to the given coordinate.
CRYSTAL_SITE = "crystal_site"
# Places the atom at the hollow site of the surface (for HEX)
HOLLOW_SITE = "hollow"
# Places the atom at the bridge site of the surface (for HEX)
BRIDGE_SITE = "bridge"
# Places the atom at the on-top site of the surface (for HEX)
ON_TOP_SITE = "on_top"


class CoordinatesShapeEnum(str, Enum):
Expand Down

0 comments on commit 50ab92c

Please sign in to comment.