Skip to content

Commit 22867f7

Browse files
authored
Js runs (#187)
* 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
1 parent c788e64 commit 22867f7

File tree

3 files changed

+41
-12
lines changed

3 files changed

+41
-12
lines changed

pymatgen/analysis/defects/core.py

+34-11
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,10 @@ def __init__(
512512
site: PeriodicSite,
513513
multiplicity: int | None = None,
514514
oxi_state: float | None = None,
515-
**kwargs,
515+
equivalent_sites: list[PeriodicSite] | None = None,
516+
symprec: float = 0.01,
517+
angle_tolerance: float = 5,
518+
user_charges: list[int] | None = None,
516519
) -> None:
517520
"""Initialize a substitutional defect object.
518521
@@ -525,9 +528,23 @@ def __init__(
525528
multiplicity: The multiplicity of the defect.
526529
oxi_state: The oxidation state of the defect, if not specified,
527530
this will be determined automatically.
528-
**kwargs: Additional kwargs to pass to the Defect constructor.
531+
equivalent_sites: A list of equivalent sites for the defect in the structure.
532+
symprec: Tolerance for symmetry finding.
533+
angle_tolerance: Angle tolerance for symmetry finding.
534+
user_charges: User specified charge states. If specified,
535+
``get_charge_states`` will return this list. If ``None`` or empty list
536+
the charge states will be determined automatically.
529537
"""
530-
super().__init__(structure, site, multiplicity, oxi_state, **kwargs)
538+
super().__init__(
539+
structure=structure,
540+
site=site,
541+
multiplicity=multiplicity,
542+
oxi_state=oxi_state,
543+
equivalent_sites=equivalent_sites,
544+
symprec=symprec,
545+
angle_tolerance=angle_tolerance,
546+
user_charges=user_charges,
547+
)
531548

532549
def get_multiplicity(self) -> int:
533550
"""Returns the multiplicity of a defect site within the structure.
@@ -643,7 +660,9 @@ def __init__(
643660
multiplicity: int = 1,
644661
oxi_state: float | None = None,
645662
equivalent_sites: list[PeriodicSite] | None = None,
646-
**kwargs,
663+
symprec: float = 0.01,
664+
angle_tolerance: float = 5,
665+
user_charges: list[int] | None = None,
647666
) -> None:
648667
"""Initialize an interstitial defect object.
649668
@@ -656,15 +675,19 @@ def __init__(
656675
oxi_state: The oxidation state of the defect, if not specified,
657676
this will be determined automatically.
658677
equivalent_sites: A list of equivalent sites for the defect in the structure.
659-
**kwargs: Additional kwargs to pass to the Defect constructor.
678+
symprec: Tolerance for symmetry finding.
679+
angle_tolerance: Angle tolerance for symmetry finding.
680+
user_charges: User specified charge states. If specified,
660681
"""
661682
super().__init__(
662-
structure,
663-
site,
664-
multiplicity,
665-
oxi_state,
666-
equivalent_sites,
667-
**kwargs,
683+
structure=structure,
684+
site=site,
685+
multiplicity=multiplicity,
686+
oxi_state=oxi_state,
687+
equivalent_sites=equivalent_sites,
688+
symprec=symprec,
689+
angle_tolerance=angle_tolerance,
690+
user_charges=user_charges,
668691
)
669692

670693
def get_multiplicity(self) -> int:

pymatgen/analysis/defects/plotting/phases.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Plotting functions for competing phases."""
22

3-
# %%
43
from __future__ import annotations
54

65
import logging

tests/test_core.py

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def test_substitution(gan_struct):
110110
n_ga = Substitution(s, n_site)
111111
assert n_ga.get_charge_states() == [-7, -6, -5, -4, -3, -2, -1, 0, 1]
112112

113+
n_ga.user_charges = [-100, 102]
114+
assert n_ga.get_charge_states() == [-100, 102]
115+
113116

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

141+
inter2 = Interstitial(s, n_site)
142+
inter2.user_charges = [-100, 102]
143+
assert inter2.get_charge_states() == [-100, 102]
144+
138145

139146
def test_adsorbate(gan_struct):
140147
s = gan_struct.copy()

0 commit comments

Comments
 (0)