File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff 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+
305347def test_dumps_wel ():
306348 from flopy4 .mf6 .gwf import Dis , Gwf , Wel
307349
You can’t perform that action at this time.
0 commit comments