Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/examples/circle.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@
"sto = flopy4.mf6.gwf.Sto(\n",
" ss=1.0e-5,\n",
" sy=0.15,\n",
" steady_state=[True],\n",
" stress_period_data={0: [(\"STEADY-STATE\",)]},\n",
" iconvert=0,\n",
" dims=dims,\n",
")"
Expand Down Expand Up @@ -612,7 +612,7 @@
"for i in np.where(chd_location)[0]:\n",
" chd_head[(1, int(i))] = 1.0\n",
"chd = flopy4.mf6.gwf.Chd(\n",
" head={\"*\": chd_head},\n",
" stress_period_data={0: [(cellid, head_val) for cellid, head_val in chd_head.items()]},\n",
" print_input=True,\n",
" print_flows=True,\n",
" save_flows=True,\n",
Expand All @@ -635,7 +635,7 @@
"outputs": [],
"source": [
"# Recharge: uniform rate applied to every cell in the top layer.\n",
"rch = flopy4.mf6.gwf.Rch(recharge={\"*\": {(0, j): 0.001 for j in range(ncpl)}}, dims=dims)"
"rch = flopy4.mf6.gwf.Rch(stress_period_data={0: [((0, j), 0.001) for j in range(ncpl)]}, dims=dims)"
]
},
{
Expand All @@ -656,8 +656,7 @@
"oc = flopy4.mf6.gwf.Oc(\n",
" budget_file=\"gwf.bud\",\n",
" head_file=\"gwf.hds\",\n",
" save_head={0: \"all\"},\n",
" save_budget={0: \"all\"},\n",
" stress_period_data={0: [(\"SAVE\", \"HEAD\", \"ALL\"), (\"SAVE\", \"BUDGET\", \"ALL\")]},\n",
" dims=dims,\n",
")"
]
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ def plot_head_ugrid(head, cbc, workspace):
oc = flopy4.mf6.gwf.Oc(
budget_file="gwf.bud",
head_file="gwf.hds",
save_head={0: "all"},
save_budget={0: "all"},
stress_period_data={0: [("SAVE", "HEAD", "ALL"), ("SAVE", "BUDGET", "ALL")]},
dims=dims,
)

