From 7cdd9c17b6ef94e3bcfa935b760e4db6e3a87c4e Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Mon, 16 May 2022 14:12:30 -0700 Subject: [PATCH 1/2] fix(ModflowUzf1): update load for iuzfopt = -1 * updates for plot_pathline() --- autotest/t034_test.py | 45 +++++++++++++++++++++++++++++++++----- flopy/modflow/mfuzf1.py | 21 +++++++++++------- flopy/plot/crosssection.py | 6 ++++- flopy/plot/map.py | 3 +++ flopy/plot/plotutil.py | 2 ++ 5 files changed, 63 insertions(+), 14 deletions(-) diff --git a/autotest/t034_test.py b/autotest/t034_test.py index cd32013b56..a6a5d0fbbc 100644 --- a/autotest/t034_test.py +++ b/autotest/t034_test.py @@ -627,6 +627,7 @@ 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", model_ws=model_ws @@ -634,14 +635,22 @@ def test_uzf_negative_iuzfopt(): 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, @@ -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() diff --git a/flopy/modflow/mfuzf1.py b/flopy/modflow/mfuzf1.py index 3e3ca31d70..f10cd11806 100644 --- a/flopy/modflow/mfuzf1.py +++ b/flopy/modflow/mfuzf1.py @@ -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") @@ -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) @@ -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) diff --git a/flopy/plot/crosssection.py b/flopy/plot/crosssection.py index 73f6e41894..56e71f07c9 100644 --- a/flopy/plot/crosssection.py +++ b/flopy/plot/crosssection.py @@ -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) diff --git a/flopy/plot/map.py b/flopy/plot/map.py index 414df18041..330e7a2f3a 100644 --- a/flopy/plot/map.py +++ b/flopy/plot/map.py @@ -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): diff --git a/flopy/plot/plotutil.py b/flopy/plot/plotutil.py index 7a6617aa76..3a1d01ffb2 100644 --- a/flopy/plot/plotutil.py +++ b/flopy/plot/plotutil.py @@ -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: From 5f1e9a10dfba831d15ffdc3b680e589893ff7ad7 Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Mon, 16 May 2022 14:56:43 -0700 Subject: [PATCH 2/2] update(t034_test.py): update test_uzf_negative_iuzfopt for linux --- autotest/t034_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotest/t034_test.py b/autotest/t034_test.py index a6a5d0fbbc..81c111a17b 100644 --- a/autotest/t034_test.py +++ b/autotest/t034_test.py @@ -629,7 +629,7 @@ def test_uzf_negative_iuzfopt(): ml = flopy.modflow.Modflow( modelname="uzf_neg", version="mfnwt", - exe_name="mfnwt.exe", + exe_name="mfnwt", model_ws=model_ws ) dis = flopy.modflow.ModflowDis(