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

Commit

Permalink
Restructured the swiftest and whm classes to accept system variabiles…
Browse files Browse the repository at this point in the history
… in place of individual cb, pl, and tp for most cases
  • Loading branch information
daminton committed Jul 2, 2021
1 parent c587459 commit 8f4e883
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 301 deletions.
8 changes: 4 additions & 4 deletions src/main/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ program swiftest_driver
iloop = 0
iout = istep_out
idump = istep_dump
if (istep_out > 0) call nbody_system%write_frame(iu, param, t, dt)
if (istep_out > 0) call nbody_system%write_frame(iu, param)
!> Define the maximum number of threads
nthreads = 1 ! In the *serial* case
!$ nthreads = omp_get_max_threads() ! In the *parallel* case
Expand All @@ -60,7 +60,7 @@ program swiftest_driver
ntp = nbody_system%tp%nbody
npl = nbody_system%pl%nbody
!> Step the system forward in time
call nbody_system%step(param)
call nbody_system%step(param, t, dt)

t = t0 + iloop * dt
if (t > tstop) exit
Expand All @@ -72,7 +72,7 @@ program swiftest_driver
if (istep_out > 0) then
iout = iout - 1
if (iout == 0) then
call nbody_system%write_frame(iu, param, t, dt)
call nbody_system%write_frame(iu, param)
iout = istep_out
end if
end if
Expand All @@ -81,7 +81,7 @@ program swiftest_driver
if (istep_dump > 0) then
idump = idump - 1
if (idump == 0) then
call nbody_system%dump(param, t, dt, statusfmt)
call nbody_system%dump(param, statusfmt)
idump = istep_dump
end if
end if
Expand Down
21 changes: 11 additions & 10 deletions src/modules/rmvs_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,15 @@ module subroutine rmvs_discard_pl_tp(self, pl, t, dt)
real(DP), intent(in) :: dt !! Stepsize
end subroutine rmvs_discard_pl_tp

module subroutine rmvs_getacch_tp(self, cb, pl, param, t, xh)
module subroutine rmvs_getacch_tp(self, system, param, t, xh)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
use whm_classes, only : whm_pl
use whm_classes, only : whm_nbody_system
implicit none
class(rmvs_tp), intent(inout) :: self !! RMVS test particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
class(whm_pl), intent(inout) :: pl !! WHM massive body particle data structure.
class(rmvs_tp), intent(inout) :: self !! RMVS test particle data structure
class(whm_nbody_system), intent(inout) :: system !! Swiftest central body particle data structuree
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of parameter
real(DP), intent(in) :: t !! Current time
real(DP), dimension(:,:), intent(in) :: xh !! Heliocentric positions of planets
real(DP), intent(in) :: t !! Current time
real(DP), dimension(:,:), intent(in) :: xh !! Heliocentric positions of planets
end subroutine rmvs_getacch_tp

module subroutine rmvs_setup_system(self, param)
Expand All @@ -148,11 +147,13 @@ module subroutine rmvs_setup_set_beg_end(self, xbeg, xend, vbeg)
real(DP), dimension(:,:), intent(in), optional :: xbeg, xend, vbeg
end subroutine rmvs_setup_set_beg_end

module subroutine rmvs_step_system(self, param)
module subroutine rmvs_step_system(self, param, t, dt)
use swiftest_classes, only : swiftest_parameters
implicit none
class(rmvs_nbody_system), intent(inout) :: self !! RMVS nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of parameters
class(rmvs_nbody_system), intent(inout) :: self !! RMVS nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters of parameters
real(DP), intent(in) :: t !! Simulation time
real(DP), intent(in) :: dt !! Current stepsize
end subroutine rmvs_step_system

module subroutine rmvs_setup_tp(self,n)
Expand Down
218 changes: 96 additions & 122 deletions src/modules/swiftest_classes.f90

Large diffs are not rendered by default.

112 changes: 55 additions & 57 deletions src/modules/whm_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -107,130 +107,127 @@ module subroutine whm_setup_set_ir3j(self)
class(whm_pl), intent(inout) :: self !! WHM massive body object
end subroutine whm_setup_set_ir3j

