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

refactor(Modpath7.create_mp7): expose porosity parameter of Modpath7Bas #2340

Merged
merged 2 commits into from
Oct 20, 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
48 changes: 48 additions & 0 deletions autotest/test_mp7.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,54 @@ def test_mp7sim_replacement(function_tmpdir):
assert success, buff


@requires_exe("mf6", "mp7")
@pytest.mark.parametrize(
"porosity_type", ("constant", "list", "array_1d", "array")
)
@pytest.mark.slow
def test_mp7bas_porosity(ex01_mf6_model, porosity_type):
sim, function_tmpdir = ex01_mf6_model
sim.run_simulation()

mpnam = f"{ex01_mf6_model_name}_mp_forward"
gwf = sim.get_model(ex01_mf6_model_name)

if porosity_type == "constant":
porosity = 0.30
elif porosity_type == "list":
porosity = [0.35, 0.30, 0.25] # constant per layer
elif porosity_type == "array_1d":
porosity = np.array([0.35, 0.30, 0.25]) # constant per layer
elif porosity_type == "array":
# Initialize porosity array based on dim of dis.botm
# lay_1=0.35, lay_2=0.30, lay_3=0.25
porosity = np.array([[[0.35]], [[0.30]], [[0.25]]]) * np.ones(
(gwf.dis.botm.array.shape)
)
# Diversify porosity values, adjust both halves of the model
porosity[:, :, : porosity.shape[2] // 2] -= 0.05
porosity[:, :, porosity.shape[2] // 2 :] += 0.05

mp = Modpath7.create_mp7(
modelname=mpnam,
trackdir="forward",
flowmodel=gwf,
exe_name="mp7",
model_ws=function_tmpdir,
rowcelldivisions=1,
columncelldivisions=1,
layercelldivisions=1,
porosity=porosity,
)

# Check mean of assigned porosity
assert np.isclose(np.mean(mp.get_package("MPBAS").porosity.array), 0.3)

mp.write_input()
success, _ = mp.run_model()
assert success, f"mp7 model ({mp.name}) did not run"


@requires_exe("mf6", "mp7")
def test_flopy_2223(function_tmpdir):
mf6sim = Mp7Cases.mf6(function_tmpdir)
Expand Down
5 changes: 4 additions & 1 deletion flopy/modpath/mp7.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ def create_mp7(
rowcelldivisions=2,
layercelldivisions=2,
nodes=None,
porosity=0.30,
):
"""
Create a default MODPATH 7 model using a passed flowmodel with
Expand Down Expand Up @@ -447,6 +448,8 @@ def create_mp7(
direction (default is 2).
nodes : int, list of ints, tuple of ints, or np.ndarray
Nodes (zero-based) with particles. If (default is node 0).
porosity: float or array of floats (nlay, nrow, ncol)
The porosity array (the default is 0.30).

Returns
-------
Expand Down Expand Up @@ -477,7 +480,7 @@ def create_mp7(

# create MODPATH 7 basic file and add to the MODPATH 7
# model instance (mp)
Modpath7Bas(mp, defaultiface=defaultiface)
Modpath7Bas(mp, porosity=porosity, defaultiface=defaultiface)

# create particles
if nodes is None:
Expand Down
Loading