Skip to content

Commit b9f1999

Browse files
authored
fix(prt): distinguish cell exit from subcell exit events (#2438)
We currently define the PRT OC package's TRACK_EXIT keyword option as enabling reporting when particles exit any grid feature (model, cell or subcell), and report all such events with event code (i.e. reason code) 1. Thus subcell exits in the ternary method appear identical in output to cell transitions, despite the fact that subcells are an implementation detail of the ternary method and occur in the interior of user-defined grid cells. Distinguish subcell exit events from cell exits. Introduce a new PRT OC option TRACK_SUBFEATURE_EXIT which applies to all grid features below the level of the user-defined discretization (currently only subcell exits in DISV grids, but this could apply later to e.g. subreaches in surface water models, etc). The old TRACK_EXIT option now only applies to grid-scale features and above, i.e. cells (and models once we implement particle exchanges). While this changes the results reported by PRT under the default settings (see changed test snapshots for instance — fewer path points, now only on cell faces, which nicely matches mp7 when ternary is forced on a structured grid) we think that since subgrid features are not likely to be of interest to most users, this is reasonable to consider a fix, not a breaking change. Users opting into subfeature transition reporting will still not be able to distinguish cell exits from subcell exits, but that may soon change pending a proposed new output column identifying the domain level at which an event occurs. Also, move exit event firing routines to their respective method types, following on #2433.
1 parent 7e0b97a commit b9f1999

File tree

22 files changed

+166
-82
lines changed

22 files changed

+166
-82
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.

autotest/prt_test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def get_ireason_code(output_event):
311311
if output_event == "RELEASE"
312312
else (
313313
1
314-
if output_event == "CELLEXIT"
314+
if output_event == "EXITFEAT"
315315
else (
316316
2
317317
if output_event == "TIMESTEP"

autotest/test_prt_newton_disv1.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,20 @@ def compare_output(name, mf6_pls, mp7_pls, mp7_eps):
321321
del mp7_pls["node"]
322322

323323
if "bprp" not in name:
324-
# pollock's method should be (nearly) identical
324+
# both methods should be (nearly) identical to mp7
325325
mf6_pls_plck = mf6_pls[mf6_pls.particlegroup == 1]
326+
mf6_pls_tern = mf6_pls[mf6_pls.particlegroup == 2]
327+
326328
assert mf6_pls_plck.shape == mp7_pls.shape
327329
assert np.allclose(mf6_pls_plck, mp7_pls, atol=1e-3)
328330

329-
# ternary method will have extra path points
330-
# due to nudging, so just compare endpoints
331-
mf6_eps_tern = mf6_eps[mf6_eps.particlegroup == 2]
332-
mf6_eps_tern = mf6_eps_tern[["x", "y", "z", "time"]]
333-
mp7_eps = mp7_eps[["x", "y", "z", "time"]]
334-
assert mf6_eps_tern.shape == mp7_eps.shape
335-
assert np.allclose(mf6_eps_tern, mp7_eps, atol=1e-3)
331+
del mf6_pls_tern["particleid"]
332+
del mf6_pls_tern["particlegroup"]
333+
del mp7_pls["particleid"]
334+
del mp7_pls["particlegroup"]
335+
336+
assert mf6_pls_tern.shape == mp7_pls.shape
337+
assert np.allclose(mf6_pls_tern, mp7_pls, atol=1e-3)
336338

337339

338340
def check_output(idx, test):
@@ -498,9 +500,9 @@ def plot_output(idx, test):
498500
for ipl, ((iprp, irpt, trelease), pl) in enumerate(mf6_plines):
499501
pl.plot(
500502
title="MF6 pathlines",
501-
linestyle="None" if "trst" in name else "--",
503+
linestyle="--" if "trst" in name else None,
502504
marker="o",
503-
markersize=2,
505+
markersize=4,
504506
x="x",
505507
y="y",
506508
ax=ax[0],
@@ -523,6 +525,8 @@ def plot_output(idx, test):
523525
ax=ax[1],
524526
legend=False,
525527
color=cm.plasma(ipl / len(mp7_plines)),
528+
marker="o",
529+
markersize=4,
526530
)
527531

528532
# view/save plot

autotest/test_prt_ternary_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def check_output(idx, test, snapshot):
244244
endpts = pls.sort_values("t").groupby(["imdl", "iprp", "irpt", "trelease"]).tail(1)
245245

246246
# check pathline shape and endpoints
247-
assert pls.shape == (116, 16)
247+
assert pls.shape == (57, 16)
248248
assert endpts.shape == (2, 16)
249249
assert set(endpts.icell) == {111, 112}
250250

autotest/test_prt_triangle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def check_output(idx, test, snapshot):
299299
assert snapshot == endpts.drop("name", axis=1).round(3).to_records(index=False)
300300

301301
if "r2l" in name:
302-
assert pls.shape == (164, 16)
302+
assert pls.shape == (84, 16)
303303
assert (pls.z == 0.5).all()
304304
rtol = 1e-6
305305
assert isclose(min(pls.x), 0, rel_tol=rtol)
@@ -310,7 +310,7 @@ def check_output(idx, test, snapshot):
310310
assert isclose(max(pls[pls.irpt == 2].y), 86, rel_tol=rtol)
311311
assert set(endpts.icell) == {130, 136}
312312
elif "diag" in name:
313-
assert pls.shape == (232, 16)
313+
assert pls.shape == (114, 16)
314314
assert endpts.shape == (4, 16)
315315
assert set(endpts.icell) == {111, 112}
316316

doc/ReleaseNotes/develop.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ description = "Add DEPENDENT\\_VARIABLE\\_SCALING option to scale the dependent
6161
[[items]]
6262
section = "fixes"
6363
subsection = "solution"
64-
description = "The Particle Tracking (PRT) Model previously reported cell exit events when a dry particle stranded in a partially saturated cell was dropped to the water table, as occurs with DRY\\_TRACKING\\_METHOD DROP (the default). An event is no longer reported at this time."
64+
description = "The Particle Tracking (PRT) Model previously reported cell exit events when a dry particle stranded in a partially saturated cell was dropped to the water table, as occurs with DRY\\_TRACKING\\_METHOD DROP (the default). An event is no longer reported at this time."
65+
66+
[[items]]
67+
section = "fixes"
68+
subsection = "solution"
69+
description = "Previously the Particle Tracking (PRT) Model's generalized DISV tracking method did not distinguish subcell exit events from cell exits, reporting both with the same reason code (1). Since subcell exits occur at a scale below that defined by the model's grid discretization, they are an implementation detail of the generalized tracking method, and will therefore no longer be written by default to particle tracking output. The PRT Output Control (OC) package's TRACK\\_EXIT option will now apply exclusively to features at grid-scale or above. Writing particle transitions between sub-grid-scale features to output is now opt-in with a new keyword option TRACK\\_SUBFEATURE\\_EXIT."

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,16 @@ name track_exit
156156
type keyword
157157
reader urword
158158
optional true
159-
longname track transitions
160-
description keyword to indicate that particle tracking output is to be written when a particle exits a feature (a model, cell, or subcell)
159+
longname track domain exits
160+
description keyword to indicate that particle tracking output is to be written when a particle exits a grid feature (e.g. model, cell)
161+
162+
block options
163+
name track_subfeature_exit
164+
type keyword
165+
reader urword
166+
optional true
167+
longname track cell exits
168+
description keyword to indicate that particle tracking output is to be written when a particle exits a sub-grid-scale feature. Such features are considered implementation details of the tracking algorithm employed for particular grid types, and reporting for exit events from such features is disabled by default.
161169

162170
block options
163171
name track_timestep

doc/mf6io/prt/prt.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ \subsection{Particle Track Output}
121121

122122
\begin{description} \itemsep0pt \parskip0pt \parsep0pt
123123
\item \texttt{0}: particle was released
124-
\item \texttt{1}: particle exited a cell
124+
\item \texttt{1}: particle exited a grid feature
125125
\item \texttt{2}: time step ended
126126
\item \texttt{3}: particle terminated
127127
\item \texttt{4}: particle entered a weak sink cell

0 commit comments

Comments
 (0)