Skip to content

Commit

Permalink
fix(swf-dis): fixes for swf dis functionality (MODFLOW-USGS#2000)
Browse files Browse the repository at this point in the history
* fix(swf-dis): fixes for swf dis functionality

* rename botm to bottom, allow idomain for disv1d, add tests

* format

* ruff check . --fix

* implement fractional cell distance calculation to offset disv1d nodes anywhere along the cell

* add more rigorous test of manning flow calculation

* for the disv1d channel grid, rename cell2d to cell1d

* remove length and input parameter in disv1d griddata; it can be calculated from vertices
  • Loading branch information
langevin-usgs authored Aug 23, 2024
1 parent 6f22a9c commit af26abf
Show file tree
Hide file tree
Showing 26 changed files with 1,257 additions and 391 deletions.
9 changes: 4 additions & 5 deletions autotest/test_chf_dfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,21 @@ def build_models(idx, test):
total_length = dx * nreach
vertices = []
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
cell2d = []
cell1d = []
for j in range(nreach):
cell2d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell2d)
cell1d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell1d)
nvert = len(vertices)

disv1d = flopy.mf6.ModflowChfdisv1D(
chf,
nodes=nodes,
nvert=nvert,
length=dx,
width=50.0,
bottom=0.0,
idomain=1,
vertices=vertices,
cell2d=cell2d,
cell1d=cell1d,
)

dfw = flopy.mf6.ModflowChfdfw(
Expand Down
9 changes: 4 additions & 5 deletions autotest/test_chf_dfw_beg2022.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def build_models(idx, test):
nreach = int(total_length / dx)
vertices = []
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
cell2d = []
cell1d = []
for j in range(nreach):
cell2d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell2d)
cell1d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell1d)
nvert = len(vertices)

slope = 1.0 / 10000.0
Expand All @@ -80,12 +80,11 @@ def build_models(idx, test):
chf,
nodes=nodes,
nvert=nvert,
length=dx,
width=40.0,
bottom=z,
idomain=1,
vertices=vertices,
cell2d=cell2d,
cell1d=cell1d,
)

dfw = flopy.mf6.ModflowChfdfw(
Expand Down
9 changes: 4 additions & 5 deletions autotest/test_chf_dfw_bowl.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,21 @@ def build_models(idx, test):

vertices = []
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
cell2d = []
cell1d = []
for j in range(nreach):
cell2d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell2d)
cell1d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell1d)
nvert = len(vertices)

disv1d = flopy.mf6.ModflowChfdisv1D(
chf,
nodes=nodes,
nvert=nvert,
length=dx,
width=1.0,
bottom=reach_bottom,
idomain=1,
vertices=vertices,
cell2d=cell2d,
cell1d=cell1d,
)

dfw = flopy.mf6.ModflowChfdfw(
Expand Down
20 changes: 16 additions & 4 deletions autotest/test_chf_dfw_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def build_models(idx, test):
[19, 3000.0, 2500.0],
]

cell2d = [
cell1d = [
[0, 0.5, 2, 0, 1],
[1, 0.5, 2, 1, 2],
[2, 0.5, 2, 2, 3],
Expand Down Expand Up @@ -218,19 +218,18 @@ def build_models(idx, test):
(608400, 0, 0),
]

nodes = len(cell2d)
nodes = len(cell1d)
nvert = len(vertices)

disv1d = flopy.mf6.ModflowChfdisv1D(
chf,
nodes=nodes,
nvert=nvert,
length=reach_length,
width=1.0,
bottom=reach_bottom,
idomain=1,
vertices=vertices,
cell2d=cell2d,
cell1d=cell1d,
)

stage0 = np.array(14 * [3] + 4 * [2])
Expand Down Expand Up @@ -413,6 +412,19 @@ def make_plot(test):
fname = ws / f"{name}.obs.2.png"
plt.savefig(fname)

fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(1, 1, 1)
ax.set_xlim(-100, 6100)
ax.set_ylim(-100, 6100)
pmv = flopy.plot.PlotMapView(model=chf, ax=ax)
pmv.plot_grid()
vertices = chf.disv1d.vertices.get_data()
ax.plot(vertices["xv"], vertices["yv"], "bo")
for iv, x, y in vertices:
ax.text(x, y, f"{iv + 1}")
fname = ws / "grid.png"
plt.savefig(fname)

return


Expand Down
10 changes: 4 additions & 6 deletions autotest/test_chf_dfw_swrt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def build_models(idx, test):

vertices = []
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
cell2d = []
cell1d = []
for j in range(nreach):
cell2d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell2d)
cell1d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell1d)
nvert = len(vertices)

reach_bottom = np.linspace(1.05, 0.05, nreach)
Expand All @@ -89,12 +89,11 @@ def build_models(idx, test):
export_array_ascii=True,
nodes=nodes,
nvert=nvert,
length=dx,
width=dx,
bottom=reach_bottom,
idomain=1,
vertices=vertices,
cell2d=cell2d,
cell1d=cell1d,
)

dfw = flopy.mf6.ModflowChfdfw(
Expand Down Expand Up @@ -226,7 +225,6 @@ def check_output(idx, test):

# ensure export array is working properly
flist = [
"disv1d.length",
"disv1d.width",
"disv1d.bottom",
"disv1d.idomain",
Expand Down
9 changes: 4 additions & 5 deletions autotest/test_chf_dfw_swrt2b.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ def build_models(idx, test):

vertices = []
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
cell2d = []
cell1d = []
for j in range(nreach):
cell2d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell2d)
cell1d.append([j, 0.5, 2, j, j + 1])
nodes = len(cell1d)
nvert = len(vertices)

reach_bottom = np.linspace(1.05, 0.05, nreach)
Expand All @@ -98,12 +98,11 @@ def build_models(idx, test):
chf,
nodes=nodes,
nvert=nvert,
length=dx,
width=dx,
bottom=reach_bottom,
idomain=1,
vertices=vertices,
cell2d=cell2d,
cell1d=cell1d,
)

dfw = flopy.mf6.ModflowChfdfw(
Expand Down
Loading

0 comments on commit af26abf

Please sign in to comment.