Skip to content

Commit a5e7b8f

Browse files
authored
clean up quickstart, rename sim_ws -> path (#129)
1 parent a471903 commit a5e7b8f

File tree

20 files changed

+61
-56
lines changed

20 files changed

+61
-56
lines changed

docs/examples/quickstart.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22

33
import matplotlib.pyplot as plt
44
import numpy as np
5+
from flopy.discretization.modeltime import ModelTime
6+
from flopy.discretization.structuredgrid import StructuredGrid
57

6-
from flopy4.mf6.gwf import Chd, Dis, Gwf, Ic, Npf, Oc
8+
from flopy4.mf6.gwf import Chd, Gwf, Npf, Oc
79
from flopy4.mf6.ims import Ims
810
from flopy4.mf6.simulation import Simulation
9-
from flopy4.mf6.tdis import Tdis
10-
11-
ws = Path(__file__).parent / "quickstart_data"
12-
name = "mymodel"
13-
tdis = Tdis()
14-
ims = Ims()
15-
sim = Simulation(name=name, tdis=tdis, solutions={"ims": ims}, sim_ws=ws)
16-
dis = Dis(nrow=10, ncol=10)
17-
gwf = Gwf(parent=sim, name=name, save_flows=True, dis=dis)
18-
ic = Ic(parent=gwf)
11+
12+
name = "quickstart"
13+
workspace = Path(__file__).parent / name
14+
time = ModelTime(perlen=[1.0], nstp=[1])
15+
grid = StructuredGrid(nlay=1, nrow=10, ncol=10)
16+
sim = Simulation(name=name, path=workspace, tdis=time)
17+
ims = Ims(parent=sim)
18+
gwf_name = "mymodel"
19+
gwf = Gwf(parent=sim, name=gwf_name, save_flows=True, dis=grid)
1920
npf = Npf(parent=gwf, save_specific_discharge=True)
2021
chd = Chd(
2122
parent=gwf,
2223
head={"*": {(0, 0, 0): 1.0, (0, 9, 9): 0.0}},
2324
)
2425
oc = Oc(
2526
parent=gwf,
26-
budget_file=f"{name}.bud",
27-
head_file=f"{name}.hds",
27+
budget_file=f"{gwf.name}.bud",
28+
head_file=f"{gwf.name}.hds",
2829
save_head={"*": "all"},
2930
save_budget={"*": "all"},
3031
)
@@ -35,7 +36,7 @@
3536
assert np.allclose(chd.data.head[:, 1:99], np.full(98, 1e30))
3637

3738
# check DIS
38-
assert dis.data.botm.sel(lay=0, col=0, row=0) == 0.0
39+
assert gwf.dis.data.botm.sel(lay=0, col=0, row=0) == 0.0
3940

4041
# check OC
4142
assert oc.data["save_head"][0] == "all"
@@ -56,4 +57,4 @@
5657
head.plot.imshow(ax=ax)
5758
head.plot.contour(ax=ax, levels=[0.2, 0.4, 0.6, 0.8], linewidths=3.0)
5859
budget.plot.quiver(x="x", y="y", u="npf-qx", v="npf-qy", ax=ax, color="white")
59-
fig.savefig(ws / "quickstart.png")
60+
fig.savefig(workspace / f"{name}.png")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)