Skip to content

Commit 0f14f1f

Browse files
fix(empty transient data): Empty first stress period block (#1091) (#2139)
* fix(empty transient data): empty stress period 1 transient data is now retained and used to create empty stress period block (#1091) * fix(empty transient data) --------- Co-authored-by: scottrp <[email protected]>
1 parent 0fe4150 commit 0f14f1f

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

autotest/regression/test_mf6.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ def test_np001(function_tmpdir, example_data_path):
751751
found_cellid = True
752752
assert found_cellid
753753

754-
# test empty stress period
754+
# test empty stress period and remove output
755755
well_spd = {0: [(-1, -1, -1, -2000.0), (0, 0, 7, -2.0)], 1: []}
756756
wel_package = ModflowGwfwel(
757757
model,
@@ -763,6 +763,13 @@ def test_np001(function_tmpdir, example_data_path):
763763
maxbound=2,
764764
stress_period_data=well_spd,
765765
)
766+
oc_package = ModflowGwfoc(
767+
model,
768+
budget_filerecord=[("np001_mod 1.cbc",)],
769+
head_filerecord=[("np001_mod 1.hds",)],
770+
saverecord={0: []},
771+
printrecord={0: []},
772+
)
766773
sim.write_simulation()
767774
found_begin = False
768775
found_end = False
@@ -787,6 +794,10 @@ def test_np001(function_tmpdir, example_data_path):
787794
spath,
788795
write_headers=False,
789796
)
797+
# test to make sure oc empty record dictionary is set
798+
oc = test_sim.get_model().get_package("oc")
799+
assert oc.saverecord.empty_keys[0] is True
800+
# test wel package
790801
wel = test_sim.get_model().get_package("wel_2")
791802
wel._filename = "np001_spd_test.wel"
792803
wel.write()

flopy/mf6/data/mfdatalist.py

+3
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,9 @@ def has_data(self, key=None):
17451745
self.get_data_prep(sto_key)
17461746
if super().has_data():
17471747
return True
1748+
for val in self.empty_keys.values():
1749+
if val:
1750+
return True
17481751
return False
17491752
else:
17501753
self.get_data_prep(key)

flopy/mf6/mfpackage.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,13 @@ def load(self, block_header, fd, strict=True):
10311031
and result[1][:3].upper() == "END"
10321032
):
10331033
break
1034+
else:
1035+
# block empty, store empty array in block variables
1036+
empty_arr = []
1037+
for ds in self.datasets.values():
1038+
if isinstance(ds, mfdata.MFTransient):
1039+
transient_key = block_header.get_transient_key()
1040+
ds.set_data(empty_arr, transient_key)
10341041
self.loaded = True
10351042
self.is_valid()
10361043

@@ -2976,7 +2983,7 @@ def _load_blocks(self, fd_input_file, strict=True, max_blocks=sys.maxsize):
29762983
block_header_info, fd_input_file, strict
29772984
)
29782985

2979-
# write post block comment comment
2986+
# write post block comment
29802987
self._simulation_data.mfdata[
29812988
cur_block.block_headers[-1].blk_post_comment_path
29822989
] = self.post_block_comments

0 commit comments

Comments
 (0)