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

Commit

Permalink
Fixed floating point error coming from uninitialized array in the fra…
Browse files Browse the repository at this point in the history
…gmentation code
  • Loading branch information
daminton committed Aug 17, 2021
1 parent 3921e9c commit b3b8394
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/fragmentation/fragmentation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module subroutine fragmentation_initialize(system, param, family, x, v, L_spin,
L_frag_budget(:) = L_frag_orb(:) + L_frag_spin(:)
f_spin = norm2(L_frag_spin(:)) / norm2(L_frag_budget(:))

call reset_fragments()
call define_coordinate_system()
call construct_temporary_system()

Expand All @@ -110,7 +111,6 @@ module subroutine fragmentation_initialize(system, param, family, x, v, L_spin,
ke_tot_deficit = 0.0_DP
do while (try < MAXTRY)
lfailure = .false.
call reset_fragments()

call set_fragment_position_vectors()

Expand Down Expand Up @@ -145,6 +145,7 @@ module subroutine fragmentation_initialize(system, param, family, x, v, L_spin,

if (.not.lfailure) exit
call restructure_failed_fragments()
call reset_fragments()
try = try + 1
end do
call restore_scale_factors()
Expand Down Expand Up @@ -326,8 +327,8 @@ subroutine define_coordinate_system()
! The cross product of the y- by z-axis will give us the x-axis
x_col_unit(:) = y_col_unit(:) .cross. z_col_unit(:)

if (.not.any(x_frag(:,:) > 0.0_DP)) return
rmag(:) = .mag. x_frag(:,:)
if (.not.any(rmag(:) > 0.0_DP)) return

call random_number(L_sigma(:,:)) ! Randomize the tangential velocity direction. This helps to ensure that the tangential velocity doesn't completely line up with the angular momentum vector,
! otherwise we can get an ill-conditioned system
Expand Down

0 comments on commit b3b8394

Please sign in to comment.