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

Commit

Permalink
Added new methods for starting and stopping encounter and fragmentati…
Browse files Browse the repository at this point in the history
…on files
  • Loading branch information
daminton committed Dec 6, 2022
1 parent 4a5a999 commit bdb75a2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
21 changes: 19 additions & 2 deletions src/modules/symba_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module symba_classes
logical :: lfragmentation = .false. !! Do fragmentation modeling instead of simple merger.
character(STRMAX) :: encounter_save = "NONE" !! Indicate if and how encounter data should be saved
character(STRMAX) :: fragmentation_save = "NONE" !! Indicate if and how fragmentation data should be saved
logical :: lencounter_save = .false. !! Turns on encounter saving
contains
procedure :: reader => symba_io_param_reader
procedure :: writer => symba_io_param_writer
Expand Down Expand Up @@ -221,6 +222,8 @@ module symba_classes
procedure :: dealloc => symba_util_dealloc_system !! Deallocates all allocatable arrays
procedure :: resize_storage => symba_util_resize_storage !! Resizes the encounter history storage object so that it contains enough spaces for the number of snapshots needed
procedure :: snapshot => symba_util_take_encounter_snapshot !! Take a minimal snapshot of the system through an encounter
procedure :: start_encounter => symba_io_start_encounter !! Initializes the new encounter and/or fragmentation save file(s)
procedure :: stop_encounter => symba_io_stop_encounter !! Saves the encounter and/or fragmentation data to file(s)
final :: symba_util_final_system !! Finalizes the SyMBA nbody system object - deallocates all allocatables
end type symba_nbody_system

Expand Down Expand Up @@ -455,6 +458,20 @@ module subroutine symba_io_param_writer(self, unit, iotype, v_list, iostat, ioms
character(len=*), intent(inout) :: iomsg !! Message to pass if iostat /= 0
end subroutine symba_io_param_writer

module subroutine symba_io_start_encounter(self, param, t)
implicit none
class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody system object
class(symba_parameters), intent(inout) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! Current simulation time
end subroutine symba_io_start_encounter

module subroutine symba_io_stop_encounter(self, param, t)
implicit none
class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody system object
class(symba_parameters), intent(inout) :: param !! Current run configuration parameters
real(DP), intent(in) :: t !! Current simulation time
end subroutine symba_io_stop_encounter

module subroutine symba_io_write_discard(self, param)
use swiftest_classes, only : swiftest_parameters
implicit none
Expand Down Expand Up @@ -563,8 +580,8 @@ recursive module subroutine symba_step_recur_system(self, param, t, ireci)
implicit none
class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody system object
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters
real(DP), intent(in) :: t
integer(I4B), intent(in) :: ireci !! input recursion level
real(DP), intent(in) :: t !! Current simulation time
integer(I4B), intent(in) :: ireci !! input recursion level
end subroutine symba_step_recur_system

module subroutine symba_step_reset_system(self, param)
Expand Down
2 changes: 2 additions & 0 deletions src/symba/symba_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ module subroutine symba_io_param_reader(self, unit, iotype, v_list, iostat, ioms
iostat = -1
return
end if
param%lencounter_save = (param%encounter_save /= "TRAJECTORY") .or. (param%encounter_save /= "CLOSEST") .or. &
(param%fragmentation_save /= "TRAJECTORY") .or. (param%fragmentation_save /= "CLOSEST")

! Call the base method (which also prints the contents to screen)
call io_param_reader(param, unit, iotype, v_list, iostat, iomsg)
Expand Down
5 changes: 2 additions & 3 deletions src/symba/symba_step.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ module subroutine symba_step_system(self, param, t, dt)
call self%reset(param)
lencounter = pl%encounter_check(param, self, dt, 0) .or. tp%encounter_check(param, self, dt, 0)
if (lencounter) then
call self%snapshot(param, t)
if (param%lencounter_save) call self%start_encounter(param, t)
call self%interp(param, t, dt)
call self%snapshot(param, t+dt)
call self%encounter_history%dump(param)
if (param%lencounter_save) call self%stop_encounter(param, t+dt)
else
self%irec = -1
call helio_step_system(self, param, t, dt)
Expand Down

0 comments on commit bdb75a2

Please sign in to comment.