Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(MF6model._set_idomain): Don't inactivate Lake BCs for MF6 models #94

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mfsetup/mf6model.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _set_idomain(self):
idomain = idomain.astype(int)

# remove cells that conincide with lakes
idomain[self.isbc == 1] = 0.
# idomain[self.isbc == 1] = 0.

# remove cells that are above stream cells
if self.get_package('sfr') is not None:
Expand Down
27 changes: 27 additions & 0 deletions mfsetup/tests/test_lakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pandas as pd
import pytest

from mfsetup import MF6model
from mfsetup.fileio import load_array
from mfsetup.lakes import (
PrismSourceData,
Expand All @@ -15,6 +16,7 @@
setup_lake_connectiondata,
setup_lake_info,
)
from mfsetup.tests.test_pleasant_mf6_inset import pleasant_mf6_cfg


@pytest.fixture
Expand Down Expand Up @@ -232,3 +234,28 @@ def test_get_flux_variable_from_config(modflow_version, config, nlakes, nper, ex
results = get_flux_variable_from_config(variable, config, nlakes, nper)
# repeat values for each lake
assert results == expected


def test_lake_idomain(pleasant_mf6_cfg):
"""For MODFLOW 6 models (at least), if no bathymetry raster is supplied,
the lake should be simulated 'above' the grid, connecting vertically with
the top model layer, and cells within the lake footprint should only
be inactive if they are pinched out based on the original layer surfaces
(cells containing lake shouldn't be inactive).
"""
cfg = pleasant_mf6_cfg.copy()
del cfg['lak']['source_data']['bathymetry_raster']
m = MF6model(cfg=cfg)
m.setup_dis()
m.setup_tdis()
m.setup_lak()


k, i, j = zip(*m.lak.connectiondata.array['cellid'])
# only a small number of cells
# should have connections to layers below the top layer
# note that this 5% criterian might change
# if the test problem changes substantially
assert np.sum(np.array(k) > 0)/np.sum(np.array(k) == 0) < 0.05
# all connections should be to active cells
assert all(m.dis.idomain.array[k, i, j] == 1)
Loading