Expand Down
145 changes: 43 additions & 102 deletions docs/examples/frenchman-flat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -815,25 +815,13 @@
"# Constant-rate pumping well: alternates between extraction and shut-in.\n",
"wel_crt = flopy4.mf6.gwf.Wel(\n",
" filename=\"ff.crt.wel\",\n",
" q={\n",
" 0: {\n",
" (1, 43, 43): -30992.50,\n",
" },\n",
" 1: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" 2: {\n",
" (1, 43, 43): -30992.50,\n",
" },\n",
" 3: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" 4: {\n",
" (1, 43, 43): -30992.50,\n",
" },\n",
" 5: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" stress_period_data={\n",
" 0: [((1, 43, 43), -30992.50)],\n",
" 1: [((1, 43, 43), -00000.0)],\n",
" 2: [((1, 43, 43), -30992.50)],\n",
" 3: [((1, 43, 43), -00000.0)],\n",
" 4: [((1, 43, 43), -30992.50)],\n",
" 5: [((1, 43, 43), -00000.0)],\n",
" },\n",
" print_input=True,\n",
" print_flows=True,\n",
Expand All @@ -859,52 +847,22 @@
"# Leakage well: injects contaminated water at rates that vary by period.\n",
"wel_leak = flopy4.mf6.gwf.Wel(\n",
" filename=\"ff.leak.wel\",\n",
" q={\n",
" 0: {\n",
" (1, 43, 43): 1.0000000e-05,\n",
" },\n",
" 7: {\n",
" (1, 43, 43): 1.5000000e03,\n",
" },\n",
" 8: {\n",
" (1, 43, 43): 2.6500000e03,\n",
" },\n",
" 9: {\n",
" (1, 43, 43): 3.1500000e03,\n",
" },\n",
" 10: {\n",
" (1, 43, 43): 4.1000000e03,\n",
" },\n",
" 11: {\n",
" (1, 43, 43): 4.6500000e03,\n",
" },\n",
" 12: {\n",
" (1, 43, 43): 4.9500000e03,\n",
" },\n",
" 13: {\n",
" (1, 43, 43): 5.3000000e03,\n",
" },\n",
" 14: {\n",
" (1, 43, 43): 5.8000000e03,\n",
" },\n",
" 16: {\n",
" (1, 43, 43): 5.9000000e03,\n",
" },\n",
" 17: {\n",
" (1, 43, 43): 5.8000000e03,\n",
" },\n",
" 19: {\n",
" (1, 43, 43): 5.6000000e03,\n",
" },\n",
" 20: {\n",
" (1, 43, 43): 4.7000000e03,\n",
" },\n",
" 22: {\n",
" (1, 43, 43): 3.4000000e03,\n",
" },\n",
" 23: {\n",
" (1, 43, 43): 1.0000000e-05,\n",
" },\n",
" stress_period_data={\n",
" 0: [((1, 43, 43), 1.0000000e-05)],\n",
" 7: [((1, 43, 43), 1.5000000e03)],\n",
" 8: [((1, 43, 43), 2.6500000e03)],\n",
" 9: [((1, 43, 43), 3.1500000e03)],\n",
" 10: [((1, 43, 43), 4.1000000e03)],\n",
" 11: [((1, 43, 43), 4.6500000e03)],\n",
" 12: [((1, 43, 43), 4.9500000e03)],\n",
" 13: [((1, 43, 43), 5.3000000e03)],\n",
" 14: [((1, 43, 43), 5.8000000e03)],\n",
" 16: [((1, 43, 43), 5.9000000e03)],\n",
" 17: [((1, 43, 43), 5.8000000e03)],\n",
" 19: [((1, 43, 43), 5.6000000e03)],\n",
" 20: [((1, 43, 43), 4.7000000e03)],\n",
" 22: [((1, 43, 43), 3.4000000e03)],\n",
" 23: [((1, 43, 43), 1.0000000e-05)],\n",
" },\n",
" print_input=True,\n",
" print_flows=True,\n",
Expand All @@ -930,40 +888,18 @@
"# Sampling well: extracts water for monitoring at scheduled intervals.\n",
"wel_sampleQ = flopy4.mf6.gwf.Wel(\n",
" filename=\"ff.sampleQ.wel\",\n",
" q={\n",
" 0: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" 22: {\n",
" (1, 43, 43): -04981.90,\n",
" },\n",
" 23: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" 24: {\n",
" (1, 43, 43): -04059.83,\n",
" },\n",
" 25: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" 26: {\n",
" (1, 43, 43): -05678.75,\n",
" },\n",
" 27: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" 28: {\n",
" (1, 43, 43): -05755.75,\n",
" },\n",
" 29: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" 30: {\n",
" (1, 43, 43): -04117.58,\n",
" },\n",
" 31: {\n",
" (1, 43, 43): -00000.0,\n",
" },\n",
" stress_period_data={\n",
" 0: [((1, 43, 43), -00000.0)],\n",
" 22: [((1, 43, 43), -04981.90)],\n",
" 23: [((1, 43, 43), -00000.0)],\n",
" 24: [((1, 43, 43), -04059.83)],\n",
" 25: [((1, 43, 43), -00000.0)],\n",
" 26: [((1, 43, 43), -05678.75)],\n",
" 27: [((1, 43, 43), -00000.0)],\n",
" 28: [((1, 43, 43), -05755.75)],\n",
" 29: [((1, 43, 43), -00000.0)],\n",
" 30: [((1, 43, 43), -04117.58)],\n",
" 31: [((1, 43, 43), -00000.0)],\n",
" },\n",
" print_input=True,\n",
" print_flows=True,\n",
Expand All @@ -990,9 +926,14 @@
"oc = flopy4.mf6.gwf.Oc(\n",
" budget_file=Path(\"ff.cbc\"),\n",
" head_file=Path(\"ff.hds\"),\n",
" save_head={\"0\": \"all\", 1: \"all\"},\n",
" save_budget={\"0\": \"STEPS 1\"},\n",
" print_budget={\"0\": \"STEPS 1 15\", 1: \"last\"},\n",
" stress_period_data={\n",
" 0: [\n",
" (\"SAVE\", \"HEAD\", \"ALL\"),\n",
" (\"SAVE\", \"BUDGET\", \"STEPS\", 1),\n",
" (\"PRINT\", \"BUDGET\", \"STEPS\", 1, 15),\n",
" ],\n",
" 1: [(\"SAVE\", \"HEAD\", \"ALL\"), (\"PRINT\", \"BUDGET\", \"LAST\")],\n",
" },\n",
" dims=dims,\n",
")"
]
Expand Down
11 changes: 8 additions & 3 deletions docs/examples/frenchman-flat.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,14 @@ def plot_head_ugrid(head, cbc, grid, workspace):
oc = flopy4.mf6.gwf.Oc(
budget_file=Path("ff.cbc"),
head_file=Path("ff.hds"),
save_head={"0": "all", 1: "all"},
save_budget={"0": "STEPS 1"},
print_budget={"0": "STEPS 1 15", 1: "last"},
stress_period_data={
0: [
("SAVE", "HEAD", "ALL"),
("SAVE", "BUDGET", "STEPS", 1),
("PRINT", "BUDGET", "STEPS", 1, 15),
],
1: [("SAVE", "HEAD", "ALL"), ("PRINT", "BUDGET", "LAST")],
},
dims=dims,
)

Expand Down
72 changes: 15 additions & 57 deletions docs/examples/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,11 @@
"id": "78ffd5e4",
"metadata": {},
"source": [
"Packages are attached to their parent at construction time via `parent=`.\n",
"This differs from the constructor-kwargs style used in other examples.\n",
"\n",
"`Ims` (iterative solver) is registered with the simulation via\n",
"`parent=sim`; `models=[gwf_name]` links it to the named flow model."
"`parent=sim`; `models=[gwf_name]` links it to the named flow model.\n",
"Single-instance codegen v2 packages (IC, NPF, OC) are attached via\n",
"attribute assignment (`gwf.ic = ...`) rather than `parent=gwf` because\n",
"xattree only registers list-type children through the constructor kwarg."
]
},
{
Expand Down Expand Up @@ -252,7 +252,7 @@
"outputs": [],
"source": [
"# Node-property flow: isotropic conductivity; saves specific-discharge for quiver plots.\n",
"npf = Npf(parent=gwf, print_flows=True, save_flows=True, save_specific_discharge=True)"
"gwf.npf = Npf(print_flows=True, save_flows=True, save_specific_discharge=True)"
]
},
{
Expand All @@ -272,7 +272,7 @@
"# Constant-head boundary: pin two corner cells to create a diagonal head gradient.\n",
"chd = Chd(\n",
" parent=gwf,\n",
" head={0: {(0, 0, 0): 1.0, (0, 9, 9): 0.0}},\n",
" stress_period_data={0: [((0, 0, 0), 1.0), ((0, 9, 9), 0.0)]},\n",
")"
]
},
Expand All @@ -291,7 +291,7 @@
"outputs": [],
"source": [
"# Initial conditions: uniform starting head of 1.0 m across the grid.\n",
"ic = Ic(parent=gwf, strt=1.0)"
"gwf.ic = Ic(strt=1.0)"
]
},
{
Expand All @@ -309,12 +309,10 @@
"outputs": [],
"source": [
"# Output control: write heads and budget to binary files at every time step.\n",
"oc = Oc(\n",
" parent=gwf,\n",
"gwf.oc = Oc(\n",
" budget_file=f\"{gwf.name}.bud\",\n",
" head_file=f\"{gwf.name}.hds\",\n",
" save_head={0: \"all\"},\n",
" save_budget={0: \"all\"},\n",
" stress_period_data={0: [(\"SAVE\", \"HEAD\", \"ALL\"), (\"SAVE\", \"BUDGET\", \"ALL\")]},\n",
")"
]
},
Expand Down Expand Up @@ -408,55 +406,15 @@
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "2b342b0f",
"metadata": {
"execution": {
"iopub.execute_input": "2026-05-23T16:59:21.415153Z",
"iopub.status.busy": "2026-05-23T16:59:21.415004Z",
"iopub.status.idle": "2026-05-23T16:59:21.419848Z",
"shell.execute_reply": "2026-05-23T16:59:21.418995Z"
}
},
"outputs": [],
"cell_type": "markdown",
"id": "d85cdb4d",
"metadata": {},
"source": [
"TODO(Phase2): restore xarray .data assertions once _PackageLean is in place\n",
"assert chd.data[\"head\"][0, 0] == 1.0\n",
"assert chd.data.head.sel(kper=0)[99] == 0.0\n",
"assert np.allclose(chd.data.head[:, 1:99], np.full(98, 3e30))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "2fb0302d",
"metadata": {
"execution": {
"iopub.execute_input": "2026-05-23T16:59:21.422100Z",
"iopub.status.busy": "2026-05-23T16:59:21.421961Z",
"iopub.status.idle": "2026-05-23T16:59:21.426355Z",
"shell.execute_reply": "2026-05-23T16:59:21.424840Z"
}
},
"outputs": [],
"source": [
"assert gwf.dis.data.botm.sel(lay=0, col=0, row=0) == 0.0"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "b056d906",
"metadata": {
"execution": {
"iopub.execute_input": "2026-05-23T16:59:21.428989Z",
"iopub.status.busy": "2026-05-23T16:59:21.428834Z",
"iopub.status.idle": "2026-05-23T16:59:21.433258Z",
"shell.execute_reply": "2026-05-23T16:59:21.432100Z"
}
},
"outputs": [],
"source": [
"assert np.allclose(chd.data.head[:, 1:99], np.full(98, 3e30))\n",
"assert gwf.dis.data.botm.sel(lay=0, col=0, row=0) == 0.0\n",
"assert oc.data[\"save_head\"][0] == \"all\"\n",
"assert oc.data.save_head.sel(kper=0) == \"all\""
]
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@
gwf.oc = Oc(
budget_file=f"{gwf.name}.bud",
head_file=f"{gwf.name}.hds",
save_head={0: "all"},
save_budget={0: "all"},
stress_period_data={0: [("SAVE", "HEAD", "ALL"), ("SAVE", "BUDGET", "ALL")]},
)

# ### Write and run
Expand Down
Loading
Loading