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

Commit

Permalink
More attempts to improve convergence speed when nfrag gets big
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Feb 12, 2023
1 parent a6b99cd commit 5af4b8d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/fraggle/fraggle_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,12 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu

! Put any remaining residual into velocity shear
angmtm: do j = 1, MAXANGMTM
if (j == MAXANGMTM) exit inner
call collider_local%get_energy_and_momentum(nbody_system, param, phase="after")
L_residual(:) = (collider_local%L_total(:,2) - collider_local%L_total(:,1))
dL_metric(:) = abs(L_residual(:)) / .mag.(collider_local%L_total(:,1)) / MOMENTUM_SUCCESS_METRIC

if (all(dL_metric(:) <= 1.0_DP)) exit angmtm
if (all(dL_metric(:) <= 1.0_DP)) exit angmtm

do i = istart, fragments%nbody
dL(:) = -L_residual(:) * fragments%mass(i) / sum(fragments%mass(istart:fragments%nbody))
Expand Down Expand Up @@ -696,7 +697,7 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu
! Remove a constant amount of velocity from the bodies so we don't shift the center of mass and screw up the momentum
ke_avail = 0.0_DP
do i = fragments%nbody, 1, -1
ke_avail = ke_avail + 0.5_DP * fragments%mass(i) * max(fragments%vmag(i) - vesc,0.0_DP)**2
ke_avail = ke_avail + 0.5_DP * fragments%mass(i) * max(fragments%vmag(i) - vesc / try,0.0_DP)**2
end do

ke_remove = min(E_residual, ke_avail)
Expand Down

0 comments on commit 5af4b8d

Please sign in to comment.