Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Added an extra check for rotation matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
anand43 committed Jan 26, 2024
1 parent 30eedc4 commit 5045e39
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/swiftest/swiftest_obl.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ module subroutine swiftest_obl_rot_matrix(n, rot, rot_matrix, rot_matrix_inv)

! Internals
real(DP) :: theta !! angle to rotate it through
real(DP), dimension(3) :: u, z_hat !! unit vector about which we rotate and z_hat
real(DP), dimension(3, 3) :: S_matrix !! rotation matrices
real(DP), dimension(3) :: u, z_hat, check !! unit vector about which we rotate, z_hat, and a check variable
real(DP), dimension(3, 3) :: S_matrix, temp !! rotation matrices, and a temporary variable
integer :: i, j !! dummy variable

! Assumed that NDIM = 3
Expand Down Expand Up @@ -100,7 +100,18 @@ module subroutine swiftest_obl_rot_matrix(n, rot, rot_matrix, rot_matrix_inv)
end do

rot_matrix = matinv3(rot_matrix_inv)


! Check that the correct rotation matrix is used
! rot_matrix * rot should be in the z_hat direction
check = MATMUL(rot, rot_matrix) ! 1x3 matrix x 3x3 matrix
check = .unit. check(:)

if(abs(check(1)) .gt. EPSILON(0.0_DP) .or. abs(check(2)) .gt. EPSILON(0.0_DP)) then
temp = rot_matrix
rot_matrix = rot_matrix_inv
rot_matrix_inv = temp
end if

return
end subroutine swiftest_obl_rot_matrix

Expand Down

0 comments on commit 5045e39

Please sign in to comment.