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

Add PRT support #1753

Merged
merged 5 commits into from Dec 22, 2023
Merged

Add PRT support #1753

merged 5 commits into from Dec 22, 2023

Conversation

wpbonelli
Copy link
Contributor

@wpbonelli wpbonelli commented Mar 23, 2023

Add basic support for MF6 PRT. #1940 and MODFLOW-USGS/modflow6#1389 depend on this. Some tests are skipped/left unimplemented until PRT classes are merged.

Features

  • to_coords() and to_prp() methods for ParticleData, LRCParticleData, NodeParticleData
    • get global coordinates and particle release point (PRP) package data, respectively
    • useful for converting MP7 release positions & models to PRT
    • limited to structured and quad-patch/-tree vertex grids
  • to_prt_pathlines(), to_mp7_pathlines(), to_mp7_endpoints() adapters
    • convert PRT pathlines to MP7 pathlines or endpoints and vice versa
    • useful for comparing and plotting MP7 and PRT results
  • support PRT pathline/endpoint plots for map view and cross section

Future directions

  • create_prtsim() function?
    • pattern after Modpath6.create_mpsim(), generate identical PRT simulation
    • not strictly necessary but convenient to start particles in boundary locns
  • TrackFile in binaryfile.pywith get_[pathlines/endpoints]() methods?
    • necessary? straightforward to read CSV or binary data with pandas or numpy, almost as easy to get endpoints e.g. sort_values("t").groupby(["imdl", "iprp", "irpt", "trelease"]).tail(1)
  • model-agnostic internal format for particle tracks instead of using mp7 as standard?
    • would need more extensive changes to plot modules

@codecov
Copy link

codecov bot commented Mar 23, 2023

Codecov Report

Merging #1753 (b49c185) into develop (c63bfca) will increase coverage by 0.1%.
The diff coverage is 86.8%.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop   #1753     +/-   ##
=========================================
+ Coverage     72.8%   72.9%   +0.1%     
=========================================
  Files          259     259             
  Lines        59040   59282    +242     
=========================================
+ Hits         43004   43261    +257     
+ Misses       16036   16021     -15     
Files Coverage Δ
flopy/utils/binaryfile.py 83.1% <100.0%> (ø)
flopy/utils/voronoi.py 70.0% <95.6%> (+2.7%) ⬆️
flopy/plot/map.py 83.6% <76.9%> (-0.4%) ⬇️
flopy/plot/plotutil.py 55.2% <92.3%> (+2.0%) ⬆️
flopy/plot/crosssection.py 66.4% <50.0%> (-0.3%) ⬇️
flopy/modpath/mp7particledata.py 86.0% <87.7%> (+4.0%) ⬆️

... and 7 files with indirect coverage changes

Copy link
Contributor

@langevin-usgs langevin-usgs left a comment

Choose a reason for hiding this comment

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

Looks like this is all cleanly set up to go in. Will be good to get @jlarsen-usgs buy in.

data = data.sort_values(["imdl", "iprp", "irpt", "trelease"])
particles = data.groupby(["imdl", "iprp", "irpt", "trelease"])
seqn_key = "sequencenumber"
data[seqn_key] = particles.ngroup()
Copy link
Contributor Author

@wpbonelli wpbonelli Oct 7, 2023

Choose a reason for hiding this comment

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

This just mimics a modpath sequencenumber — can't guarantee particles are indexed in the same order so this should be ignored when comparing prt and modpath results

It's possible to preserve particle identity by running modpath first, then setting prt PRP release point numbers or boundnames to modpath sequencenumbers

Could maybe add switches name_as_sequencenumber/irpt_as_sequencenumber or maybe simpler sequencenumber="irpt" (or "name") to set sequencenumber to that property

@@ -699,7 +967,7 @@ class LRCParticleData:
--------

>>> import flopy
>>> pg = flopy.modpath.LRCParticleData(lrcregions=[0, 0, 0, 3, 10, 10])
>>> pg = flopy.modpath.LRCParticleData(lrcregions=[[0, 0, 0, 3, 10, 10]])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

correction unrelated to PRT, lrcregions needs to be 2D

@wpbonelli wpbonelli force-pushed the prt-utils branch 2 times, most recently from e97a4cd to 0c939fd Compare October 19, 2023 16:01
@wpbonelli
Copy link
Contributor Author

wpbonelli commented Nov 1, 2023

@langevin-usgs suggested adding functions to convert mp7 to PRT results (currently only the other way is supported) but otherwise that full correspondence between result formats is not necessary until there is a demonstrated need

edit: added conversion functions

@wpbonelli wpbonelli force-pushed the prt-utils branch 2 times, most recently from 01bac86 to 61b66d9 Compare November 21, 2023 01:37
wpbonelli and others added 4 commits November 27, 2023 14:48
* to_coords() and to_prt() methods on particle data classes
* to_[mp7/prt]_[pathlines/endpoints]() conversion functions
* support plotting PRT pathlines in map/cross-section plots
* add basic tests for flopy.utils.geometry.point_in_polygon
Copy link
Contributor

@jlarsen-usgs jlarsen-usgs left a comment

Choose a reason for hiding this comment

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

Overall, this PR look goods.

Is there anything else that needs to be added/modified for PRT export support (e.g., shapefiles, vtk)? If so, will that be included here or will there be a follow up PR?

flopy/plot/plotutil.py Show resolved Hide resolved
@wpbonelli
Copy link
Contributor Author

Yes export functionality is still to come, planned in a separate PR after MF6 package classes are in

@wpbonelli wpbonelli merged commit a53cda7 into modflowpy:develop Dec 22, 2023
24 checks passed
@wpbonelli wpbonelli deleted the prt-utils branch December 22, 2023 18:43
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.

None yet

3 participants