Skip to content

MAW support for grouping wells#509

Merged
bdestombe merged 6 commits intodevfrom
multiwel
Aug 12, 2025
Merged

MAW support for grouping wells#509
bdestombe merged 6 commits intodevfrom
multiwel

Conversation

@bdestombe
Copy link
Collaborator

The function maw_from_df now has the additional argument group, that allows for grouping of wells. This might be of use if a single pump is used to extract water from multiple wells. These individual wells may be placed in different cells, in different layers, but have to have the same radius.

group : str, optional
    The column in df that contains the group name for the wells. If this is not
    None, wells with the same group name are grouped together such that the rate is
    divided over the wells in the group. Note that empty strings are treated as
    unique group names, so wells with an empty string in the group column are
    treated as a separate group. The default is None, which means that each well is
    treated as a separate well.

Note that boundnames have to be the same for every well within a group, which makes sense but will be a common pitfall.

- Introduced a new optional parameter 'group' to allow grouping of wells.
- Updated documentation to reflect changes in well rate handling for grouped wells.
- Added validation to ensure unique DataFrame index and consistent flow rates within groups.
@OnnoEbbens
Copy link
Collaborator

Looks good! The function is a bit hard to check because the function is pretty lengthy but I think the approach is good.

2 remarks:

  • The 2 previous maw_from_df tests fail now. Can you fix these?
  • Could you add a test for the group option?

@bdestombe
Copy link
Collaborator Author

Looks good! The function is a bit hard to check because the function is pretty lengthy but I think the approach is good.

2 remarks:

  • The 2 previous maw_from_df tests fail now. Can you fix these?
  • Could you add a test for the group option?

Yes, it is not running correctly yet. I'll ask you for another review once fixed

@OnnoEbbens
Copy link
Collaborator

Okay, I will check it later. To avoid having your PR reviewed to soon you can also convert the PR to a draft ("Convert to draft" link in the side pane below "reviewers"). Once you are finished you can use the "Ready for Review" button to let me know I can start reviewing.

@bdestombe bdestombe marked this pull request as draft August 11, 2025 14:26
@bdestombe bdestombe marked this pull request as ready for review August 11, 2025 15:20
@bdestombe bdestombe requested a review from Copilot August 11, 2025 15:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for grouping wells in the Multi-Aquifer Well (MAW) functionality. Wells can now be grouped together such that they share the same pump and flow rate, which is useful for scenarios where multiple wells are connected to a single extraction system.

Key changes:

  • Added a group parameter to maw_from_df function for specifying well grouping
  • Added support for skin parameters (radius_skin and hk_skin) for advanced well modeling
  • Enhanced validation to ensure consistency within well groups

Reviewed Changes

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

File Description
nlmod/gwf/wells.py Core implementation of well grouping logic and skin parameter support
tests/test_010_wells.py Comprehensive test coverage for new grouping functionality and skin parameters

# configure groups
if df.index.has_duplicates:
raise ValueError(
"The index of the DataFrame must be unique. Indexing `multipliers` would go"
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

There's a missing space in the error message. The text "would gowrong" should be "would go wrong".

Suggested change
"The index of the DataFrame must be unique. Indexing `multipliers` would go"
"The index of the DataFrame must be unique. Indexing `multipliers` would go "

Copilot uses AI. Check for mistakes.
default is None, which means that the skin is not used.
hk_skin : str, optional
The column in df that contains the horizontal hydraulic conductivity of the skin
around the well. Only used if `condeqn` is SKIN, CUMULATIVE, or MEAN. The default
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

There's a trailing space at the end of this line in the docstring.

Copilot uses AI. Check for mistakes.
Comment on lines +240 to +242
iw = 0 # grouped well index
for well_group_name, well_group in tqdm(
df.groupby(group_by), total=len(df), desc="Adding MAW wells", disable=silent
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

The total parameter in tqdm should reflect the number of groups being processed, not the number of wells. When wells are grouped, there will be fewer iterations than len(df). This could cause the progress bar to be inaccurate.

Suggested change
iw = 0 # grouped well index
for well_group_name, well_group in tqdm(
df.groupby(group_by), total=len(df), desc="Adding MAW wells", disable=silent
n_groups = group_by.nunique()
iw = 0 # grouped well index
for well_group_name, well_group in tqdm(
df.groupby(group_by), total=n_groups, desc="Adding MAW wells", disable=silent

Copilot uses AI. Check for mistakes.
# [wellno, radius, bottom, strt, condeqn, ngwfnodes]
if strt is None:
if isinstance(irow["cellid"], (np.integer, int)):
if pd.api.types.is_integer_dtype(df.cellid):
Copy link

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

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

This check uses df.cellid but should use well_group['cellid'] to check the data type for the current group. Using the entire dataframe could give incorrect results when the group contains mixed data types.

Suggested change
if pd.api.types.is_integer_dtype(df.cellid):
if pd.api.types.is_integer_dtype(well_group["cellid"]):

Copilot uses AI. Check for mistakes.
@bdestombe
Copy link
Collaborator Author

The errors in the tests are unrelated

@bdestombe
Copy link
Collaborator Author

Accidentally clicked on the copilot button and thereby asking for it to review the PR.. It actually did a good job here ;)

Ready to be merged as far as I am concerned

Copy link
Collaborator

@OnnoEbbens OnnoEbbens left a comment

Choose a reason for hiding this comment

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

Haha, nice. Copilot took my job!

@github-project-automation github-project-automation bot moved this from Todo to In Progress in NHFLO Aug 12, 2025
@bdestombe bdestombe merged commit 02466d1 into dev Aug 12, 2025
2 of 4 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in NHFLO Aug 12, 2025
@bdestombe bdestombe deleted the multiwel branch August 12, 2025 09:05
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.

3 participants