Skip to content

Example of interaction with Flopy and Modflow

Alexandre Pryet edited this page Jun 6, 2013 · 26 revisions

Introduction

Flopy provides a python interface for the USGS Modflow model. In this example, we illustrate the potential of Qgridder as a Qgis based preprocessor for Flopy. We consider the propagation of the tidal signal in a theoretical island. The simulation is transient, sea level is imposed at the coast of the island.

You can download the dataset with python scripts and follow the instructions below.

Requirements :

There is no need to install an independent python distribution, Qgis contains its own.

Grid construction

In Qgis, load "island.shp" and start the Qgridder plugin. From the Qgridder "Build New Grid" tab, select the layer "island" and click "Update Extents from layer". Set grid resolution to 50 m. Set the output path and click "Build grid". The grid is ready.

Grid numbering (optional)

Go to the Qgridder "Pre-processing" tab. Check that "Model type" is set to "Modflow" at the top of the window. Click "Proceed to numbering". This will add fields ROW and COL to the grid attribute table.

Setting of IBOUND

  1. IBOUND of active cells must be set to 1. In Qgis, open the menu Vector / Research Tools / Select by Location. Select features in the grid layer that intersect features in the island layer. Open the grid layer attribute table, start editing, and click the calculator icon. Check "Create new field", set "Name" to IBOUND, "Type" to Whole number (integer), and "Width" to 10. Type 1 in the "expression" text box below. Click OK in the calculator, remain in the attribute table.
  2. IBOUND of inactive cells must be set to 0. From the grid attribute table, click "invert selection". Open the calculator, check "Update existing field" and set IBOUND of selected features to 0.

Pre-processing with Flopy from the Qgis console

image

Preprocessing with Flopy from the Qgis console

Subsequent pre-rocessing steps must be completed from the Qgis python console. Available from the menu Plugin / Python Console. The whole python script is available here, but the principal Qgridder python commands are detailed hereafter.

Before running the commands detailed hereafter, you must set a variable pointing to the grid layer. First select the grid layer in the layer list panel, and type :

gridLayer = qgis.utils.iface.activeLayer()

Get nrow, ncol :

nrow, ncol =  qgridder_utils.get_rgrid_nrow_ncol(gridLayer)

Get delr, delc :

delr, delc = qgridder_utils.get_rgrid_delr_delc(gridLayer)

Following a flopy standard, delr and delc will be scalars for regular grid, list otherwise.

Get any layer parameter :

This can be used to set any modflow distributed variable (IBOUND, TRANS, ...)

ibound = qgridder_utils.get_param(gridLayer, output_type = 'array', fieldName = 'IBOUND')

Get any list parameter :

This can be used to set boundary conditions. Note that you must first select the cells of interest in the grid layer.

bcells = qgridder_utils.get_param(gridLayer, output_type = 'list', layer = 1)

Get cell coordinates

This can be used for post-processing purposes.

cx = qgridder_utils.get_param(gridLayer, output_type = 'array', fieldName = 'CX')
cy = qgridder_utils.get_param(gridLayer, output_type = 'array', fieldName = 'CY')

Post-processing

The result may be visualized with an animated gif. The python script is avaiable here.

image