Skip to content

Commit 8ef3ad7

Browse files
authored
fix(prt): skip release times falling outside tdis (#2127)
Mentioned in the discussion in #2125, skip release times before simulation start, and after simulation end if no extended tracking.
1 parent 5105ce7 commit 8ef3ad7

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

doc/ReleaseNotes/develop.tex

+5-7
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
% \item xxx
1818
%\end{itemize}
1919

20-
%\textbf{\underline{BUG FIXES AND OTHER CHANGES TO EXISTING FUNCTIONALITY}} \\
21-
%\underline{BASIC FUNCTIONALITY}
22-
%\begin{itemize}
23-
% \item xxx
24-
% \item xxx
25-
% \item xxx
26-
%\end{itemize}
20+
\textbf{\underline{BUG FIXES AND OTHER CHANGES TO EXISTING FUNCTIONALITY}} \\
21+
\underline{BASIC FUNCTIONALITY}
22+
\begin{itemize}
23+
\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.
24+
\end{itemize}
2725

2826
%\underline{INTERNAL FLOW PACKAGES}
2927
%\begin{itemize}

doc/mf6io/mf6ivar/dfn/prt-prp.dfn

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ type double precision
134134
reader urword
135135
optional true
136136
longname stop time
137-
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.
137+
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.
138138

139139
block options
140140
name stoptraveltime
141141
type double precision
142142
reader urword
143143
optional true
144144
longname stop travel time
145-
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.
145+
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.
146146

147147
block options
148148
name stop_at_weak_sink

src/Model/ModelUtilities/ReleaseSchedule.f90

+3-4
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,16 @@ subroutine advance(this, lines)
142142
tprevious = trelease
143143
end if
144144

145-
! Add explicitly configured release times, up
146-
! to the configured tolerance of coincidence.
145+
! Schedule explicitly specified release times, up
146+
! to the configured tolerance of coincidence
147147
if (this%time_select%any()) then
148148
do it = this%time_select%selection(1), this%time_select%selection(2)
149149
trelease = this%time_select%times(it)
150-
! Skip the release time if it's too close
151-
! to the previously scheduled release time.
152150
if (tprevious >= DZERO .and. is_close( &
153151
tprevious, &
154152
trelease, &
155153
atol=this%tolerance)) cycle
154+
156155
call this%schedule(trelease)
157156
tprevious = trelease
158157
end do

src/Model/ParticleTracking/prt-prp.f90

+19-1
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,10 @@ end subroutine prp_ar
308308

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

314316
! Notes
315317
! -----
@@ -344,7 +346,23 @@ subroutine prp_ad(this)
344346
! each release time in the current step.
345347
do ip = 1, this%nreleasepoints
346348
do it = 1, this%schedule%count()
347-
call this%release(ip, this%schedule%times(it))
349+
t = this%schedule%times(it)
350+
! Skip the release time if it's before the simulation
351+
! starts, or if no `extend_tracking`, after it ends.
352+
if (t < DZERO) then
353+
write (warnmsg, '(a,g0,a)') &
354+
'Skipping negative release time (t=', t, ').'
355+
call store_warning(warnmsg)
356+
cycle
357+
else if (t > totalsimtime .and. this%iextend == 0) then
358+
write (warnmsg, '(a,g0,a)') &
359+
'Skipping release time falling after the end of the &
360+
&simulation (t=', t, '). Enable EXTEND_TRACKING to &
361+
&release particles after the simulation end time.'
362+
call store_warning(warnmsg)
363+
cycle
364+
end if
365+
call this%release(ip, t)
348366
end do
349367
end do
350368
end subroutine prp_ad

0 commit comments

Comments
 (0)