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

Commit

Permalink
Fixed bugs in info tracking. Code seems to work now.
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Aug 28, 2021
1 parent a86b33e commit b92eb1f
Show file tree
Hide file tree
Showing 11 changed files with 3,969 additions and 3,058 deletions.
470 changes: 470 additions & 0 deletions examples/symba_energy_momentum/Untitled.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/symba_energy_momentum/param.disruption_headon.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ PL_IN disruption_headon.in
TP_IN tp.in
IN_TYPE ASCII
ISTEP_OUT 1 ! output cadence every year
BIN_OUT bin.disruption_headon.dat
BIN_OUT bin.disruption_headon.nc
PARTICLE_OUT particle.disruption_headon.dat
OUT_TYPE REAL8 ! double precision real output
OUT_FORM XV ! osculating element output
OUT_TYPE NETCDF_DOUBLE ! double precision real output
OUT_FORM XVEL ! osculating element output
OUT_STAT REPLACE
ISTEP_DUMP 1 ! system dump cadence
CHK_CLOSE yes ! check for planetary close encounters
Expand Down
8 changes: 4 additions & 4 deletions examples/symba_energy_momentum/param.disruption_off_axis.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
T0 0.0e0
TSTOP 0.000100 ! simulation length in seconds = 100 years
TSTOP 0.0000100 ! simulation length in seconds = 100 years
DT 0.0000001 ! stepsize in seconds
CB_IN cb.in
PL_IN disruption_off_axis.in
TP_IN tp.in
IN_TYPE ASCII
ISTEP_OUT 1 ! output cadence every year
BIN_OUT bin.disruption_off_axis.dat
BIN_OUT bin.disruption_off_axis.nc
PARTICLE_OUT particle.disruption_off_axis.dat
OUT_TYPE REAL8 ! double precision real output
OUT_FORM XV ! osculating element output
OUT_TYPE NETCDF_DOUBLE ! double precision real output
OUT_FORM XVEL ! osculating element output
OUT_STAT REPLACE
ISTEP_DUMP 1 ! system dump cadence
CHK_CLOSE yes ! check for planetary close encounters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ CB_IN cb.in
TP_IN tp.in
IN_TYPE ASCII
ISTEP_OUT 1 ! output cadence every year
BIN_OUT bin.supercatastrophic_headon.dat
BIN_OUT bin.supercatastrophic_headon.nc
PARTICLE_OUT particle.supercatastrophic_headon.dat
OUT_TYPE REAL8 ! double precision real output
OUT_FORM XV ! osculating element output
OUT_TYPE NETCDF_DOUBLE ! double precision real output
OUT_FORM XVEL ! osculating element output
OUT_STAT REPLACE
ISTEP_DUMP 1 ! system dump cadence
CHK_CLOSE yes ! check for planetary close encounters
Expand Down
6,016 changes: 3,008 additions & 3,008 deletions examples/symba_mars_disk/mars.in

Large diffs are not rendered by default.

433 changes: 422 additions & 11 deletions examples/symba_mars_disk/testnetcdf.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/netcdf/netcdf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ module subroutine netcdf_write_frame_base(self, iu, param)
associate(n => self%nbody)
if (n == 0) return
allocate(ind(n))
call util_sort(self%id(1:n), ind(1:n))
call util_sort(self%id(1:n), ind)

do i = 1, n
j = ind(i)
Expand Down
10 changes: 0 additions & 10 deletions src/symba/symba_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ module subroutine symba_util_append_pl(self, source, lsource_mask)
call util_append(self%peri, source%peri, nold, nsrc, lsource_mask)
call util_append(self%atp, source%atp, nold, nsrc, lsource_mask)
call util_append(self%kin, source%kin, nold, nsrc, lsource_mask)
call util_append(self%info, source%info, nold, nsrc, lsource_mask)

