Skip to content

Commit af26abf

Browse files
fix(swf-dis): fixes for swf dis functionality (#2000)
* 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
1 parent 6f22a9c commit af26abf

26 files changed

+1257
-391
lines changed

autotest/test_chf_dfw.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,21 @@ def build_models(idx, test):
5757
total_length = dx * nreach
5858
vertices = []
5959
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
60-
cell2d = []
60+
cell1d = []
6161
for j in range(nreach):
62-
cell2d.append([j, 0.5, 2, j, j + 1])
63-
nodes = len(cell2d)
62+
cell1d.append([j, 0.5, 2, j, j + 1])
63+
nodes = len(cell1d)
6464
nvert = len(vertices)
6565

6666
disv1d = flopy.mf6.ModflowChfdisv1D(
6767
chf,
6868
nodes=nodes,
6969
nvert=nvert,
70-
length=dx,
7170
width=50.0,
7271
bottom=0.0,
7372
idomain=1,
7473
vertices=vertices,
75-
cell2d=cell2d,
74+
cell1d=cell1d,
7675
)
7776

7877
dfw = flopy.mf6.ModflowChfdfw(

autotest/test_chf_dfw_beg2022.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ def build_models(idx, test):
6666
nreach = int(total_length / dx)
6767
vertices = []
6868
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
69-
cell2d = []
69+
cell1d = []
7070
for j in range(nreach):
71-
cell2d.append([j, 0.5, 2, j, j + 1])
72-
nodes = len(cell2d)
71+
cell1d.append([j, 0.5, 2, j, j + 1])
72+
nodes = len(cell1d)
7373
nvert = len(vertices)
7474

7575
slope = 1.0 / 10000.0
@@ -80,12 +80,11 @@ def build_models(idx, test):
8080
chf,
8181
nodes=nodes,
8282
nvert=nvert,
83-
length=dx,
8483
width=40.0,
8584
bottom=z,
8685
idomain=1,
8786
vertices=vertices,
88-
cell2d=cell2d,
87+
cell1d=cell1d,
8988
)
9089

9190
dfw = flopy.mf6.ModflowChfdfw(

autotest/test_chf_dfw_bowl.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,21 @@ def build_models(idx, test):
9191

9292
vertices = []
9393
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
94-
cell2d = []
94+
cell1d = []
9595
for j in range(nreach):
96-
cell2d.append([j, 0.5, 2, j, j + 1])
97-
nodes = len(cell2d)
96+
cell1d.append([j, 0.5, 2, j, j + 1])
97+
nodes = len(cell1d)
9898
nvert = len(vertices)
9999

100100
disv1d = flopy.mf6.ModflowChfdisv1D(
101101
chf,
102102
nodes=nodes,
103103
nvert=nvert,
104-
length=dx,
105104
width=1.0,
106105
bottom=reach_bottom,
107106
idomain=1,
108107
vertices=vertices,
109-
cell2d=cell2d,
108+
cell1d=cell1d,
110109
)
111110

112111
dfw = flopy.mf6.ModflowChfdfw(

autotest/test_chf_dfw_loop.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def build_models(idx, test):
8282
[19, 3000.0, 2500.0],
8383
]
8484

85-
cell2d = [
85+
cell1d = [
8686
[0, 0.5, 2, 0, 1],
8787
[1, 0.5, 2, 1, 2],
8888
[2, 0.5, 2, 2, 3],
@@ -218,19 +218,18 @@ def build_models(idx, test):
218218
(608400, 0, 0),
219219
]
220220

221-
nodes = len(cell2d)
221+
nodes = len(cell1d)
222222
nvert = len(vertices)
223223

224224
disv1d = flopy.mf6.ModflowChfdisv1D(
225225
chf,
226226
nodes=nodes,
227227
nvert=nvert,
228-
length=reach_length,
229228
width=1.0,
230229
bottom=reach_bottom,
231230
idomain=1,
232231
vertices=vertices,
233-
cell2d=cell2d,
232+
cell1d=cell1d,
234233
)
235234

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

415+
fig = plt.figure(figsize=(6, 6))
416+
ax = fig.add_subplot(1, 1, 1)
417+
ax.set_xlim(-100, 6100)
418+
ax.set_ylim(-100, 6100)
419+
pmv = flopy.plot.PlotMapView(model=chf, ax=ax)
420+
pmv.plot_grid()
421+
vertices = chf.disv1d.vertices.get_data()
422+
ax.plot(vertices["xv"], vertices["yv"], "bo")
423+
for iv, x, y in vertices:
424+
ax.text(x, y, f"{iv + 1}")
425+
fname = ws / "grid.png"
426+
plt.savefig(fname)
427+
416428
return
417429

418430

autotest/test_chf_dfw_swrt2.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ def build_models(idx, test):
7676

7777
vertices = []
7878
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
79-
cell2d = []
79+
cell1d = []
8080
for j in range(nreach):
81-
cell2d.append([j, 0.5, 2, j, j + 1])
82-
nodes = len(cell2d)
81+
cell1d.append([j, 0.5, 2, j, j + 1])
82+
nodes = len(cell1d)
8383
nvert = len(vertices)
8484

8585
reach_bottom = np.linspace(1.05, 0.05, nreach)
@@ -89,12 +89,11 @@ def build_models(idx, test):
8989
export_array_ascii=True,
9090
nodes=nodes,
9191
nvert=nvert,
92-
length=dx,
9392
width=dx,
9493
bottom=reach_bottom,
9594
idomain=1,
9695
vertices=vertices,
97-
cell2d=cell2d,
96+
cell1d=cell1d,
9897
)
9998

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

227226
# ensure export array is working properly
228227
flist = [
229-
"disv1d.length",
230228
"disv1d.width",
231229
"disv1d.bottom",
232230
"disv1d.idomain",

autotest/test_chf_dfw_swrt2b.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ def build_models(idx, test):
8686

8787
vertices = []
8888
vertices = [[j, j * dx, 0.0] for j in range(nreach + 1)]
89-
cell2d = []
89+
cell1d = []
9090
for j in range(nreach):
91-
cell2d.append([j, 0.5, 2, j, j + 1])
92-
nodes = len(cell2d)
91+
cell1d.append([j, 0.5, 2, j, j + 1])
92+
nodes = len(cell1d)
9393
nvert = len(vertices)
9494

9595
reach_bottom = np.linspace(1.05, 0.05, nreach)
@@ -98,12 +98,11 @@ def build_models(idx, test):
9898
chf,
9999
nodes=nodes,
100100
nvert=nvert,
101-
length=dx,
102101
width=dx,
103102
bottom=reach_bottom,
104103
idomain=1,
105104
vertices=vertices,
106-
cell2d=cell2d,
105+
cell1d=cell1d,
107106
)
108107

109108
dfw = flopy.mf6.ModflowChfdfw(

0 commit comments

Comments
 (0)