@@ -147,11 +147,25 @@ def get_freysoldt_correction(
147
147
else : # pragma: no cover
148
148
defect_fpos = self .sc_defect_frac_coords
149
149
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
+
150
164
frey_corr = get_freysoldt_correction (
151
165
q = self .charge_state ,
152
166
dielectric = dielectric ,
153
167
defect_locpot = defect_locpot ,
154
- bulk_locpot = bulk_locpot ,
168
+ bulk_locpot = bulk_sc_locpot ,
155
169
defect_frac_coords = defect_fpos ,
156
170
lattice = defect_struct .lattice ,
157
171
** kwargs ,
@@ -885,7 +899,8 @@ def ensure_stable_bulk(
885
899
886
900
def get_sc_locpot (
887
901
uc_locpot : Locpot ,
888
- defect_locpot : Locpot ,
902
+ defect_struct : Structure ,
903
+ grid_out : tuple ,
889
904
up_sample : int = 2 ,
890
905
sm : StructureMatcher = None ,
891
906
):
@@ -897,19 +912,20 @@ def get_sc_locpot(
897
912
898
913
Args:
899
914
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
901
917
up_sample: upsample factor for the supercell locpot
902
918
sm: StructureMatcher to use for finding the transformation for UC to SC.
903
919
904
920
Returns:
905
921
Locpot: Locpot object for the unit cell transformed to be like the supercell.
906
922
"""
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 )
908
924
bulk_sc = uc_locpot .structure * sc_mat
909
925
sc_locpot = get_volumetric_like_sc (
910
926
uc_locpot ,
911
927
bulk_sc ,
912
- grid_out = defect_locpot . dim ,
928
+ grid_out = grid_out ,
913
929
up_sample = up_sample ,
914
930
sm = sm ,
915
931
normalization = None ,
0 commit comments