Skip to content

Commit 0756f90

Browse files
authored
fix(csub): CSUB observations (#2137)
* Make mf6io and code consistent. * Add observation test. Closes #1447
1 parent ab37a2d commit 0756f90

File tree

11 files changed

+360
-61
lines changed

11 files changed

+360
-61
lines changed

autotest/test_gwf_csub_obs.py

Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
import flopy
2+
import pytest
3+
from framework import TestFramework
4+
5+
# fmt: off
6+
obs_names = [
7+
"delay-flowtop", "delay-flowtop",
8+
"delay-flowbot", "delay-flowbot",
9+
"delay-head", "delay-head",
10+
"delay-gstress", "delay-gstress",
11+
"delay-estress", "delay-estress",
12+
"delay-preconstress", "delay-preconstress",
13+
"delay-compaction", "delay-compaction",
14+
"delay-thickness", "delay-thickness",
15+
"delay-theta", "delay-theta",
16+
"csub", "csub",
17+
"inelastic-csub", "inelastic-csub",
18+
"elastic-csub", "elastic-csub",
19+
"interbed-compaction", "interbed-compaction",
20+
"inelastic-compaction", "inelastic-compaction",
21+
"elastic-compaction", "elastic-compaction",
22+
]
23+
# fmt: off
24+
boundname = [
25+
False, True,
26+
False, True,
27+
False, True,
28+
False, True,
29+
False, True,
30+
False, True,
31+
False, True,
32+
False, True,
33+
False, True,
34+
False, True,
35+
False, True,
36+
False, True,
37+
False, True,
38+
False, True,
39+
False, True,
40+
]
41+
# fmt: off
42+
test_fail = [
43+
False, False,
44+
False, False,
45+
False, True,
46+
False, True,
47+
False, True,
48+
False, True,
49+
False, True,
50+
False, True,
51+
False, True,
52+
False, False,
53+
False, False,
54+
False, False,
55+
False, True,
56+
False, True,
57+
False, True,
58+
]
59+
cases = [f"csub_obs{idx + 1:02d}" for idx, _ in enumerate(obs_names)]
60+
61+
paktest = "csub"
62+
budtol = 1e-2
63+
ndcell = [19] * len(cases)
64+
65+
# static model data
66+
# spatial discretization
67+
nlay, nrow, ncol = 1, 1, 3
68+
shape3d = (nlay, nrow, ncol)
69+
size3d = nlay * nrow * ncol
70+
delr, delc = 1.0, 1.0
71+
top = 0.0
72+
botm = [-100.0]
73+
74+
# temporal discretization
75+
nper = 1
76+
perlen = [1000.0 for _ in range(nper)]
77+
nstp = [100 for _ in range(nper)]
78+
tsmult = [1.05 for _ in range(nper)]
79+
steady = [False for _ in range(nper)]
80+
81+
strt = 0.0
82+
strt6 = 1.0
83+
hnoflo = 1e30
84+
hdry = -1e30
85+
hk = 1e6
86+
laytyp = [0]
87+
S = 1e-4
88+
sy = 0.0
89+
90+
nouter, ninner = 1000, 300
91+
hclose, rclose, relax = 1e-6, 1e-6, 0.97
92+
93+
tdis_rc = []
94+
for i in range(nper):
95+
tdis_rc.append((perlen[i], nstp[i], tsmult[i]))
96+
97+
ib = 1
98+
99+
c = []
100+
c6 = []
101+
for j in range(0, ncol, 2):
102+
c.append([0, 0, j, strt, strt])
103+
c6.append([(0, 0, j), strt])
104+
cd = {0: c}
105+
cd6 = {0: c6}
106+
107+
# sub data
108+
ndb = 1
109+
nndb = 0
110+
cc = 100.0
111+
cr = 1.0
112+
void = 0.82
113+
theta = void / (1.0 + void)
114+
kv = 0.025
115+
sgm = 0.0
116+
sgs = 0.0
117+
ini_stress = 1.0
118+
thick = [1.0]
119+
sfe = cr * thick[0]
120+
sfv = cc * thick[0]
121+
lnd = [0]
122+
ldnd = [0]
123+
dp = [[kv, cr, cc]]
124+
ss = S / (100.0 - thick[0])
125+
126+
ds15 = [0, 0, 0, 2052, 0, 0, 0, 0, 0, 0, 0, 0]
127+
ds16 = [0, 0, 0, 100, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]
128+
129+
130+
def get_model(idx, ws):
131+
name = cases[idx]
132+
133+
sim = flopy.mf6.MFSimulation(
134+
sim_name=name, version="mf6", exe_name="mf6", sim_ws=ws
135+
)
136+
# create tdis package
137+
tdis = flopy.mf6.ModflowTdis(sim, time_units="DAYS", nper=nper, perioddata=tdis_rc)
138+
139+
# create iterative model solution
140+
ims = flopy.mf6.ModflowIms(
141+
sim,
142+
print_option="SUMMARY",
143+
outer_dvclose=hclose,
144+
outer_maximum=nouter,
145+
under_relaxation="NONE",
146+
inner_maximum=ninner,
147+
inner_dvclose=hclose,
148+
rcloserecord=rclose,
149+
linear_acceleration="CG",
150+
scaling_method="NONE",
151+
reordering_method="NONE",
152+
relaxation_factor=relax,
153+
)
154+
155+
# create gwf model
156+
gwf = flopy.mf6.ModflowGwf(sim, modelname=name)
157+
158+
dis = flopy.mf6.ModflowGwfdis(
159+
gwf,
160+
nlay=nlay,
161+
nrow=nrow,
162+
ncol=ncol,
163+
delr=delr,
164+
delc=delc,
165+
top=top,
166+
botm=botm,
167+
filename=f"{name}.dis",
168+
)
169+
170+
# initial conditions
171+
ic = flopy.mf6.ModflowGwfic(gwf, strt=strt, filename=f"{name}.ic")
172+
173+
# node property flow
174+
npf = flopy.mf6.ModflowGwfnpf(gwf, save_flows=False, icelltype=laytyp, k=hk, k33=hk)
175+
# storage
176+
sto = flopy.mf6.ModflowGwfsto(
177+
gwf,
178+
save_flows=False,
179+
iconvert=laytyp,
180+
ss=0.0,
181+
sy=sy,
182+
storagecoefficient=True,
183+
transient={0: True},
184+
)
185+
186+
# chd files
187+
chd = flopy.mf6.modflow.mfgwfchd.ModflowGwfchd(
188+
gwf, maxbound=len(c6), stress_period_data=cd6, save_flows=False
189+
)
190+
191+
# csub files
192+
sub6 = [
193+
[
194+
0,
195+
(0, 0, 1),
196+
"delay",
197+
ini_stress,
198+
thick[0],
199+
1.0,
200+
230.258658761733000,
201+
2.302586587617330,
202+
theta,
203+
kv,
204+
ini_stress,
205+
]
206+
]
207+
bname = "interbed"
208+
if boundname[idx]:
209+
sub6[0].append(bname)
210+
obs_idx = ("obs_value", obs_names[idx], bname)
211+
else:
212+
obs_idx = ("obs_value", obs_names[idx], (0,), (0,))
213+
214+
opth = f"{name}.csub.obs"
215+
csub = flopy.mf6.ModflowGwfcsub(
216+
gwf,
217+
boundnames=boundname[idx],
218+
head_based=False,
219+
print_input=True,
220+
save_flows=True,
221+
ndelaycells=ndcell[idx],
222+
ninterbeds=1,
223+
beta=0.0,
224+
cg_ske_cr=ss,
225+
packagedata=sub6,
226+
)
227+
orecarray = {}
228+
orecarray["csub_obs.csv"] = [obs_idx]
229+
csub_obs_package = csub.obs.initialize(
230+
filename=opth, digits=10, print_input=True, continuous=orecarray
231+
)
232+
233+
# output control
234+
oc = flopy.mf6.ModflowGwfoc(
235+
gwf,
236+
printrecord=[("BUDGET", "ALL")],
237+
)
238+
239+
return sim
240+
241+
242+
def build_models(idx, test):
243+
sim = get_model(idx, test.workspace)
244+
245+
return sim, None
246+
247+
248+
@pytest.mark.parametrize("idx, name", enumerate(cases))
249+
def test_mf6model(idx, name, function_tmpdir, targets):
250+
test = TestFramework(
251+
name=name,
252+
workspace=function_tmpdir,
253+
build=lambda t: build_models(idx, t),
254+
targets=targets,
255+
xfail=test_fail[idx],
256+
)
257+
test.run()

autotest/test_gwf_csub_sub03.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ def get_model(idx, ws):
318318
)
319319
orecarray = {}
320320
orecarray["csub_obs.csv"] = [
321-
("tcomp1", "interbed-compaction", "01_05_05"),
322-
("tcomp2", "interbed-compaction", "02_05_05"),
323-
("tcomp3", "interbed-compaction", "03_05_05"),
321+
("tcomp1", "interbed-compaction", (44,)),
322+
("tcomp2", "interbed-compaction", (140,)),
323+
("tcomp3", "interbed-compaction", (240,)),
324324
]
325325
csub_obs_package = csub.obs.initialize(
326326
filename=opth, digits=10, print_input=True, continuous=orecarray

autotest/test_gwf_csub_subwt01.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def get_model(idx, ws):
212212
)
213213
orecarray = {}
214214
orecarray["csub_obs.csv"] = [
215-
("w1l1", "interbed-compaction", "01_01_02"),
215+
("w1l1", "compaction-cell", (0, 0, 1)),
216216
("w1l1t", "csub-cell", (0, 0, 1)),
217217
]
218218
csub_obs_package = csub.obs.initialize(

autotest/test_gwf_csub_subwt02.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,14 @@ def get_model(idx, ws):
344344
)
345345

