Skip to content

Commit

Permalink
Fix gradient rotation in CFOUR calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory authored and Gregory committed Dec 10, 2024
1 parent 01fbf7a commit dd653d5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pysisyphus/calculators/CFOUR.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ def calc_rot_matrix(
):
H = (source_coords_3d - source_centroid).T @ (target_coords_3d - target_centroid)
assert H.shape == (3, 3)
U, S, V = np.linalg.svd(H)
R = V @ U.T
U, S, Vh = np.linalg.svd(H)
R = Vh.T @ U.T

# Cover corner case
if np.linalg.det(R) < 0:
U, S, V = np.linalg.svd(R)
V[:, 2] = V[:, 2] * -1
R = V @ U.T
U, S, Vh = np.linalg.svd(R)
Vh[2, :] = Vh[2, :] * -1
R = Vh.T @ U.T

return R

Expand Down

0 comments on commit dd653d5

Please sign in to comment.