|
1 | | -from flopy4.mf6 import Simulation, Tdis |
2 | | -from flopy4.mf6.gwf import Chd, Dis, Gwf, Ic, Npf, Oc |
| 1 | +import numpy as np |
3 | 2 |
|
4 | | -# TODO rewrite bottom up |
| 3 | +from flopy4.mf6.gwf import Chd, Dis, Gwf, Ic, Npf, Oc |
| 4 | +from flopy4.mf6.simulation import Simulation |
| 5 | +from flopy4.mf6.tdis import Tdis |
5 | 6 |
|
6 | 7 | ws = "./mymodel" |
7 | 8 | name = "mymodel" |
8 | | -sim = Simulation(name=name) |
9 | | -tdis = Tdis(sim) |
10 | | -gwf = Gwf(sim, name=name, save_flows=True) |
11 | | -dis = Dis(gwf, nrow=10, ncol=10) |
12 | | -ic = Ic(gwf) |
13 | | -npf = Npf(gwf, save_specific_discharge=True) |
| 9 | +tdis = Tdis() |
| 10 | +sim = Simulation(name=name, tdis=tdis) |
| 11 | +dis = Dis(nrow=10, ncol=10) |
| 12 | +gwf = Gwf(parent=sim, name=name, save_flows=True, dis=dis) |
| 13 | +ic = Ic(parent=gwf) |
| 14 | +npf = Npf(parent=gwf, save_specific_discharge=True) |
14 | 15 | chd = Chd( |
15 | | - gwf, |
16 | | - head={(0, 0, 0): 1.0, (0, 9, 9): 0.0}, |
| 16 | + parent=gwf, |
| 17 | + head={"*": {(0, 0, 0): 1.0, (0, 9, 9): 0.0}}, |
17 | 18 | ) |
18 | | - |
19 | | -# list input in the mf6 paradigm, just stored in xarray. |
20 | | -# this is straightforward to implement. even in flopy3? |
21 | | -assert all( |
22 | | - period == Chd.Period((0, 0, 0), 1.0) |
23 | | - for period in chd.data["stress_period_data"] |
| 19 | +oc = Oc( |
| 20 | + parent=gwf, |
| 21 | + budget_file=f"{name}.bud", |
| 22 | + head_file=f"{name}.hds", |
| 23 | + save_head={"*": "all"}, |
| 24 | + save_budget={"*": "all"}, |
24 | 25 | ) |
25 | 26 |
|
26 | | -# adopt xarray paradigm. transpose lists to arrays. this |
27 | | -# is no longer "sparse": in the sense that lists specify |
28 | | -# <maxbound> features of interest, where arrays specify |
29 | | -# the entire domain. but to maximize the value of xarray |
30 | | -# we want to "align" everything to the discretization in |
31 | | -# both time and space. |
| 27 | +# check CHD |
| 28 | +assert chd.data["head"][0, 0].item() == 1.0 |
| 29 | +assert chd.data["head"][0, 99].item() == 0.0 |
| 30 | +assert np.allclose(chd.data["head"][:, 1:99], np.full(98, 1e30)) |
32 | 31 |
|
| 32 | +# TODO: xarray index aliasing nlay/ncol/nrow to k/i/j? |
33 | 33 | # assert chd.data["head"].loc(dict(k=0, i=0, j=0)) == 1. |
34 | 34 | # assert chd.data["head"].loc(dict(k=0, i=9, j=9)) == 0. |
35 | 35 |
|
36 | | -oc = Oc( |
37 | | - gwf, |
38 | | - budget_filerecord=f"{name}.bud", |
39 | | - head_filerecord=f"{name}.hds", |
40 | | - saverecord=[("HEAD", "ALL"), ("BUDGET", "ALL")], |
41 | | -) |
42 | | - |
43 | | -# xarray style. this is how imod-python does it too. |
44 | | -# assert oc.data["save_head"] == "all" |
45 | | -# assert oc.data["save_budget"] == "all" |
| 36 | +# check OC |
| 37 | +assert oc.data["save_head"][0].item() == "all" |
| 38 | +assert oc.data["save_budget"][0].item() == "all" |
0 commit comments