Skip to content

Commit 670d368

Browse files
mjrenomjreno
authored andcommitted
add rcha codec test
1 parent 08c9eb0 commit 670d368

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

test/test_mf6_codec.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,48 @@ def test_dumps_chdg():
302302
pprint(loaded)
303303

304304

305+
def test_dumps_rcha():
306+
from flopy4.mf6.gwf import Dis, Gwf, Rcha
307+
308+
nlay = 3
309+
nrow = 10
310+
ncol = 10
311+
312+
dis = Dis(nlay=nlay, nrow=nrow, ncol=ncol)
313+
gwf = Gwf(dis=dis)
314+
315+
recharge = np.full((nrow, ncol), FILL_DNODATA, dtype=float)
316+
recharge[0, 0] = 1.0
317+
recharge[9, 9] = 0.0
318+
rch = Rcha(
319+
parent=gwf,
320+
recharge=np.expand_dims(recharge.ravel(), axis=0),
321+
save_flows=True,
322+
print_input=True,
323+
dims={"nper": 1},
324+
)
325+
326+
dumped = dumps(COMPONENT_CONVERTER.unstructure(rch))
327+
print("RCH dump:")
328+
print(dumped)
329+
330+
assert "BEGIN PERIOD 1" in dumped
331+
assert "END PERIOD 1" in dumped
332+
333+
period_section = dumped.split("BEGIN PERIOD 1")[1].split("END PERIOD 1")[0].strip()
334+
lines = [line.strip() for line in period_section.split("\n") if line.strip()]
335+
336+
assert len(lines) == 3
337+
assert "READASARRAYS" in dumped
338+
dump_data = [float(x) for x in lines[2].split()]
339+
dump_recharge = np.array(dump_data)
340+
assert np.allclose(recharge, dump_recharge.reshape(nrow, ncol))
341+
342+
loaded = loads(dumped)
343+
print("RCHA load:")
344+
pprint(loaded)
345+
346+
305347
def test_dumps_wel():
306348
from flopy4.mf6.gwf import Dis, Gwf, Wel
307349

0 commit comments

Comments
 (0)