module subroutine whm_step_pl(self, cb, param, t, dt)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
module subroutine whm_step_pl(self, system, param, t, dt)
use swiftest_classes, only : swiftest_nbody_system, swiftest_parameters
implicit none
class(whm_pl), intent(inout) :: self !! WHM massive body object
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structure
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
real(DP), intent(in) :: t !! Current time
real(DP), intent(in) :: dt !! Stepsize
class(whm_pl), intent(inout) :: self !! WHM massive body object
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters of parameters
real(DP), intent(in) :: t !! Simulation time
real(DP), intent(in) :: dt !! Current stepsize
end subroutine whm_step_pl

!> Get heliocentric accelration of massive bodies
module subroutine whm_getacch_pl(self, cb, param, t)
module subroutine whm_getacch_pl(self, system, param, t)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
implicit none
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structure
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
real(DP), intent(in) :: t !! Current time
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(whm_nbody_system), intent(inout) :: system !! WHM nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
real(DP), intent(in) :: t !! Current simulation time
end subroutine whm_getacch_pl

module subroutine whm_drift_pl(self, cb, param, dt)
module subroutine whm_drift_pl(self, system, param, dt)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
implicit none
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structur
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
real(DP), intent(in) :: dt !! Stepsize
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(whm_nbody_system), intent(inout) :: system !! WHM nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
real(DP), intent(in) :: dt !! Stepsize
end subroutine whm_drift_pl

module subroutine whm_getacch_int_pl(self, cb)
use swiftest_classes, only : swiftest_cb
implicit none
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structure
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structure
end subroutine whm_getacch_int_pl

module subroutine whm_coord_h2j_pl(self, cb)
use swiftest_classes, only : swiftest_cb
implicit none
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
end subroutine whm_coord_h2j_pl

module subroutine whm_coord_j2h_pl(self, cb)
use swiftest_classes, only : swiftest_cb
implicit none
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
end subroutine whm_coord_j2h_pl

module subroutine whm_coord_vh2vj_pl(self, cb)
use swiftest_classes, only : swiftest_cb
implicit none
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
end subroutine whm_coord_vh2vj_pl

module subroutine whm_gr_getacch_pl(self, cb, param)
module subroutine whm_gr_getacch_pl(self, param)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
implicit none
class(whm_pl), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
end subroutine whm_gr_getacch_pl

module pure subroutine whm_gr_p4_pl(self, param, dt)
use swiftest_classes, only : swiftest_parameters
implicit none
class(whm_pl), intent(inout) :: self !! Swiftest particle object
class(whm_pl), intent(inout) :: self !! Swiftest particle object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of on parameters
real(DP), intent(in) :: dt !! Step size
real(DP), intent(in) :: dt !! Step size
end subroutine whm_gr_p4_pl

module pure subroutine whm_gr_vh2pv_pl(self, param)
use swiftest_classes, only : swiftest_parameters
implicit none
class(whm_pl), intent(inout) :: self !! Swiftest particle object
class(whm_pl), intent(inout) :: self !! Swiftest particle object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of on parameters
end subroutine whm_gr_vh2pv_pl

module pure subroutine whm_gr_pv2vh_pl(self, param)
use swiftest_classes, only : swiftest_parameters
implicit none
class(whm_pl), intent(inout) :: self !! Swiftest particle object
class(whm_pl), intent(inout) :: self !! Swiftest particle object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of on parameters
end subroutine whm_gr_pv2vh_pl

!> WHM test particle constructor
module subroutine whm_setup_tp(self,n)
implicit none
class(whm_tp), intent(inout) :: self !! WHM test particle data structure
integer, intent(in) :: n !! Number of test particles to allocate
class(whm_tp), intent(inout) :: self !! WHM test particle data structure
integer, intent(in) :: n !! Number of test particles to allocate
end subroutine whm_setup_tp

