Working with MODFLOW packages

This tutorial shows how to access, edit, and add new MODFLOW parameters and packages to a GSFLOW model using pyGSFLOW

Note: this is a minimal overview for working with the Modflow object. For a more information and examples showing FloPy’s capabilities and data types please visit the flopy homepage here

[1]:
# Package import
import os
import gsflow
import flopy

Load a demonstration model

[2]:
model_ws = os.path.join("..", "..", "data", "sagehen", "gsflow")
[3]:
control_file = os.path.join(model_ws, "saghen_new_cont.control")
gsf = gsflow.GsflowModel.load_from_file(control_file)
Control file is loaded
Working on loading PRMS model ...
Prms model loading ...
------------------------------------
Reading parameter file : saghen_new_par_0.params
------------------------------------
Warning: ncascade data type will be infered from data supplied
Warning: ncascdgw data type will be infered from data supplied
Warning: ndays data type will be infered from data supplied
Warning: ndepl data type will be infered from data supplied
Warning: ndeplval data type will be infered from data supplied
Warning: nevap data type will be infered from data supplied
Warning: ngw data type will be infered from data supplied
Warning: ngwcell data type will be infered from data supplied
Warning: nhru data type will be infered from data supplied
Warning: nhrucell data type will be infered from data supplied
Warning: nlake data type will be infered from data supplied
Warning: nlake_hrus data type will be infered from data supplied
Warning: nmonths data type will be infered from data supplied
Warning: nobs data type will be infered from data supplied
Warning: nrain data type will be infered from data supplied
Warning: nreach data type will be infered from data supplied
Warning: nsegment data type will be infered from data supplied
Warning: nsnow data type will be infered from data supplied
Warning: nsol data type will be infered from data supplied
Warning: nssr data type will be infered from data supplied
Warning: nsub data type will be infered from data supplied
Warning: ntemp data type will be infered from data supplied
Warning: one data type will be infered from data supplied
------------------------------------
Reading parameter file : saghen_new_par_1.params
------------------------------------
------------------------------------
Reading parameter file : saghen_new_par_2.params
------------------------------------
------------------------------------
Reading parameter file : saghen_new_par_3.params
------------------------------------
PRMS model loaded ...
Working on loading MODFLOW files ....
   loading iuzfbnd array...
   loading irunbnd array...
   loading vks array...
   loading eps array...
   loading thts array...
stress period 1:
   loading finf array...
stress period 2:
MODFLOW files are loaded ...

Accessing the Modflow object

The modflow object can be accessed using the mf parameter.

[4]:
ml = gsf.mf

Getting packages from the Modflow object

[5]:
dis = gsf.mf.dis

Getting parameter values from the Modflow object

[6]:
top = ml.dis.top.array

Adjusting parameter values

[7]:
ml.dis.top *= 1.2

Adding a new package to the Modflow object

[8]:
spd = {i: [[0, 30, 30, -150.],] for i in range(ml.nper)}
wel = flopy.modflow.ModflowWel(ml, stress_period_data=spd)