Skip to content

Commit

Permalink
fix(empty transient data): Empty first stress period block (#1091) (#…
Browse files Browse the repository at this point in the history
…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 <45947939+scottrp@users.noreply.github.com>
  • Loading branch information
spaulins-usgs and scottrp committed Apr 5, 2024
1 parent 0fe4150 commit 0f14f1f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
13 changes: 12 additions & 1 deletion autotest/regression/test_mf6.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ def test_np001(function_tmpdir, example_data_path):
found_cellid = True
assert found_cellid

# test empty stress period
# test empty stress period and remove output
well_spd = {0: [(-1, -1, -1, -2000.0), (0, 0, 7, -2.0)], 1: []}
wel_package = ModflowGwfwel(
model,
Expand All @@ -763,6 +763,13 @@ def test_np001(function_tmpdir, example_data_path):
maxbound=2,
stress_period_data=well_spd,
)
oc_package = ModflowGwfoc(
model,
budget_filerecord=[("np001_mod 1.cbc",)],
head_filerecord=[("np001_mod 1.hds",)],
saverecord={0: []},
printrecord={0: []},
)
sim.write_simulation()
found_begin = False
found_end = False
Expand All @@ -787,6 +794,10 @@ def test_np001(function_tmpdir, example_data_path):
spath,
write_headers=False,
)
# test to make sure oc empty record dictionary is set
oc = test_sim.get_model().get_package("oc")
assert oc.saverecord.empty_keys[0] is True
# test wel package
wel = test_sim.get_model().get_package("wel_2")
wel._filename = "np001_spd_test.wel"
wel.write()
Expand Down
3 changes: 3 additions & 0 deletions flopy/mf6/data/mfdatalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,9 @@ def has_data(self, key=None):
self.get_data_prep(sto_key)
if super().has_data():
return True
for val in self.empty_keys.values():
if val:
return True
return False
else:
self.get_data_prep(key)
Expand Down
9 changes: 8 additions & 1 deletion flopy/mf6/mfpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,13 @@ def load(self, block_header, fd, strict=True):
and result[1][:3].upper() == "END"
):
break
else:
# block empty, store empty array in block variables
empty_arr = []
for ds in self.datasets.values():
if isinstance(ds, mfdata.MFTransient):
transient_key = block_header.get_transient_key()
ds.set_data(empty_arr, transient_key)
self.loaded = True
self.is_valid()

Expand Down Expand Up @@ -2976,7 +2983,7 @@ def _load_blocks(self, fd_input_file, strict=True, max_blocks=sys.maxsize):
block_header_info, fd_input_file, strict
)

# write post block comment comment
# write post block comment
self._simulation_data.mfdata[
cur_block.block_headers[-1].blk_post_comment_path
] = self.post_block_comments
Expand Down

0 comments on commit 0f14f1f

Please sign in to comment.