diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index 0094782fd..6bd9a442b 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -17,7 +17,6 @@ module swiftest_classes public :: orbel_el2xv_vec, orbel_xv2el_vec, orbel_scget, orbel_xv2aeq, orbel_xv2aqt public :: setup_body, setup_construct_system, setup_pl, setup_set_ir3h, setup_set_msys, setup_set_mu_pl, setup_set_mu_tp, & setup_set_rhill, setup_tp - public :: user_getacch_body public :: util_coord_b2h_pl, util_coord_b2h_tp, util_coord_h2b_pl, util_coord_h2b_tp, util_copy_body, util_copy_cb, util_copy_pl, & util_copy_tp, util_copy_system, util_fill_body, util_fill_pl, util_fill_tp, util_reverse_status, util_set_beg_end, & util_spill_body, util_spill_pl, util_spill_tp @@ -161,6 +160,7 @@ module swiftest_classes procedure(abstract_discard_body), public, deferred :: discard procedure(abstract_set_mu), public, deferred :: set_mu procedure(abstract_step_body), public, deferred :: step + procedure(abstract_get_accel), public, deferred :: get_accel ! These are concrete because the implementation is the same for all types of particles procedure, public :: initialize => io_read_body_in !! Read in body initial conditions from a file procedure, public :: read_frame => io_read_frame_body !! I/O routine for writing out a single frame of time-series data for the central body @@ -171,7 +171,6 @@ module swiftest_classes procedure, public :: xv2el => orbel_xv2el_vec !! Convert position and velocity vectors to orbital elements procedure, public :: set_ir3 => setup_set_ir3h !! Sets the inverse heliocentric radius term (1/rh**3) procedure, public :: setup => setup_body !! A constructor that sets the number of bodies and allocates all allocatable arrays - procedure, public :: user_getacch => user_getacch_body !! Base user-defined acceleration subroutine procedure, public :: copy => util_copy_body !! Copies elements of one object to another. procedure, public :: fill => util_fill_body !! "Fills" bodies from one object into another depending on the results of a mask (uses the MERGE intrinsic) procedure, public :: spill => util_spill_body !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic) @@ -289,36 +288,45 @@ end subroutine abstract_copy subroutine abstract_discard_body(self, system, param) import swiftest_body, swiftest_nbody_system, swiftest_parameters - class(swiftest_body), intent(inout) :: self !! Swiftest particle object + class(swiftest_body), intent(inout) :: self !! Swiftest body object class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters end subroutine abstract_discard_body + subroutine abstract_get_accel(self, system, param, t) + use swiftest_classes, only : swiftest_body, swifest_nbody_system, swiftest_parameters + implicit none + class(swiftest_body), intent(inout) :: self !! Swiftest body data structure + class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object + class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of + real(DP), intent(in) :: t !! Current simulation time + end subroutine abstract_get_accel + subroutine abstract_initialize(self, param) import swiftest_base, swiftest_parameters class(swiftest_base), intent(inout) :: self !! Swiftest base object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine abstract_initialize subroutine abstract_read_frame(self, iu, param, form, ierr) import DP, I4B, swiftest_base, swiftest_parameters - class(swiftest_base), intent(inout) :: self !! Swiftest base object - integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - character(*), intent(in) :: form !! Input format code ("XV" or "EL") - integer(I4B), intent(out) :: ierr !! Error code + class(swiftest_base), intent(inout) :: self !! Swiftest base object + integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + character(*), intent(in) :: form !! Input format code ("XV" or "EL") + integer(I4B), intent(out) :: ierr !! Error code end subroutine abstract_read_frame subroutine abstract_set_mu(self, cb) import swiftest_body, swiftest_cb - class(swiftest_body), intent(inout) :: self !! Swiftest particle object + class(swiftest_body), intent(inout) :: self !! Swiftest body object class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object end subroutine abstract_set_mu subroutine abstract_step_body(self, system, param, t, dt) import DP, swiftest_body, swiftest_nbody_system, swiftest_parameters implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest particle object + class(swiftest_body), intent(inout) :: self !! Swiftest body object class(swiftest_nbody_system), intent(inout) :: system !! Swiftest system object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters real(DP), intent(in) :: t !! Simulation time @@ -438,7 +446,7 @@ end subroutine io_param_writer module subroutine io_read_body_in(self, param) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest particle object + class(swiftest_body), intent(inout) :: self !! Swiftest body object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine io_read_body_in @@ -450,48 +458,47 @@ end subroutine io_read_cb_in module subroutine io_read_param_in(self, param_file_name) implicit none - class(swiftest_parameters), intent(out) :: self !! Current run configuration parameters + class(swiftest_parameters), intent(out) :: self !! Current run configuration parameters character(len=*), intent(in) :: param_file_name !! Parameter input file name (i.e. param.in) end subroutine io_read_param_in module subroutine io_read_frame_body(self, iu, param, form, ierr) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest particle object - integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to + class(swiftest_body), intent(inout) :: self !! Swiftest body object + integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - character(*), intent(in) :: form !! Input format code ("XV" or "EL") - integer(I4B), intent(out) :: ierr !! Error code + character(*), intent(in) :: form !! Input format code ("XV" or "EL") + integer(I4B), intent(out) :: ierr !! Error code end subroutine io_read_frame_body module subroutine io_read_frame_cb(self, iu, param, form, ierr) implicit none - class(swiftest_cb), intent(inout) :: self !! Swiftest central body object - integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to + class(swiftest_cb), intent(inout) :: self !! Swiftest central body object + integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - character(*), intent(in) :: form !! Input format code ("XV" or "EL") - integer(I4B), intent(out) :: ierr !! Error code + character(*), intent(in) :: form !! Input format code ("XV" or "EL") + integer(I4B), intent(out) :: ierr !! Error code end subroutine io_read_frame_cb module subroutine io_read_frame_system(self, iu, param, form, ierr) implicit none - class(swiftest_nbody_system),intent(inout) :: self !! Swiftest system object - integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to + class(swiftest_nbody_system),intent(inout) :: self !! Swiftest system object + integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - character(*), intent(in) :: form !! Input format code ("XV" or "EL") - integer(I4B), intent(out) :: ierr !! Error code + character(*), intent(in) :: form !! Input format code ("XV" or "EL") + integer(I4B), intent(out) :: ierr !! Error code end subroutine io_read_frame_system module subroutine io_read_initialize_system(self, param) implicit none - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine io_read_initialize_system module subroutine io_write_discard(self, param) implicit none - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object - class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters - !class(swiftest_body), intent(inout) :: discards !! Swiftest discard object + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object + class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters end subroutine io_write_discard module subroutine io_write_encounter(t, name1, name2, mass1, mass2, radius1, radius2, & @@ -505,40 +512,42 @@ end subroutine io_write_encounter module subroutine io_write_frame_body(self, iu, param) implicit none - class(swiftest_body), intent(in) :: self !! Swiftest particle object - integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to + class(swiftest_body), intent(in) :: self !! Swiftest body object + integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters end subroutine io_write_frame_body module subroutine io_write_frame_cb(self, iu, param) implicit none - class(swiftest_cb), intent(in) :: self !! Swiftest central body object - integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to + class(swiftest_cb), intent(in) :: self !! Swiftest central body object + integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters end subroutine io_write_frame_cb module subroutine io_write_frame_system(self, iu, param) implicit none - class(swiftest_nbody_system), intent(in) :: self !! Swiftest system object - integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to + class(swiftest_nbody_system), intent(in) :: self !! Swiftest system object + integer(I4B), intent(inout) :: iu !! Unit number for the output file to write frame to class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters end subroutine io_write_frame_system module subroutine kickvh_body(self, dt) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest generic body object + class(swiftest_body), intent(inout) :: self !! Swiftest body object real(DP), intent(in) :: dt !! Stepsize end subroutine kickvh_body - module subroutine obl_acc_body(self, cb) + module subroutine obl_acc_body(self, system, param, t) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest generic body object - class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object + class(swiftest_body), intent(inout) :: self !! Swiftest massive body data structure + class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object + class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of + real(DP), intent(in) :: t !! Current simulation time end subroutine obl_acc_body module subroutine orbel_el2xv_vec(self, cb) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest generic body object + class(swiftest_body), intent(inout) :: self !! Swiftest body object class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object end subroutine orbel_el2xv_vec @@ -564,181 +573,173 @@ end subroutine orbel_xv2aqt module subroutine orbel_xv2el_vec(self, cb) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest generic body object - class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object + class(swiftest_body), intent(inout) :: self !! Swiftest body object + class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object end subroutine orbel_xv2el_vec module subroutine setup_body(self,n) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest generic body object - integer, intent(in) :: n !! Number of particles to allocate space for + class(swiftest_body), intent(inout) :: self !! Swiftest body object + integer, intent(in) :: n !! Number of particles to allocate space for end subroutine setup_body module subroutine setup_construct_system(system, param) implicit none - class(swiftest_nbody_system), allocatable, intent(inout) :: system !! Swiftest system object - type(swiftest_parameters), intent(in) :: param !! Swiftest parameters + class(swiftest_nbody_system), allocatable, intent(inout) :: system !! Swiftest system object + type(swiftest_parameters), intent(in) :: param !! Swiftest parameters end subroutine setup_construct_system module subroutine setup_pl(self,n) implicit none - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - integer, intent(in) :: n !! Number of massive bodies to allocate space for + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object + integer, intent(in) :: n !! Number of massive bodies to allocate space for end subroutine setup_pl module subroutine setup_set_ir3h(self) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest generic body object + class(swiftest_body), intent(inout) :: self !! Swiftest body object end subroutine setup_set_ir3h module subroutine setup_set_msys(self) implicit none - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest system object end subroutine setup_set_msys module subroutine setup_set_mu_pl(self, cb) implicit none - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object + class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object end subroutine setup_set_mu_pl module subroutine setup_set_mu_tp(self, cb) implicit none - class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object + class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object end subroutine setup_set_mu_tp module subroutine setup_set_rhill(self,cb) implicit none - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - class(swiftest_cb), intent(inout) :: cb !! Swiftest massive body object + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object + class(swiftest_cb), intent(inout) :: cb !! Swiftest massive body object end subroutine setup_set_rhill module subroutine setup_tp(self, n) implicit none - class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - integer, intent(in) :: n !! Number of bodies to allocate space for + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object + integer, intent(in) :: n !! Number of bodies to allocate space for end subroutine setup_tp - module subroutine user_getacch_body(self, system, param, t) - implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest massive body particle data structure - class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nobody system object - class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters of - real(DP), intent(in) :: t !! Current time - end subroutine user_getacch_body - module subroutine util_coord_b2h_pl(self, cb) implicit none - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object + class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object end subroutine util_coord_b2h_pl module subroutine util_coord_b2h_tp(self, cb) implicit none - class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - class(swiftest_cb), intent(in) :: cb !! Swiftest central body object + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object + class(swiftest_cb), intent(in) :: cb !! Swiftest central body object end subroutine util_coord_b2h_tp module subroutine util_coord_h2b_pl(self, cb) implicit none - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object + class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object end subroutine util_coord_h2b_pl module subroutine util_coord_h2b_tp(self, cb) implicit none - class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - class(swiftest_cb), intent(in) :: cb !! Swiftest central body object + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object + class(swiftest_cb), intent(in) :: cb !! Swiftest central body object end subroutine util_coord_h2b_tp module subroutine util_copy_body(self, src, mask) implicit none - class(swiftest_body), intent(inout) :: self - class(swiftest_base), intent(in) :: src - logical, dimension(:), intent(in) :: mask + class(swiftest_body), intent(inout) :: self !! Swiftest body object to copy into + class(swiftest_base), intent(in) :: src !! Swiftest base object to copy from + logical, dimension(:), intent(in) :: mask !! Mask of elements in src object to copy into self end subroutine util_copy_body module subroutine util_copy_cb(self, src, mask) implicit none - class(swiftest_cb), intent(inout) :: self - class(swiftest_base), intent(in) :: src - logical, dimension(:), intent(in) :: mask + class(swiftest_cb), intent(inout) :: self !! Swiftest central body object to copy into + class(swiftest_base), intent(in) :: src !! Swiftest base object to copy from + logical, dimension(:), intent(in) :: mask !! Mask of elements in src object to copy into selfk end subroutine util_copy_cb module subroutine util_copy_pl(self, src, mask) implicit none - class(swiftest_pl), intent(inout) :: self - class(swiftest_base), intent(in) :: src - logical, dimension(:), intent(in) :: mask + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object to copy into + class(swiftest_base), intent(in) :: src !! Swiftest base object to copy from + logical, dimension(:), intent(in) :: mask !! Mask of elements in src object to copy into self end subroutine util_copy_pl module subroutine util_copy_tp(self, src, mask) implicit none - class(swiftest_tp), intent(inout) :: self - class(swiftest_base), intent(in) :: src - logical, dimension(:), intent(in) :: mask + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object to copy into + class(swiftest_base), intent(in) :: src !! Swiftest base object to copy from + logical, dimension(:), intent(in) :: mask !! Mask of elements in src object to copy into self end subroutine util_copy_tp module subroutine util_copy_system(self, src, mask) implicit none - class(swiftest_nbody_system), intent(inout) :: self - class(swiftest_base), intent(in) :: src - logical, dimension(:), intent(in) :: mask + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object to copy into + class(swiftest_base), intent(in) :: src !! Swiftest base object to copy from + logical, dimension(:), intent(in) :: mask !! Mask of elements in src object to copy into self end subroutine util_copy_system module subroutine util_fill_body(self, inserts, lfill_list) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest generic body object - class(swiftest_body), intent(inout) :: inserts !! Insertted object - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps + class(swiftest_body), intent(inout) :: self !! Swiftest body object + class(swiftest_body), intent(inout) :: inserts !! Swiftest body object to be inserted + logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps end subroutine util_fill_body module subroutine util_fill_pl(self, inserts, lfill_list) implicit none class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - class(swiftest_body), intent(inout) :: inserts !! Inserted object + class(swiftest_body), intent(inout) :: inserts !! Swiftest body object to be inserted logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps end subroutine util_fill_pl module subroutine util_fill_tp(self, inserts, lfill_list) implicit none - class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - class(swiftest_body), intent(inout) :: inserts !! Inserted object + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object + class(swiftest_body), intent(inout) :: inserts !! Swiftest body object to be inserted logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps end subroutine util_fill_tp module subroutine util_reverse_status(self) implicit none - class(swiftest_body), intent(inout) :: self + class(swiftest_body), intent(inout) :: self !! Swiftest body object end subroutine util_reverse_status module subroutine util_set_beg_end(self, xbeg, xend, vbeg) implicit none - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object real(DP), dimension(:,:), intent(in), optional :: xbeg, xend !! Positions at beginning and end of step real(DP), dimension(:,:), intent(in), optional :: vbeg !! vbeg is an unused variable to keep this method forward compatible with RMVS end subroutine util_set_beg_end module subroutine util_spill_body(self, discards, lspill_list) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest generic body object + class(swiftest_body), intent(inout) :: self !! Swiftest body object class(swiftest_body), intent(inout) :: discards !! Discarded object logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards end subroutine util_spill_body module subroutine util_spill_pl(self, discards, lspill_list) implicit none - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body body object + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_body), intent(inout) :: discards !! Discarded object logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards end subroutine util_spill_pl module subroutine util_spill_tp(self, discards, lspill_list) implicit none - class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - class(swiftest_body), intent(inout) :: discards !! Discarded object - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object + class(swiftest_body), intent(inout) :: discards !! Discarded object + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards end subroutine util_spill_tp end interface