-
Notifications
You must be signed in to change notification settings - Fork 21
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
Does sfrmaker work with mf6 disv grids? #93
Comments
Hi @porterma, thanks for raising this issue. In principal, SFRmaker should work with any kind of unstructured grid, but I haven't had any project work so far to motivate implementing that capability. It would be great to add a quadtree example/test case. How is your grid refined in the z-direction? Does it coarsen with depth away from the streams? The intersection and setup of the SFR reaches should be fine, but one potential hang-up I can imagine is the streams cutting into layers below layer 1, after the streambed elevations are smoothed. In this case, either the layer bottoms need to be adjusted so that the streambed bottom is above the bottom of layer 1, or the reach needs to be assigned to the appropriate layer. In the later case, if the grid coarsens downward, those reaches would be in unrefined cells, and there would be a bunch of "wasted" refined cells above them. |
@aleaf, Thanks for the quick reply. My grid uses the same 2D quadtree mesh for each layer, so it does not coarsen with depth. Additionally, all of my streams are in the first layer. I am reading the gridgen.exe quadtree shapefile using geopandas, then using Unstructured grid to create a grid. Code is
sfrmaker prints out the following to the screen: SFRmaker version 0.1.2+3.g17dfa49 Creating sfr dataset... Culling hydrography to active area... Intersecting 99 flowlines with 47,871 grid cells... Building spatial index... Intersecting 99 features... Setting up reach data... (may take a few minutes for large grids) Dropping 216 reaches with length < 8.00 feet... Repairing routing connections... Setting up segment data... Then I get an error. I followed the the execution of code into sfrdata.py to line 501. Code is In my case self.structured is False and the code crashes. I don't see any other ways to specify an unstructured grid to pass into |
@porterma , no, doesn't look like you're missing anything. I think it's an issue with how SFRmaker is interacting with Flopy in sfrdata. It mostly uses the structure of "old-style" (pre-MODFLOW 6) SFR packages internally (i.e. segments and reaches), and converts this to MODFLOW 6 input on write. Part of that is creating a flopy.modflow.ModflowSfr2 package instance with an attached flopy.modflow.Modflow model instance. The fix might be as simple as just adding |
@aleaf, that did indeed fix the problem. So it appears that in my script I need to instantiate a flopy modflow model with version='mfusg', then create a dis package and possibly a bas6 file for the ibound, then call:
` |
My case is very similar to @porterma I tried the workaround suggested in this issue, but it may not work for the current version of SFRmaker? I instantiate a Lines object using sfrmaker.Lines.from_shapefile and upon running If i instead instantiate a regular flopy mf model i get AttributeError: 'NoneType' object has no attribute 'nrow' Could you give a more detailed description on how you managed the workaround, or perhaps I'm just a lost cause? :) I think the possibility to use this package with MF6 DISV grids would be a great feature. Unfortunately I have no idea how to contribute towards this goal. |
Hi @nikobenho, it sounds like SFRmaker might be trying to work with the flopy modelgrid attached to your flopy model, and also assuming that the flopy grid is structured. Can you post a more complete version of your script? Did you do the first two lines that @porterma has above: grd = UnstructuredGrid.from_dataframe(grd_df, node_col='nodenumber', geometry_column='geometry', model_units='feet', proj_str='epsg:2243', )
sfr = stream_lines.to_sfr(grd, model=mdl) This creates an SFRmaker unstructured grid instance from a DataFrame of shapely polygons representing the cells, and then passes that to the |
Hi @aleaf, thanks for replying. I really appreciate it! So my model consist of a 3-layer quadtree disv grid, which is refined along the creek (that I want to represent using SFR) as well as around a few wells. I eventually figured out that I had worked with the Flopy modelgrid rather than sfrmaker.grid.UnstructuredGrid. It got me a little bit further, but then i eventually got stuck again:
The DF of stream_lines looks as follows:
The DF of the grid looks like this:
Typing grd yields:
So far so good (I think). This is where my confusion starts. When i run
I then try to pass my MF6 model instance like this: I then try to do a hacky I then try to pass the base-modelgrid (an instance of flopy.modflow.Modflow() with the flopy.modflow.ModflowDis package), used by gridgen to create the disv-grid. Although this model is similar in terms of coordinates, rotation and elevations, it does not contain the same amount of cells and refinement as does the disv-grid created through gridgen. Before passing the base model i run
The rows and columns stated above are from what I can tell based on the structure of the basemodel passed as the model argument in By running
Running I then apply
In the docs i find the following:
But I'm not really sure what to make of that. At any rate, I go ahead and run
The layer information (k) is set to 0 in 320 cells, and 1 in 26 cells. Shouldn't this be the same number for all cells (i.e. SFR is supposed to be defined for the top layer only)? Given the assumption that I'm doing things right by passing the basemodel to Running
For a disv grid, the cellid is identified by layer and cell2d number, is it possible to translate from k i j to cell2d? Sorry for the long reply, but perhaps it makes it easier to identify where I fail. |
Hi all, Sorry to open this issue back up after several years, but I have encountered the same problem as @nikobenho: I generated an unstructured quadtree grid in gridgen as a .gsf and tried to use this grid with NHD Plus data to generate the SFR input data for my model with SFRmaker. I can provide more specifics, but the hang up that I cannot figure out is the same assertion error: structured=False can only be specified for mfusg models My first question is this: is it even possible to use SFRmaker with unstructured grid data? If so, Is there any progress on this front, and if so can somebody please direct me to a solution? Thank you! -Brett |
I have a suggestion for a "fix" (maybe more of a workaround). In the .to_sfr() function in lines.py between the printing of grid and model information to the screen and the check if flowlines need to be re-projected. But basically do a check if the grid is unstructured (or not structured) and there's either no model object or an mf6 model object that was supplied, and if so make a temporary/dummy mfusg model with structured=False.
I haven't done any extensive testing, but it "just works" (so far) and would prevent users from needing to know workaround of needing an mfusg model object. The notice message could maybe use some streamlining and/or better explanation. |
I have been working my way through this package the past week or so and things look promising. I am trying to intersect my stream shape file with an unstructured grid that is created with gridgen.exe. I am using a quadtree mesh. I am stuck at defining the grid that goes into
stream_lines.to_sfr(grid, model=mdl)
. It works fine with the StructuredGrid.from_sr package when I am using a structured grid. However, when I try UnstructuredGrid.from_dataframe(), I get an error that says AssertionError: structured=False can only be specified for mfusg models. Does sfrmaker work with gridgen quadtree mesh grids and if so do you have any examples? Thanks!The text was updated successfully, but these errors were encountered: