Skip to content

Commit ab9d7b8

Browse files
mjrenomjreno
authored andcommitted
add chdg baseline
1 parent d50342f commit ab9d7b8

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

flopy4/mf6/gwf/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from xattree import xattree
99

1010
from flopy4.mf6.gwf.chd import Chd
11+
from flopy4.mf6.gwf.chdg import Chdg
1112
from flopy4.mf6.gwf.dis import Dis
1213
from flopy4.mf6.gwf.drn import Drn
1314
from flopy4.mf6.gwf.ic import Ic
@@ -19,7 +20,7 @@
1920
from flopy4.mf6.utils import open_cbc, open_hds
2021
from flopy4.utils import to_path
2122

22-
__all__ = ["Gwf", "Chd", "Dis", "Drn", "Ic", "Npf", "Oc", "Wel"]
23+
__all__ = ["Gwf", "Chd", "Chdg", "Dis", "Drn", "Ic", "Npf", "Oc", "Wel"]
2324

2425

2526
def convert_grid(value):
@@ -76,6 +77,7 @@ def budget(self):
7677
oc: Oc = field(block="packages")
7778
npf: Npf = field(block="packages")
7879
chd: list[Chd] = field(block="packages")
80+
chdg: list[Chdg] = field(block="packages")
7981
wel: list[Wel] = field(block="packages")
8082
drn: list[Drn] = field(block="packages")
8183
output: Output = attrs.field(

flopy4/mf6/gwf/chdg.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from pathlib import Path
2+
from typing import ClassVar, Optional
3+
4+
import numpy as np
5+
from attrs import Converter
6+
from numpy.typing import NDArray
7+
from xattree import xattree
8+
9+
from flopy4.mf6.converter import structure_array
10+
from flopy4.mf6.package import Package
11+
from flopy4.mf6.spec import array, field, path
12+
from flopy4.utils import to_path
13+
14+
15+
@xattree
16+
class Chdg(Package):
17+
multi_package: ClassVar[bool] = True
18+
auxiliary: Optional[list[str]] = array(block="options", default=None)
19+
auxmultname: Optional[str] = field(block="options", default=None)
20+
print_input: bool = field(block="options", default=False)
21+
print_flows: bool = field(block="options", default=False)
22+
save_flows: bool = field(block="options", default=False)
23+
ts_filerecord: Optional[Path] = path(
24+
block="options", default=None, converter=to_path, inout="filein"
25+
)
26+
obs_filerecord: Optional[Path] = path(
27+
block="options", default=None, converter=to_path, inout="fileout"
28+
)
29+
dev_no_newton: bool = field(default=False, block="options")
30+
maxbound: Optional[int] = field(block="dimensions", default=None, init=False)
31+
head: Optional[NDArray[np.float64]] = array(
32+
block="period",
33+
dims=(
34+
"nper",
35+
"nodes",
36+
),
37+
default=None,
38+
converter=Converter(structure_array, takes_self=True, takes_field=True),
39+
)
40+
aux: Optional[NDArray[np.float64]] = array(
41+
block="period",
42+
dims=(
43+
"nper",
44+
"nodes",
45+
),
46+
default=None,
47+
converter=Converter(structure_array, takes_self=True, takes_field=True),
48+
)

test/test_component.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88

99
from flopy4.mf6.component import COMPONENTS
1010
from flopy4.mf6.constants import FILL_DNODATA, LENBOUNDNAME
11-
from flopy4.mf6.gwf import Chd, Dis, Gwf, Ic, Npf, Oc
11+
from flopy4.mf6.gwf import Chd, Chdg, Dis, Gwf, Ic, Npf, Oc
1212
from flopy4.mf6.ims import Ims
1313
from flopy4.mf6.simulation import Simulation
1414
from flopy4.mf6.tdis import Tdis
1515

16+
DNODATA = 3.0e30
17+
1618

1719
def test_registry():
1820
assert COMPONENTS["simulation"] is Simulation
@@ -394,6 +396,46 @@ def test_quickstart(function_tmpdir):
394396
sim.run()
395397

396398

399+
def test_quickstart_array(function_tmpdir):
400+
sim_name = "quickstart"
401+
gwf_name = "mymodel"
402+
nlay = 1
403+
nrow = 10
404+
ncol = 10
405+
time = ModelTime(perlen=[1.0], nstp=[1], tsmult=[1.0])
406+
ims = Ims(filename="mymodel.ims", models=[gwf_name])
407+
dis = Dis(
408+
nlay=nlay,
409+
nrow=nrow,
410+
ncol=ncol,
411+
top=1.0,
412+
botm=0.0,
413+
)
414+
sim = Simulation(
415+
tdis=time,
416+
workspace=function_tmpdir,
417+
name=sim_name,
418+
solutions={"ims": ims},
419+
)
420+
gwf = Gwf(parent=sim, dis=dis, name=gwf_name)
421+
ic = Ic(parent=gwf)
422+
oc = Oc(
423+
parent=gwf,
424+
budget_file=f"{gwf_name}.bud",
425+
head_file=f"{gwf_name}.hds",
426+
save_head=["all"],
427+
save_budget=["all"],
428+
)
429+
npf = Npf(parent=gwf, icelltype=0, k=1.0)
430+
head = {0: np.full((nlay, nrow, ncol), DNODATA, dtype=float)}
431+
head[0][0, 0, 0] = 1.0
432+
head[0][0, 9, 9] = 0.0
433+
chd = Chdg(parent=gwf, head=head)
434+
435+
sim.write()
436+
sim.run()
437+
438+
397439
def test_write_ascii(function_tmpdir):
398440
sim_name = "sim"
399441
gwf_name = "gwf"

0 commit comments

Comments
 (0)