Skip to content

Commit

Permalink
fix(prt): fix fpe by constraining local z coord to unit interval (#2183)
Browse files Browse the repository at this point in the history
In the generalized particle tracking method, a local Z coordinate could be calculated to fall slightly outside of the unit interval due to numerical imprecision. This could cause the vertical travel time calculation to fail with a floating point exception. Constrain the local Z coordinate to the unit interval to prevent this.
  • Loading branch information
wpbonelli authored Jan 31, 2025
1 parent 608bce5 commit 42cdc58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/ReleaseNotes/develop.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
\item A regression was recently introduced into the PRT model's generalized tracking method, in which a coordinate transformation was carried out prematurely. This could result in incorrect particle positions in and near quad-refined cells. This bug has been fixed.
\item The PRT model previously allowed particles to be released at any time. Release times falling outside the bounds of the simulation's time discretization could produce undefined behavior. Any release times occurring before the simulation begins (i.e. negative times) will now be skipped with a warning message. If EXTEND\_TRACKING is not enabled, release times occurring after the end of the simulation will now be skipped with a warning message as well. If EXTEND\_TRACKING is enabled, release times after the end of the simulation are allowed.
\item The PRT Model did not previously report all expected tracking events. In particular, time step end and termination events could go unreported with the DRY\_TRACKING\_METHOD options DROP and STAY (only relevant for Newton formulation models), and termination events were not always reported at the end of the simulation. Reporting has been corrected for the cases identified.
\item In the generalized particle tracking method, a local Z coordinate could be calculated to fall slightly outside of the unit interval due to numerical imprecision. This could cause the vertical travel time calculation to fail with a floating point exception. Constrain the local Z coordinate to the unit interval to prevent this.
\item A profiling module is added for more enhanced performance diagnostics of the program. It can be activated through the PROFILE\_OPTION in the simulation name file.
\end{itemize}

Expand Down
8 changes: 7 additions & 1 deletion src/Solution/ParticleTracker/MethodSubcellTernary.f90
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,14 @@ subroutine track_subcell(this, subcell, particle, tmax)
call clamp_bary(alpi, beti, gami, pad=DSAME * DEP3)

! Do calculations related to the analytical z solution.
! todo: just once for each cell? store at cell-level?
! (TODO: just once for each cell? store at cell-level?)
! Clamp the relative z coordinate to the unit interval.
zirel = (zi - zbot) / dz
if (zirel > DONE) then
zirel = DONE
else
zirel = DZERO
end if
call calculate_dt(vzbot, vztop, dz, zirel, vzi, &
az, dtexitz, izstatus, &
itopbotexit)
Expand Down

0 comments on commit 42cdc58

Please sign in to comment.