Skip to content

Imod5 converter feature branch#1252

Merged
JoerivanEngelen merged 83 commits intomasterfrom
imod5_converter_feature_branch
Oct 23, 2024
Merged

Imod5 converter feature branch#1252
JoerivanEngelen merged 83 commits intomasterfrom
imod5_converter_feature_branch

Conversation

@JoerivanEngelen
Copy link
Copy Markdown
Contributor

Description

Merge all developed features to convert a iMOD5 model to a MODFLOW6 model. With important contributions from @luitjansl and @Manangka .

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

JoerivanEngelen and others added 30 commits May 1, 2024 09:51
Fixes #964 

# Description
Implements from_imod5 classmethod to StructuredDiscretization
classmethod.

NOTE: I had to modify the default regridding method of "idomain" as the
"mode" method appears to have a bug with perfectly aligned structured
grids.
This bug requires further investigation. Will post an issue if found.

# Checklist
<!---
Before requesting review, please go through this checklist:
-->

- [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
Fixes #965 

# Description
Adds a function to import an npf package from an imod5 project file.
Adds tests.

# Checklist


- [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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Fixes #961

# Description
implements importing from a imod5 project file for storage and initial
conditions.

# Checklist
- [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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Fixes #969

# Description
implements importing recharge packages from a project file. The recharge
can be imported using a planar grid,
in which case it assigns the recharge to the uppermost active cell for
each column.
The recharge can also be imported from a non-planar (so fully 3d) grid
in which case it is just regridded to the target grid.

# Checklist
- [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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
# Conflicts:
#	imod/mf6/dis.py
#	imod/mf6/package.py
#	imod/tests/test_typing/test_typing_grid.py
#	imod/typing/grid.py
Fixes #967 

# Description
implements importing drainage packages from imod5 data. Adds tests. 
Methods for allocation and conductivity assignment can be specified per
package, but it requires knowledge on what the packages are called in
the imod5 project file (like "drn-1" and "drn-2"). If not specified,
defaults are in place.

# Checklist

- [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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Fixes #1041

# Description
Adds a function that imports a simulation from an imod5 project file. It
creates a simulation, containing 1 GroundwaterFlowModel, containing the
packages for which we support importing currently. This includes the
mandatory flow packages like NPF and STO, and some boundary conditions
(like DRN and RCH) but not yet CHD or WEL.

# Checklist
- [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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Fixes #1053 

# Description
On importing wells, the filter top and bottom are now parsed and stored
in the project file data structure

# 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 #1051

# Description
Now validates that well top > well bottom. 

# Checklist

- [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
Fixes #968 

# Description
Imports riverpackages from IMOD5. The infiltration factor (which does
not exist in MF6) is accounted for by creating a drainage package.

# Checklist
<!---
Before requesting review, please go through this checklist:
-->

- [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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Fixes #1052 

# Description
when importing wells from imod5: If not all wells could be assigned to
the modflow6 model (this can be due to inactive cells,
or due to constraints of minimum thickness/permeability) then a log
message will be generated to document in the log
file that not all wells were successfully imported. 

# 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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Fixes #502 

# Description
Converts hfb's from imod5 to mf6, but only in the following cases:

- the hfb has an assgined layer that is not zero
- the hfb is mappable to the LayeredHorizontalFlowBarrierResistance
class.

It creates a single mf6 hfb package containing all the hfb's that are
present in the model domain area.
The hfb package is added to the simulation. 

# Checklist

- [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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Follow-up on: #1070

# Description
For some reason, I erronously merged #1070. This implements my
suggestion to concatenate pandas dataframes.

# Checklist
<!---
Before requesting review, please go through this checklist:
-->

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

---------

Co-authored-by: luitjan <luitjan.slooten@deltares.nl>
# Conflicts:
#	docs/api/changelog.rst
#	imod/mf6/dis.py
#	imod/mf6/drn.py
#	imod/mf6/ic.py
#	imod/mf6/npf.py
#	imod/mf6/oc.py
#	imod/mf6/package.py
#	imod/mf6/rch.py
#	imod/mf6/riv.py
#	imod/mf6/sto.py
#	pixi.lock
Fixes #1083 

# Description
When importing wells, we now make sure that when the ipf file defines 2
or more wells with the same x, y , filter_top, filter_bottom and id,
then the ID of the second well is appended with "_1", and so on for
successive findings of a well with the same characteristics (_2, _3
etc).

# Checklist

- [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
Fixes #1064 

# Description
Imports wells as grid-agnostic well packages, based on filter top and
filter bottom, and x/y location as stated in the imod5_dataset object.

# Checklist
- [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

---------

Co-authored-by: Joeri van Engelen <joerivanengelen@hotmail.com>
Fixes #966

# Description
Imports chd packages present in imod5_data. These packages are imported
one by one. If none are present, then a chd package is created at all
locations where ibound == -1. In that case the starting head of the
simulation is assigned as the chd value for each cell with ibound == -1.

# Checklist
- [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
Fixes #598

# Description
There was some confusion (also by me) about the use of the
``LayeredHorizontalFlowBarrier`` classes, so @HendrikKok explained me
they were intended for single layers. I therefore changed the following
to clarify:

- Rename to ``SingleLayerHorizontalFlowBarrier`` classes
- Throw ``ValidationError`` if multiple layers are added to dataset
- Added missing test for SingleLayerHorizontalFlowBarrier class

This means multiple SingleLayerHorizontalFlowBarrier need to be added to
GroundwaterFlowModel object, whereas MODFLOW 6 only accepts one single
HFB. So these have to be merged together. I think the best opportunity
for this is to merge the low level ``Mf6HorizontalFlowBarrier`` objects.

# 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 #1209

# Description
- Add setting to ``to_mf6_pkg``: ``error_on_well_removal``, which throws
an error if wells are removed entirely during well assignment.
- Separated code to collect filtered well ids in separate method. This
method is now also called to collect ids of errors being removed in
error message.
- Added attribute ``_is_from_imod5`` to Modflow6Simulation to keep track
if the simulation is loaded from iMOD5 data or not. Based on this, some
validation settings might be set to be a bit more permissive. (Or call
some extra cleanup?)
- ``is_from_imod5`` property to WriteContext to keep track of the same
thing within the writing context.

# 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 #1222

# Description
- Add a ``ValidationContext`` dataclass
- Add a ``_validation_context`` attribute to ``Modflow6Simulation``;
this replaces the ``_is_from_imod5`` attribute.
- The ``ValidationContext`` contains an attribute for strict well
checks, turned on by default. This is set to False when calling
``from_imod5`` or for split simulations.
- Adds a ``_to_mf6_pkg`` method in a similar design as proposed in
#1223, this to preserve public API.
- Refactor ``WriteContext``, to make it a dataclass again. I had to
ignore type annotation for ``write_directory``, otherwise MyPy would
throw errors. The whole property shebang presumably started with MyPy
throwing errors. Reverting it back to a dataclass reduces the lines of
code considerably, which makes it more maintainable.
- Use jit for examples run, this speeds them up considerably. The
examples ran into a TimeOut on TeamCity, and this reduces the change of
that happening again.

# Checklist
<!---
Before requesting review, please go through this 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 #1230

# Description
- Fix bug where distributed conductances were dropped when their
elevation equalled surface level
- In topsystem test cases, make sure "layer" coordinate is dropped
consistently amongst cases.

# Checklist
<!---
Before requesting review, please go through this 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 #1228

# Description
- Provides hydraulic conductivity ("k") to distribute_riv_conductances
instead of the riv conductance, which is entirely wrong.
- Align ``Drainage`` and ``River`` signatures, which should be nearly
the same.
- Align arg names and order

# Checklist
<!---
Before requesting review, please go through this checklist:
-->

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

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

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.

2 participants