Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ conserving total angular momentum. See
Bug Fixes
---------

Fixed an issue where the `find0_quadratic` subroutine provided by the `num` module could accidentally divide by 0 when the points used for the quadratic interpolant did not bracket a root.

Fixed ``switch_to_radiative`` zeroing saved ``mlt_vc`` during TDC photo
restarts and preparation for a new step. Mixing cleanup now preserves
the velocity until it has been copied to ``mlt_vc_old``.
Expand Down
5 changes: 5 additions & 0 deletions num/public/num_lib.f90
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,11 @@ real(dp) function find0_quadratic(xx1, yy1, xx2, yy2, xx3, yy3, ierr) result(x)
b = sqrt(s2)
a = xx3**2*(yy1 - yy2) + xx1**2*(yy2 - yy3) + xx2**2*(-yy1 + yy3)
denom = 2*(xx3*(yy1 - yy2) + xx1*(yy2 - yy3) + xx2*(-yy1 + yy3))
! Guard against an unlikely, but unfortunate, division by 0.
if (denom == 0) then
ierr = -1
return
end if
x = (a + b)/denom
if (x > max(xx1, xx2, xx3)) x = (a - b)/denom
if (x < min(xx1, xx2, xx3) .or. x > max(xx1, xx2, xx3)) ierr = -1
Expand Down
Loading