346346
cobs = [
347-
("w1l1", "interbed-compaction", "01_09_10"),
348-
("w1l2", "interbed-compaction", "02_09_10"),
349-
("w1l3", "interbed-compaction", "03_09_10"),
350-
("w1l4", "interbed-compaction", "04_09_10"),
351-
("w2l1", "interbed-compaction", "01_12_07"),
352-
("w2l2", "interbed-compaction", "02_12_07"),
353-
("w2l3", "interbed-compaction", "03_12_07"),
354-
("w2l4", "interbed-compaction", "04_12_07"),
347+
("w1l1", "interbed-compaction", (89,)),
348+
("w1l2", "interbed-compaction", (299,)),
349+
("w1l3", "interbed-compaction", (509,)),
350+
("w1l4", "interbed-compaction", (719,)),
351+
("w2l1", "interbed-compaction", (130,)),
352+
("w2l2", "interbed-compaction", (340,)),
353+
("w2l3", "interbed-compaction", (550,)),
354+
("w2l4", "interbed-compaction", (760,)),
355355
("s1l1", "coarse-compaction", (0, 8, 9)),
356356
("s1l2", "coarse-compaction", (1, 8, 9)),
357357
("s1l3", "coarse-compaction", (2, 8, 9)),
@@ -383,7 +383,7 @@ def get_model(idx, ws):
383383
("pc4", "preconstress-cell", (3, 8, 9)),
384384
("sk1l2", "ske-cell", (1, 8, 9)),
385385
("sk2l4", "ske-cell", (3, 11, 6)),
386-
("t1l2", "theta", "02_09_10"),
386+
("t1l2", "theta", (1, 8, 9)),
387387
]
388388

