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

Commit

Permalink
Fixed problem that was prevening runs from working properly in pure m…
Browse files Browse the repository at this point in the history
…erger mode
  • Loading branch information
daminton committed Sep 28, 2021
1 parent 96091ee commit d7aaa55
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/fraggle/fraggle_set.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ module subroutine fraggle_set_mass_dist_fragments(self, colliders, param)
!! author: David A. Minton
!!
!! Sets the mass of fragments based on the mass distribution returned by the regime calculation.
!! This subroutine must be run after the the setup rourtine has been run on the fragments
!! This subroutine must be run after the the setup routine has been run on the fragments
!!
implicit none
! Arguments
class(fraggle_fragments), intent(inout) :: self !! Fraggle fragment system object
Expand Down Expand Up @@ -61,26 +62,27 @@ module subroutine fraggle_set_mass_dist_fragments(self, colliders, param)
jtarg = 2
jproj = 1
end if

select type(param)
class is (symba_parameters)
min_mfrag = (param%min_GMfrag / param%GU)
! The number of fragments we generate is bracked by the minimum required by fraggle_generate (7) and the
! maximum set by the NFRAG_SIZE_MULTIPLIER which limits the total number of fragments to prevent the nbody
! code from getting an overwhelmingly large number of fragments
nfrag = ceiling(NFRAG_SIZE_MULTIPLIER * log(frag%mtot / min_mfrag))
nfrag = max(min(nfrag, NFRAGMAX), NFRAGMIN)
class default
min_mfrag = 0.0_DP
nfrag = NFRAGMAX
end select

select case(frag%regime)
case(COLLRESOLVE_REGIME_DISRUPTION, COLLRESOLVE_REGIME_SUPERCATASTROPHIC, COLLRESOLVE_REGIME_HIT_AND_RUN)
! The first two bins of the mass_dist are the largest and second-largest fragments that came out of fraggle_regime.
! The remainder from the third bin will be distributed among nfrag-2 bodies. The following code will determine nfrag based on
! the limits bracketed above and the model size distribution of fragments.
! Check to see if our size distribution would give us a smaller number of fragments than the maximum number

select type(param)
class is (symba_parameters)
min_mfrag = (param%min_GMfrag / param%GU)
! The number of fragments we generate is bracked by the minimum required by fraggle_generate (7) and the
! maximum set by the NFRAG_SIZE_MULTIPLIER which limits the total number of fragments to prevent the nbody
! code from getting an overwhelmingly large number of fragments
nfrag = ceiling(NFRAG_SIZE_MULTIPLIER * log(frag%mtot / min_mfrag))
nfrag = max(min(nfrag, NFRAGMAX), NFRAGMIN)
class default
min_mfrag = 0.0_DP
nfrag = NFRAGMAX
end select

i = iMrem
mremaining = frag%mass_dist(iMrem)
do while (i <= nfrag)
Expand All @@ -97,7 +99,7 @@ module subroutine fraggle_set_mass_dist_fragments(self, colliders, param)
frag%mass(1) = frag%mass_dist(1)
frag%radius(1) = colliders%radius(jtarg)
frag%density(1) = frag%mass_dist(1) / volume(jtarg)
frag%Ip(:, 1) = colliders%Ip(:,1)
if (param%lrotation) frag%Ip(:, 1) = colliders%Ip(:,1)
return
case default
write(*,*) "fraggle_set_mass_dist_fragments error: Unrecognized regime code",frag%regime
Expand Down
3 changes: 3 additions & 0 deletions src/symba/symba_collision.f90
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ module subroutine symba_collision_resolve_mergers(self, system, param)

frag%regime = COLLRESOLVE_REGIME_MERGE
frag%mtot = sum(colliders%mass(:))
frag%mass_dist(1) = frag%mtot
frag%mass_dist(2) = 0.0_DP
frag%mass_dist(3) = 0.0_DP
frag%xbcom(:) = (colliders%mass(1) * colliders%xb(:,1) + colliders%mass(2) * colliders%xb(:,2)) / frag%mtot
frag%vbcom(:) = (colliders%mass(1) * colliders%vb(:,1) + colliders%mass(2) * colliders%vb(:,2)) / frag%mtot
plplcollision_list%status(i) = symba_collision_casemerge(system, param, colliders, frag)
Expand Down

0 comments on commit d7aaa55

Please sign in to comment.