From 90d41835c6dc0e7c98464231773ae367cb152b77 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Tue, 13 Jul 2021 12:03:15 -0400 Subject: [PATCH] Added placeholder system spin stepper method. Verified that the WHM, RMVS, and Helio examples still work correctly. --- .../swiftest_rmvs_vs_swifter_rmvs.ipynb | 4 +- .../whm_swifter_comparison/cb.swiftest.in | 1 + examples/whm_swifter_comparison/pl.swifter.in | 48 +++++++++---------- .../whm_swifter_comparison/pl.swiftest.in | 32 ++++++------- examples/whm_swifter_comparison/tp.swifter.in | 16 +++---- .../whm_swifter_comparison/tp.swiftest.in | 16 +++---- src/helio/helio_step.f90 | 14 +++--- src/modules/helio_classes.f90 | 19 ++++---- src/modules/swiftest_classes.f90 | 17 +++++-- src/rmvs/rmvs_step.f90 | 1 + src/tides/tides_spin_step.f90 | 15 ++++++ src/whm/whm_step.f90 | 2 + 12 files changed, 106 insertions(+), 79 deletions(-) create mode 100644 src/tides/tides_spin_step.f90 diff --git a/examples/rmvs_swifter_comparison/9pl_18tp_encounters/swiftest_rmvs_vs_swifter_rmvs.ipynb b/examples/rmvs_swifter_comparison/9pl_18tp_encounters/swiftest_rmvs_vs_swifter_rmvs.ipynb index c6bb630b2..973a1d8c1 100644 --- a/examples/rmvs_swifter_comparison/9pl_18tp_encounters/swiftest_rmvs_vs_swifter_rmvs.ipynb +++ b/examples/rmvs_swifter_comparison/9pl_18tp_encounters/swiftest_rmvs_vs_swifter_rmvs.ipynb @@ -622,7 +622,7 @@ " 1.17040422e-11])\n", "Coordinates:\n", " id int64 2\n", - " * time (d) (time (d)) float64 0.0 11.0 22.0 ... 3.63e+03 3.641e+03 3.652e+03
    • id
      ()
      int64
      2
      array(2)
    • time (d)
      (time (d))
      float64
      0.0 11.0 ... 3.641e+03 3.652e+03
      array([   0.,   11.,   22., ..., 3630., 3641., 3652.])
  • " ], "text/plain": [ "\n", diff --git a/examples/whm_swifter_comparison/cb.swiftest.in b/examples/whm_swifter_comparison/cb.swiftest.in index 058975b81..e4a010b1e 100644 --- a/examples/whm_swifter_comparison/cb.swiftest.in +++ b/examples/whm_swifter_comparison/cb.swiftest.in @@ -1,3 +1,4 @@ +0 39.476926408897626 0.004650467260962157 4.7535806948127355e-12 diff --git a/examples/whm_swifter_comparison/pl.swifter.in b/examples/whm_swifter_comparison/pl.swifter.in index 7412144e0..e0ef4e881 100644 --- a/examples/whm_swifter_comparison/pl.swifter.in +++ b/examples/whm_swifter_comparison/pl.swifter.in @@ -2,35 +2,35 @@ 0 39.476926408897625196 0.0 0.0 0.0 0.0 0.0 0.0 -1 6.5537098095653139645e-06 0.0014751253039664285066 +1 6.5537098095653139645e-06 0.0014751243077781048702 1.6306381826061645943e-05 -0.36019833403308620934 -0.07157757063116521046 -0.038889932331457412185 -0.012062683987023428416 10.539199589223686515 0.86012493216791845955 -2 9.663313399581537916e-05 0.006759112363391176217 +0.33206272695596028566 0.07436707001147663254 -0.02438290851908785084 +-4.2340114788918336805 10.486553514018327622 1.2453138107251555947 +2 9.663313399581537916e-05 0.006759104275397271956 4.0453784346544178454e-05 --0.71276554591539231787 0.0894943770131735733 0.042358444034962597358 --0.96047232050779632014 -7.363179644470093107 -0.045627977257453471387 -3 0.000120026935827952453094 0.010044757472678654026 +-0.7188115337296047125 -0.0118554711069603201795 0.041316403191083782287 +0.07826338813583945357 -7.419533988988633545 -0.10634201014368884618 +3 0.000120026935827952453094 0.010044787321379672528 4.25875607065040958e-05 -0.27645830888837641393 -0.97837771886398083865 4.5542715832163949185e-05 -5.9448497026859876977 1.6852493323830119935 -9.895818943662129852e-05 -4 1.2739802010675941456e-05 0.007246754169100752911 +0.35677088372527121507 -0.95189300879814897627 4.4027442504036787155e-05 +5.7819217550992820422 2.18192814489641851 -0.00012230072278352209966 +4 1.2739802010675941456e-05 0.007246743835971885302 2.265740805092889601e-05 --1.4965217056830220077 0.729867855162097956 0.052005223740499352536 --2.049353987860530548 -4.1577626275819368415 -0.03686191825212072444 -5 0.037692251088985676735 0.3552713962079929143 +-1.5233712071242269115 0.6723825347339112968 0.051459143378398922164 +-1.8728417739956807141 -4.239719661832373223 -0.042909557750301418264 +5 0.037692251088985676735 0.35527126534549128905 0.00046732617030490929307 -4.027841704615886087 -3.0231618001306270749 -0.077559557972985263 -1.6231826570873460391 2.3366237981055781438 -0.046019759896080974796 -6 0.011285899820091272997 0.43765160695836118215 +4.049944927347420176 -2.9910878677758190314 -0.078187280837353656526 +1.6060801375519682711 2.349356876761497338 -0.045690062807172619064 +6 0.011285899820091272997 0.4376527512949726007 0.00038925687730393611812 -6.2788354074558432316 -7.724005035333701308 -0.11559390097316769863 -1.4696075442034620881 1.282966226939726742 -0.08077393754283409384 -7 0.0017236589478267730203 0.4695227539643713788 +6.298929503477405767 -7.706413024510769816 -0.11669919842191249504 +1.4661378456572359413 1.2872251175075805794 -0.08070991686100478242 +7 0.0017236589478267730203 0.4695362423191493196 0.00016953449859497231466 -14.869154031353570389 12.9936724365634095335 -0.1443982771709022006 --0.95437109658589562686 1.0170745961532793757 0.016089151184688745742 -8 0.0020336100526728302319 0.78127049251990261927 +14.856082147529010129 13.007589275314199284 -0.14417795763685259391 +-0.9554310497290159123 1.0161753499437922057 0.016099529164307530124 +8 0.0020336100526728302319 0.7812870996943599397 0.000164587904124493665 -29.55509611047864027 -4.6450138458072487424 -0.585533781429422695 -0.17223467348300621534 1.1421766618084267115 -0.027457548207218328868 +29.55744967800954015 -4.629377558152945049 -0.58590957207831262377 +0.17162147939801157335 1.1422848961108499101 -0.027445465472921385952 diff --git a/examples/whm_swifter_comparison/pl.swiftest.in b/examples/whm_swifter_comparison/pl.swiftest.in index e144eae8f..9d49cc3da 100644 --- a/examples/whm_swifter_comparison/pl.swiftest.in +++ b/examples/whm_swifter_comparison/pl.swiftest.in @@ -1,33 +1,33 @@ 8 1 6.5537098095653139645e-06 1.6306381826061645943e-05 -0.36019833403308620934 -0.07157757063116521046 -0.038889932331457412185 -0.012062683987023428416 10.539199589223686515 0.86012493216791845955 +0.33206272695596028566 0.07436707001147663254 -0.02438290851908785084 +-4.2340114788918336805 10.486553514018327622 1.2453138107251555947 2 9.663313399581537916e-05 4.0453784346544178454e-05 --0.71276554591539231787 0.0894943770131735733 0.042358444034962597358 --0.96047232050779632014 -7.363179644470093107 -0.045627977257453471387 +-0.7188115337296047125 -0.0118554711069603201795 0.041316403191083782287 +0.07826338813583945357 -7.419533988988633545 -0.10634201014368884618 3 0.000120026935827952453094 4.25875607065040958e-05 -0.27645830888837641393 -0.97837771886398083865 4.5542715832163949185e-05 -5.9448497026859876977 1.6852493323830119935 -9.895818943662129852e-05 +0.35677088372527121507 -0.95189300879814897627 4.4027442504036787155e-05 +5.7819217550992820422 2.18192814489641851 -0.00012230072278352209966 4 1.2739802010675941456e-05 2.265740805092889601e-05 --1.4965217056830220077 0.729867855162097956 0.052005223740499352536 --2.049353987860530548 -4.1577626275819368415 -0.03686191825212072444 +-1.5233712071242269115 0.6723825347339112968 0.051459143378398922164 +-1.8728417739956807141 -4.239719661832373223 -0.042909557750301418264 5 0.037692251088985676735 0.00046732617030490929307 -4.027841704615886087 -3.0231618001306270749 -0.077559557972985263 -1.6231826570873460391 2.3366237981055781438 -0.046019759896080974796 +4.049944927347420176 -2.9910878677758190314 -0.078187280837353656526 +1.6060801375519682711 2.349356876761497338 -0.045690062807172619064 6 0.011285899820091272997 0.00038925687730393611812 -6.2788354074558432316 -7.724005035333701308 -0.11559390097316769863 -1.4696075442034620881 1.282966226939726742 -0.08077393754283409384 +6.298929503477405767 -7.706413024510769816 -0.11669919842191249504 +1.4661378456572359413 1.2872251175075805794 -0.08070991686100478242 7 0.0017236589478267730203 0.00016953449859497231466 -14.869154031353570389 12.9936724365634095335 -0.1443982771709022006 --0.95437109658589562686 1.0170745961532793757 0.016089151184688745742 +14.856082147529010129 13.007589275314199284 -0.14417795763685259391 +-0.9554310497290159123 1.0161753499437922057 0.016099529164307530124 8 0.0020336100526728302319 0.000164587904124493665 -29.55509611047864027 -4.6450138458072487424 -0.585533781429422695 -0.17223467348300621534 1.1421766618084267115 -0.027457548207218328868 +29.55744967800954015 -4.629377558152945049 -0.58590957207831262377 +0.17162147939801157335 1.1422848961108499101 -0.027445465472921385952 diff --git a/examples/whm_swifter_comparison/tp.swifter.in b/examples/whm_swifter_comparison/tp.swifter.in index a9fa06f46..b37f04011 100644 --- a/examples/whm_swifter_comparison/tp.swifter.in +++ b/examples/whm_swifter_comparison/tp.swifter.in @@ -1,13 +1,13 @@ 4 101 -2.3071617894844269614 1.6438449758645010679 -0.37312906258436789875 --2.256588666826445461 2.8302735208962828827 0.50519430783805206563 +2.2759060918449769417 1.6823262546111898974 -0.3661544509052930274 +-2.3097811686367798667 2.7916683305060454227 0.51377483806222698173 102 -3.011471099377928784 -1.1061264985150089935 0.5067865823770466571 -0.69505215270382913404 2.5183263418638507098 -1.8031340524448678953 +3.0206599411327550442 -1.0715345879373190385 0.4820489106686373093 +0.64736314289225124926 2.5354787229381968757 -1.8109825958052419904 103 --0.51350730399144917104 -3.139963346661017951 0.7339670445581878422 -3.0598116277417892524 -0.1107568728194456082 -0.09922455469700767241 +-0.47156753362343428737 -3.1411451968218520037 0.73253063903937232215 +3.067486522793096946 -0.061867034122113133084 -0.11064022385054755856 104 --2.070517783632789044 -0.7764919020604850175 0.27514297675486260042 -1.7817875607764876778 -3.94088558602991294 -0.09896621676031464546 +-2.0454358521790818592 -0.83017357434175576003 0.27369621627497042748 +1.8825682786003801814 -3.9015333153827542793 -0.112405737336568095776 diff --git a/examples/whm_swifter_comparison/tp.swiftest.in b/examples/whm_swifter_comparison/tp.swiftest.in index a9fa06f46..b37f04011 100644 --- a/examples/whm_swifter_comparison/tp.swiftest.in +++ b/examples/whm_swifter_comparison/tp.swiftest.in @@ -1,13 +1,13 @@ 4 101 -2.3071617894844269614 1.6438449758645010679 -0.37312906258436789875 --2.256588666826445461 2.8302735208962828827 0.50519430783805206563 +2.2759060918449769417 1.6823262546111898974 -0.3661544509052930274 +-2.3097811686367798667 2.7916683305060454227 0.51377483806222698173 102 -3.011471099377928784 -1.1061264985150089935 0.5067865823770466571 -0.69505215270382913404 2.5183263418638507098 -1.8031340524448678953 +3.0206599411327550442 -1.0715345879373190385 0.4820489106686373093 +0.64736314289225124926 2.5354787229381968757 -1.8109825958052419904 103 --0.51350730399144917104 -3.139963346661017951 0.7339670445581878422 -3.0598116277417892524 -0.1107568728194456082 -0.09922455469700767241 +-0.47156753362343428737 -3.1411451968218520037 0.73253063903937232215 +3.067486522793096946 -0.061867034122113133084 -0.11064022385054755856 104 --2.070517783632789044 -0.7764919020604850175 0.27514297675486260042 -1.7817875607764876778 -3.94088558602991294 -0.09896621676031464546 +-2.0454358521790818592 -0.83017357434175576003 0.27369621627497042748 +1.8825682786003801814 -3.9015333153827542793 -0.112405737336568095776 diff --git a/src/helio/helio_step.f90 b/src/helio/helio_step.f90 index 8557477f7..d37b21bbb 100644 --- a/src/helio/helio_step.f90 +++ b/src/helio/helio_step.f90 @@ -1,10 +1,14 @@ submodule(helio_classes) s_helio_step use swiftest contains + module subroutine helio_step_system(self, param, t, dt) !! author: David A. Minton !! - !! Step massive bodies and and active test particles ahead in heliocentric coordinates + !! Step massive bodies and and active test particles ahead in heliocentric coordinates. + !! + !! Currently there's no difference between this and the WHM system stepper, so this is just + !! a wrapper function to keep the method calls consistent for inherited types. !! !! Adapted from Hal Levison's Swift routine step_kdk.f !! Adapted from David E. Kaufmann's Swifter routine helio_step.f90 @@ -14,13 +18,7 @@ module subroutine helio_step_system(self, param, t, dt) class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters real(DP), intent(in) :: t !! Simulation time real(DP), intent(in) :: dt !! Current stepsize - - associate(system => self, cb => self%cb, pl => self%pl, tp => self%tp) - tp%lfirst = pl%lfirst - call pl%set_rhill(cb) - call pl%step(system, param, t, dt) - call tp%step(system, param, t, dt) - end associate + call whm_step_system(self, param, t, dt) return end subroutine helio_step_system diff --git a/src/modules/helio_classes.f90 b/src/modules/helio_classes.f90 index b7bdf826c..190c354b7 100644 --- a/src/modules/helio_classes.f90 +++ b/src/modules/helio_classes.f90 @@ -14,6 +14,7 @@ module helio_classes !******************************************************************************************************************************** type, public, extends(whm_nbody_system) :: helio_nbody_system contains + procedure, public :: step => helio_step_system !! Advance the Helio nbody system forward in time by one step end type helio_nbody_system !******************************************************************************************************************************** @@ -151,15 +152,6 @@ module subroutine helio_kickvb_tp(self, dt) real(DP), intent(in) :: dt !! Stepsize end subroutine helio_kickvb_tp - module subroutine helio_step_system(self, param, t, dt) - use swiftest_classes, only : swiftest_parameters - implicit none - class(helio_nbody_system), intent(inout) :: self !! Helio nbody system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! Simulation time - real(DP), intent(in) :: dt !! Current stepsize - end subroutine helio_step_system - module subroutine helio_step_pl(self, system, param, t, dt) use swiftest_classes, only : swiftest_nbody_system, swiftest_parameters implicit none @@ -170,6 +162,15 @@ module subroutine helio_step_pl(self, system, param, t, dt) real(DP), intent(in) :: dt !! Stepsize end subroutine helio_step_pl + module subroutine helio_step_system(self, param, t, dt) + use swiftest_classes, only : swiftest_parameters + implicit none + class(helio_nbody_system), intent(inout) :: self !! Helio nbody system object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! Simulation time + real(DP), intent(in) :: dt !! Current stepsize + end subroutine helio_step_system + module subroutine helio_step_tp(self, system, param, t, dt) use swiftest_classes, only : swiftest_cb, swiftest_parameters, swiftest_nbody_system implicit none diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index 59b1ddac0..63af68fe8 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -17,7 +17,7 @@ module swiftest_classes public :: obl_acc_body, obl_acc_pl, obl_acc_tp public :: orbel_el2xv_vec, orbel_xv2el_vec, orbel_scget, orbel_xv2aeq, orbel_xv2aqt public :: setup_body, setup_construct_system, setup_pl, setup_tp - public :: tides_getacch_pl + public :: tides_getacch_pl, tides_step_spin_system public :: user_getacch_body public :: util_coord_b2h_pl, util_coord_b2h_tp, util_coord_h2b_pl, util_coord_h2b_tp, util_exit, util_fill_body, util_fill_pl, util_fill_tp, & util_index, util_peri_tp, util_reverse_status, util_set_beg_end_cb, util_set_beg_end_pl, util_set_ir3h, util_set_msys, util_set_mu_pl, & @@ -286,9 +286,10 @@ module swiftest_classes procedure, public :: dump => io_dump_system !! Dump the state of the system to a file procedure, public :: initialize => io_read_initialize_system !! Initialize the system from an input file procedure, public :: read_frame => io_read_frame_system !! Append a frame of output data to file - procedure, public :: set_msys => util_set_msys !! Sets the value of msys from the masses of system bodies. procedure, public :: write_discard => io_write_discard !! Append a frame of output data to file procedure, public :: write_frame => io_write_frame_system !! Append a frame of output data to file + procedure, public :: step_spin => tides_step_spin_system !! Steps the spins of the massive & central bodies due to tides. + procedure, public :: set_msys => util_set_msys !! Sets the value of msys from the masses of system bodies. end type swiftest_nbody_system abstract interface @@ -682,11 +683,19 @@ module subroutine tides_getacch_pl(self, system) class(swiftest_nbody_system), intent(inout) :: system !! Swiftest nbody system object end subroutine tides_getacch_pl + module subroutine tides_step_spin_system(self, param, t, dt) + implicit none + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object + class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! Simulation time + real(DP), intent(in) :: dt !! Current stepsize + end subroutine tides_step_spin_system + module subroutine user_getacch_body(self, system, param, t, lbeg) implicit none class(swiftest_body), intent(inout) :: self !! Swiftest 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 of user parameters + 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 user_getacch_body @@ -744,7 +753,7 @@ end subroutine util_fill_tp module subroutine util_index(arr, index) implicit none integer(I4B), dimension(:), intent(out) :: index - real(DP), dimension(:), intent(in) :: arr + real(DP), dimension(:), intent(in) :: arr end subroutine util_index module subroutine util_peri_tp(self, system, param) diff --git a/src/rmvs/rmvs_step.f90 b/src/rmvs/rmvs_step.f90 index bb6c0d843..c3aa9dd8b 100644 --- a/src/rmvs/rmvs_step.f90 +++ b/src/rmvs/rmvs_step.f90 @@ -50,6 +50,7 @@ module subroutine rmvs_step_system(self, param, t, dt) where (tp%status(:) == INACTIVE) tp%status(:) = ACTIVE pl%lfirst = lfirstpl tp%lfirst = lfirsttp + if (param%ltides) call system%step_spin(param, t, dt) else call whm_step_system(system, param, t, dt) end if diff --git a/src/tides/tides_spin_step.f90 b/src/tides/tides_spin_step.f90 new file mode 100644 index 000000000..52f2bae0f --- /dev/null +++ b/src/tides/tides_spin_step.f90 @@ -0,0 +1,15 @@ +submodule(swiftest_classes) s_tides_step_spin + use swiftest +contains + module subroutine tides_step_spin_system(self, param, t, dt) + !! author: Jennifer L.L. Pouplin and David A. Minton + !! + !! Integrates the spin equations for central and massive bodies of the system subjected to tides. + implicit none + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object + class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! Simulation time + real(DP), intent(in) :: dt !! Current stepsize + return + end subroutine tides_step_spin_system +end submodule s_tides_step_spin \ No newline at end of file diff --git a/src/whm/whm_step.f90 b/src/whm/whm_step.f90 index ce00b86b1..22dd16387 100644 --- a/src/whm/whm_step.f90 +++ b/src/whm/whm_step.f90 @@ -17,8 +17,10 @@ module subroutine whm_step_system(self, param, t, dt) real(DP), intent(in) :: dt !! Current stepsize associate(system => self, cb => self%cb, pl => self%pl, tp => self%tp) + tp%lfirst = pl%lfirst call pl%step(system, param, t, dt) call tp%step(system, param, t, dt) + if (param%ltides) call system%step_spin(param, t, dt) end associate return end subroutine whm_step_system