Skip to content

Commit 4d9a763

Browse files
committed
fix(prt): record user tracking times for stationary particles
1 parent 7d47192 commit 4d9a763

File tree

7 files changed

+52
-8
lines changed

7 files changed

+52
-8
lines changed
Binary file not shown.

autotest/test_prt_dry.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
for i in range(nper):
7171
period_data.append((perlen[i], nstp[i], tsmult[i]))
7272

73+
user_time = 100.0
74+
7375

7476
def build_gwf_sim(name, gwf_ws, mf6, newton=False):
7577
sim = flopy.mf6.MFSimulation(
@@ -319,6 +321,8 @@ def build_prt_sim(name, gwf, prt_ws, mf6, drape=False, dry_tracking_method=False
319321
trackcsv_filerecord=[trackcsvfile],
320322
saverecord=[("BUDGET", "ALL")],
321323
pname="oc",
324+
ntracktimes=1 if "stay" in name else 0,
325+
tracktimes=[(user_time,)] if "stay" in name else None,
322326
)
323327

324328
rel_prt_folder = os.path.relpath(gwf_ws, start=prt_ws)
@@ -373,6 +377,8 @@ def check_output(idx, test, snapshot):
373377
# ignore particle 4, it terminates early with optimization=2 when built with ifort
374378
if "drop" in name:
375379
actual = actual.drop(actual[actual.irpt == 4].index)
380+
if "stay" in name:
381+
assert len(actual[actual.t == user_time]) == 5
376382
assert snapshot == actual.to_records(index=False)
377383

378384
plot_pathlines = False

src/Solution/ParticleTracker/Method.f90

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,18 @@ end subroutine save
191191
!! tracking the particle or terminate it, as well as whether to
192192
!! record any output data as per selected reporting conditions.
193193
!<
194-
subroutine check(this, particle, cell_defn)
194+
subroutine check(this, particle, cell_defn, tmax)
195195
! modules
196196
use TdisModule, only: endofsimulation, totim
197197
! dummy
198198
class(MethodType), intent(inout) :: this
199199
type(ParticleType), pointer, intent(inout) :: particle
200200
type(CellDefnType), pointer, intent(inout) :: cell_defn
201+
real(DP), intent(in) :: tmax
201202
! local
202203
logical(LGP) :: dry_cell, dry_particle, no_exit_face, stop_zone, weak_sink
204+
integer(I4B) :: i
205+
real(DP) :: t
203206

204207
dry_cell = this%fmi%ibdgwfsat0(cell_defn%icell) == 0
205208
dry_particle = particle%z > cell_defn%top
@@ -235,6 +238,8 @@ subroutine check(this, particle, cell_defn)
235238

236239
if (dry_cell) then
237240
if (particle%idrymeth == 0) then
241+
! drop to cell bottom. handled by pass
242+
! to bottom method, nothing to do here
238243
no_exit_face = .false.
239244
else if (particle%idrymeth == 1) then
240245
! stop
@@ -246,23 +251,38 @@ subroutine check(this, particle, cell_defn)
246251
! stay
247252
no_exit_face = .false.
248253
particle%advancing = .false.
254+
255+
! update tracking time to time
256+
! step end time and save record
249257
particle%ttrack = totim
258+
call this%save(particle, reason=2)
259+
260+
! record user tracking times
261+
call this%tracktimes%advance()
262+
if (this%tracktimes%any()) then
263+
do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
264+
t = this%tracktimes%times(i)
265+
if (t < particle%ttrack) cycle
266+
if (t >= tmax) exit
267+
particle%ttrack = t
268+
call this%save(particle, reason=5)
269+
end do
270+
end if
271+
250272
! terminate if last period/step
251273
if (endofsimulation) then
252274
particle%istatus = 5
253275
call this%save(particle, reason=3)
254276
return
255277
end if
256-
call this%save(particle, reason=2)
257278
end if
258279
else if (dry_particle .and. this%name /= "passtobottom") then
259-
! dry particle
260280
if (particle%idrymeth == 0) then
261281
! drop to water table
262282
particle%z = cell_defn%top
263283
call this%save(particle, reason=1)
264284
else if (particle%idrymeth == 1) then
265-
! terminate
285+
! stop
266286
particle%advancing = .false.
267287
particle%istatus = 7
268288
call this%save(particle, reason=3)
@@ -271,6 +291,24 @@ subroutine check(this, particle, cell_defn)
271291
! stay
272292
no_exit_face = .false.
273293
particle%advancing = .false.
294+
295+
! update tracking time to time
296+
! step end time and save record
297+
particle%ttrack = totim
298+
call this%save(particle, reason=2)
299+
300+
! record user tracking times
301+
call this%tracktimes%advance()
302+
if (this%tracktimes%any()) then
303+
do i = this%tracktimes%selection(1), this%tracktimes%selection(2)
304+
t = this%tracktimes%times(i)
305+
if (t < particle%ttrack) cycle
306+
if (t >= tmax) exit
307+
particle%ttrack = t
308+
call this%save(particle, reason=5)
309+
end do
310+
end if
311+
274312
return
275313
end if
276314
end if

src/Solution/ParticleTracker/MethodCellPassToBot.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ subroutine apply_ptb(this, particle, tmax)
4747
real(DP), intent(in) :: tmax
4848

4949
! Check termination/reporting conditions
50-
call this%check(particle, this%cell%defn)
50+
call this%check(particle, this%cell%defn, tmax)
5151
if (.not. particle%advancing) return
5252

5353
! Pass to bottom face

src/Solution/ParticleTracker/MethodCellPollock.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ subroutine apply_mcp(this, particle, tmax)
130130
select type (cell => this%cell)
131131
type is (CellRectType)
132132
! Check termination/reporting conditions
133-
call this%check(particle, cell%defn)
133+
call this%check(particle, cell%defn, tmax)
134134
if (.not. particle%advancing) return
135135

136136
! Transform model coordinates to local cell coordinates

src/Solution/ParticleTracker/MethodCellPollockQuad.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ subroutine apply_mcpq(this, particle, tmax)
209209
select type (cell => this%cell)
210210
type is (CellRectQuadType)
211211
! Check termination/reporting conditions
212-
call this%check(particle, cell%defn)
212+
call this%check(particle, cell%defn, tmax)
213213
if (.not. particle%advancing) return
214214

215215
! Transform model coordinates to local cell coordinates

src/Solution/ParticleTracker/MethodCellTernary.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ subroutine apply_mct(this, particle, tmax)
165165
select type (cell => this%cell)
166166
type is (CellPolyType)
167167
! Check termination/reporting conditions
168-
call this%check(particle, this%cell%defn)
168+
call this%check(particle, this%cell%defn, tmax)
169169
if (.not. particle%advancing) return
170170

171171
! Number of vertices

0 commit comments

Comments
 (0)