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

Commit

Permalink
Refactored codebase to place getacc subroutines inside of kick. Next …
Browse files Browse the repository at this point in the history
…I will include accel method calls inside of kicks to simplify the algorithms and fix an issue specific to SyMBA in which don't want to reset accelerations to 0 before calling the helio getacch methods
  • Loading branch information
daminton committed Jul 26, 2021
1 parent a79de93 commit a6ca940
Show file tree
Hide file tree
Showing 15 changed files with 188 additions and 190 deletions.
6 changes: 3 additions & 3 deletions src/gr/gr.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
submodule(swiftest_classes) s_gr
use swiftest
contains
module pure subroutine gr_getaccb_ns_body(self, system, param)
module pure subroutine gr_kick_getaccb_ns_body(self, system, param)
!! author: David A. Minton
!!
!! Add relativistic correction acceleration for non-symplectic integrators.
Expand All @@ -11,7 +11,7 @@ module pure subroutine gr_getaccb_ns_body(self, system, param)
!! Quinn, T.R., Tremaine, S., Duncan, M., 1991. A three million year integration of the earth’s orbit.
!! AJ 101, 2287–2305. https://doi.org/10.1086/115850
!!
!! Adapted from David A. Minton's Swifter routine routine gr_getaccb_ns.f90
!! Adapted from David A. Minton's Swifter routine routine gr_kick_getaccb_ns.f90
implicit none
! Arguments
class(swiftest_body), intent(inout) :: self !! Swiftest generic body object
Expand Down Expand Up @@ -41,7 +41,7 @@ module pure subroutine gr_getaccb_ns_body(self, system, param)

return

end subroutine gr_getaccb_ns_body
end subroutine gr_kick_getaccb_ns_body

module pure subroutine gr_p4_pos_kick(param, x, v, dt)
!! author: David A. Minton
Expand Down
69 changes: 0 additions & 69 deletions src/helio/helio_getacch.f90

This file was deleted.

77 changes: 71 additions & 6 deletions src/helio/helio_kick.f90
Original file line number Diff line number Diff line change
@@ -1,13 +1,78 @@
submodule(helio_classes) s_helio_kick
use swiftest
contains
module subroutine helio_kickvb_pl(self, dt)
module subroutine helio_kick_getacch_pl(self, system, param, t, lbeg)
!! author: David A. Minton
!!
!! Compute heliocentric accelerations of massive bodies
!!
!! Adapted from David E. Kaufmann's Swifter routine helio_kick_getacch.f90
!! Adapted from Hal Levison's Swift routine helio_kick_getacch.f
implicit none
! Arguments
class(helio_pl), intent(inout) :: self !! Helio massive body particle data structure
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! Current simulation time
logical, optional, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step

associate(cb => system%cb, pl => self, npl => self%nbody)
pl%ah(:,:) = 0.0_DP
call pl%accel_int()
if (param%loblatecb) then
cb%aoblbeg = cb%aobl
call pl%accel_obl(system)
cb%aoblend = cb%aobl
if (param%ltides) then
cb%atidebeg = cb%atide
call pl%accel_tides(system)
cb%atideend = cb%atide
end if
end if
if (param%lextra_force) call pl%accel_user(system, param, t)
!if (param%lgr) call pl%gr_accel(param)
end associate

return
end subroutine helio_kick_getacch_pl

module subroutine helio_kick_getacch_tp(self, system, param, t, lbeg)
!! author: David A. Minton
!!
!! Compute heliocentric accelerations of test particles
!!
!! Adapted from David E. Kaufmann's Swifter routine helio_kick_getacch_tp.f90
!! Adapted from Hal Levison's Swift routine helio_kick_getacch_tp.f
implicit none
! Arguments
class(helio_tp), intent(inout) :: self !! Helio test particle data structure
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! Current time
logical, optional, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step

associate(tp => self, cb => system%cb, pl => system%pl, npl => system%pl%nbody)
tp%ah(:,:) = 0.0_DP
if (present(lbeg)) system%lbeg = lbeg
if (system%lbeg) then
call tp%accel_int(pl%Gmass(:), pl%xbeg(:,:), npl)
else
call tp%accel_int(pl%Gmass(:), pl%xend(:,:), npl)
end if
if (param%loblatecb) call tp%accel_obl(system)
if (param%lextra_force) call tp%accel_user(system, param, t)
!if (param%lgr) call tp%gr_accel(param)
end associate
return
end subroutine helio_kick_getacch_tp

