Skip to content

Commit

Permalink
feat(swf): separate swf model into channel model and overland flow mo…
Browse files Browse the repository at this point in the history
…del (#1995)

* feat(swf): separate swf model into channel model and overland flow model

* update msvs

* update makefile

* updated allowed packages for chf and olf models

* ruff
  • Loading branch information
langevin-usgs authored Aug 19, 2024
1 parent bf47ec6 commit 644cf96
Show file tree
Hide file tree
Showing 83 changed files with 16,056 additions and 1,270 deletions.
34 changes: 17 additions & 17 deletions autotest/test_swf_dfw.py → autotest/test_chf_dfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from framework import TestFramework

cases = [
"swf-dfw01",
"chf-dfw01",
]


Expand All @@ -48,7 +48,7 @@ def build_models(idx, test):
outer_dvclose=1.0e-7,
inner_dvclose=1.0e-8,
)
swf = flopy.mf6.ModflowSwf(
chf = flopy.mf6.ModflowChf(
sim, modelname=name, save_flows=True, print_flows=True
)

Expand All @@ -63,8 +63,8 @@ def build_models(idx, test):
nodes = len(cell2d)
nvert = len(vertices)

disv1d = flopy.mf6.ModflowSwfdisv1D(
swf,
disv1d = flopy.mf6.ModflowChfdisv1D(
chf,
nodes=nodes,
nvert=nvert,
length=dx,
Expand All @@ -75,36 +75,36 @@ def build_models(idx, test):
cell2d=cell2d,
)

dfw = flopy.mf6.ModflowSwfdfw(
swf,
dfw = flopy.mf6.ModflowChfdfw(
chf,
print_flows=True,
save_flows=True,
manningsn=0.035,
idcxs=0,
)

sto = flopy.mf6.ModflowSwfsto(
swf,
sto = flopy.mf6.ModflowChfsto(
chf,
save_flows=True,
)

ic = flopy.mf6.ModflowSwfic(swf, strt=1.0)
ic = flopy.mf6.ModflowChfic(chf, strt=1.0)

xfraction = [0.0, 0.0, 1.0, 1.0]
height = [100.0, 0.0, 0.0, 100.0]
mannfraction = [1.0, 1.0, 1.0, 1.0]
cxsdata = list(zip(xfraction, height, mannfraction))
cxs = flopy.mf6.ModflowSwfcxs(
swf,
cxs = flopy.mf6.ModflowChfcxs(
chf,
nsections=1,
npoints=4,
packagedata=[(0, 4)],
crosssectiondata=cxsdata,
)

# output control
oc = flopy.mf6.ModflowSwfoc(
swf,
oc = flopy.mf6.ModflowChfoc(
chf,
budget_filerecord=f"{name}.bud",
stage_filerecord=f"{name}.stage",
saverecord=[
Expand Down Expand Up @@ -135,16 +135,16 @@ def build_models(idx, test):
}
else:
flw_spd = {0: flw_list}
flw = flopy.mf6.ModflowSwfflw(
swf,
flw = flopy.mf6.ModflowChfflw(
chf,
maxbound=maxbound,
print_input=True,
print_flows=True,
stress_period_data=flw_spd,
)

chd = flopy.mf6.ModflowSwfchd(
swf,
chd = flopy.mf6.ModflowChfchd(
chf,
maxbound=1,
print_input=True,
print_flows=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
from framework import TestFramework

cases = [
"swf-beg2022",
"chf-beg2022",
]
data_path = project_root_path / "autotest/data/beg2022/"


def build_models(idx, test):
sim_ws = test.workspace
name = "swfmodel"
name = "chfmodel"
sim = flopy.mf6.MFSimulation(
sim_name=name,
version="mf6",
Expand Down Expand Up @@ -59,7 +59,7 @@ def build_models(idx, test):
outer_dvclose=1.0e-4,
inner_dvclose=1.0e-4,
)
swf = flopy.mf6.ModflowSwf(sim, modelname=name, save_flows=True)
chf = flopy.mf6.ModflowChf(sim, modelname=name, save_flows=True)

total_length = 21000
dx = 1000.0
Expand All @@ -76,8 +76,8 @@ def build_models(idx, test):
x = np.linspace(dx / 2, total_length - dx / 2, nreach)
z = (total_length - x) * slope

disv1d = flopy.mf6.ModflowSwfdisv1D(
swf,
disv1d = flopy.mf6.ModflowChfdisv1D(
chf,
nodes=nodes,
nvert=nvert,
length=dx,
Expand All @@ -88,42 +88,42 @@ def build_models(idx, test):
cell2d=cell2d,
)

dfw = flopy.mf6.ModflowSwfdfw(
swf,
dfw = flopy.mf6.ModflowChfdfw(
chf,
central_in_space=True,
print_flows=True,
save_flows=True,
manningsn=1.0 / 80.0,
idcxs=0,
)

sto = flopy.mf6.ModflowSwfsto(
swf,
sto = flopy.mf6.ModflowChfsto(
chf,
save_flows=True,
steady_state={0: True, 1: False},
transient={0: False, 1: True},
)

water_depth = 4.0
strt = z + water_depth
ic = flopy.mf6.ModflowSwfic(swf, strt=strt)
ic = flopy.mf6.ModflowChfic(chf, strt=strt)

xfraction = np.array([0.0, 0.0, 10.0, 15.0, 25.0, 30.0, 40.0, 40.0]) / 40.0
height = [40.0, 10.0, 10.0, 0.0, 0.0, 10.0, 10.0, 40.0]
npts = len(height)
mannfraction = npts * [1.0]
cxsdata = list(zip(xfraction, height, mannfraction))
cxs = flopy.mf6.ModflowSwfcxs(
swf,
cxs = flopy.mf6.ModflowChfcxs(
chf,
nsections=1,
npoints=npts,
packagedata=[(0, npts)],
crosssectiondata=cxsdata,
)

# output control
oc = flopy.mf6.ModflowSwfoc(
swf,
oc = flopy.mf6.ModflowChfoc(
chf,
budget_filerecord=f"{name}.bud",
stage_filerecord=f"{name}.stage",
saverecord=[
Expand All @@ -147,8 +147,8 @@ def build_models(idx, test):
flwlist = [
[(0,), "reach1"],
]
flw = flopy.mf6.ModflowSwfflw(
swf,
flw = flopy.mf6.ModflowChfflw(
chf,
maxbound=len(flwlist),
print_input=True,
print_flows=True,
Expand All @@ -164,8 +164,8 @@ def build_models(idx, test):
interpolation_methodrecord=interpolation_methodrecord,
)

chd = flopy.mf6.ModflowSwfchd(
swf,
chd = flopy.mf6.ModflowChfchd(
chf,
maxbound=1,
print_input=True,
print_flows=True,
Expand All @@ -189,7 +189,7 @@ def make_plot(test, mfsim):
df_mfswr = df_mfswr.loc[df_mfswr["TOTTIME"] > 86400]
print(df_mfswr)

fpth = test.workspace / "swfmodel.bud"
fpth = test.workspace / "chfmodel.bud"
budobj = flopy.utils.binaryfile.CellBudgetFile(fpth, precision="double")
flowja = budobj.get_data(text="FLOW-JA-FACE")
qstorage = budobj.get_data(text="STORAGE")
Expand Down Expand Up @@ -228,11 +228,11 @@ def make_plot(test, mfsim):
plt.xlabel("time, in hours")
plt.ylabel("flow, in meters cubed per second")
plt.legend()
fname = test.workspace / "swfmodel.flow.png"
fname = test.workspace / "chfmodel.flow.png"
plt.savefig(fname)

# read and plot stages
fpth = test.workspace / "swfmodel.stage"
fpth = test.workspace / "chfmodel.stage"
qobj = flopy.utils.HeadFile(fpth, precision="double", text="STAGE")
stage = qobj.get_alldata()

Expand All @@ -251,7 +251,7 @@ def make_plot(test, mfsim):
plt.xlabel("time, in hours")
plt.ylabel("stage, in meters")
plt.legend()
fname = test.workspace / "swfmodel.stage.png"
fname = test.workspace / "chfmodel.stage.png"
plt.savefig(fname)

return
Expand All @@ -268,7 +268,7 @@ def check_output(idx, test):
make_plot(test, sim)

# assign name
name = "swfmodel"
name = "chfmodel"

# read the binary grid file
fpth = test.workspace / f"{name}.disv1d.grb"
Expand Down
Loading

0 comments on commit 644cf96

Please sign in to comment.