module subroutine whm_drift_tp(self, cb, param, dt)
module subroutine whm_drift_tp(self, system, param, dt)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
implicit none
class(whm_tp), intent(inout) :: self !! WHM test particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
class(whm_tp), intent(inout) :: self !! WHM test particle data structure
class(whm_nbody_system), intent(inout) :: system !! WHM nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
real(DP), intent(in) :: dt !! Stepsize
real(DP), intent(in) :: dt !! Stepsize
end subroutine whm_drift_tp

!> Get heliocentric accelration of the test particle
module subroutine whm_getacch_tp(self, cb, pl, param, t, xh)
module subroutine whm_getacch_tp(self, system, param, t, xh)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
implicit none
class(whm_tp), intent(inout) :: self !! WHM test particle data structure
class(swiftest_cb), intent(inout) :: cb !! Generic Swiftest central body particle data structuree
class(whm_pl), intent(inout) :: pl !! WHM massive body particle data structure.
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
class(whm_nbody_system), intent(inout) :: system !! WHM nbody system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
real(DP), intent(in) :: t !! Current time
real(DP), dimension(:,:), intent(in) :: xh !! Heliocentric positions of planets
end subroutine whm_getacch_tp

module subroutine whm_step_tp(self, cb, pl, param, t, dt)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
module subroutine whm_step_tp(self, system, param, t, dt)
use swiftest_classes, only : swiftest_nbody_system, swiftest_parameters
implicit none
class(whm_tp), intent(inout) :: self !! WHM test particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structure
class(whm_pl), intent(inout) :: pl !! WHM massive body data structure
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
real(DP), intent(in) :: t !! Current time
real(DP), intent(in) :: dt !! Stepsize
class(whm_tp), intent(inout) :: self !! WHM test particle data structure
class(swiftest_nbody_system), intent(inout) :: system !! Swiftest central body particle data structure
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters of
real(DP), intent(in) :: t !! Current simulation time
real(DP), intent(in) :: dt !! Stepsize
end subroutine whm_step_tp

module subroutine whm_setup_set_beg_end(self, xbeg, xend, vbeg)
Expand All @@ -240,26 +237,25 @@ module subroutine whm_setup_set_beg_end(self, xbeg, xend, vbeg)
real(DP), dimension(:,:), intent(in), optional :: vbeg ! vbeg is an unused variable to keep this method forward compatible with RMVS
end subroutine whm_setup_set_beg_end

module subroutine whm_gr_getacch_tp(self, cb, param)
module subroutine whm_gr_getacch_tp(self, param)
use swiftest_classes, only : swiftest_cb, swiftest_parameters
implicit none
class(whm_tp), intent(inout) :: self !! WHM massive body particle data structure
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structuree
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of
end subroutine whm_gr_getacch_tp

module pure subroutine whm_gr_p4_tp(self, param, dt)
use swiftest_classes, only : swiftest_parameters
implicit none
class(whm_tp), intent(inout) :: self !! Swiftest particle object
class(whm_tp), intent(inout) :: self !! Swiftest particle object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of on parameters
real(DP), intent(in) :: dt !! Step size
real(DP), intent(in) :: dt !! Step size
end subroutine whm_gr_p4_tp

module pure subroutine whm_gr_vh2pv_tp(self, param)
use swiftest_classes, only : swiftest_parameters
implicit none
class(whm_tp), intent(inout) :: self !! Swiftest particle object
class(whm_tp), intent(inout) :: self !! Swiftest particle object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of on parameters
end subroutine whm_gr_vh2pv_tp

Expand Down Expand Up @@ -294,11 +290,13 @@ module subroutine whm_fill_pl(self, inserts, lfill_list)
end subroutine whm_fill_pl

!> Steps the Swiftest nbody system forward in time one stepsize
module subroutine whm_step_system(self, param)
module subroutine whm_step_system(self, param, t, dt)
use swiftest_classes, only : swiftest_parameters
implicit none
class(whm_nbody_system), intent(inout) :: self !! WHM system object
class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of on parameters
class(whm_nbody_system), intent(inout) :: self !! WHM system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters of parameters
real(DP), intent(in) :: t !! Simulation time
real(DP), intent(in) :: dt !! Current stepsize
end subroutine whm_step_system
end interface

Expand Down
Loading

0 comments on commit 8f4e883

Please sign in to comment.