Skip to content

Commit d988e80

Browse files
committed
update: correct strain
1 parent 68c432f commit d988e80

File tree

1 file changed

+9
-0
lines changed
  • src/py/mat3ra/made/tools/analyze/interface

1 file changed

+9
-0
lines changed

src/py/mat3ra/made/tools/analyze/interface/zsl.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ def convert_generated_match_to_match_holder(self, match_id: int, match_pymatgen)
153153
):
154154
return None
155155

156+
# Ensure both vector systems have the same handedness before calculating strain
157+
film_det = np.linalg.det(film_sl_supercell_vectors)
158+
substrate_det = np.linalg.det(substrate_sl_supercell_vectors)
159+
160+
# If handedness differs, flip the film vectors to match substrate handedness
161+
if (film_det > 0) != (substrate_det > 0):
162+
film_sl_supercell_vectors = film_sl_supercell_vectors.copy()
163+
film_sl_supercell_vectors[1] = -film_sl_supercell_vectors[1]
164+
156165
real_strain_matrix = np.linalg.solve(film_sl_supercell_vectors, substrate_sl_supercell_vectors)
157166

158167
real_strain_matrix = convert_2x2_to_3x3(real_strain_matrix.tolist())

0 commit comments

Comments
 (0)