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

Commit

Permalink
Fixed swiftest_body sort method to accept all defined componenbts. Ad…
Browse files Browse the repository at this point in the history
…ded sort method to initilization to ensure bodies are in correct heliocentric order before computing Jacobis
  • Loading branch information
daminton committed Jul 28, 2021
1 parent 952ffc8 commit bc943d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/util/util_sort.f90
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ module subroutine util_sort_body(self, sortby, ascending)
select case(sortby)
case("id")
call util_sort(direction * body%id(1:n), ind(1:n))
case("status")
call util_sort(direction * body%status(1:n), ind(1:n))
case("ir3h")
call util_sort(direction * body%ir3h(1:n), ind(1:n))
case("a")
call util_sort(direction * body%a(1:n), ind(1:n))
case("e")
Expand All @@ -35,7 +39,7 @@ module subroutine util_sort_body(self, sortby, ascending)
call util_sort(direction * body%capom(1:n), ind(1:n))
case("mu")
call util_sort(direction * body%mu(1:n), ind(1:n))
case("lfirst", "nbody","xh", "vh", "xb", "vb", "ah", "aobl", "atide", "agr")
case("lfirst", "nbody", "ldiscard", "xh", "vh", "xb", "vb", "ah", "aobl", "atide", "agr")
write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!'
case default
write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not found!'
Expand Down
7 changes: 5 additions & 2 deletions src/whm/whm_setup.f90
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ module subroutine whm_util_set_mu_eta_pl(self, cb)
!! Sets the Jacobi mass value eta for all massive bodies
implicit none
! Arguments
class(whm_pl), intent(inout) :: self !! Swiftest system object
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body particle data structure
class(whm_pl), intent(inout) :: self !! WHM system object
class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object
! Internals
integer(I4B) :: i

Expand Down Expand Up @@ -82,6 +82,9 @@ module subroutine whm_setup_initialize_system(self, param)
class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters

call setup_initialize_system(self, param)
! First we need to make sure that the massive bodies are sorted by heliocentric distance before computing jacobies
call util_set_ir3h(self%pl)
call self%pl%sort("ir3h", ascending=.false.)
! Make sure that the discard list gets allocated initially
call self%tp_discards%setup(self%tp%nbody)
call self%pl%set_mu(self%cb)
Expand Down

0 comments on commit bc943d3

Please sign in to comment.