Skip to content

Commit

Permalink
fix(MF6model._set_idomain): Don't inactivate Lake BCs for MF6 models
Browse files Browse the repository at this point in the history
  • Loading branch information
aleaf committed Sep 23, 2024
1 parent 9f53a9c commit 3142198
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
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)

0 comments on commit 3142198

Please sign in to comment.