From 8e4cb9a7fc2a88bea384837c7c3d2556994fe0d0 Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Thu, 5 May 2022 13:13:55 -0700 Subject: [PATCH 1/2] fix(ModflowUzf1): fix for loading negative iuzfopt --- autotest/t034_test.py | 43 +++++++++++++++++++++++++++++++++++++++++ flopy/modflow/mfuzf1.py | 4 ++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/autotest/t034_test.py b/autotest/t034_test.py index 2b30612263..2bf3c59a84 100644 --- a/autotest/t034_test.py +++ b/autotest/t034_test.py @@ -622,6 +622,48 @@ def test_load_write_wel_option_line(): assert wel.iunitramp == 20 +def test_uzf_negative_iuzfopt(): + model_ws = f"{base_dir}_test_uzf_negative_iuzfopt" + test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws) + + ml = flopy.modflow.Modflow( + version="mfnwt", + exe_name="mfnwt.exe", + model_ws=model_ws + ) + dis = flopy.modflow.ModflowDis( + ml, + nper=2, + perlen=[1,1], + nstp=[1,1], + tsmult=1, + steady=[True, False] + ) + bas = flopy.modflow.ModflowBas(ml) + upw = flopy.modflow.ModflowUpw(ml) + oc = flopy.modflow.ModflowOc(ml) + + iuzfbnd = 1 + irunbnd = 1 + vks = 1e-4 + surfk = 1e-4 + + finf = 1e-6 + pet = 1e-8 + extdp = 0.2 + extwc = 0.10 + + uzf = flopy.modflow.ModflowUzf1( + ml, + nuztop=3, + iuzfopt=-1, + irunflg=1, + ietflg=1, + irunbnd=1, + specifysurfk=True, + seepsurfk=True + ) + if __name__ == "__main__": test_create_uzf() test_read_write_nwt_options() @@ -632,3 +674,4 @@ def test_load_write_wel_option_line(): test_load_write_wel_option_block() test_load_write_wel_option_line() test_uzf_surfk() + test_uzf_negative_iuzfopt() diff --git a/flopy/modflow/mfuzf1.py b/flopy/modflow/mfuzf1.py index 7f3b469a93..3e3ca31d70 100644 --- a/flopy/modflow/mfuzf1.py +++ b/flopy/modflow/mfuzf1.py @@ -1005,7 +1005,7 @@ def load_util2d(name, dtype, per=None): load_util2d("irunbnd", np.int32) # dataset 4 - if iuzfopt in [0, 1]: + if np.abs(iuzfopt) in [0, 1]: load_util2d("vks", np.float32) # dataset 4b @@ -1049,7 +1049,7 @@ def load_util2d(name, dtype, per=None): if nuzf1 >= 0: load_util2d("finf", np.float32, per=per) - if ietflg > 0: + if ietflg > 0 and iuzfopt > 0: # dataset 11 line = line_parse(f.readline()) nuzf2 = pop_item(line, int) From 095b455a6a4402d3e54d1a8ec3176e5805b7f5c1 Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Thu, 5 May 2022 13:18:38 -0700 Subject: [PATCH 2/2] remove unused variables from test --- autotest/t034_test.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/autotest/t034_test.py b/autotest/t034_test.py index 2bf3c59a84..cd32013b56 100644 --- a/autotest/t034_test.py +++ b/autotest/t034_test.py @@ -643,16 +643,6 @@ def test_uzf_negative_iuzfopt(): upw = flopy.modflow.ModflowUpw(ml) oc = flopy.modflow.ModflowOc(ml) - iuzfbnd = 1 - irunbnd = 1 - vks = 1e-4 - surfk = 1e-4 - - finf = 1e-6 - pet = 1e-8 - extdp = 0.2 - extwc = 0.10 - uzf = flopy.modflow.ModflowUzf1( ml, nuztop=3,