call util_append_pl(self, source, lsource_mask) ! Note: helio_pl does not have its own append method, so we skip back to the base class
end associate
Expand Down Expand Up @@ -148,7 +147,6 @@ module subroutine symba_util_append_tp(self, source, lsource_mask)
call util_append(self%nplenc, source%nplenc, nold, nsrc, lsource_mask)
call util_append(self%levelg, source%levelg, nold, nsrc, lsource_mask)
call util_append(self%levelm, source%levelm, nold, nsrc, lsource_mask)
call util_append(self%info, source%info, nold, nsrc, lsource_mask)

call util_append_tp(self, source, lsource_mask) ! Note: helio_tp does not have its own append method, so we skip back to the base class
end associate
Expand Down Expand Up @@ -229,7 +227,6 @@ module subroutine symba_util_fill_pl(self, inserts, lfill_list)
call util_fill(keeps%peri, inserts%peri, lfill_list)
call util_fill(keeps%atp, inserts%atp, lfill_list)
call util_fill(keeps%kin, inserts%kin, lfill_list)
call util_fill(keeps%info, inserts%info, lfill_list)

call util_fill_pl(keeps, inserts, lfill_list) ! Note: helio_pl does not have its own fill method, so we skip back to the base class
class default
Expand Down Expand Up @@ -260,7 +257,6 @@ module subroutine symba_util_fill_tp(self, inserts, lfill_list)
call util_fill(keeps%nplenc, inserts%nplenc, lfill_list)
call util_fill(keeps%levelg, inserts%levelg, lfill_list)
call util_fill(keeps%levelm, inserts%levelm, lfill_list)
call util_fill(keeps%info, inserts%info, lfill_list)

call util_fill_tp(keeps, inserts, lfill_list) ! Note: helio_tp does not have its own fill method, so we skip back to the base class
class default
Expand Down Expand Up @@ -607,7 +603,6 @@ module subroutine symba_util_resize_pl(self, nnew)
call util_resize(self%peri, nnew)
call util_resize(self%atp, nnew)
call util_resize(self%kin, nnew)
call util_resize(self%info, nnew)

call util_resize_pl(self, nnew)

Expand All @@ -627,7 +622,6 @@ module subroutine symba_util_resize_tp(self, nnew)
call util_resize(self%nplenc, nnew)
call util_resize(self%levelg, nnew)
call util_resize(self%levelm, nnew)
call util_resize(self%info, nnew)

call util_resize_tp(self, nnew)

Expand Down Expand Up @@ -779,7 +773,6 @@ module subroutine symba_util_sort_rearrange_pl(self, ind)
call util_sort_rearrange(pl%isperi, ind, npl)
call util_sort_rearrange(pl%peri, ind, npl)
call util_sort_rearrange(pl%atp, ind, npl)
call util_sort_rearrange(pl%info, ind, npl)
call util_sort_rearrange(pl%kin, ind, npl)

call util_sort_rearrange_pl(pl,ind)
Expand All @@ -803,7 +796,6 @@ module subroutine symba_util_sort_rearrange_tp(self, ind)
call util_sort_rearrange(tp%nplenc, ind, ntp)
call util_sort_rearrange(tp%levelg, ind, ntp)
call util_sort_rearrange(tp%levelm, ind, ntp)
call util_sort_rearrange(tp%info, ind, ntp)

call util_sort_rearrange_tp(tp,ind)
end associate
Expand Down Expand Up @@ -880,7 +872,6 @@ module subroutine symba_util_spill_pl(self, discards, lspill_list, ldestructive)
call util_spill(keeps%isperi, discards%isperi, lspill_list, ldestructive)
call util_spill(keeps%peri, discards%peri, lspill_list, ldestructive)
call util_spill(keeps%atp, discards%atp, lspill_list, ldestructive)
call util_spill(keeps%info, discards%info, lspill_list, ldestructive)
call util_spill(keeps%kin, discards%kin, lspill_list, ldestructive)

call util_spill_pl(keeps, discards, lspill_list, ldestructive)
Expand Down Expand Up @@ -945,7 +936,6 @@ module subroutine symba_util_spill_tp(self, discards, lspill_list, ldestructive)
call util_spill(keeps%nplenc, discards%nplenc, lspill_list, ldestructive)
call util_spill(keeps%levelg, discards%levelg, lspill_list, ldestructive)
call util_spill(keeps%levelm, discards%levelm, lspill_list, ldestructive)
call util_spill(keeps%info, discards%info, lspill_list, ldestructive)

