Skip to content

Commit 11b98f2

Browse files
authoredDec 17, 2024··
refactor(prt): make exit_solve_tolerance optional, update release notes (#2107)
Mention the EXIT_SOLVE_TOLERANCE option now in the PRP package in the release notes, I missed this before. This was previously a required option, but need not be — set a default of 1e-5, and simplify some tests in light of this. Also draft a PRT migration guide, building on the development notes added in #2066, which could be distributed with the release. I'm not sure whether this is something to version, and if so, where it should go, but figured it can't hurt to have it.
1 parent 5a0f854 commit 11b98f2

16 files changed

+216
-164
lines changed
 

‎autotest/test_prt_budget.py

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from flopy.utils.binaryfile import HeadFile
2020
from framework import TestFramework
2121
from prt_test_utils import (
22-
DEFAULT_EXIT_SOLVE_TOL,
2322
HorizontalCase,
2423
all_equal,
2524
check_budget_data,
@@ -88,7 +87,6 @@ def build_prt_sim(name, gwf_ws, prt_ws, mf6):
8887
trackcsv_filerecord=[prp_track_csv_file],
8988
stop_at_weak_sink=False,
9089
boundnames=True,
91-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
9290
extend_tracking=True,
9391
)
9492

‎autotest/test_prt_drape.py

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from flopy.utils.binaryfile import HeadFile
2121
from framework import TestFramework
2222
from prt_test_utils import (
23-
DEFAULT_EXIT_SOLVE_TOL,
2423
all_equal,
2524
check_track_data,
2625
get_model_name,
@@ -182,7 +181,6 @@ def build_prt_sim(name, gwf_ws, prt_ws, mf6):
182181
track_filerecord=[prp_track_file],
183182
trackcsv_filerecord=[prp_track_csv_file],
184183
drape="drp" in name,
185-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
186184
extend_tracking=True,
187185
)
188186

‎autotest/test_prt_dry.py

-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,6 @@ def build_prt_sim(name, gwf, prt_ws, mf6, drape=False, dry_tracking_method=False
301301
packagedata=prp_data,
302302
nreleasetimes=1,
303303
releasetimes=[(0.0,)],
304-
exit_solve_tolerance=1e-7,
305304
drape=drape,
306305
dry_tracking_method=dry_tracking_method,
307306
pname="prp",

‎autotest/test_prt_exg.py

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from flopy.utils.binaryfile import HeadFile
2525
from framework import TestFramework
2626
from prt_test_utils import (
27-
DEFAULT_EXIT_SOLVE_TOL,
2827
FlopyReadmeCase,
2928
check_budget_data,
3029
check_track_data,
@@ -73,7 +72,6 @@ def build_mf6_sim(idx, test):
7372
packagedata=rpts,
7473
perioddata={0: ["FIRST"]},
7574
boundnames="bnms" in name,
76-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
7775
extend_tracking=True,
7876
)
7977

‎autotest/test_prt_fmi.py

-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from flopy.utils.binaryfile import HeadFile
3939
from framework import TestFramework
4040
from prt_test_utils import (
41-
DEFAULT_EXIT_SOLVE_TOL,
4241
FlopyReadmeCase,
4342
all_equal,
4443
check_budget_data,
@@ -116,7 +115,6 @@ def build_prt_sim(name, gwf_ws, prt_ws, mf6):
116115
trackcsv_filerecord=[prp_track_csv_file],
117116
stop_at_weak_sink="saws" in prt_name,
118117
boundnames=True,
119-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
120118
extend_tracking="noext" not in prt_name,
121119
)
122120

‎autotest/test_prt_quad_refinement.py

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from flopy.utils.gridgen import Gridgen
1919
from framework import TestFramework
2020
from prt_test_utils import (
21-
DEFAULT_EXIT_SOLVE_TOL,
2221
FlopyReadmeCase,
2322
check_budget_data,
2423
check_track_data,
@@ -144,7 +143,6 @@ def build_mf6_sim(idx, test, **kwargs):
144143
nreleasepts=len(rpts),
145144
packagedata=rpts,
146145
perioddata={0: ["FIRST"]},
147-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
148146
dev_forceternary=tracking_method == "ternary",
149147
extend_tracking=True,
150148
)

‎autotest/test_prt_release_timing.py

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from framework import TestFramework
2525
from modflow_devtools.markers import requires_pkg
2626
from prt_test_utils import (
27-
DEFAULT_EXIT_SOLVE_TOL,
2827
FlopyReadmeCase,
2928
all_equal,
3029
check_budget_data,
@@ -176,7 +175,6 @@ def build_prt_sim(name, gwf_ws, prt_ws, mf6):
176175
else None,
177176
release_time_frequency=0.2 if "freq" in name else None,
178177
print_input=True,
179-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
180178
extend_tracking=True,
181179
release_time_tolerance=0.2 if "tol" in name else None,
182180
)

‎autotest/test_prt_stop_zones.py

-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from framework import TestFramework
3636
from matplotlib.collections import LineCollection
3737
from prt_test_utils import (
38-
DEFAULT_EXIT_SOLVE_TOL,
3938
FlopyReadmeCase,
4039
check_budget_data,
4140
check_track_data,
@@ -127,7 +126,6 @@ def build_prt_sim(name, gwf_ws, prt_ws, mf6):
127126
packagedata=FlopyReadmeCase.releasepts_prt,
128127
perioddata={0: ["FIRST"]},
129128
istopzone=1,
130-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
131129
extend_tracking=True,
132130
)
133131

‎autotest/test_prt_track_events.py

-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from flopy.utils.binaryfile import HeadFile
3535
from framework import TestFramework
3636
from prt_test_utils import (
37-
DEFAULT_EXIT_SOLVE_TOL,
3837
FlopyReadmeCase,
3938
check_budget_data,
4039
check_track_data,
@@ -140,7 +139,6 @@ def build_prt_sim(name, gwf_ws, prt_ws, mf6):
140139
nreleasepts=len(releasepts_prt[grp]),
141140
packagedata=releasepts_prt[grp],
142141
perioddata={0: ["FIRST"]},
143-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
144142
extend_tracking=True,
145143
)
146144
for grp in ["a", "b"]

‎autotest/test_prt_triangle.py

-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ def build_prt_sim(idx, name, gwf_ws, prt_ws, targets):
177177
perioddata={0: ["FIRST"]},
178178
boundnames=True,
179179
stop_at_weak_sink=True, # currently required for this problem
180-
exit_solve_tolerance=1e-5,
181180
extend_tracking=True,
182181
)
183182
prt_track_file = f"{prtname}.trk"

‎autotest/test_prt_weak_sinks.py

-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from flopy.utils.binaryfile import HeadFile
3535
from framework import TestFramework
3636
from prt_test_utils import (
37-
DEFAULT_EXIT_SOLVE_TOL,
3837
FlopyReadmeCase,
3938
check_budget_data,
4039
check_track_data,
@@ -97,7 +96,6 @@ def build_prt_sim(name, gwf_ws, prt_ws, mf6):
9796
packagedata=FlopyReadmeCase.releasepts_prt,
9897
perioddata={0: ["FIRST"]},
9998
stop_at_weak_sink="saws" in name,
100-
exit_solve_tolerance=DEFAULT_EXIT_SOLVE_TOL,
10199
extend_tracking=True,
102100
)
103101

‎doc/ReleaseNotes/develop.tex

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
\item With a flow model using the Newton formulation, the PRT model could crash upon a particle's entry into a dry cell. This has been fixed.
5555
\item With a flow model using the Newton formulation, the PRT model could enter an endless loop upon a particle's entry to a dry cell if that cell contains a boundary package (e.g. a pumping well). Where the particle should be captured and terminate, it would instead be passed back and forth between the cell bottom and the top of the cell below. To avoid this, particles are forbidden from backtracking (reentering the previous cell) within the same time step.
5656
\item The PRT model now allows more control over vertical particle motion in dry conditions. In addition to the existing DRAPE option, which controls release-time behavior, the PRP package now provides a DRY\_TRACKING\_METHOD option which configures how dry particles (particles in dry cells, or above the water table in partially saturated cells) behave at tracking time. This option is relevant only when the Newton formulation is used, in which case dry cells remain active; otherwise, dry cells are inactive and particles will terminate. See the MF6IO document for a detailed explanation of DRY\_TRACKING\_METHOD.
57+
\item The PRT model's Particle Release Point (PRP) package now provides an option EXIT\_SOLVE\_TOLERANCE which configures the tolerance to use when solving for a particle's exit location from an unstructured grid cell. This value is only used for the generalized (ternary) tracking method on vertex grids. A value of 0.00001 is set by default. This value works well for many problems, but the value that strikes the best balance between accuracy and runtime is problem-dependent.
5758
\end{itemize}
5859

5960
%\underline{INTERNAL FLOW PACKAGES}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ block options
3030
name exit_solve_tolerance
3131
type double precision
3232
reader urword
33-
optional false
33+
optional true
3434
longname exit solve tolerance
3535
description the convergence tolerance for iterative solution of particle exit location and time in the generalized Pollock's method. A value of 0.00001 works well for many problems, but the value that strikes the best balance between accuracy and runtime is problem-dependent.
36+
default_value 1e-5
3637

3738
block options
3839
name local_z

‎src/Model/ParticleTracking/prt-prp.f90

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module PrtPrpModule
22
use KindModule, only: DP, I4B, LGP
3-
use ConstantsModule, only: DZERO, DEM1, DONE, LENFTYPE, LINELENGTH, &
3+
use ConstantsModule, only: DZERO, DEM1, DEM5, DONE, LENFTYPE, LINELENGTH, &
44
LENBOUNDNAME, LENPAKLOC, TABLEFT, TABCENTER, &
55
MNORMAL, DSAME, DEP3, DEP9
66
use BndModule, only: BndType
@@ -64,7 +64,6 @@ module PrtPrpModule
6464
real(DP), pointer :: offset => null() !< release time offset
6565
real(DP), pointer :: stoptime => null() !< stop time for all release points
6666
real(DP), pointer :: stoptraveltime => null() !< stop travel time for all points
67-
logical(LGP), pointer :: foundtol => null() !< whether tolerance option was found
6867
integer(I4B), pointer, contiguous :: rptnode(:) => null() !< release point reduced nns
6968
integer(I4B), pointer, contiguous :: rptzone(:) => null() !< release point zone numbers
7069
real(DP), pointer, contiguous :: rptx(:) => null() !< release point x coordinates
@@ -173,7 +172,6 @@ subroutine prp_da(this)
173172
call mem_deallocate(this%extol)
174173
call mem_deallocate(this%rttol)
175174
call mem_deallocate(this%rtfreq)
176-
call mem_deallocate(this%foundtol)
177175

178176
! Deallocate arrays
179177
call mem_deallocate(this%rptx)
@@ -263,7 +261,6 @@ subroutine prp_allocate_scalars(this)
263261
call mem_allocate(this%extol, 'EXTOL', this%memoryPath)
264262
call mem_allocate(this%rttol, 'RTTOL', this%memoryPath)
265263
call mem_allocate(this%rtfreq, 'RTFREQ', this%memoryPath)
266-
call mem_allocate(this%foundtol, 'FOUNDTOL', this%memoryPath)
267264

268265
! Set values
269266
this%ilocalz = 0
@@ -284,10 +281,9 @@ subroutine prp_allocate_scalars(this)
284281
this%irlstls = 0
285282
this%ifrctrn = 0
286283
this%iexmeth = 0
287-
this%extol = DZERO
284+
this%extol = DEM5
288285
this%rttol = DSAME * DEP9
289286
this%rtfreq = DZERO
290-
this%foundtol = .false.
291287

292288
end subroutine prp_allocate_scalars
293289

@@ -782,7 +778,6 @@ subroutine prp_options(this, option, found)
782778
if (this%extol <= DZERO) &
783779
call store_error('EXIT_SOLVE_TOLERANCE MUST BE POSITIVE')
784780
found = .true.
785-
this%foundtol = .true.
786781
case ('RELEASE_TIME_TOLERANCE')
787782
this%rttol = this%parser%GetDouble()
788783
if (this%rttol <= DZERO) &
@@ -832,9 +827,6 @@ subroutine prp_read_dimensions(this)
832827
integer(I4B) :: ierr
833828
logical :: isfound, endOfBlock
834829

835-
if (.not. this%foundtol) &
836-
call store_error('EXIT_SOLVE_TOLERANCE MISSING, VALUE REQUIRED')
837-
838830
! get dimension block
839831
call this%parser%GetBlock('DIMENSIONS', isfound, ierr, &
840832
supportOpenClose=.true.)

0 commit comments

Comments
 (0)
Please sign in to comment.