Skip to content

Commit

Permalink
fix(ModflowUzf1): update load for iuzfopt = -1 (#1416)
Browse files Browse the repository at this point in the history
* updates for plot_pathline()
* update(t034_test.py): update test_uzf_negative_iuzfopt for linux
* Close #1406
  • Loading branch information
jlarsen-usgs committed May 17, 2022
1 parent 1cd4ba0 commit 0136b7f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 15 deletions.
47 changes: 41 additions & 6 deletions autotest/t034_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,21 +627,30 @@ def test_uzf_negative_iuzfopt():
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)

ml = flopy.modflow.Modflow(
modelname="uzf_neg",
version="mfnwt",
exe_name="mfnwt.exe",
exe_name="mfnwt",
model_ws=model_ws
)
dis = flopy.modflow.ModflowDis(
ml,
nper=2,
perlen=[1,1],
nstp=[1,1],
nlay=1,
nrow=10,
ncol=10,
top=10,
perlen=[1, 1],
nstp=[5, 5],
tsmult=1,
steady=[True, False]
steady=[False, False]
)
bas = flopy.modflow.ModflowBas(ml, strt=9, ibound=1)
upw = flopy.modflow.ModflowUpw(
ml,
vka=0.1,
)
bas = flopy.modflow.ModflowBas(ml)
upw = flopy.modflow.ModflowUpw(ml)
oc = flopy.modflow.ModflowOc(ml)
nwt = flopy.modflow.ModflowNwt(ml, options="SIMPLE")

uzf = flopy.modflow.ModflowUzf1(
ml,
Expand All @@ -650,10 +659,36 @@ def test_uzf_negative_iuzfopt():
irunflg=1,
ietflg=1,
irunbnd=1,
finf=1e-06,
pet=0.1,
extdp=0.2,
specifysurfk=True,
seepsurfk=True
)

# uzf.write_file(os.path.join(model_ws, "uzf_neg.uzf"))

ml.write_input()
success, buff = ml.run_model()
if not success:
raise AssertionError("UZF model with -1 iuzfopt failed to run")

ml2 = flopy.modflow.Modflow.load(
"uzf_neg.nam",
version="mfnwt",
model_ws=model_ws
)

pet = ml2.uzf.pet.array
extpd = ml2.uzf.pet.array

if not np.max(pet) == np.min(pet) and np.max(pet) != 0.1:
raise AssertionError("Read error for iuzfopt less than 0")

if not np.max(extpd) == np.min(extpd) and np.max(extpd) != 0.2:
raise AssertionError("Read error for iuzfopt less than 0")


if __name__ == "__main__":
test_create_uzf()
test_read_write_nwt_options()
Expand Down
21 changes: 13 additions & 8 deletions flopy/modflow/mfuzf1.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,11 @@ def write_transient(name):
write_transient("extdp")
if self.iuzfopt > 0:
write_transient("extwc")
if self.capillaryuzet and "nwt" in self.parent.version:
if (
self.capillaryuzet
and "nwt" in self.parent.version
and self.iuzfopt > 0
):
write_transient("air_entry")
write_transient("hroot")
write_transient("rootact")
Expand Down Expand Up @@ -1049,7 +1053,7 @@ def load_util2d(name, dtype, per=None):
if nuzf1 >= 0:
load_util2d("finf", np.float32, per=per)

if ietflg > 0 and iuzfopt > 0:
if ietflg > 0:
# dataset 11
line = line_parse(f.readline())
nuzf2 = pop_item(line, int)
Expand All @@ -1063,13 +1067,14 @@ def load_util2d(name, dtype, per=None):
# dataset 14
load_util2d("extdp", np.float32, per=per)
# dataset 15
line = line_parse(f.readline())
nuzf4 = pop_item(line, int)
if nuzf4 >= 0:
# dataset 16
load_util2d("extwc", np.float32, per=per)
if iuzfopt > 0:
line = line_parse(f.readline())
nuzf4 = pop_item(line, int)
if nuzf4 >= 0:
# dataset 16
load_util2d("extwc", np.float32, per=per)

if capillaryuzet:
if capillaryuzet and iuzfopt > 0:
# dataset 17
line = line_parse(f.readline())
nuzf5 = pop_item(line, int)
Expand Down
6 changes: 5 additions & 1 deletion flopy/plot/crosssection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,11 @@ def plot_pathline(

# make sure pathlines is a list
if not isinstance(pl, list):
pl = [pl]
pids = np.unique(pl["particleid"])
if len(pids) > 1:
pl = [pl[pl["particleid"] == pid] for pid in pids]
else:
pl = [pl]

marker = kwargs.pop("marker", None)
markersize = kwargs.pop("markersize", None)
Expand Down
3 changes: 3 additions & 0 deletions flopy/plot/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ def plot_pathline(self, pl, travel_time=None, **kwargs):
color=markercolor,
ms=markersize,
)

ax.set_xlim(self.extent[0], self.extent[1])
ax.set_ylim(self.extent[2], self.extent[3])
return lc

def plot_timeseries(self, ts, travel_time=None, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions flopy/plot/plotutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2789,6 +2789,8 @@ def reproject_modpath_to_crosssection(
while tcell >= ncpl:
tcell -= ncpl
line = xypts[tcell]
if len(line) < 2:
continue
if projection == "x":
d0 = np.min([i[0] for i in projpts[cell]])
else:
Expand Down

0 comments on commit 0136b7f

Please sign in to comment.