From 3698cfb6f68105724a492ffe4e5a25abbaa9f35b Mon Sep 17 00:00:00 2001 From: "Leaf, Andrew T" Date: Mon, 23 Sep 2024 08:56:15 -0500 Subject: [PATCH] fix(MF6model._set_idomain): Don't inactivate Lake BCs for MF6 models --- mfsetup/mf6model.py | 2 +- mfsetup/tests/test_lakes.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/mfsetup/mf6model.py b/mfsetup/mf6model.py index 90452d05..a552c458 100644 --- a/mfsetup/mf6model.py +++ b/mfsetup/mf6model.py @@ -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: diff --git a/mfsetup/tests/test_lakes.py b/mfsetup/tests/test_lakes.py index 25dbd0af..dd450db4 100644 --- a/mfsetup/tests/test_lakes.py +++ b/mfsetup/tests/test_lakes.py @@ -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, @@ -15,6 +16,7 @@ setup_lake_connectiondata, setup_lake_info, ) +from mfsetup.tests.test_pleasant_mf6_inset import pleasant_mf6_cfg @pytest.fixture @@ -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)