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

Commit

Permalink
Improved the fail_scale method
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 31, 2022
1 parent f281125 commit 6adca2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/fraggle/fraggle_generate.f90
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module subroutine fraggle_generate_disrupt(self, nbody_system, param, t, lfailur
logical :: lk_plpl, lfailure_local
logical, dimension(size(IEEE_ALL)) :: fpe_halting_modes, fpe_quiet_modes
character(len=STRMAX) :: message
real(DP), parameter :: fail_scale_initial = 1.001_DP

! The minimization and linear solvers can sometimes lead to floating point exceptions. Rather than halting the code entirely if this occurs, we
! can simply fail the attempt and try again. So we need to turn off any floating point exception halting modes temporarily
Expand Down Expand Up @@ -137,6 +138,7 @@ module subroutine fraggle_generate_disrupt(self, nbody_system, param, t, lfailur
call self%get_energy_and_momentum(nbody_system, param, lbefore=.true.)
call self%set_budgets()
do try = 1, MAXTRY
self%fail_scale = (fail_scale_initial)**try
write(message,*) try
call fraggle_generate_pos_vec(self)
call fraggle_generate_rot_vec(self)
Expand Down Expand Up @@ -254,8 +256,6 @@ module subroutine fraggle_generate_pos_vec(collider)
logical :: lcat, lhitandrun
integer(I4B), parameter :: MAXLOOP = 10000
real(DP) :: rdistance
real(DP), parameter :: fail_scale = 1.001_DP ! Scale factor to apply to cloud radius and distance if cloud generation fails


associate(fragments => collider%fragments, impactors => collider%impactors, nfrag => collider%fragments%nbody)
lcat = (impactors%regime == COLLRESOLVE_REGIME_SUPERCATASTROPHIC)
Expand Down Expand Up @@ -301,8 +301,8 @@ module subroutine fraggle_generate_pos_vec(collider)
loverlap(i) = loverlap(i) .or. (dis <= (fragments%radius(i) + fragments%radius(j)))
end do
end do
rdistance = rdistance * fail_scale
fragment_cloud_radius(:) = fragment_cloud_radius(:) * fail_scale
rdistance = rdistance * collider%fail_scale
fragment_cloud_radius(:) = fragment_cloud_radius(:) * collider%fail_scale
end do

call collision_util_shift_vector_to_origin(fragments%mass, fragments%rc)
Expand Down
7 changes: 4 additions & 3 deletions src/fraggle/fraggle_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ module fraggle
type, extends(collision_fragments) :: fraggle_fragments
contains

procedure :: reset => fraggle_util_reset_fragments !! Resets all position and velocity-dependent fragment quantities in order to do a fresh calculation (does not reset mass, radius, or other values that get set prior to the call to fraggle_generate)
final :: fraggle_final_fragments !! Finalizer will deallocate all allocatables
procedure :: reset => fraggle_util_reset_fragments !! Resets all position and velocity-dependent fragment quantities in order to do a fresh calculation (does not reset mass, radius, or other values that get set prior to the call to fraggle_generate)
final :: fraggle_final_fragments !! Finalizer will deallocate all allocatables
end type fraggle_fragments


Expand All @@ -31,7 +31,8 @@ module fraggle
real(DP) :: tscale = 1.0_DP !! Time scale factor
real(DP) :: vscale = 1.0_DP !! Velocity scale factor (a convenience unit that is derived from dscale and tscale)
real(DP) :: Escale = 1.0_DP !! Energy scale factor (a convenience unit that is derived from dscale, tscale, and mscale)
real(DP) :: Lscale = 1.0_DP !! Angular momentum scale factor (a convenience unit that is derived from dscale, tscale, and mscale)
real(DP) :: Lscale = 1.0_DP !! Angular momentum scale factor (a convenience unit that is derived from dscale, tscale, and mscale)
real(DP) :: fail_scale !! Scale factor to apply to distance values in the position model when overlaps occur.
contains
procedure :: disrupt => fraggle_generate_disrupt !! Generates a system of fragments in barycentric coordinates that conserves energy and momentum.
procedure :: generate => fraggle_generate !! A simple disruption models that does not constrain energy loss in collisions
Expand Down

0 comments on commit 6adca2b

Please sign in to comment.