Skip to content

Commit

Permalink
Ensure defect_site has oxi_state property
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed Jun 10, 2024
1 parent 2202d84 commit 23dc8f9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions doped/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ def _get_chempot_term(self, chemical_potentials=None):
if el in element_changes
)

def get_ediff(self) -> float | None:
def get_ediff(self) -> float:
"""
Get the energy difference between the defect and bulk supercell
calculations, including finite-size corrections.
Expand Down Expand Up @@ -1680,6 +1680,14 @@ def _set_oxi_state(self):
self.structure, timeout_1=5, timeout_2=5, break_early_if_expensive=True
):
self.structure = struct_w_oxi
if self.defect_type != core.DefectType.Interstitial:
self._defect_site = min(
self.structure.get_sites_in_sphere(
self.site.coords,
0.5,
),
key=lambda x: x[1],
)
else:
self.oxi_state = "Undetermined"
return
Expand Down Expand Up @@ -1990,7 +1998,13 @@ def defect_site(self) -> PeriodicSite:

# else defect_site is the closest site in ``structure`` to the provided ``site``:
if not hasattr(self, "_defect_site"):
self._defect_site = super().defect_site
self._defect_site = min(
self.structure.get_sites_in_sphere(
self.site.coords,
0.5,
),
key=lambda x: x[1],
)

return self._defect_site

Expand Down

0 comments on commit 23dc8f9

Please sign in to comment.