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

Merge MetaSWAP refactoring feature branch #1279

Merged
merged 9 commits into from
Nov 8, 2024

Conversation

JoerivanEngelen
Copy link
Contributor

Description

This merges MetaSWAP refactoring feature branch into master. Fixes merge conflicts.

This consolidates the work in #1255

Checklist

  • Links to correct issue
  • Update changelog, if changes affect users
  • PR title starts with Issue #nr, e.g. Issue #737
  • Unit tests were added
  • If feature added: Added/extended example

Fixes #728

# Description
This PR updates two MetaSWAP packages that depend on wells to use of the
deprecated ``WellDisStructured`` object to the ``Mf6Wel`` object.

It fixes the first small step of the big metaswap refactor. I chose a
feature branch as base branch to merge into, to still have the option to
create some hotfixes for a new release of iMOD Python while primod is
being updated.

I also renamed some variable names and dimension names with clearer
names. Furthermore, I type annotated some method.

# Checklist

- [x] Links to correct issue
- [x] Update changelog, if changes affect users
- [x] PR title starts with ``Issue #nr``, e.g. ``Issue #737``
- [ ] Unit tests were added
- [ ] **If feature added**: Added/extended example
Fixes #1255 and #1056

# Description
This is part 2 of the metaswap refactoring on the iMOD Python side. The
goal of this step was to require a Mf6Wel object at ``write`` instead of
at init. For this I was struggling quite a lot with Linkov's principle
and the resulting mypy errors. In the end, I resorted to requiring all
arguments for the write method for each package. This results in a bit
of a weird situation, where a ``None`` has to be provided for the
``mf6_dis`` and ``mf6_wel`` arguments to the ``write`` of an individual
no even using these args. I don't think this is a major hickup for
users, as they are nearly always writing with ``model.write`` directly,
and not writing individual packages manually.

Though not perfect, I think this is certainly a big improvement to the
current situation.

In total, this PR:

- Removes the mf6 packages as attributes from ``Sprinkling`` and
``CouplerMapping``. This makes dumping the metaswap packages easier.
This affects the files ``imod.msw.sprinkling.py`` and
``imod.msw.coupler_mapping.py``.
- Updates the ``Sprinkling`` and ``CouplerMapping`` class to ask
MODFLOW6 packages at ``write`` instead of at ``__init__``. This affects
``imod.msw.sprinkling.py``, ``imod.msw.coupler_mapping.py``, and
``imod.msw.model.py``
- Updates the signatures
- Implements a ``regrid_like`` for the Sprinkling package. Affects
``imod.msw.sprinkling.py``.
- Adds a test to regrid a MetaSWAP model and its coupled MODFLOW6 model.
The ``Mf6Wel`` package has to be created manually now after regridding.

# Checklist
- [x] Links to correct issue
- [x] 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
Fixes #1267 and #1268

# Description
This does the following:
- fixes a bug with ``self.__get_k`` and different keys for the
``NodePropertyFlow``. Now the method ``__get_k`` is implicitly hardcoded
with the "npf" key, as this is the ``NodePropertyFlow._pkg_id``
- Adds a method ``Groundwater.prepare_wel_for_mf6`` to allocate wells to
the public API. Users can call this for debugging purposes and
``primod`` can call it to fetch Mf6Wel objects to for its coupling
schemes
- Make ``_get_k`` and ``_get_domain_geometry`` methods semi-private and
add tests for these functions.

# Checklist

- [x] Links to correct issue
- [x] 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
Copy link

sonarqubecloud bot commented Nov 8, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
4.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@JoerivanEngelen JoerivanEngelen removed the request for review from Manangka November 8, 2024 14:20
@JoerivanEngelen JoerivanEngelen merged commit fc0cac0 into master Nov 8, 2024
0 of 6 checks passed
@JoerivanEngelen JoerivanEngelen deleted the msw_refactoring_feature_branch branch November 8, 2024 14:21
@JoerivanEngelen JoerivanEngelen restored the msw_refactoring_feature_branch branch November 8, 2024 14:40
@JoerivanEngelen JoerivanEngelen deleted the msw_refactoring_feature_branch branch November 8, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant