Skip to content

Commit 98c1022

Browse files
authored
Cleanup for SC locpot (#181)
* sc locpot * ccd bug
1 parent 074cfcd commit 98c1022

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

pymatgen/analysis/defects/thermo.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,25 @@ def get_freysoldt_correction(
147147
else: # pragma: no cover
148148
defect_fpos = self.sc_defect_frac_coords
149149

150+
if isinstance(defect_locpot, Locpot):
151+
defect_gn = defect_locpot.dim
152+
elif isinstance(defect_locpot, dict):
153+
defect_gn = tuple(map(len, (defect_locpot for k in ["0", "1", "2"])))
154+
155+
if isinstance(bulk_locpot, Locpot):
156+
bulk_sc_locpot = get_sc_locpot(
157+
uc_locpot=bulk_locpot,
158+
defect_struct=defect_struct,
159+
grid_out=defect_gn,
160+
up_sample=2,
161+
)
162+
bulk_locpot = bulk_sc_locpot
163+
150164
frey_corr = get_freysoldt_correction(
151165
q=self.charge_state,
152166
dielectric=dielectric,
153167
defect_locpot=defect_locpot,
154-
bulk_locpot=bulk_locpot,
168+
bulk_locpot=bulk_sc_locpot,
155169
defect_frac_coords=defect_fpos,
156170
lattice=defect_struct.lattice,
157171
**kwargs,
@@ -885,7 +899,8 @@ def ensure_stable_bulk(
885899

886900
def get_sc_locpot(
887901
uc_locpot: Locpot,
888-
defect_locpot: Locpot,
902+
defect_struct: Structure,
903+
grid_out: tuple,
889904
up_sample: int = 2,
890905
sm: StructureMatcher = None,
891906
):
@@ -897,19 +912,20 @@ def get_sc_locpot(
897912
898913
Args:
899914
uc_locpot: Locpot object for the unit cell.
900-
defect_locpot: Locpot object for the defect supercell.
915+
defect_struct: Defect structure to use for the transformation.
916+
grid_out: grid dimensions for the supercell locpot
901917
up_sample: upsample factor for the supercell locpot
902918
sm: StructureMatcher to use for finding the transformation for UC to SC.
903919
904920
Returns:
905921
Locpot: Locpot object for the unit cell transformed to be like the supercell.
906922
"""
907-
sc_mat = get_closest_sc_mat(uc_locpot.structure, defect_locpot.structure)
923+
sc_mat = get_closest_sc_mat(uc_locpot.structure, sc_struct=defect_struct, sm=sm)
908924
bulk_sc = uc_locpot.structure * sc_mat
909925
sc_locpot = get_volumetric_like_sc(
910926
uc_locpot,
911927
bulk_sc,
912-
grid_out=defect_locpot.dim,
928+
grid_out=grid_out,
913929
up_sample=up_sample,
914930
sm=sm,
915931
normalization=None,

0 commit comments

Comments
 (0)