module subroutine helio_kick_vb_pl(self, dt)
!! author: David A. Minton
!!
!! Kick barycentric velocities of bodies
!!
!! Adapted from Martin Duncan and Hal Levison's Swift routine kickvh.f
!! Adapted from David E. Kaufmann's Swifter routine helio_kickvb.f90
!! Adapted from David E. Kaufmann's Swifter routine helio_kick_vb.f90
implicit none
! Arguments
class(helio_pl), intent(inout) :: self !! Swiftest generic body object
Expand All @@ -24,15 +89,15 @@ module subroutine helio_kickvb_pl(self, dt)

return

end subroutine helio_kickvb_pl
end subroutine helio_kick_vb_pl

module subroutine helio_kickvb_tp(self, dt)
module subroutine helio_kick_vb_tp(self, dt)
!! author: David A. Minton
!!
!! Kick barycentric velocities of bodies
!!
!! Adapted from Martin Duncan and Hal Levison's Swift routine kickvh_tp.f
!! Adapted from David E. Kaufmann's Swifter routine helio_kickvb_tp.f90
!! Adapted from David E. Kaufmann's Swifter routine helio_kick_vb_tp.f90
implicit none
! Arguments
class(helio_tp), intent(inout) :: self !! Swiftest generic body object
Expand All @@ -49,5 +114,5 @@ module subroutine helio_kickvb_tp(self, dt)

return

end subroutine helio_kickvb_tp
end subroutine helio_kick_vb_tp
end submodule s_helio_kick
12 changes: 6 additions & 6 deletions src/kick/kick.f90
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
submodule(swiftest_classes) s_kick
use swiftest
contains
module pure subroutine kick_getacch_int_pl(self)
module pure subroutine kick_kick_getacch_int_pl(self)
!! author: David A. Minton
!!
!! Compute direct cross (third) term heliocentric accelerations of massive bodies
!!
!! Adapted from Hal Levison's Swift routine getacch_ah3.f
!! Adapted from David E. Kaufmann's Swifter routine whm_getacch_ah3.f90 and helio_getacch_int.f90
!! Adapted from David E. Kaufmann's Swifter routine whm_kick_getacch_ah3.f90 and helio_kick_getacch_int.f90
implicit none
! Arguments
class(swiftest_pl), intent(inout) :: self
Expand All @@ -31,15 +31,15 @@ module pure subroutine kick_getacch_int_pl(self)
end associate

return
end subroutine kick_getacch_int_pl
end subroutine kick_kick_getacch_int_pl

module pure subroutine kick_getacch_int_tp(self, GMpl, xhp, npl)
module pure subroutine kick_kick_getacch_int_tp(self, GMpl, xhp, npl)
!! author: David A. Minton
!!
!! Compute direct cross (third) term heliocentric accelerations of test particles by massive bodies
!!
!! Adapted from Hal Levison's Swift routine getacch_ah3_tp.f
!! Adapted from David E. Kaufmann's Swifter routine whm_getacch_ah3.f90 and helio_getacch_int_tp.f90
!! Adapted from David E. Kaufmann's Swifter routine whm_kick_getacch_ah3.f90 and helio_kick_getacch_int_tp.f90
implicit none
! Arguments
class(swiftest_tp), intent(inout) :: self !! Swiftest test particle
Expand All @@ -62,7 +62,7 @@ module pure subroutine kick_getacch_int_tp(self, GMpl, xhp, npl)
end do
end associate
return
end subroutine kick_getacch_int_tp
end subroutine kick_kick_getacch_int_tp

module subroutine kick_vh_body(self, dt)
!! author: David A. Minton
Expand Down
24 changes: 12 additions & 12 deletions src/modules/helio_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ module helio_classes
procedure, public :: vb2vh => helio_coord_vb2vh_pl !! Convert massive bodies from barycentric to heliocentric coordinates (velocity only)
procedure, public :: drift => helio_drift_pl !! Method for Danby drift in Democratic Heliocentric coordinates
procedure, public :: lindrift => helio_drift_linear_pl !! Method for linear drift of massive bodies due to barycentric momentum of Sun
procedure, public :: accel => helio_getacch_pl !! Compute heliocentric accelerations of massive bodies
procedure, public :: kick => helio_kickvb_pl !! Kicks the barycentric velocities
procedure, public :: accel => helio_kick_getacch_pl !! Compute heliocentric accelerations of massive bodies
procedure, public :: kick => helio_kick_vb_pl !! Kicks the barycentric velocities
procedure, public :: step => helio_step_pl !! Steps the body forward one stepsize
end type helio_pl

