Skip to content

docs(lakpak_utils): add embedded lake connection examples - #2793

Open
jdhughes-dev wants to merge 3 commits into
modflowpy:developfrom
jdhughes-dev:feat-lak-connections-notebooks
Open

docs(lakpak_utils): add embedded lake connection examples#2793
jdhughes-dev wants to merge 3 commits into
modflowpy:developfrom
jdhughes-dev:feat-lak-connections-notebooks

Conversation

@jdhughes-dev

Copy link
Copy Markdown
Contributor
  • Adds a notebook that embeds a lake in a structured grid and one that embeds the same lake in the equivalent vertex grid, using the get_lak_connections support added in feat(lakpak_utils): add support for VertexGrid embedded lakes #2786
  • The vertex grid notebook checks that the two grids give the same lake connections
  • Both notebooks run the model and put the lake stage into the head array, so a single map shows the water surface across the lake and the aquifer

get_lak_connections builds the Lake Package connection data for a lake
embedded in the model domain, and support for a vertex grid was added in
modflowpy#2786, but no notebook showed either one.

Two notebooks are added. The first embeds a lake in a structured grid, and the
second embeds the same lake in the equivalent vertex grid and checks that the
two give the same connections. Both run the model and put the lake stage into
the head array so that a single map shows the water surface across the lake
and the aquifer rather than leaving a hole where the lake is.
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.8%. Comparing base (556c088) to head (df277c1).
⚠️ Report is 187 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2793      +/-   ##
===========================================
+ Coverage     55.5%    72.8%   +17.2%     
===========================================
  Files          644      662      +18     
  Lines       124135   133001    +8866     
===========================================
+ Hits         68947    96828   +27881     
+ Misses       55188    36173   -19015     

see 583 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The two notebooks were written in an impersonal voice and never named
MODFLOW 6, unlike the notebooks added alongside them. They now use the first
person for what the notebook does and name the program whose package input is
being built.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds two executable Jupytext example notebooks to the FloPy docs demonstrating how to generate MODFLOW 6 LAK connection data for an embedded lake in both a structured grid (DIS) and an equivalent vertex grid (DISV), including running a small model and visualizing a combined water-surface map by embedding lake stage into the head array.

Changes:

  • Add a structured-grid embedded lake example (dis_lake_connections_example.py) using get_lak_connections().
  • Add a vertex-grid counterpart (disv_lake_connections_example.py) that builds an equivalent VertexGrid and checks connections against the structured case.
  • Run MODFLOW 6 in both notebooks and plot a single “water surface” map by filling inactive lake cells with simulated stage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.docs/Notebooks/dis_lake_connections_example.py New structured-grid example notebook for embedded lake connections and head/stage visualization.
.docs/Notebooks/disv_lake_connections_example.py New vertex-grid example notebook, including a structured-vs-vertex connection equivalence check and DISV model run.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +29
import sys
from pathlib import Path
from tempfile import TemporaryDirectory

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in df277c1.

Worth noting it would not have tripped this repository, since F401 is in the ruff ignore list in pyproject.toml, so ruff check passed on it. It was still dead code in a notebook people read, which is the part that mattered.

return (lakeno, *cellid, claktype, connlen, connwidth)


assert sorted(map(normalize, dis_data)) == sorted(map(normalize, disv_data))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed in df277c1. The cells and the connection types are still compared exactly, and the lengths and widths with np.allclose. The sort key is the discrete part only, so the ordering cannot shift with the floats.

For the record the two grids agree exactly on this geometry, maximum difference 0.0 over all 21 connections, so the comparison was not failing. The tolerance is there because the widths come from np.linalg.norm on the vertex grid and from delr/delc on the structured grid, and the notebook runs on three platforms.

…lerance

The structured notebook imported Path without using it. The vertex notebook
compared the connection lengths and widths of the two grids for exact
equality, which is brittle because the two grids compute them differently.
The cells and the connection types are still compared exactly, and the lengths
and widths to within rounding.
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