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

Commit

Permalink
Fixed bug in which the largest body in a collision was misidentified,…
Browse files Browse the repository at this point in the history
… causing recursion level and info flags to be set incorrectly
  • Loading branch information
daminton committed Aug 20, 2021
1 parent e829a2b commit 3c14d19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/symba/symba_collision.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module function symba_collision_casedisruption(system, param, family, x, v, mass
! Result
integer(I4B) :: status !! Status flag assigned to this outcome
! Internals
integer(I4B) :: i, istart, nfrag, ibiggest, nfamily, nstart, nend
integer(I4B) :: i, istart, nfrag, nfamily, nstart, nend
real(DP) :: mtot, avg_dens
real(DP), dimension(NDIM) :: xcom, vcom, Ip_new
real(DP), dimension(2) :: vol
Expand Down Expand Up @@ -156,7 +156,7 @@ module function symba_collision_casehitandrun(system, param, family, x, v, mass,
allocate(rot_frag(NDIM, nfrag))
allocate(Ip_frag(NDIM, nfrag))
m_frag(1) = mass(jtarg)
ibiggest = maxloc(system%pl%Gmass(family(:)), dim=1)
ibiggest = family(maxloc(system%pl%Gmass(family(:)), dim=1))
id_frag(1) = system%pl%id(ibiggest)
rad_frag(1) = radius(jtarg)
xb_frag(:, 1) = x(:, jtarg)
Expand Down Expand Up @@ -235,8 +235,8 @@ module function symba_collision_casemerge(system, param, family, x, v, mass, rad
class is (symba_pl)
write(*, '("Merging bodies ",I8,99(:,",",I8))') pl%id(family(:))

ibiggest = maxloc(pl%Gmass(family(:)), dim=1)
id_frag(1) = pl%id(family(ibiggest))
ibiggest = family(maxloc(pl%Gmass(family(:)), dim=1))
id_frag(1) = pl%id(ibiggest)

m_frag(1) = sum(mass(:))

Expand Down Expand Up @@ -838,7 +838,7 @@ subroutine symba_collision_mergeaddsub(system, param, family, id_frag, Ip_frag,
! Setup new bodies
allocate(plnew, mold=pl)
call plnew%setup(nfrag, param)
ibiggest = maxloc(pl%Gmass(family(:)), dim=1)
ibiggest = family(maxloc(pl%Gmass(family(:)), dim=1))

! Copy over identification, information, and physical properties of the new bodies from the fragment list
plnew%id(1:nfrag) = id_frag(1:nfrag)
Expand Down
6 changes: 3 additions & 3 deletions src/symba/symba_encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ module function symba_encounter_check_pl(self, system, dt, irec) result(lany_enc
if (lany_encounter) then
associate(plplenc_list => system%plplenc_list)
call plplenc_list%resize(nenc)
plplenc_list%lvdotr(1:nenc) = pack(loc_lvdotr(:), lencounter(:))
plplenc_list%index1(1:nenc) = pack(pl%k_plpl(1,:), lencounter(:))
plplenc_list%index2(1:nenc) = pack(pl%k_plpl(2,:), lencounter(:))
plplenc_list%lvdotr(1:nenc) = pack(loc_lvdotr(1:nplplm), lencounter(1:nplplm))
plplenc_list%index1(1:nenc) = pack(pl%k_plpl(1,1:nplplm), lencounter(1:nplplm))
plplenc_list%index2(1:nenc) = pack(pl%k_plpl(2,1:nplplm), lencounter(1:nplplm))
plplenc_list%id1(1:nenc) = pl%id(plplenc_list%index1(1:nenc))
plplenc_list%id2(1:nenc) = pl%id(plplenc_list%index2(1:nenc))
do k = 1, nenc
Expand Down

0 comments on commit 3c14d19

Please sign in to comment.