Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/py/mat3ra/made/tools/analyze/interface/zsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ def _calculate_and_reduce_supercell_matrices(
return film_supercell_matrix, substrate_supercell_matrix, area

def _calculate_strain(self, film_sl_supercell_vectors, substrate_sl_supercell_vectors):
film_det = np.linalg.det(film_sl_supercell_vectors)
substrate_det = np.linalg.det(substrate_sl_supercell_vectors)
# film_det = np.linalg.det(film_sl_supercell_vectors)
# substrate_det = np.linalg.det(substrate_sl_supercell_vectors)

# Handle cases where lattices match but are oriented in opposite directions (e.g., 180° rotation).
# This keeps the right-handed system for the strain calculation.
# The strain calculation uses vector magnitudes, so we need consistent orientation to avoid artificial strain
if (film_det > 0) != (substrate_det > 0):
film_sl_supercell_vectors = film_sl_supercell_vectors.copy()
film_sl_supercell_vectors[1] = -film_sl_supercell_vectors[1]
# if (film_det > 0) != (substrate_det > 0):
# film_sl_supercell_vectors = film_sl_supercell_vectors.copy()
# film_sl_supercell_vectors[1] = -film_sl_supercell_vectors[1]

real_strain_matrix = np.linalg.solve(film_sl_supercell_vectors, substrate_sl_supercell_vectors)
real_strain_matrix = convert_2x2_to_3x3(real_strain_matrix.tolist())
Expand Down
Loading