Skip to content

Commit

Permalink
Update Substitution oxi state guessing to work with uncharged struc…
Browse files Browse the repository at this point in the history
…tures (#139)

* Pass `VoronoiInterstitialGenerator` parameters through to `TopographyAnalyzer` (bugfix)

* Pass `min_dist` from `VoronoiInterstitialGenerator` initialisation through to `InterstitialGenerator` superclass (bugfix)

* Refactor `filter_colliding` to return coords _and_ index, for correct multiplicities (bugfix)

* Refactor `multiplicies` to `multiplicities` (small typo)

* Update type hint

* Add `equivalent_sites` parameter to `Defect` objects and `target_frac_coords` parameter to `get_supercell_structure` to allow choice of generated defect site in supercell

* Add `return_site` option to `get_supercell_structure` (useful information!)

* Update supercell site setting for dummy species as well

* Automatically bump `max_cell_range` to 2 in `TopographyAnalyzer` if `num_atoms < 5`, for accurate/complete Voronoi tessellation (small unit cells anyway so negligible cost!)

* Use `oxi_state` of substituting specie in the host structure if present (when guessing oxi state of substitution defect) – i.e. antisite defects!

* Add `target_frac_coords` and `return_site` to `DefectComplex` `get_supercell_structure` to make compatible with supertype `Defect`

* Linting

* Comment cleanup

* Also return list of equivalent supercell sites if `return_sites` set to `True`

* Use self.site if self.equivalent_sites is empty

* Make Defect.equivalent_sites match element symbol for Defect.site (rather than Defect.defect_site) with `Substitution` defects

* Fix typo

* Remove oxidation states from defect supercell sites (as well as overall returned structure)

* Add tests for `target_frac_coords` with `get_supercell_structure` for `Interstitial` and `Substitution`

* Add test for oxidation state guessing with (antisite) substitution defects

* Compare `specie.symbol` rather than `specie.element.symbol` in case `specie` is already an element

* Add test for `Substitution` definition and oxi state guessing for input structure without oxi states, and substitution as `Element` not `Specie`
  • Loading branch information
kavanase authored Aug 17, 2023
1 parent e509671 commit ec4f507
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pymatgen/analysis/defects/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ def _guess_oxi_state(self) -> float:
sub_elt_sites_in_struct = [
site
for site in self.structure
if site.specie.element.symbol == self.site.specie.element.symbol
if site.specie.symbol
== self.site.specie.symbol # gives Element symbol (without oxi state)
]
if len(sub_elt_sites_in_struct) == 0:
sub_states = self.site.specie.common_oxidation_states
Expand Down
8 changes: 8 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ def test_substitution(gan_struct):
n_ga = Substitution(s, n_site)
assert n_ga.get_charge_states() == [-7, -6, -5, -4, -3, -2, -1, 0, 1]

# test also works fine when input structure does not have oxidation states:
s.remove_oxidation_states()
ga_site = s.sites[0]
assert ga_site.specie.symbol == "Ga"
n_site = PeriodicSite(Element("N"), ga_site.frac_coords, s.lattice)
n_ga = Substitution(s, n_site)
assert n_ga.get_charge_states() == [-7, -6, -5, -4, -3, -2, -1, 0, 1]


def test_interstitial(gan_struct):
s = gan_struct.copy()
Expand Down

0 comments on commit ec4f507

Please sign in to comment.