Skip to content

Commit

Permalink
Js runs (#187)
Browse files Browse the repository at this point in the history
* sc locpot

* ccd bug

* volumetric data

* get_ediff first

* get_ediff first

* get_ediff first

* lint

* lint

* lint

* lint

* lint

* lint

* lint

* lint

* lint

* lint

* lint

* lint

* lint

* fixed serialzation error

* fix kwarg passing

* fix kwarg passing

* fix kwarg passing
  • Loading branch information
jmmshn committed Apr 30, 2024
1 parent c788e64 commit 22867f7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
45 changes: 34 additions & 11 deletions pymatgen/analysis/defects/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,10 @@ def __init__(
site: PeriodicSite,
multiplicity: int | None = None,
oxi_state: float | None = None,
**kwargs,
equivalent_sites: list[PeriodicSite] | None = None,
symprec: float = 0.01,
angle_tolerance: float = 5,
user_charges: list[int] | None = None,
) -> None:
"""Initialize a substitutional defect object.
Expand All @@ -525,9 +528,23 @@ def __init__(
multiplicity: The multiplicity of the defect.
oxi_state: The oxidation state of the defect, if not specified,
this will be determined automatically.
**kwargs: Additional kwargs to pass to the Defect constructor.
equivalent_sites: A list of equivalent sites for the defect in the structure.
symprec: Tolerance for symmetry finding.
angle_tolerance: Angle tolerance for symmetry finding.
user_charges: User specified charge states. If specified,
``get_charge_states`` will return this list. If ``None`` or empty list
the charge states will be determined automatically.
"""
super().__init__(structure, site, multiplicity, oxi_state, **kwargs)
super().__init__(
structure=structure,
site=site,
multiplicity=multiplicity,
oxi_state=oxi_state,
equivalent_sites=equivalent_sites,
symprec=symprec,
angle_tolerance=angle_tolerance,
user_charges=user_charges,
)

def get_multiplicity(self) -> int:
"""Returns the multiplicity of a defect site within the structure.
Expand Down Expand Up @@ -643,7 +660,9 @@ def __init__(
multiplicity: int = 1,
oxi_state: float | None = None,
equivalent_sites: list[PeriodicSite] | None = None,
**kwargs,
symprec: float = 0.01,
angle_tolerance: float = 5,
user_charges: list[int] | None = None,
) -> None:
"""Initialize an interstitial defect object.
Expand All @@ -656,15 +675,19 @@ def __init__(
oxi_state: The oxidation state of the defect, if not specified,
this will be determined automatically.
equivalent_sites: A list of equivalent sites for the defect in the structure.
**kwargs: Additional kwargs to pass to the Defect constructor.
symprec: Tolerance for symmetry finding.
angle_tolerance: Angle tolerance for symmetry finding.
user_charges: User specified charge states. If specified,
"""
super().__init__(
structure,
site,
multiplicity,
oxi_state,
equivalent_sites,
**kwargs,
structure=structure,
site=site,
multiplicity=multiplicity,
oxi_state=oxi_state,
equivalent_sites=equivalent_sites,
symprec=symprec,
angle_tolerance=angle_tolerance,
user_charges=user_charges,
)

def get_multiplicity(self) -> int:
Expand Down
1 change: 0 additions & 1 deletion pymatgen/analysis/defects/plotting/phases.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Plotting functions for competing phases."""

# %%
from __future__ import annotations

import logging
Expand Down
7 changes: 7 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ 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]

n_ga.user_charges = [-100, 102]
assert n_ga.get_charge_states() == [-100, 102]


def test_interstitial(gan_struct):
s = gan_struct.copy()
Expand All @@ -135,6 +138,10 @@ def test_interstitial(gan_struct):
fpos = finder.get_defect_fpos(inter_sc_struct, inter.structure)
assert np.allclose(fpos, [0.25, 0.5, 0.89809658]) # closest equivalent site

inter2 = Interstitial(s, n_site)
inter2.user_charges = [-100, 102]
assert inter2.get_charge_states() == [-100, 102]


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

0 comments on commit 22867f7

Please sign in to comment.