Skip to content

Commit 41a8eb1

Browse files
committed
fix termination reporting
1 parent eccf492 commit 41a8eb1

File tree

8 files changed

+262
-228
lines changed

8 files changed

+262
-228
lines changed
Binary file not shown.
Binary file not shown.

autotest/test_prt_dry.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@
7272

7373
user_time = 100.0
7474

75+
# particles are released in layer 0
76+
offsets = [
77+
(-1, 0, 0),
78+
(-1, -1, 0),
79+
(-1, 1, 0),
80+
(-1, 0, -1),
81+
(-1, 0, 1),
82+
]
83+
7584

7685
def build_gwf_sim(name, gwf_ws, mf6, newton=False):
7786
sim = flopy.mf6.MFSimulation(
@@ -269,15 +278,6 @@ def build_prt_sim(name, gwf, prt_ws, mf6, drape=False, dry_tracking_method=False
269278

270279
flopy.mf6.ModflowPrtmip(prt, porosity=porosity, pname="mip")
271280

272-
# particles are released in layer 0
273-
offsets = [
274-
(-1, 0, 0),
275-
(-1, -1, 0),
276-
(-1, 1, 0),
277-
(-1, 0, -1),
278-
(-1, 0, 1),
279-
]
280-
281281
lay = 1
282282
row, col = (int(nrow / 4), int(ncol / 4))
283283
prp_cells = [(lay + k, row + i, col + j) for k, i, j in offsets]
@@ -372,13 +372,30 @@ def check_output(idx, test, snapshot):
372372
strtpts = pls[pls.ireason == 0]
373373

374374
# compare to expected results
375-
decimals = 1 if "drop" in name else 2
376-
actual = pls.drop(["name", "icell"], axis=1).round(decimals).reset_index(drop=True)
377-
# ignore particle 4, it terminates early with optimization=2 when built with ifort
378-
if "drop" in name:
375+
places = 1 if "drop" in name else 2
376+
actual = pls.drop(["name", "icell"], axis=1).round(places).reset_index(drop=True)
377+
nparts = len(offsets) # number of particles
378+
379+
if "drape" in name:
380+
assert len(actual[actual.ireason == 0]) == nparts # release
381+
elif "drop" in name:
382+
# ignore particle 4, it terminates early with optimization=2 when built with ifort
379383
actual = actual.drop(actual[actual.irpt == 4].index)
380-
if "stay" in name:
381-
assert len(actual[actual.t == user_time]) == 5
384+
nparts -= 1
385+
assert len(actual[actual.ireason == 0]) == nparts # release
386+
elif "stop" in name:
387+
assert len(actual[actual.ireason == 0]) == nparts # release
388+
elif "stay" in name:
389+
assert len(actual[actual.ireason == 0]) == nparts # release
390+
assert len(actual[actual.t == user_time]) == nparts # user time
391+
else:
392+
# immediate termination, permanently unreleased
393+
assert len(actual) == nparts
394+
395+
# in all cases, all particles should have a termination event
396+
assert len(actual[actual.ireason == 3]) == nparts
397+
398+
# snapshot comparison
382399
assert snapshot == actual.to_records(index=False)
383400

384401
plot_pathlines = False

src/Model/ModelUtilities/TrackFile.f90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ module TrackFileModule
4747
!! 1: active
4848
!! 2: terminated at boundary face
4949
!! 3: terminated in weak sink cell
50-
!! 4: terminated in weak source cell**
50+
!! 4: terminated in weak source cell
5151
!! 5: terminated in cell with no exit face
5252
!! 6: terminated in cell with specified zone number
5353
!! 7: terminated in inactive cell
5454
!! 8: permanently unreleased***
5555
!! 9: terminated in subcell with no exit face*****
56+
!! 10: terminated upon simulation's end
5657
!!
5758
!! PRT shares the same status enumeration as MODPATH 7. However, some
5859
!! don't apply to PRT; for instance, MODPATH 7 distinguishes forwards

src/Model/ParticleTracking/prt-prp.f90

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,11 @@ subroutine release(this, ip, trelease)
436436
type(ParticleType), pointer :: particle
437437

438438
call this%initialize_particle(particle, ip, trelease)
439-
440-
! Increment cumulative particle count
441439
np = this%nparticles + 1
442440
this%nparticles = np
443-
444-
! Save the particle to the store
445-
call this%particles%save_particle(particle, np)
441+
call this%particles%put(particle, np)
446442
deallocate (particle)
447-
448-
! Accumulate mass for release point
449-
this%rptm(ip) = this%rptm(ip) + DONE
443+
this%rptm(ip) = this%rptm(ip) + DONE ! TODO configurable mass
450444

451445
end subroutine release
452446

@@ -486,7 +480,6 @@ subroutine initialize_particle(this, particle, ip, trelease)
486480
end select
487481
particle%ilay = ilay
488482
particle%izone = this%rptzone(ic)
489-
490483
particle%istatus = 0
491484
! If the cell is inactive, either drape the particle
492485
! to the top-most active cell beneath it if drape is
@@ -495,8 +488,9 @@ subroutine initialize_particle(this, particle, ip, trelease)
495488
ic_old = ic
496489
if (this%idrape > 0) then
497490
call this%dis%highest_active(ic, this%ibound)
498-
if (ic == ic_old .or. this%ibound(ic) == 0) &
491+
if (ic == ic_old .or. this%ibound(ic) == 0) then
499492
particle%istatus = 8
493+
end if
500494
else
501495
particle%istatus = 8
502496
end if

0 commit comments

Comments
 (0)