Skip to content

Commit

Permalink
fix(prt): skip release times falling outside tdis (#2127)
Browse files Browse the repository at this point in the history
Mentioned in the discussion in #2125, skip release times before simulation start, and after simulation end if no extended tracking.
  • Loading branch information
wpbonelli authored Jan 6, 2025
1 parent 5105ce7 commit 8ef3ad7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
12 changes: 5 additions & 7 deletions doc/ReleaseNotes/develop.tex
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
% \item xxx
%\end{itemize}

%\textbf{\underline{BUG FIXES AND OTHER CHANGES TO EXISTING FUNCTIONALITY}} \\
%\underline{BASIC FUNCTIONALITY}
%\begin{itemize}
% \item xxx
% \item xxx
% \item xxx
%\end{itemize}
\textbf{\underline{BUG FIXES AND OTHER CHANGES TO EXISTING FUNCTIONALITY}} \\
\underline{BASIC FUNCTIONALITY}
\begin{itemize}
\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.
\end{itemize}

%\underline{INTERNAL FLOW PACKAGES}
%\begin{itemize}
Expand Down
4 changes: 2 additions & 2 deletions doc/mf6io/mf6ivar/dfn/prt-prp.dfn
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ type double precision
reader urword
optional true
longname stop time
description real value defining the maximum simulation time to which particles in the package can be tracked. Particles that have not terminated earlier due to another termination condition will terminate when simulation time STOPTIME is reached. If the last stress period in the simulation consists of more than one time step, particles will not be tracked past the ending time of the last stress period, regardless of STOPTIME. If the last stress period in the simulation consists of a single time step, it is assumed to be a steady-state stress period, and its ending time will not limit the simulation time to which particles can be tracked. If STOPTIME and STOPTRAVELTIME are both provided, particles will be stopped if either is reached.
description real value defining the maximum simulation time to which particles in the package can be tracked. Particles that have not terminated earlier due to another termination condition will terminate when simulation time STOPTIME is reached. If the last stress period in the simulation consists of more than one time step, particles will not be tracked past the ending time of the last stress period, regardless of STOPTIME. If the EXTEND\_TRACKING option is enabled and the last stress period in the simulation is steady-state, the simulation ending time will not limit the time to which particles can be tracked, but STOPTIME and STOPTRAVELTIME will continue to apply. If STOPTIME and STOPTRAVELTIME are both provided, particles will be stopped if either is reached.

block options
name stoptraveltime
type double precision
reader urword
optional true
longname stop travel time
description real value defining the maximum travel time over which particles in the model can be tracked. Particles that have not terminated earlier due to another termination condition will terminate when their travel time reaches STOPTRAVELTIME. If the last stress period in the simulation consists of more than one time step, particles will not be tracked past the ending time of the last stress period, regardless of STOPTRAVELTIME. If the last stress period in the simulation consists of a single time step, it is assumed to be a steady-state stress period, and its ending time will not limit the travel time over which particles can be tracked. If STOPTIME and STOPTRAVELTIME are both provided, particles will be stopped if either is reached.
description real value defining the maximum travel time over which particles in the model can be tracked. Particles that have not terminated earlier due to another termination condition will terminate when their travel time reaches STOPTRAVELTIME. If the last stress period in the simulation consists of more than one time step, particles will not be tracked past the ending time of the last stress period, regardless of STOPTRAVELTIME. If the EXTEND\_TRACKING option is enabled and the last stress period in the simulation is steady-state, the simulation ending time will not limit the time to which particles can be tracked, but STOPTIME and STOPTRAVELTIME will continue to apply. If STOPTIME and STOPTRAVELTIME are both provided, particles will be stopped if either is reached.

block options
name stop_at_weak_sink
Expand Down
7 changes: 3 additions & 4 deletions src/Model/ModelUtilities/ReleaseSchedule.f90
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,16 @@ subroutine advance(this, lines)
tprevious = trelease
end if

! Add explicitly configured release times, up
! to the configured tolerance of coincidence.
! Schedule explicitly specified release times, up
! to the configured tolerance of coincidence
if (this%time_select%any()) then
do it = this%time_select%selection(1), this%time_select%selection(2)
trelease = this%time_select%times(it)
! Skip the release time if it's too close
! to the previously scheduled release time.
if (tprevious >= DZERO .and. is_close( &
tprevious, &
trelease, &
atol=this%tolerance)) cycle

call this%schedule(trelease)
tprevious = trelease
end do
Expand Down
20 changes: 19 additions & 1 deletion src/Model/ParticleTracking/prt-prp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,10 @@ end subroutine prp_ar

!> @brief Advance a time step and release particles if scheduled.
subroutine prp_ad(this)
use TdisModule, only: totalsimtime
class(PrtPrpType) :: this
integer(I4B) :: ip, it
real(DP) :: t

! Notes
! -----
Expand Down Expand Up @@ -344,7 +346,23 @@ subroutine prp_ad(this)
! each release time in the current step.
do ip = 1, this%nreleasepoints
do it = 1, this%schedule%count()
call this%release(ip, this%schedule%times(it))
t = this%schedule%times(it)
! Skip the release time if it's before the simulation
! starts, or if no `extend_tracking`, after it ends.
if (t < DZERO) then
write (warnmsg, '(a,g0,a)') &
'Skipping negative release time (t=', t, ').'
call store_warning(warnmsg)
cycle
else if (t > totalsimtime .and. this%iextend == 0) then
write (warnmsg, '(a,g0,a)') &
'Skipping release time falling after the end of the &
&simulation (t=', t, '). Enable EXTEND_TRACKING to &
&release particles after the simulation end time.'
call store_warning(warnmsg)
cycle
end if
call this%release(ip, t)
end do
end do
end subroutine prp_ad
Expand Down

0 comments on commit 8ef3ad7

Please sign in to comment.