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

Commit

Permalink
Refactored num_comparisons to more compact nplpl, and added nplplm fo…
Browse files Browse the repository at this point in the history
…r the SyMBA case with MTINY bodies
  • Loading branch information
daminton committed Jul 23, 2021
1 parent 05570b9 commit 4836fcb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/eucl/eucl.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ module subroutine eucl_dist_index_plpl(self)
integer(I8B) :: i, j, counter, npl

npl = int(self%nbody, kind=I8B)
associate(num_comparisons => self%num_comparisons)
num_comparisons = (npl * (npl - 1) / 2) ! number of entries in a strict lower triangle, nplm x npl, minus first column
associate(nplpl => self%nplpl)
nplpl = (npl * (npl - 1) / 2) ! number of entries in a strict lower triangle, nplm x npl, minus first column
if (allocated(self%k_eucl)) deallocate(self%k_eucl) ! Reset the index array if it's been set previously
if (allocated(self%irij3)) deallocate(self%irij3)
allocate(self%k_eucl(2, num_comparisons))
allocate(self%irij3(num_comparisons))
allocate(self%k_eucl(2, nplpl))
allocate(self%irij3(nplpl))
do i = 1, npl
counter = (i - 1_I8B) * npl - i * (i - 1_I8B) / 2_I8B + 1_I8B
do j = i + 1_I8B, npl
Expand Down Expand Up @@ -61,7 +61,7 @@ module subroutine eucl_irij3_plpl(self)
real(DP), dimension(NDIM) :: dx
real(DP) :: rji2

associate(k_eucl => self%k_eucl, xh => self%xh, irij3 => self%irij3, nk => self%num_comparisons)
associate(k_eucl => self%k_eucl, xh => self%xh, irij3 => self%irij3, nk => self%nplpl)
do k = 1, nk
i = k_eucl(1, k)
j = k_eucl(2, k)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/swiftest_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ module swiftest_classes
real(DP), dimension(:), allocatable :: capm !! Mean anomaly
real(DP), dimension(:), allocatable :: mu !! G * (Mcb + [m])
integer(I4B), dimension(:,:), allocatable :: k_eucl !! Index array used to convert flattened the body-body comparison upper triangular matrix
integer(I8B) :: num_comparisons !! Number of body-body comparisons in the flattened upper triangular matrix
integer(I8B) :: nplpl !! Number of body-body comparisons in the flattened upper triangular matrix
!! Note to developers: If you add components to this class, be sure to update methods and subroutines that traverse the
!! component list, such as setup_body and util_spill
contains
Expand Down
1 change: 1 addition & 0 deletions src/modules/symba_classes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ module symba_classes
logical, dimension(:), allocatable :: lencounter !! flag indicating whether body is part of an encounter this time step
logical, dimension(:), allocatable :: lmtiny !! flag indicating whether this body is below the MTINY cutoff value
integer(I4B) :: nplm !! number of bodies above the MTINY limit
integer(I8B) :: nplplm !! Number of body (all massive)-body (only those above MTINY) comparisons in the flattened upper triangular matrix
integer(I4B), dimension(:), allocatable :: nplenc !! number of encounters with other planets this time step
integer(I4B), dimension(:), allocatable :: ntpenc !! number of encounters with test particles this time step
integer(I4B), dimension(:), allocatable :: levelg !! level at which this body should be moved
Expand Down
2 changes: 1 addition & 1 deletion src/setup/setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ module subroutine setup_pl(self,n)
self%k2(:) = 0.0_DP
self%Q(:) = 0.0_DP
self%tlag(:) = 0.0_DP
self%num_comparisons = 0
self%nplpl = 0
return
end subroutine setup_pl

Expand Down

0 comments on commit 4836fcb

Please sign in to comment.