call util_spill_tp(keeps, discards, lspill_list, ldestructive)
class default
Expand Down
36 changes: 24 additions & 12 deletions src/util/util_append.f90
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,35 @@ module subroutine util_append_arr_info(arr, source, nold, nsrc, lsource_mask)
logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to
! Internals
integer(I4B) :: nnew
class(swiftest_particle_info), allocatable :: tmp
class(swiftest_particle_info), dimension(:), allocatable :: arr_tmp, source_tmp

if (.not. allocated(source)) return

nnew = count(lsource_mask(1:nsrc))
if (.not.allocated(arr)) then
select type(source)
class is (symba_particle_info)
allocate(symba_particle_info :: arr(nold+nnew))
class default
allocate(swiftest_particle_info :: arr(nold+nnew))
end select
else
call util_resize(arr, nold + nnew)
end if

arr(nold + 1:nold + nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc))
select type(source)
class is (symba_particle_info)
allocate(symba_particle_info :: arr_tmp(nold+nnew))
if (nold > 0) then
arr_tmp(1:nold) = arr(1:nold)
deallocate(arr)
end if
class is (swiftest_particle_info)
allocate(swiftest_particle_info :: arr_tmp(nold+nnew))
if (nold > 0) then
arr_tmp(1:nold) = arr(1:nold)
deallocate(arr)
end if
end select

select type(source)
class is (symba_particle_info)
arr_tmp(nold + 1:nold + nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc))
class is (swiftest_particle_info)
arr_tmp(nold + 1:nold + nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc))
end select

call move_alloc(arr_tmp, arr)

return
end subroutine util_append_arr_info
Expand Down
28 changes: 25 additions & 3 deletions src/util/util_fill.f90
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,34 @@ module subroutine util_fill_arr_info(keeps, inserts, lfill_list)
! Arguments
class(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep
class(swiftest_particle_info), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep
logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps
logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps
! Internals
class(swiftest_particle_info), dimension(:), allocatable :: ktmp, itmp
integer(I4B) :: nk, ni

if (.not.allocated(keeps) .or. .not.allocated(inserts)) return

keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:))
keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:))
nk = size(keeps)
ni = size(inserts)

select type(keeps)
class is (symba_particle_info)
allocate(symba_particle_info :: ktmp(nk))
class is (swiftest_particle_info)
allocate(swiftest_particle_info :: ktmp(nk))
end select

select type(inserts)
class is (symba_particle_info)
allocate(symba_particle_info :: itmp(ni))
class is (swiftest_particle_info)
allocate(swiftest_particle_info :: itmp(ni))
end select

ktmp(:) = unpack(ktmp(:), .not.lfill_list(:), ktmp(:))
ktmp(:) = unpack(itmp(:), lfill_list(:), ktmp(:))

keeps(:) = ktmp(:)

return
end subroutine util_fill_arr_info
Expand Down
12 changes: 9 additions & 3 deletions src/util/util_sort.f90
Original file line number Diff line number Diff line change
Expand Up @@ -466,15 +466,21 @@ module subroutine util_sort_rearrange_arr_info(arr, ind, n)
implicit none
! Arguments
class(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array
integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against
integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against
integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange
! Internals
class(swiftest_particle_info), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation
integer(I4B) :: i

if (.not. allocated(arr) .or. n <= 0) return
allocate(tmp, source=arr)
select type(arr)
class is (symba_particle_info)
allocate(symba_particle_info :: tmp(n))
class is (swiftest_particle_info)
allocate(swiftest_particle_info :: tmp(n))
end select
tmp(1:n) = arr(ind(1:n))
call move_alloc(tmp, arr)
arr(1:n) = tmp(1:n)

return
end subroutine util_sort_rearrange_arr_info
Expand Down

0 comments on commit b92eb1f

Please sign in to comment.