Skip to content

Commit

Permalink
fix(modflow/mfrch,mfevt): mfusg rch,evt load and write fixes (#1148)
Browse files Browse the repository at this point in the history
* fix(pakbase/_check_storage) unstructured mfusg storage checks
* modify array indexing for unstructured storage checks
* minor fixes and refatoring of test t016.py
* add unstructured capability to modflow/mfrch and modflow/mfevt
* move rch/evt input data util2d shape detection code to utils.utils_def.get_pak_vals_shape
* add mfusg load and write tests to t016 (and t038) with different rch,evt options
* Close #896 
* Close #633
  • Loading branch information
cnicol-gwlogic committed Jul 13, 2021
1 parent 04fe7e4 commit b780bfb
Show file tree
Hide file tree
Showing 19 changed files with 468 additions and 27 deletions.
53 changes: 50 additions & 3 deletions autotest/t016_test.py
Expand Up @@ -171,11 +171,10 @@ def test_usg_load_45usg():
assert os.path.isfile(fname), "nam file not found {}".format(fname)

# Create the model
m = flopy.modflow.Modflow(modelname="usgload_1b", verbose=True)
m = flopy.modflow.Modflow(modelname="45usg", verbose=True)

# Load the model, with checking.
# RCH not loaded as mfusg rch and evt loading needs work (TO DO)
m = m.load(fname, check=True, load_only=["DISU","BAS6","LPF","SMS","OC","DRN","WEL"])
m = m.load(fname, check=True)

# assert disu, lpf, bas packages have been loaded
msg = "flopy failed on loading mfusg disu package"
Expand All @@ -193,10 +192,58 @@ def test_usg_load_45usg():
msg = "flopy failed on loading mfusg wel package"
assert isinstance(m.wel, flopy.modflow.mfwel.ModflowWel), msg

def test_usg_rch_evt_models01():
# this test has RCH nrchop == 1, and EVT nevtop == 1
print("testing unstructured mfusg RCH nrchop == 1, and EVT nevtop == 1: \
usg_rch_evt.nam")
model_ws = os.path.join(
'..', 'examples', 'data', 'mfusg_test', 'rch_evt_tests')
nam = 'usg_rch_evt.nam'
m = flopy.modflow.Modflow.load(
nam, model_ws=model_ws, version='mfusg', exe_name=v)
m.model_ws = tpth
m.write_input()
if run:
success, buff = m.run_model()
assert success

def test_usg_rch_evt_models02():
# this test has RCH nrchop == 2, and EVT nevtop == 2
print("testing unstructured mfusg RCH nrchop == 2, and EVT nevtop == 2: \
usg_rch_evt_nrchop2.nam")
model_ws = os.path.join(
'..', 'examples', 'data', 'mfusg_test', 'rch_evt_tests')
nam = 'usg_rch_evt_nrchop2.nam'
m = flopy.modflow.Modflow.load(
nam, model_ws=model_ws, version='mfusg', exe_name=v)
m.model_ws = tpth
m.write_input()
if run:
success, buff = m.run_model()
assert success

def test_usg_rch_evt_models02a():
# this test has RCH nrchop == 2, and EVT nevtop == 2
print("testing unstructured mfusg RCH nrchop == 2, and EVT nevtop == 2,\
but with fewer irch nodes: than in nodelay[0] usg_rch_evt_nrchop2.nam")
model_ws = os.path.join(
'..', 'examples', 'data', 'mfusg_test', 'rch_evt_tests')
nam = 'usg_rch_evt_nrchop2a.nam'
m = flopy.modflow.Modflow.load(
nam, model_ws=model_ws, version='mfusg', exe_name=v)
m.model_ws = tpth
m.write_input()
if run:
success, buff = m.run_model()
assert success

if __name__ == "__main__":
test_usg_disu_load()
test_usg_sms_load()
test_usg_model()
test_usg_load_01B()
test_usg_load_45usg()
test_usg_rch_evt_models01()
test_usg_rch_evt_models02()
test_usg_rch_evt_models02a()

12 changes: 12 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.bas
@@ -0,0 +1,12 @@
# MODFLOW-USGs Basic Package
# MODFLOW Data Set Created by Groundwater Vistas
#
UNSTRUCTURED FREE
CONSTANT 1 IBOUND Layer 1
CONSTANT 1 IBOUND Layer 2
INTERNAL 1 (FREE) -1 IBOUND Layer 3
1 1 1 1 1 1 1 1 1
9.990000e+002
CONSTANT 3.000000 Starting Heads Layer 1
CONSTANT 3.000000 Starting Heads Layer 2
CONSTANT 3.000000 Starting Heads Layer 3
7 changes: 7 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.chd
@@ -0,0 +1,7 @@
# MODFLOW-USGs Constant-Head Boundary Package (CHD)
4
4 Stress Period 1
20 2.500000 2.500000
25 3.000000 3.000000
26 3.000000 3.000000
27 3.000000 3.000000
104 changes: 104 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.disu
@@ -0,0 +1,104 @@
27 3 135 -1 1 4 0 0 0
0 0 0
CONSTANT 9 NODELAY
INTERNAL 1.000000e+000 (FREE) -1 Top elevation Layer 1
3.000000e+000 3.000000e+000 3.000000e+000 3.000000e+000 3.000000e+000 3.000000e+000 3.000000e+000 3.000000e+000 3.000000e+000
INTERNAL 1.000000e+000 (FREE) -1 Top elevation Layer 2
2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000
INTERNAL 1.000000e+000 (FREE) -1 Top elevation Layer 3
1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
INTERNAL 1.000000e+000 (FREE) -1 Bottom elevation Layer 1
2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000 2.000000e+000
INTERNAL 1.000000e+000 (FREE) -1 Bottom elevation Layer 2
1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
CONSTANT 0.000000e+000 Bottom elevation Layer 3
CONSTANT 1.000000e+000 Nodal Areas
INTERNAL 1 (FREE) -1 IA()
4 5 4 5 6 5 4 5 4 5
6 5 6 7 6 5 6 5 4 5
4 5 6 5 4 5 4
INTERNAL 1 (FREE) -1 JA()
1 2 4 10
2 1 3 5 11
3 2 6 12
4 1 5 7 13
5 2 4 6 8 14
6 3 5 9 15
7 4 8 16
8 5 7 9 17
9 6 8 18
10 1 11 13 19
11 2 10 12 14 20
12 3 11 15 21
13 4 10 14 16 22
14 5 11 13 15 17 23
15 6 12 14 18 24
16 7 13 17 25
17 8 14 16 18 26
18 9 15 17 27
19 10 20 22
20 11 19 21 23
21 12 20 24
22 13 19 23 25
23 14 20 22 24 26
24 15 21 23 27
25 16 22 26
26 17 23 25 27
27 18 24 26
INTERNAL 1 (FREE) -1 CLn()
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001 5.000000e-001
0.000000e+000 5.000000e-001 5.000000e-001 5.000000e-001
INTERNAL 1 (FREE) -1 FAHL()
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
0.000000e+000 1.000000e+000 1.000000e+000 1.000000e+000
365.000000 10 1.414000 TR
5 changes: 5 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.evt
@@ -0,0 +1,5 @@
1 50
1 1 1
CONSTANT 30.0 # surf kper1
CONSTANT 1.000000E-4 # evtr kper1
CONSTANT 1.000000E+0 # exdp kper1
21 changes: 21 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.lpf
@@ -0,0 +1,21 @@
# MODFLOW-USG Layer Property Flow (LPF) Package
50 -1.000000e+030 0 0 NOVFC
4 4 4
0 0 0
1.000000e+000
1.000000e+000
1.000000e+000
0 0 0
0 0 0
CONSTANT 1.000000e+000 Kx Layer 1
CONSTANT 1.000000e-001 Kz Layer 1
CONSTANT 1.000000e-006 Ss Layer 1
CONSTANT 1.000000e-002 Sy Layer 1
CONSTANT 1.000000e+000 Kx Layer 2
CONSTANT 1.000000e-001 Kz Layer 2
CONSTANT 1.000000e-006 Ss Layer 2
CONSTANT 1.000000e-002 Sy Layer 2
CONSTANT 1.000000e+000 Kx Layer 3
CONSTANT 1.000000e-001 Kz Layer 3
CONSTANT 1.000000e-006 Ss Layer 3
CONSTANT 1.000000e-002 Sy Layer 3
12 changes: 12 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.nam
@@ -0,0 +1,12 @@
LIST 7 usg_rch_evt.lst
BAS6 1 usg_rch_evt.bas
SMS 19 usg_rch_evt.sms
DISU 29 usg_rch_evt.disu
OC 22 usg_rch_evt.oc
RCH 18 usg_rch_evt.rch
evt 17 usg_rch_evt.evt
CHD 199 usg_rch_evt.chd
LPF 11 usg_rch_evt.lpf
DATA(BINARY) 50 usg_rch_evt.cbb
DATA(BINARY) 30 usg_rch_evt.hds
DATA(BINARY) 31 usg_rch_evt.ddn
53 changes: 53 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.oc
@@ -0,0 +1,53 @@
HEAD SAVE UNIT 30
DRAWDOWN SAVE UNIT 31
COMPACT BUDGET AUX
PERIOD 1 STEP 1
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 2
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 3
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 4
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 5
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 6
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 7
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 8
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 9
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
PERIOD 1 STEP 10
SAVE HEAD
SAVE DRAWDOWN
SAVE BUDGET
PRINT BUDGET
3 changes: 3 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.rch
@@ -0,0 +1,3 @@
3 50
1 0
CONSTANT 0.000000E+0 # rch kper1
3 changes: 3 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt.sms
@@ -0,0 +1,3 @@
1.000000e-003 1.000000e-004 500 100 2 2 2 SOLVEACTIVE
7.000000e-001 7.000000e-002 3.000000e-001 1.000000e-001 200 2.100000e+000 2.000000e-001 1.000000e+000
BCGS 2 0 0 1.000000e-003
@@ -0,0 +1,9 @@
2 50
9
1 1 1 9
CONSTANT 30.0 # surf kper1
CONSTANT 1.000000E-4 # evtr kper1
CONSTANT 1.000000E+0 # exdp kper1
INTERNAL 1 (FREE) -1 ievt kper1
1 2 3 4 5 6 16 17 18

14 changes: 14 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt_nrchop2.nam
@@ -0,0 +1,14 @@
# Name file for MODFLOW-USG, generated by Flopy version 3.3.4.
#xll:0.0; yll:0.0; rotation:0.0; units:undefined; lenuni:0; start_datetime:None
LIST 7 usg_rch_evt_nrchop2.lst
DISU 29 usg_rch_evt.disu
BAS6 1 usg_rch_evt.bas
SMS 19 usg_rch_evt.sms
OC 22 usg_rch_evt.oc
RCH 18 usg_rch_evt_nrchop2.rch
EVT 17 usg_rch_evt_nevtop2.evt
CHD 199 usg_rch_evt.chd
LPF 11 usg_rch_evt.lpf
DATA(BINARY) 30 usg_rch_evt_nrchop2.hds REPLACE
DATA(BINARY) 31 usg_rch_evt_nrchop2.ddn REPLACE
DATA(BINARY) 50 usg_rch_evt_nrchop2.cbb REPLACE
@@ -0,0 +1,7 @@
2 50
9
1 9
CONSTANT 1.000000E-4 # rch kper1
INTERNAL 1 (FREE) -1 irch kper1
1 2 3 4 5 6 16 17 18

14 changes: 14 additions & 0 deletions examples/data/mfusg_test/rch_evt_tests/usg_rch_evt_nrchop2a.nam
@@ -0,0 +1,14 @@
# Name file for MODFLOW-USG, generated by Flopy version 3.3.4.
#xll:0.0; yll:0.0; rotation:0.0; units:undefined; lenuni:0; start_datetime:None
LIST 7 usg_rch_evt_nrchop2a.lst
DISU 29 usg_rch_evt.disu
BAS6 1 usg_rch_evt.bas
SMS 19 usg_rch_evt.sms
OC 22 usg_rch_evt.oc
RCH 18 usg_rch_evt_nrchop2a.rch
EVT 17 usg_rch_evt_nevtop2.evt
CHD 199 usg_rch_evt.chd
LPF 11 usg_rch_evt.lpf
DATA(BINARY) 30 usg_rch_evt_nrchop2a.hds REPLACE
DATA(BINARY) 31 usg_rch_evt_nrchop2a.ddn REPLACE
DATA(BINARY) 50 usg_rch_evt_nrchop2a.cbb REPLACE
@@ -0,0 +1,7 @@
# RCH package for MODFLOW-USG, generated by Flopy.
2 50
6
1 6 # Stress period 1
CONSTANT 1.000000E-04 #rech_1
INTERNAL 1 (FREE) -1 #irch_1
1 2 3 4 5 6

0 comments on commit b780bfb

Please sign in to comment.