389389
orecarray = {"csub_obs.csv": cobs}

autotest/test_gwf_csub_zdisp01.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,13 @@ def build_models(idx, test):
283283
packagedata=sub6,
284284
)
285285
orecarray = {}
286-
tag = f"{3:02d}_{wrp[0] + 1:02d}_{wcp[0] + 1:02d}"
287286
oloc = (2, wrp[0], wcp[0])
287+
ibloc = (449,)
288288
orecarray["csub_obs.csv"] = [
289-
("tcomp3", "interbed-compaction", tag),
289+
("tcomp3", "interbed-compaction", ibloc),
290290
("sk-tcomp3", "coarse-compaction", oloc),
291-
("ibi-tcomp3", "inelastic-compaction", tag),
292-
("ibe-tcomp3", "elastic-compaction", tag),
291+
("ibi-tcomp3", "inelastic-compaction", ibloc),
292+
("ibe-tcomp3", "elastic-compaction", ibloc),
293293
]
294294
csub_obs_package = csub.obs.initialize(
295295
filename=opth, digits=10, print_input=True, continuous=orecarray

doc/Common/gwf-csubobs.tex

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,39 @@
55
CSUB & csub-cell & cellid & -- & Flow between the groundwater system for all interbeds and coarse-grained materials in a GWF cell. \\
66
CSUB & wcomp-csub-cell & cellid & -- & Flow between the groundwater system for all interbeds and coarse-grained materials in a GWF cell from water compressibility. \\
77

8-
CSUB & sk & icsubno or boundname & -- & Convertible interbed storativity in a interbed or group of interbeds. Convertible interbed storativity is inelastic interbed storativity if the current effective stress is greater than the preconsolidation stress. The NODATA value is reported for steady-state stress periods. \\
9-
CSUB & ske & icsubno or boundname & -- & Elastic interbed storativity in a interbed or group of interbeds. The NODATA value is reported for steady-state stress periods. \\
10-
CSUB & sk-cell & cellid & -- & Convertible interbed and coarse-grained material storativity in a GWF cell. Convertible interbed storativity is inelastic interbed storativity if the current effective stress is greater than the preconsolidation stress. The NODATA value is reported for steady-state stress periods. \\
11-
CSUB & ske-cell & cellid & -- & Elastic interbed and coarse-grained material storativity in a GWF cell. The NODATA value is reported for steady-state stress periods. \\
8+
CSUB & sk & icsubno & -- & Convertible interbed storativity in a interbed. Convertible interbed storativity is inelastic interbed storativity if the current effective stress is greater than the preconsolidation stress. \\
9+
CSUB & ske & icsubno & -- & Elastic interbed storativity in a interbed. \\
10+
CSUB & sk-cell & cellid & -- & Convertible interbed and coarse-grained material storativity in a GWF cell. Convertible interbed storativity is inelastic interbed storativity if the current effective stress is greater than the preconsolidation stress. \\
11+
CSUB & ske-cell & cellid & -- & Elastic interbed and coarse-grained material storativity in a GWF cell. \\
1212

1313
CSUB & estress-cell & cellid & -- & effective stress in a GWF cell. \\
1414
CSUB & gstress-cell & cellid & -- & geostatic stress in a GWF cell. \\
1515

16-
CSUB & interbed-compaction & icsubno or boundname & -- & interbed compaction in a interbed or group of interbeds. \\
17-
CSUB & inelastic-compaction & icsubno or boundname & -- & inelastic interbed compaction in a interbed or group of interbeds. \\
18-
CSUB & elastic-compaction & icsubno or boundname & -- & elastic interbed compaction a interbed or group of interbeds. \\
16+
CSUB & interbed-compaction & icsubno & -- & interbed compaction in a interbed. \\
17+
CSUB & inelastic-compaction & icsubno & -- & inelastic interbed compaction in a interbed. \\
18+
CSUB & elastic-compaction & icsubno & -- & elastic interbed compaction a interbed. \\
1919
CSUB & coarse-compaction & cellid & -- & elastic compaction in coarse-grained materials in a GWF cell. \\
2020
CSUB & inelastic-compaction-cell & cellid & -- & inelastic compaction in all interbeds in a GWF cell. \\
2121
CSUB & elastic-compaction-cell & cellid & -- & elastic compaction in coarse-grained materials and all interbeds in a GWF cell. \\
2222
CSUB & compaction-cell & cellid & -- & total compaction in coarse-grained materials and all interbeds in a GWF cell. \\
2323

24-
CSUB & thickness & icsubno or boundname & -- & thickness of a interbed or group of interbeds. \\
25-
CSUB & coarse-thickness & cellid & -- & thickness of coarse-grained materials in a GWF cell. \\
26-
CSUB & thickness-cell & cellid & -- & total thickness of coarse-grained materials and all interbeds in a GWF cell. \\
24+
CSUB & thickness & icsubno & -- & thickness of a interbed. \\
25+
CSUB & coarse-thickness & cellid & -- & thickness of coarse-grained materials in a GWF cell. \\
26+
CSUB & thickness-cell & cellid & -- & total thickness of coarse-grained materials and all interbeds in a GWF cell. \\
2727

28-
CSUB & theta & icsubno & -- & porosity of a interbed . \\
28+
CSUB & theta & icsubno & -- & porosity of a interbed. \\
2929
CSUB & coarse-theta & cellid & -- & porosity of coarse-grained materials in a GWF cell. \\
3030
CSUB & theta-cell & cellid & -- & thickness-weighted porosity of coarse-grained materials and all interbeds in a GWF cell. \\
3131

32-
CSUB & delay-flowtop & icsubno & -- & Flow between the groundwater system and a delay interbed across the top of the interbed. \\
33-
CSUB & delay-flowbot & icsubno & -- & Flow between the groundwater system and a delay interbed across the bottom of the interbed. \\
32+
CSUB & delay-flowtop & icsubno or boundname & -- & Flow between the groundwater system and a delay interbed or group of interbeds across the top of the interbed(s). \\
33+
CSUB & delay-flowbot & icsubno or boundname & -- & Flow between the groundwater system and a delay interbed or group of interbeds across the bottom of the interbed(s). \\
3434

35-
CSUB & delay-head & icsubno & idcellno & head in interbed delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). The NODATA value is reported for steady-state stress periods. \\
36-
CSUB & delay-gstress & icsubno & idcellno & geostatic stress in interbed delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). The NODATA value is reported for steady-state stress periods. \\
37-
CSUB & delay-estress & icsubno & idcellno & effective stress in interbed delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). The NODATA value is reported for steady-state stress periods. \\
38-
CSUB & delay-preconstress & icsubno & idcellno & preconsolidation stress in interbed delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). The NODATA value is reported for steady-state stress periods. \\
39-
CSUB & delay-compaction & icsubno & idcellno & compaction in interbed delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
40-
CSUB & delay-thickness & icsubno & idcellno & thickness of interbed delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
41-
CSUB & delay-theta & icsubno & idcellno & porosity of interbed delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
42-
43-
CSUB & preconstress-cell & cellid & -- & preconsolidation stress in a GWF cell containing at least one interbed. The NODATA value is reported for steady-state stress periods.
35+
CSUB & delay-head & icsubno & idcellno & head in interbed in delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
36+
CSUB & delay-gstress & icsubno & idcellno & geostatic stress in interbed in delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
37+
CSUB & delay-estress & icsubno & idcellno & effective stress in interbed in delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
38+
CSUB & delay-preconstress & icsubno & idcellno & preconsolidation stress in interbed in delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
39+
CSUB & delay-compaction & icsubno & idcellno & compaction in interbed in delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
40+
CSUB & delay-thickness & icsubno & idcellno & thickness of interbed or group of interbeds in delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
41+
CSUB & delay-theta & icsubno & idcellno & porosity of interbed in delay cell idcellno (1 $<=$ idcellno $<=$ NDELAYCELLS). \\
4442

43+
CSUB & preconstress-cell & cellid & -- & preconsolidation stress in a GWF cell containing at least one interbed.

0 commit comments

Comments
 (0)