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

Commit

Permalink
Made lbeg flag required instead of optional so I can correctly set be…
Browse files Browse the repository at this point in the history
…ginning/ending states of pl variables
  • Loading branch information
daminton committed Jul 26, 2021
1 parent 29d5d6a commit 029ebc8
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 36 deletions.
26 changes: 16 additions & 10 deletions src/helio/helio_kick.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@ module subroutine helio_kick_getacch_pl(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step

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

Expand All @@ -48,17 +54,17 @@ module subroutine helio_kick_getacch_tp(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag 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)
if (present(lbeg)) system%lbeg = 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%lextra_force) call tp%accel_user(system, param, t, lbeg)
!if (param%lgr) call tp%gr_accel(param)
end associate
return
Expand Down Expand Up @@ -86,7 +92,7 @@ module subroutine helio_kick_vb_pl(self, system, param, t, dt, mask, lbeg)
associate(pl => self, npl => self%nbody)
if (npl ==0) return
pl%ah(:,:) = 0.0_DP
call pl%accel(system, param, t)
call pl%accel(system, param, t, lbeg)
if (lbeg) then
call pl%set_beg_end(xbeg = pl%xh)
else
Expand Down
4 changes: 2 additions & 2 deletions src/modules/helio_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ module subroutine helio_kick_getacch_pl(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
end subroutine helio_kick_getacch_pl

module subroutine helio_kick_getacch_tp(self, system, param, t, lbeg)
Expand All @@ -151,7 +151,7 @@ module subroutine helio_kick_getacch_tp(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
end subroutine helio_kick_getacch_tp

module subroutine helio_kick_vb_pl(self, system, param, t, dt, mask, lbeg)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/rmvs_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
end subroutine rmvs_kick_getacch_tp

module subroutine rmvs_setup_pl(self,n)
Expand Down
4 changes: 2 additions & 2 deletions src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ subroutine abstract_accel(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step
end subroutine abstract_accel

subroutine abstract_initialize(self, param)
Expand Down Expand Up @@ -729,7 +729,7 @@ module subroutine user_kick_getacch_body(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Optional argument that determines whether or not this is the beginning or end of the step
end subroutine user_kick_getacch_body

module subroutine util_coord_b2h_pl(self, cb)
Expand Down
4 changes: 2 additions & 2 deletions src/modules/symba_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ module subroutine symba_kick_getacch_pl(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
end subroutine symba_kick_getacch_pl

module subroutine symba_kick_getacch_tp(self, system, param, t, lbeg)
Expand All @@ -229,7 +229,7 @@ module subroutine symba_kick_getacch_tp(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
end subroutine symba_kick_getacch_tp

module subroutine symba_kick_pltpenc(self, system, dt, irec, sgn)
Expand Down
4 changes: 2 additions & 2 deletions src/modules/whm_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module subroutine whm_kick_getacch_pl(self, system, param, t, lbeg)
class(swiftest_nbody_system), intent(inout) :: system !! WHM 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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
end subroutine whm_kick_getacch_pl

!> Get heliocentric accelration of the test particle
Expand All @@ -135,7 +135,7 @@ module subroutine whm_kick_getacch_tp(self, system, param, t, lbeg)
class(swiftest_nbody_system), intent(inout) :: system !! WHM 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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
end subroutine whm_kick_getacch_tp

module subroutine whm_kick_vh_pl(self, system, param, t, dt, mask, lbeg)
Expand Down
8 changes: 4 additions & 4 deletions src/rmvs/rmvs_kick.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
! Internals
type(swiftest_parameters) :: param_planetocen
real(DP), dimension(:, :), allocatable :: xh_original
Expand All @@ -34,7 +34,7 @@ module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg)
class is (rmvs_cb)
associate(xpc => pl%xh, xpct => self%xh, apct => self%ah, system_planetocen => system)

if (present(lbeg)) system_planetocen%lbeg = lbeg
system_planetocen%lbeg = lbeg

if (system_planetocen%lbeg) then
allocate(xhp, source=pl%xbeg)
Expand All @@ -49,7 +49,7 @@ module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg)
param_planetocen%lextra_force = .false.
param_planetocen%lgr = .false.
! Now compute the planetocentric values of acceleration
call whm_kick_getacch_tp(tp, system_planetocen, param_planetocen, t)
call whm_kick_getacch_tp(tp, system_planetocen, param_planetocen, t, lbeg)

! Now compute any heliocentric values of acceleration
if (tp%lfirst) then
Expand All @@ -66,7 +66,7 @@ module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg)
GMcb_original = cb%Gmass
cb%Gmass = tp%cb_heliocentric%Gmass
if (param%loblatecb) call tp%accel_obl(system_planetocen)
if (param%lextra_force) call tp%accel_user(system_planetocen, param, t)
if (param%lextra_force) call tp%accel_user(system_planetocen, param, t, lbeg)
if (param%lgr) call tp%accel_gr(param)
tp%xh(:,:) = xh_original(:,:)
cb%Gmass = GMcb_original
Expand Down
4 changes: 2 additions & 2 deletions src/symba/symba_kick.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module subroutine symba_kick_getacch_pl(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
! Internals
integer(I4B) :: k
real(DP) :: irij3, rji2, rlim2, faci, facj
Expand Down Expand Up @@ -59,7 +59,7 @@ module subroutine symba_kick_getacch_tp(self, system, param, t, lbeg)
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
! Internals
integer(I4B) :: k
real(DP) :: rji2, fac, rlim2
Expand Down
2 changes: 1 addition & 1 deletion src/user/user_getacch.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module subroutine user_kick_getacch_body(self, system, param, t, lbeg)
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody_system_object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters user 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 ste
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the ste

return
end subroutine user_kick_getacch_body
Expand Down
23 changes: 13 additions & 10 deletions src/whm/whm_kick.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module subroutine whm_kick_getacch_pl(self, system, param, t, lbeg)
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest central body particle data structure
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
! Internals
integer(I4B) :: i
real(DP), dimension(NDIM) :: ah0
Expand All @@ -33,9 +33,12 @@ module subroutine whm_kick_getacch_pl(self, system, param, t, lbeg)
call pl%accel_int()

if (param%loblatecb) then
cb%aoblbeg = cb%aobl
call pl%accel_obl(system)
cb%aoblend = cb%aobl
if (lbeg) then
cb%aoblbeg = cb%aobl
else
cb%aoblend = cb%aobl
end if
if (param%ltides) then
cb%atidebeg = cb%aobl
call pl%accel_tides(system)
Expand All @@ -45,7 +48,7 @@ module subroutine whm_kick_getacch_pl(self, system, param, t, lbeg)

if (param%lgr) call pl%accel_gr(param)

if (param%lextra_force) call pl%accel_user(system, param, t)
if (param%lextra_force) call pl%accel_user(system, param, t, lbeg)
end associate
return
end subroutine whm_kick_getacch_pl
Expand All @@ -63,16 +66,16 @@ module subroutine whm_kick_getacch_tp(self, system, param, t, lbeg)
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest central body particle data structure
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
logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step
! Internals
integer(I4B) :: i
real(DP), dimension(NDIM) :: ah0

associate(tp => self, ntp => self%nbody, pl => system%pl, cb => system%cb, npl => system%pl%nbody)
if (ntp == 0 .or. npl == 0) return
if (present(lbeg)) system%lbeg = lbeg
system%lbeg = lbeg

if (system%lbeg) then
if (lbeg) then
ah0(:) = whm_kick_getacch_ah0(pl%Gmass(:), pl%xbeg(:,:), npl)
do i = 1, ntp
tp%ah(:, i) = tp%ah(:, i) + ah0(:)
Expand All @@ -87,7 +90,7 @@ module subroutine whm_kick_getacch_tp(self, system, param, t, lbeg)
end if

if (param%loblatecb) call tp%accel_obl(system)
if (param%lextra_force) call tp%accel_user(system, param, t)
if (param%lextra_force) call tp%accel_user(system, param, t, lbeg)
if (param%lgr) call tp%accel_gr(param)
end associate
return
Expand Down Expand Up @@ -204,13 +207,13 @@ module subroutine whm_kick_vh_pl(self, system, param, t, dt, mask, lbeg)
if (pl%lfirst) then
call pl%h2j(cb)
pl%ah(:,:) = 0.0_DP
call pl%accel(system, param, t)
call pl%accel(system, param, t, lbeg)
pl%lfirst = .false.
end if
call pl%set_beg_end(xbeg = pl%xh)
else
pl%ah(:,:) = 0.0_DP
call pl%accel(system, param, t)
call pl%accel(system, param, t, lbeg)
call pl%set_beg_end(xend = pl%xh)
end if
do concurrent(i = 1:npl, mask(i))
Expand Down

0 comments on commit 029ebc8

Please sign in to comment.