Expand All @@ -54,8 +54,8 @@ module helio_classes
procedure, public :: vb2vh => helio_coord_vb2vh_tp !! Convert test particles from barycentric to heliocentric coordinates (velocity only)
procedure, public :: lindrift => helio_drift_linear_tp !! Method for linear drift of massive bodies due to barycentric momentum of Sun
procedure, public :: drift => helio_drift_tp !! Method for Danby drift in Democratic Heliocentric coordinates
procedure, public :: accel => helio_getacch_tp !! Compute heliocentric accelerations of massive bodies
procedure, public :: kick => helio_kickvb_tp !! Kicks the barycentric velocities
procedure, public :: accel => helio_kick_getacch_tp !! Compute heliocentric accelerations of massive bodies
procedure, public :: kick => helio_kick_vb_tp !! Kicks the barycentric velocities
procedure, public :: step => helio_step_tp !! Steps the body forward one stepsize
end type helio_tp

Expand Down Expand Up @@ -132,37 +132,37 @@ module subroutine helio_drift_linear_tp(self, cb, dt, lbeg)
logical, intent(in) :: lbeg !! Argument that determines whether or not this is the beginning or end of the step
end subroutine helio_drift_linear_tp

module subroutine helio_getacch_pl(self, system, param, t, lbeg)
module subroutine helio_kick_getacch_pl(self, system, param, t, lbeg)
use swiftest_classes, only : swiftest_parameters, swiftest_nbody_system
implicit none
class(helio_pl), intent(inout) :: self !! Helio massive body object
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! Current simulation time
logical, optional, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step
end subroutine helio_getacch_pl
end subroutine helio_kick_getacch_pl

module subroutine helio_getacch_tp(self, system, param, t, lbeg)
module subroutine helio_kick_getacch_tp(self, system, param, t, lbeg)
use swiftest_classes, only : swiftest_parameters, swiftest_nbody_system
implicit none
class(helio_tp), intent(inout) :: self !! Helio test particle object
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! Current time
logical, optional, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step
end subroutine helio_getacch_tp
end subroutine helio_kick_getacch_tp

module subroutine helio_kickvb_pl(self, dt)
module subroutine helio_kick_vb_pl(self, dt)
implicit none
class(helio_pl), intent(inout) :: self !! Helio massive body object
real(DP), intent(in) :: dt !! Stepsize
end subroutine helio_kickvb_pl
end subroutine helio_kick_vb_pl

module subroutine helio_kickvb_tp(self, dt)
module subroutine helio_kick_vb_tp(self, dt)
implicit none
class(helio_tp), intent(inout) :: self !! Helio test particle object
real(DP), intent(in) :: dt !! Stepsize
end subroutine helio_kickvb_tp
end subroutine helio_kick_vb_tp

module subroutine helio_step_pl(self, system, param, t, dt)
use swiftest_classes, only : swiftest_nbody_system, swiftest_parameters
Expand Down
6 changes: 3 additions & 3 deletions src/modules/rmvs_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module rmvs_classes
procedure, public :: discard => rmvs_discard_tp !! Check to see if test particles should be discarded based on pericenter passage distances with respect to planets encountered
procedure, public :: encounter_check => rmvs_encounter_check_tp !! Checks if any test particles are undergoing a close encounter with a massive body
procedure, public :: fill => rmvs_util_fill_tp !! "Fills" bodies from one object into another depending on the results of a mask (uses the MERGE intrinsic)
procedure, public :: accel => rmvs_getacch_tp !! Calculates either the standard or modified version of the acceleration depending if the
procedure, public :: accel => rmvs_kick_getacch_tp !! Calculates either the standard or modified version of the acceleration depending if the
!! if the test particle is undergoing a close encounter or not
procedure, public :: setup => rmvs_setup_tp !! Constructor method - Allocates space for number of particles
procedure, public :: spill => rmvs_util_spill_tp !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic)
Expand Down Expand Up @@ -136,15 +136,15 @@ module subroutine rmvs_util_fill_tp(self, inserts, lfill_list)
logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps
end subroutine rmvs_util_fill_tp

module subroutine rmvs_getacch_tp(self, system, param, t, lbeg)
module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg)
use swiftest_classes, only : swiftest_nbody_system, swiftest_parameters
implicit none
class(rmvs_tp), intent(inout) :: self !! RMVS test particle data structure
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest central body particle data structuree
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! Current time
logical, optional, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step
end subroutine rmvs_getacch_tp
end subroutine rmvs_kick_getacch_tp

module subroutine rmvs_setup_pl(self,n)
implicit none
Expand Down
Loading

0 comments on commit a6ca940

Please sign in to comment.