Skip to content

Commit af3ace1

Browse files
authored
Fix for missing lattice matches in ZSLGenerator (#3127)
* Fixed the missing upper bound in self.max_area / (film/substrate)_area due to the range() function in generate_sl_transformation_sets(). This was resulting in some film/substrate matches to be within the tolerances being ignored. See the related PR for details. * Updated the assertion conditions in the unittests to reflect the changes made in ZSLGenerator.
1 parent cb213d9 commit af3ace1

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pymatgen/analysis/interfaces/tests/test_substrate_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_init(self):
3030
s = SubstrateAnalyzer()
3131

3232
matches = list(s.calculate(film, substrate, film_elac))
33-
assert len(matches) == 192
33+
assert len(matches) == 296
3434
for match in matches:
3535
assert match is not None
3636
assert isinstance(match.match_area, float)

pymatgen/analysis/interfaces/tests/test_zsl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ def test_bidirectional(self):
5454
z = ZSLGenerator(max_area_ratio_tol=0.05, max_angle_tol=0.05, max_length_tol=0.05)
5555

5656
matches = list(z(self.film.lattice.matrix[:2], self.substrate.lattice.matrix[:2]))
57-
assert len(matches) == 48
57+
assert len(matches) == 60
5858

5959
matches = list(z(self.substrate.lattice.matrix[:2], self.film.lattice.matrix[:2]))
60-
assert len(matches) == 40
60+
assert len(matches) == 52
6161

6262
z.bidirectional = True
6363
matches = list(z(self.substrate.lattice.matrix[:2], self.film.lattice.matrix[:2]))
64-
assert len(matches) == 48
64+
assert len(matches) == 60
6565

6666
for match in matches:
6767
assert match is not None

pymatgen/analysis/interfaces/zsl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ def generate_sl_transformation_sets(self, film_area, substrate_area):
122122
"""
123123
transformation_indices = [
124124
(ii, jj)
125-
for ii in range(1, int(self.max_area / film_area))
126-
for jj in range(1, int(self.max_area / substrate_area))
125+
for ii in range(1, int(np.ceil(self.max_area / film_area)))
126+
for jj in range(1, int(np.ceil(self.max_area / substrate_area)))
127127
if np.absolute(film_area / substrate_area - float(jj) / ii) < self.max_area_ratio_tol
128128
] + [
129129
(ii, jj)
130-
for ii in range(1, int(self.max_area / film_area))
131-
for jj in range(1, int(self.max_area / substrate_area))
130+
for ii in range(1, int(np.ceil(self.max_area / film_area)))
131+
for jj in range(1, int(np.ceil(self.max_area / substrate_area)))
132132
if np.absolute(substrate_area / film_area - float(ii) / jj) < self.max_area_ratio_tol
133133
]
134134
transformation_indices = list(set(transformation_indices))

0 commit comments

Comments
 (0)