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

Commit

Permalink
Cleaned up the system step method for Helio and corrected the first f…
Browse files Browse the repository at this point in the history
…lag assignments
  • Loading branch information
daminton committed Jul 7, 2021
1 parent 6826eb3 commit 986cfaf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 24 deletions.
32 changes: 10 additions & 22 deletions src/helio/helio_step.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,12 @@ module subroutine helio_step_system(self, param, t, dt)
real(DP), intent(in) :: t !! Simulation time
real(DP), intent(in) :: dt !! Current stepsize

select type(system => self)
class is (helio_nbody_system)
select type(cb => self%cb)
class is (helio_cb)
select type(pl => self%pl)
class is (helio_pl)
select type(tp => self%tp)
class is (helio_tp)
call pl%set_rhill(cb)
call pl%step(system, param, t, dt)
call tp%step(system, param, t, dt)
end select
end select
end select
end select
associate(system => self, cb => self%cb, pl => self%pl, tp => self%tp)
call pl%set_rhill(cb)
tp%lfirst = pl%lfirst
call pl%step(system, param, t, dt)
call tp%step(system, param, t, dt)
end associate
return
end subroutine helio_step_system

Expand All @@ -50,16 +41,14 @@ module subroutine helio_step_pl(self, system, param, t, dt)
! Internals
integer(I4B) :: i
real(DP) :: dth, msys
!real(DP), dimension(NDIM) :: ptbeg, ptend !! TODO: Incorporate these into the tp structure
logical, save :: lfirst = .true.

select type(system)
class is (helio_nbody_system)
associate(pl => self, cb => system%cb, ptb => system%ptb, pte => system%pte)
dth = 0.5_DP * dt
if (lfirst) then
if (pl%lfirst) then
call pl%vh2vb(cb)
lfirst = .false.
pl%lfirst = .false.
end if
call pl%lindrift(system, dth, ptb)
call pl%get_accel(system, param, t)
Expand Down Expand Up @@ -94,16 +83,15 @@ module subroutine helio_step_tp(self, system, param, t, dt)
real(DP), intent(in) :: t !! Current simulation time
real(DP), intent(in) :: dt !! Stepsiz
! Internals
logical, save :: lfirst = .true. !! Flag to indicate that this is the first call
real(DP) :: dth !! Half step size

select type(system)
class is (helio_nbody_system)
associate(tp => self, cb => system%cb, pl => system%pl, xbeg => system%xbeg, xend => system%xend, ptb => system%ptb, pte => system%pte)
dth = 0.5_DP * dt
if (lfirst) then
if (tp%lfirst) then
call tp%vh2vb(vbcb = -ptb)
lfirst = .false.
tp%lfirst = .false.
end if
call tp%lindrift(system, dth, ptb)
call tp%get_accel(system, param, t, xbeg)
Expand Down
2 changes: 0 additions & 2 deletions src/main/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ program swiftest_driver
integer(I4B) :: integrator !! Integrator type code (see swiftest_globals for symbolic names)
character(len=:),allocatable :: param_file_name !! Name of the file containing user-defined parameters
integer(I4B) :: ierr !! I/O error code
logical :: lfirst !! Flag indicating that this is the first time through the main loop
integer(I8B) :: iloop !! Loop counter
integer(I8B) :: idump !! Dump cadence counter
integer(I8B) :: iout !! Output cadence counter
Expand Down Expand Up @@ -42,7 +41,6 @@ program swiftest_driver
istep_out => param%istep_out, &
istep_dump => param%istep_dump)
call nbody_system%initialize(param)
lfirst = .true.
t = t0
iloop = 0
iout = istep_out
Expand Down
1 change: 1 addition & 0 deletions src/setup/setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module subroutine setup_body(self,n)

self%nbody = n
if (n <= 0) return
self%lfirst = .true.

!write(*,*) 'Allocating the basic Swiftest particle'
allocate(self%name(n))
Expand Down

0 comments on commit 986cfaf

Please sign in to comment.