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

Commit

Permalink
Changed rotphase to be unitless (0 to 1). Edited swiftest_sph to acco…
Browse files Browse the repository at this point in the history
…unt for this by converting the phase to radians
  • Loading branch information
anand43 committed Feb 9, 2024
1 parent 85c779a commit bc38920
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/swiftest/swiftest_drift.f90
Original file line number Diff line number Diff line change
Expand Up @@ -583,15 +583,17 @@ end subroutine swiftest_drift_kepu_stumpff
module subroutine swiftest_drift_cb_rotphase_update(self, param, dt)
!! Author : Kaustub Anand
!! subroutine to update the rotation phase of the central body
!! Units: Radians
!! Units: None
!!
!! initial 0 is set at the x-axis
!! phase is stored and calculated in a unitless manner, i.e., a phase of 0, 0.5, 1 = 0, pi, 2pi radians = 0, 180, 360 degrees

! Arguments
class(swiftest_cb), intent(inout) :: self !! Swiftest central body data structure
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
real(DP), intent(in) :: dt !! Stepsize

self%rotphase = MOD(self%rotphase + (.mag. self%rot(:)) * dt * param%TU2S, 2 * PI) ! radians
self%rotphase = MOD(self%rotphase + (.mag. self%rot(:)) * dt * param%TU2S, 2 * PI) / (2 * PI) ! phase angle calculated in radians and then scaled by 2pi to be unitless

end subroutine swiftest_drift_cb_rotphase_update

Expand Down
3 changes: 2 additions & 1 deletion src/swiftest/swiftest_sph.f90
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module subroutine swiftest_sph_g_acc_one(GMcb, r_0, phi_cb, rh, c_lm, g_sph, GMp
! Arguments
real(DP), intent(in) :: GMcb !! GMass of the central body
real(DP), intent(in) :: r_0 !! radius of the central body
real(DP), intent(in) :: phi_cb !! rotation phase of the central body
real(DP), intent(in) :: phi_cb !! rotation phase of the central body (from 0 to 1)
real(DP), intent(in), dimension(:) :: rh !! distance vector of body
real(DP), intent(in), dimension(:, :, :) :: c_lm !! Spherical Harmonic coefficients
real(DP), intent(out), dimension(NDIM) :: g_sph !! acceleration vector
Expand All @@ -47,6 +47,7 @@ module subroutine swiftest_sph_g_acc_one(GMcb, r_0, phi_cb, rh, c_lm, g_sph, GMp
real(DP) :: fac1, fac2, r_fac !! calculation factors

g_sph(:) = 0.0_DP
phi_cb = phi_cb * 2 * PI ! scale the phase by 2pi radians
theta = atan2(sqrt(rh(1)**2 + rh(2)**2), rh(3))
phi = atan2(rh(2), rh(1))
phi_bar = MOD(phi - phi_cb, 2 * PI) ! represents the phase difference between the central body's and the particle's phase
Expand Down

0 comments on commit bc38920

Please sign in to comment.