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

Commit

Permalink
Removed restriction on spins of first two bodies. Success rate of fra…
Browse files Browse the repository at this point in the history
…ggle_generation is improved.
  • Loading branch information
daminton committed Sep 7, 2021
1 parent 50afb8f commit ed5bfff
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/fraggle/fraggle_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -234,20 +234,18 @@ subroutine fraggle_generate_spins(frag, colliders, f_spin, lfailure)
lfailure = .false.

! Start the first two bodies with the same rotation as the original two impactors, then distribute the remaining angular momentum among the rest
frag%rot(:,1:2) = colliders%rot(:, :)
frag%rot(:,3:nfrag) = 0.0_DP
call frag%get_ang_mtm()
L_remainder(:) = frag%L_budget(:) - frag%L_spin(:)
L_remainder(:) = frag%L_budget(:)
frag%rot(:,:) = 0.0_DP

frag%ke_spin = 0.0_DP
do i = 1, nfrag
! Convert a fraction (f_spin) of either the remaining angular momentum or kinetic energy budget into spin, whichever gives the smaller rotation so as not to blow any budgets
rot_ke(:) = sqrt(2 * f_spin * frag%ke_budget / (nfrag * frag%mass(i) * frag%radius(i)**2 * frag%Ip(3, i))) * L_remainder(:) / norm2(L_remainder(:))
rot_L(:) = f_spin * L_remainder(:) / (nfrag * frag%mass(i) * frag%radius(i)**2 * frag%Ip(3, i))
if (norm2(rot_ke) < norm2(rot_L)) then
frag%rot(:,i) = frag%rot(:, i) + rot_ke(:)
frag%rot(:,i) = rot_ke(:)
else
frag%rot(:, i) = frag%rot(:, i) + rot_L(:)
frag%rot(:, i) = rot_L(:)
end if
frag%ke_spin = frag%ke_spin + frag%mass(i) * frag%Ip(3, i) * frag%radius(i)**2 * dot_product(frag%rot(:, i), frag%rot(:, i))
end do
Expand Down Expand Up @@ -296,7 +294,7 @@ subroutine fraggle_generate_tan_vel(frag, colliders, lfailure)
integer(I4B) :: i
real(DP), parameter :: TOL_MIN = 1e-1_DP ! This doesn't have to be very accurate, as we really just want a tangential velocity distribution with less kinetic energy than our initial guess.
real(DP), parameter :: TOL_INIT = 1e-14_DP
real(DP), parameter :: VNOISE_MAG = 1e-2_DP !! Magnitude of the noise to apply to initial conditions to help minimizer find a solution in case of failure
real(DP), parameter :: VNOISE_MAG = 1e-3_DP !! Magnitude of the noise to apply to initial conditions to help minimizer find a solution in case of failure
integer(I4B), parameter :: MAXLOOP = 10
real(DP) :: tol, ke_remainder
real(DP), dimension(:), allocatable :: v_t_initial
Expand Down

0 comments on commit ed5bfff

Please sign in to comment.