Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed Oct 22, 2024
1 parent f178b64 commit d91d46a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
17 changes: 14 additions & 3 deletions doped/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ def __init__(
interstitial_gen_kwargs (dict, bool):
Keyword arguments to be passed to ``get_Voronoi_interstitial_sites``
(such as ``min_dist``, ``clustering_tol``, ``symmetry_preference``,
``stol`` and ``tight_stol`` -- see its docstring), or
``stol``, ``tight_stol`` and ``symprec`` -- see its docstring), or
``InterstitialGenerator`` if ``interstitial_coords`` is specified.
If set to ``False``, interstitial generation will be skipped entirely.
target_frac_coords (list):
Expand Down Expand Up @@ -2435,6 +2435,9 @@ def get_Voronoi_interstitial_sites(
Structure matcher tolerance for looser site matching. Defaults to 0.32.
- tight_stol (float):
Structure matcher tolerance for tighter site matching. Defaults to 0.02.
- symprec (float):
Symmetry precision for (symmetry-)equivalent site determination. Defaults
to 0.01.
Returns:
list: List of interstitial sites as fractional coordinates
Expand All @@ -2451,6 +2454,7 @@ def get_Voronoi_interstitial_sites(
"symmetry_preference",
"stol",
"tight_stol",
"symprec",
}
if any( # check interstitial_gen_kwargs and warn if any missing:
i not in supported_interstitial_gen_kwargs for i in interstitial_gen_kwargs
Expand All @@ -2472,12 +2476,14 @@ def get_Voronoi_interstitial_sites(
)

label_equiv_fpos_dict: dict[int, list[np.ndarray[float]]] = {}
sga = symmetry.get_sga(host_structure)
sga = symmetry.get_sga(host_structure, symprec=interstitial_gen_kwargs.get("symprec", 0.01))
symm_ops = sga.get_symmetry_operations()
tight_dist = get_stol_equiv_dist(
interstitial_gen_kwargs.get("tight_stol", 0.02), host_structure
) # 0.06 Å for CdTe, Sb2Si2Te6

# this now depends on symprec in `_get_all_equiv_sites` (doesn't matter in most cases,
# but e.g. changes results in Ag2Se where we have some slight differences in site coordinations)
for i, frac_coords in enumerate(site_frac_coords_array.tolist()):
match_found = False
for equiv_fpos in list(label_equiv_fpos_dict.values()):
Expand All @@ -2488,7 +2494,12 @@ def get_Voronoi_interstitial_sites(
if not match_found: # try equiv sites:
this_equiv_fpos = [
site.frac_coords
for site in symmetry._get_all_equiv_sites(frac_coords, host_structure, symm_ops=symm_ops)
for site in symmetry._get_all_equiv_sites(
frac_coords,
host_structure,
symm_ops=symm_ops,
symprec=interstitial_gen_kwargs.get("symprec", 0.01),
)
]
for label, equiv_fpos in list(label_equiv_fpos_dict.items()):
if np.min(host_structure.lattice.get_all_distances(equiv_fpos, frac_coords)) < tight_dist:
Expand Down
35 changes: 25 additions & 10 deletions tests/test_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,16 +690,28 @@ def setUp(self):
Se_Ag_C2_Ag2.80 [+3,+2,+1,0,-1,-2,-3] [0.391,0.000,0.000] 2a
Se_Ag_C2_Ag2.85 [+3,+2,+1,0,-1,-2,-3] [0.615,0.500,0.500] 2b
Interstitials Guessed Charges Conv. Cell Coords Wyckoff
--------------- ----------------- ------------------- ---------
Ag_i_C1_Ag2.04 [+2,+1,0] [0.335,0.435,0.002] 4e
Ag_i_C1_Ag2.09 [+2,+1,0] [0.435,0.123,0.251] 4e
Ag_i_C2_Ag2.02 [+2,+1,0] [0.500,0.250,0.319] 2d
Ag_i_C2_Ag2.48 [+2,+1,0] [0.091,0.500,0.500] 2b
Se_i_C1_Ag2.04 [0,-1,-2] [0.335,0.435,0.002] 4e
Se_i_C1_Ag2.09 [0,-1,-2] [0.435,0.123,0.251] 4e
Se_i_C2_Ag2.02 [0,-1,-2] [0.500,0.250,0.319] 2d
Se_i_C2_Ag2.48 [0,-1,-2] [0.091,0.500,0.500] 2b
Interstitials Guessed Charges Conv. Cell Coords Wyckoff
--------------------------- ----------------- ------------------- ---------
Ag_i_C1_Ag2.03 [+2,+1,0] [0.341,0.438,0.498] 4e
Ag_i_C1_Ag2.04 [+2,+1,0] [0.335,0.435,0.002] 4e
Ag_i_C1_Ag2.05 [+2,+1,0] [0.570,0.589,0.250] 4e
Ag_i_C1_Ag2.09 [+2,+1,0] [0.435,0.123,0.251] 4e
Ag_i_C2_Ag1.95Se1.95Ag2.98a [+2,+1,0] [0.500,0.250,0.668] 2d
Ag_i_C2_Ag1.95Se1.95Ag2.98b [+2,+1,0] [0.500,0.750,0.171] 2d
Ag_i_C2_Ag2.02Se2.02Ag2.88 [+2,+1,0] [0.500,0.250,0.184] 2d
Ag_i_C2_Ag2.02Se2.02Ag2.89 [+2,+1,0] [0.500,0.250,0.319] 2d
Ag_i_C2_Ag2.45 [+2,+1,0] [0.899,0.000,0.000] 2a
Ag_i_C2_Ag2.48 [+2,+1,0] [0.091,0.500,0.500] 2b
Se_i_C1_Ag2.03 [0,-1,-2] [0.341,0.438,0.498] 4e
Se_i_C1_Ag2.04 [0,-1,-2] [0.335,0.435,0.002] 4e
Se_i_C1_Ag2.05 [0,-1,-2] [0.570,0.589,0.250] 4e
Se_i_C1_Ag2.09 [0,-1,-2] [0.435,0.123,0.251] 4e
Se_i_C2_Ag1.95Se1.95Ag2.98a [0,-1,-2] [0.500,0.250,0.668] 2d
Se_i_C2_Ag1.95Se1.95Ag2.98b [0,-1,-2] [0.500,0.750,0.171] 2d
Se_i_C2_Ag2.02Se2.02Ag2.88 [0,-1,-2] [0.500,0.250,0.184] 2d
Se_i_C2_Ag2.02Se2.02Ag2.89 [0,-1,-2] [0.500,0.250,0.319] 2d
Se_i_C2_Ag2.45 [0,-1,-2] [0.899,0.000,0.000] 2a
Se_i_C2_Ag2.48 [0,-1,-2] [0.091,0.500,0.500] 2b
\n"""
"The number in the Wyckoff label is the site multiplicity/degeneracy of that defect in "
"the conventional ('conv.') unit cell, which comprises 4 formula unit(s) of Ag2Se.\n"
Expand Down Expand Up @@ -727,16 +739,19 @@ def setUp(self):
Si_i_C1_Si2.21 [+4,+3,+2,+1,0] [0.158,0.359,0.167] 18f
Si_i_C1_Si2.48 [+4,+3,+2,+1,0] [0.348,0.348,0.457] 18f
Si_i_C1_Te2.44 [+4,+3,+2,+1,0] [0.336,0.335,0.711] 18f
Si_i_C3_Sb2.41 [+4,+3,+2,+1,0] [0.000,0.000,0.050] 6c
Si_i_C3_Si2.64 [+4,+3,+2,+1,0] [0.000,0.000,0.318] 6c
Si_i_C3i_Te2.81 [+4,+3,+2,+1,0] [0.000,0.000,0.000] 3a
Sb_i_C1_Si2.21 [+5,+4,+3,+2,+1,0,-1,-2,-3] [0.158,0.359,0.167] 18f
Sb_i_C1_Si2.48 [+5,+4,+3,+2,+1,0,-1,-2,-3] [0.348,0.348,0.457] 18f
Sb_i_C1_Te2.44 [+5,+4,+3,+2,+1,0,-1,-2,-3] [0.336,0.335,0.711] 18f
Sb_i_C3_Sb2.41 [+5,+4,+3,+2,+1,0,-1,-2,-3] [0.000,0.000,0.050] 6c
Sb_i_C3_Si2.64 [+5,+4,+3,+2,+1,0,-1,-2,-3] [0.000,0.000,0.318] 6c
Sb_i_C3i_Te2.81 [+5,+4,+3,+2,+1,0,-1,-2,-3] [0.000,0.000,0.000] 3a
Te_i_C1_Si2.21 [+4,+3,+2,+1,0,-1,-2] [0.158,0.359,0.167] 18f
Te_i_C1_Si2.48 [+4,+3,+2,+1,0,-1,-2] [0.348,0.348,0.457] 18f
Te_i_C1_Te2.44 [+4,+3,+2,+1,0,-1,-2] [0.336,0.335,0.711] 18f
Te_i_C3_Sb2.41 [+4,+3,+2,+1,0,-1,-2] [0.000,0.000,0.050] 6c
Te_i_C3_Si2.64 [+4,+3,+2,+1,0,-1,-2] [0.000,0.000,0.318] 6c
Te_i_C3i_Te2.81 [+4,+3,+2,+1,0,-1,-2] [0.000,0.000,0.000] 3a
\n"""
Expand Down

0 comments on commit d91d46a

Please sign in to comment.