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

Commit

Permalink
Fixed issues of convergence of the positioning algorithm once the buf…
Browse files Browse the repository at this point in the history
…fer was added
  • Loading branch information
daminton committed Feb 8, 2023
1 parent 8fd9293 commit 287beed
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/fraggle/fraggle_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,15 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu
real(DP), dimension(collider%fragments%nbody) :: mass_rscale, phi, theta, u
integer(I4B) :: i, j, loop, istart
logical :: lsupercat, lhitandrun
integer(I4B), parameter :: MAXLOOP = 100
integer(I4B), parameter :: MAXLOOP = 200
real(DP), parameter :: rdistance_scale_factor = 1.0_DP ! Scale factor to apply to distance scaling of cloud centers in the event of overlap
! The distance is chosen to be close to the original locations of the impactors
! but far enough apart to prevent a collisional cascade between fragments
real(DP), parameter :: cloud_size_scale_factor = 3.0_DP ! Scale factor to apply to the size of the cloud relative to the distance from the impact point.
! A larger value puts more space between fragments initially
real(DP) :: rbuffer ! Body radii are inflated by this scale factor to prevent secondary collisions
rbuffer = 1.1_DP
real(DP), parameter :: rbuffer_max = 1.2
rbuffer = 1.05_DP

associate(fragments => collider%fragments, impactors => collider%impactors, nfrag => collider%fragments%nbody, &
pl => nbody_system%pl, tp => nbody_system%tp, npl => nbody_system%pl%nbody, ntp => nbody_system%tp%nbody)
Expand Down Expand Up @@ -355,8 +356,8 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu
fragment_cloud_center(:,1) = impactors%rc(:,1)
fragment_cloud_center(:,2) = impactors%rc(:,2) + rdistance * impactors%bounce_unit(:)
else ! Keep the first and second bodies at approximately their original location, but so as not to be overlapping
fragment_cloud_center(:,1) = impactors%rc(:,1)
fragment_cloud_center(:,2) = impactors%rcimp(:) + 1.001_DP * max(fragments%radius(2),impactors%radius(2)) * impactors%y_unit(:)
fragment_cloud_center(:,1) = impactors%rcimp(:) - rbuffer * max(fragments%radius(1),impactors%radius(1)) * impactors%y_unit(:)
fragment_cloud_center(:,2) = impactors%rcimp(:) + rbuffer * max(fragments%radius(2),impactors%radius(2)) * impactors%y_unit(:)
fragment_cloud_radius(:) = cloud_size_scale_factor * rdistance
end if
fragments%rc(:,1) = fragment_cloud_center(:,1)
Expand All @@ -376,7 +377,7 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu

! Make a random cloud
phi(i) = TWOPI * phi(i)
theta(i) = acos( 2 * theta(i) - 1.0_DP)
theta(i) = acos(2 * theta(i) - 1.0_DP)
! Scale the cloud size
fragments%rmag(i) = fragment_cloud_radius(j) * mass_rscale(i) * u(i)**(THIRD)

Expand Down Expand Up @@ -426,7 +427,7 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu
end do
end do
rdistance = rdistance * collider%fail_scale
rbuffer = rbuffer * collider%fail_scale
rbuffer = min(rbuffer * collider%fail_scale, rbuffer_max)
end do

lfailure = any(loverlap(:))
Expand Down

0 comments on commit 287beed

Please sign in to comment.