Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a4b711

Browse files
authored
Issue #746 slice model transport (#781)
Fixes #746 # Description Fixes the slice_model function to slice transport models as well. Includes changes to the Advection package. The advection scheme parameter is set by the constructors of derived types of advection. Trying to reinitialize the derived type throws an error, as its construction method doesn't expect arguments. As a pragmatic solution, the constructor methods now get a ``**ignored`` argument to ignore these kwargs. - [x] Links to correct issue - [ ] Update changelog, if changes affect users - [x] PR title starts with ``Issue #nr``, e.g. ``Issue #737`` - [x] Unit tests were added - [ ] **If feature added**: Added/extended example
1 parent 9ed15a4 commit 9a4b711

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

imod/mf6/adv.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
Upstream weighting is a fast alternative, and TVD is a more expensive and more
99
robust alternative.
1010
"""
11+
from copy import deepcopy
12+
1113
from imod.mf6.package import Package
1214

1315

@@ -23,12 +25,20 @@ def render(self, directory, pkgname, globaltimes, binary):
2325
scheme = self.dataset["scheme"].item()
2426
return self._template.render({"scheme": scheme})
2527

28+
def mask(self, _) -> Package:
29+
"""
30+
The mask method is irrelevant for this package , instead this method
31+
retuns a copy of itself.
32+
"""
33+
return deepcopy(self)
34+
2635

2736
class AdvectionUpstream(Advection):
2837
"""
2938
The upstream weighting (first order upwind) scheme sets the concentration
3039
at the cellface between two adjacent cells equal to the concentration in
3140
the cell where the flow comes from. It surpresses oscillations.
41+
Note: all constructor arguments will be ignored
3242
"""
3343

3444
def __init__(self):
@@ -44,6 +54,7 @@ class AdvectionCentral(Advection):
4454
grids without equal spacing between connected cells, it is retained here
4555
for consistency with nomenclature used by other MODFLOW-based transport
4656
programs, such as MT3D.
57+
Note: all constructor arguments will be ignored
4758
"""
4859

4960
def __init__(self):
@@ -54,6 +65,7 @@ class AdvectionTVD(Advection):
5465
"""
5566
An implicit second order TVD scheme. More expensive than upstream
5667
weighting but more robust.
68+
Note: all constructor arguments will be ignored
5769
"""
5870

5971
def __init__(self):

imod/mf6/multimodel/modelsplitter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from imod.mf6.boundary_condition import BoundaryCondition
1010
from imod.mf6.hfb import HorizontalFlowBarrierBase
1111
from imod.mf6.model import Modflow6Model
12-
from imod.mf6.model_gwf import GroundwaterFlowModel
1312
from imod.mf6.utilities.clip import clip_by_grid
1413
from imod.mf6.utilities.grid import get_active_domain_slice
1514
from imod.mf6.wel import Well
@@ -70,7 +69,8 @@ def slice_model(partition_info: PartitionInfo, model: Modflow6Model) -> Modflow6
7069
that are sliced using the domain_slice. A domain_slice can be created using the
7170
:func:`imod.mf6.modelsplitter.create_domain_slices` function.
7271
"""
73-
new_model = GroundwaterFlowModel(**model._options)
72+
modelclass = type(model)
73+
new_model = modelclass(**model._options)
7474
domain_slice2d = get_active_domain_slice(partition_info.active_domain)
7575
if is_unstructured(model.domain):
7676
new_idomain = model.domain.sel(domain_slice2d)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from imod.mf6.multimodel.modelsplitter import create_partition_info, slice_model
2+
from imod.typing.grid import zeros_like
3+
4+
5+
def test_slice_model_structured(flow_transport_simulation):
6+
# Arrange.
7+
transport_model = flow_transport_simulation["tpt_a"]
8+
submodel_labels = zeros_like(transport_model.domain)
9+
submodel_labels[:, :, 30:] = 1
10+
11+
partition_info = create_partition_info(submodel_labels)
12+
13+
submodel_list = []
14+
15+
# Act
16+
for submodel_partition_info in partition_info:
17+
submodel_list.append(slice_model(submodel_partition_info, transport_model))
18+
19+
# Assert
20+
assert len(submodel_list) == 2
21+
for submodel in submodel_list:
22+
for package_name in list(transport_model.keys()):
23+
assert package_name in list(submodel.keys())

0 commit comments

Comments
 (0)