Skip to content

Commit

Permalink
test(idm): add exchange binary input tests (MODFLOW-USGS#1784)
Browse files Browse the repository at this point in the history
* update test_gwfgwf to read exchange data from binary input

* add gwfgwf_lgr binary input tests

* add disu binary exchange input test

---------

Co-authored-by: mjreno <[email protected]>
  • Loading branch information
mjreno and mjreno authored May 14, 2024
1 parent b6e2b6b commit d591a8e
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 5 deletions.
117 changes: 117 additions & 0 deletions autotest/data/gwfgwf_lgr_exg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
1 3 2 1 1 1 1 50.00000000 16.66666667 33.33333333 0.00000000 74.53559925
1 2 3 1 1 1 1 50.00000000 16.66666667 33.33333333 270.00000000 74.53559925
2 3 3 1 1 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 2 3 1 1 2 1 50.00000000 16.66666667 33.33333333 270.00000000 66.66666667
2 3 3 1 1 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 2 3 1 1 3 1 50.00000000 16.66666667 33.33333333 270.00000000 74.53559925
2 3 3 1 1 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 2 4 1 1 4 1 50.00000000 16.66666667 33.33333333 270.00000000 74.53559925
2 3 4 1 1 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 2 4 1 1 5 1 50.00000000 16.66666667 33.33333333 270.00000000 66.66666667
2 3 4 1 1 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 2 4 1 1 6 1 50.00000000 16.66666667 33.33333333 270.00000000 74.53559925
2 3 4 1 1 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 2 5 1 1 7 1 50.00000000 16.66666667 33.33333333 270.00000000 74.53559925
2 3 5 1 1 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 2 5 1 1 8 1 50.00000000 16.66666667 33.33333333 270.00000000 66.66666667
2 3 5 1 1 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 3 6 1 1 9 1 50.00000000 16.66666667 33.33333333 180.00000000 74.53559925
1 2 5 1 1 9 1 50.00000000 16.66666667 33.33333333 270.00000000 74.53559925
2 3 5 1 1 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 3 2 1 2 1 1 50.00000000 16.66666667 33.33333333 0.00000000 66.66666667
2 3 3 1 2 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 3 1 2 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 3 1 2 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 4 1 2 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 4 1 2 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 4 1 2 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 5 1 2 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 5 1 2 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 3 6 1 2 9 1 50.00000000 16.66666667 33.33333333 180.00000000 66.66666667
2 3 5 1 2 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 3 2 1 3 1 1 50.00000000 16.66666667 33.33333333 0.00000000 74.53559925
2 3 3 1 3 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 3 1 3 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 3 1 3 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 4 1 3 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 4 1 3 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 4 1 3 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 5 1 3 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 3 5 1 3 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 3 6 1 3 9 1 50.00000000 16.66666667 33.33333333 180.00000000 74.53559925
2 3 5 1 3 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 4 2 1 4 1 1 50.00000000 16.66666667 33.33333333 0.00000000 74.53559925
2 4 3 1 4 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 3 1 4 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 3 1 4 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 4 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 4 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 4 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 5 1 4 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 5 1 4 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 4 6 1 4 9 1 50.00000000 16.66666667 33.33333333 180.00000000 74.53559925
2 4 5 1 4 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 4 2 1 5 1 1 50.00000000 16.66666667 33.33333333 0.00000000 66.66666667
2 4 3 1 5 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 3 1 5 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 3 1 5 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 5 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 5 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 5 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 5 1 5 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 5 1 5 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 4 6 1 5 9 1 50.00000000 16.66666667 33.33333333 180.00000000 66.66666667
2 4 5 1 5 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 4 2 1 6 1 1 50.00000000 16.66666667 33.33333333 0.00000000 74.53559925
2 4 3 1 6 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 3 1 6 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 3 1 6 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 6 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 6 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 4 1 6 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 5 1 6 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 4 5 1 6 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 4 6 1 6 9 1 50.00000000 16.66666667 33.33333333 180.00000000 74.53559925
2 4 5 1 6 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 5 2 1 7 1 1 50.00000000 16.66666667 33.33333333 0.00000000 74.53559925
2 5 3 1 7 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 3 1 7 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 3 1 7 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 4 1 7 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 4 1 7 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 4 1 7 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 5 1 7 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 5 1 7 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 5 6 1 7 9 1 50.00000000 16.66666667 33.33333333 180.00000000 74.53559925
2 5 5 1 7 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 5 2 1 8 1 1 50.00000000 16.66666667 33.33333333 0.00000000 66.66666667
2 5 3 1 8 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 3 1 8 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 3 1 8 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 4 1 8 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 4 1 8 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 4 1 8 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 5 1 8 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
2 5 5 1 8 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 5 6 1 8 9 1 50.00000000 16.66666667 33.33333333 180.00000000 66.66666667
2 5 5 1 8 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 5 2 1 9 1 1 50.00000000 16.66666667 33.33333333 0.00000000 74.53559925
1 6 3 1 9 1 1 50.00000000 16.66666667 33.33333333 90.00000000 74.53559925
2 5 3 1 9 1 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 6 3 1 9 2 1 50.00000000 16.66666667 33.33333333 90.00000000 66.66666667
2 5 3 1 9 2 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 6 3 1 9 3 1 50.00000000 16.66666667 33.33333333 90.00000000 74.53559925
2 5 3 1 9 3 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 6 4 1 9 4 1 50.00000000 16.66666667 33.33333333 90.00000000 74.53559925
2 5 4 1 9 4 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 6 4 1 9 5 1 50.00000000 16.66666667 33.33333333 90.00000000 66.66666667
2 5 4 1 9 5 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 6 4 1 9 6 1 50.00000000 16.66666667 33.33333333 90.00000000 74.53559925
2 5 4 1 9 6 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 6 5 1 9 7 1 50.00000000 16.66666667 33.33333333 90.00000000 74.53559925
2 5 5 1 9 7 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 6 5 1 9 8 1 50.00000000 16.66666667 33.33333333 90.00000000 66.66666667
2 5 5 1 9 8 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 5 6 1 9 9 1 50.00000000 16.66666667 33.33333333 180.00000000 74.53559925
1 6 5 1 9 9 1 50.00000000 16.66666667 33.33333333 90.00000000 74.53559925
2 5 5 1 9 9 0 50.00000000 50.00000000 1111.11111111 180.00000000 100.00000000
1 change: 1 addition & 0 deletions autotest/data/par_gwf_disu_exg/par_gwf_disu3_exg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 1 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
5 changes: 5 additions & 0 deletions autotest/data/par_gwf_disu_exg/par_gwf_disu4_exg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
5 1 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
10 6 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
15 11 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
20 16 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
25 21 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
25 changes: 25 additions & 0 deletions autotest/data/par_gwf_disu_exg/par_gwf_disu5_exg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
5 1 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
30 26 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
55 51 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
80 76 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
105 101 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
10 6 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
35 31 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
60 56 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
85 81 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
110 106 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
15 11 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
40 36 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
65 61 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
90 86 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
115 111 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
20 16 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
45 41 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
70 66 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
95 91 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
120 116 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
25 21 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
50 46 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
75 71 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
100 96 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
125 121 1 50.00000000 50.00000000 100.00000000 0.00000000 100.00000000
58 changes: 55 additions & 3 deletions autotest/test_gwfgwf_lgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@
import pytest
from flopy.utils.lgrutil import Lgr

from conftest import project_root_path
from framework import TestFramework

cases = ["gwfgwf_lgr_classic", "gwfgwf_lgr_ifmod"]
ifmod = [False, True]
data_path = project_root_path / "autotest" / "data"
cases = [
"gwfgwf_lgr_classic",
"gwfgwf_lgr_ifmod",
"gwfgwf_lgr_classic_binary",
"gwfgwf_lgr_ifmod_binary",
]
ifmod = [False, True, False, True]
parent_name = "parent"
child_name = "child"
h_left = 1.0
Expand Down Expand Up @@ -222,13 +229,58 @@ def get_model(idx, test):

exgdata = lgr.get_exchange_data(angldegx=True, cdist=True)

if name.endswith("_binary"):
exchangedata = {
"factor": 1.0,
"filename": "exg.bin",
"data": None,
"binary": True,
}
exg_fpath = data_path / "gwfgwf_lgr_exg.txt"
exg_fdata = np.loadtxt(
exg_fpath,
dtype={
"names": (
"c11",
"c12",
"c13",
"c21",
"c22",
"c23",
"ihc",
"cl1",
"cl2",
"hwva",
"aux1",
"aux2",
),
"formats": (
"i4",
"i4",
"i4",
"i4",
"i4",
"i4",
"i4",
"f8",
"f8",
"f8",
"f8",
"f8",
),
},
)
exg_fdata.tofile(ws / "exg.bin")
else:
exchangedata = exgdata

gwfgwf = flopy.mf6.ModflowGwfgwf(
sim,
exgtype="GWF6-GWF6",
nexg=len(exgdata),
exgmnamea=parent_name,
exgmnameb=child_name,
exchangedata=exgdata,
exchangedata=exchangedata,
print_flows=True,
auxiliary=["ANGLDEGX", "CDIST"],
dev_interfacemodel_on=ifmod[idx],
Expand Down
46 changes: 44 additions & 2 deletions autotest/test_par_gwf_disu.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
import pytest
from flopy.utils.gridutil import get_disu_kwargs

from conftest import project_root_path
from framework import TestFramework

data_path = project_root_path / "autotest" / "data" / "par_gwf_disu_exg"
cases = [
"par_gwf_disu1d",
"par_gwf_disu2d",
"par_gwf_disu3d",
"par_gwf_disu1d_binary",
"par_gwf_disu2d_binary",
"par_gwf_disu3d_binary",
]
dis_shape = [(1, 1, 5), (1, 1, 5), (1, 1, 5), (1, 5, 5), (5, 5, 5)]
dis_shape = [(1, 1, 5), (1, 5, 5), (5, 5, 5), (1, 1, 5), (1, 5, 5), (5, 5, 5)]

# global convenience...
name_left = "leftmodel"
Expand Down Expand Up @@ -184,13 +189,50 @@ def get_model(idx, dir):
for ilay in range(nlay)
]

if name.endswith("_binary"):
exchangedata = {
"factor": 1.0,
"filename": "exg.bin",
"data": None,
"binary": True,
}
exg_fpath = data_path / f"par_gwf_disu{idx}_exg.txt"
exg_fdata = np.loadtxt(
exg_fpath,
dtype={
"names": (
"c11",
"c21",
"ihc",
"cl1",
"cl2",
"hwva",
"aux1",
"aux2",
),
"formats": (
"i4",
"i4",
"i4",
"f8",
"f8",
"f8",
"f8",
"f8",
),
},
)
exg_fdata.tofile(dir / "exg.bin")
else:
exchangedata = gwfgwf_data

gwfgwf = flopy.mf6.ModflowGwfgwf(
sim,
exgtype="GWF6-GWF6",
nexg=len(gwfgwf_data),
exgmnamea=name_left,
exgmnameb=name_right,
exchangedata=gwfgwf_data,
exchangedata=exchangedata,
auxiliary=["ANGLDEGX", "CDIST"],
print_input=True,
)
Expand Down

0 comments on commit d591a8e

Please sign in to comment.