Skip to content

Commit 59e14c5

Browse files
committed
sc locpot
1 parent ed4cb1a commit 59e14c5

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

pymatgen/analysis/defects/ccd.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ def from_directories(
286286
)
287287
charge_state = vaspruns[0].final_structure.charge
288288

289-
if any(v.final_structure.charge != charge_state for v in vaspruns):
290-
raise ValueError("All vaspruns must have the same charge state.")
289+
if any(v.final_structure.charge != charge_state for v in vaspruns):
290+
raise ValueError("All vaspruns must have the same charge state.")
291291

292292
return cls.from_vaspruns(
293293
vaspruns=vaspruns,

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)