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

Issue #1051 validate well filters #1062

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 12 additions & 1 deletion imod/mf6/wel.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import imod
from imod.logging import init_log_decorator
from imod.logging.logging_decorators import standard_log_decorator
from imod.mf6.boundary_condition import (
BoundaryCondition,
DisStructuredBoundaryCondition,
Expand All @@ -26,6 +27,7 @@
from imod.prepare import assign_wells
from imod.prepare.layer import create_layered_top
from imod.schemata import (
AllValueSchema,
AnyNoDataSchema,
DTypeSchema,
EmptyIndexesSchema,
Expand Down Expand Up @@ -177,7 +179,11 @@ def y(self) -> npt.NDArray[np.float64]:
}
_write_schemata = {
"screen_top": [AnyNoDataSchema(), EmptyIndexesSchema()],
"screen_bottom": [AnyNoDataSchema(), EmptyIndexesSchema()],
"screen_bottom": [
AnyNoDataSchema(),
EmptyIndexesSchema(),
AllValueSchema("<", "screen_top"),
],
"y": [AnyNoDataSchema(), EmptyIndexesSchema()],
"x": [AnyNoDataSchema(), EmptyIndexesSchema()],
"rate": [AnyNoDataSchema(), EmptyIndexesSchema()],
Expand Down Expand Up @@ -363,6 +369,11 @@ def __create_wells_df(self) -> pd.DataFrame:

return wells_df

@standard_log_decorator()
def _validate(self, schemata: dict, **kwargs) -> dict[str, list[ValidationError]]:
kwargs["screen_top"] = self.dataset["screen_top"]
return Package._validate(self, schemata, **kwargs)

def __create_assigned_wells(
self,
wells_df: pd.DataFrame,
Expand Down
23 changes: 23 additions & 0 deletions imod/tests/test_mf6/test_mf6_wel.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@ def test_to_mf6_pkg__validate(well_high_lvl_test_data_stationary):
assert len(errors) == 1


def test_to_mf6_pkg__validate_filter_top(well_high_lvl_test_data_stationary):
# Arrange
x, y, screen_top, screen_bottom, rate_wel, concentration = (
well_high_lvl_test_data_stationary
)
screen_top = [-2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
screen_bottom = [0.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0, -2.0]
well_test_data = (x, y, screen_top, screen_bottom, rate_wel, concentration)

wel = imod.mf6.Well(*well_test_data)

# Act
kwargs = {"screen_top": wel.dataset["screen_top"]}
errors = wel._validate(wel._write_schemata, **kwargs)

# Assert
assert len(errors) == 1
assert (
str(errors["screen_bottom"][0])
== "not all values comply with criterion: < screen_top"
)


def test_to_mf6_pkg__high_lvl_multilevel(basic_dis, well_high_lvl_test_data_stationary):
"""
Test with stationary wells where the first 4 well screens extend over 2 layers.
Expand Down