You are on page 1of 24

The Groundwater Modeling Tool for GRASS;

a tutorial
Jaime J. Carrera-Hernandez
January 2005 DRAFT version

McGill University
Department of Civil Engineering and Applied Mechanics
jaime.carrera@mail.mcgill.ca

Abstract
This tutorial shows how to develop groundwater flow models using GRASS
and MODFLOW. This is done through the “Groundwater Modeling Tool for
GRASS” (GMTG) or r.gmtg module which works under GRASS. This mod-
ule can be used to run stady state and transient simulations on multilayer
aquifers. The current MODFLOW packages supported by r.gmtg are those
used to simulate wells (extraction and injection), rivers, recharge and drains.

1 Introduction
This is a brief tutorial on how to develop groundwater flow models using GRASS’
module r.gmtg. The user should be familiar with different modules of GRASS
such as r.reclass, r.mapcalc. For further reference on GRASS you can read the on-
line tutorials or the GRASS book by Neteler and Mitasova (2004). The problems
developed in this tutorial are taken from Chiang (2001), who developed the Pro-
cessing MODFLOW for Windows (PMWIN) software. These examples are used
to compare the results obtained using a well known MODFLOW processor with
those obtained using GMTG. This module is an improved version of the one de-
scribed by Carrera-Hernández and Gaskin (2004) and current work is being done
to use other MODFLOW packages.

1

1.1 Description of tutorial
The examples developed in this tutorial will help you to gain a general knowl-
edge on how to use GRASS and GMT to develop groundwater flow models. The
tutorial will explain how to:

1. Create a GRASS region.

2. Import ASCII files (e.g. Digital Elevation Models and sites files) using the
module r.in.ascii

3. Reclassify existing categories from raster maps using r.reclass

4. Use map algebra with r.mapcalc

2 Module description
The r.gmt module uses GRASS as a preprocessor and postprocessor for MOD-
FLOW. It uses raster maps as input for MODFLOW simulations and then imports
the results to different raster maps with a prefix specified by the user which are
explained in table 1.
r.gmt simulation=value units=value layers=value aqtype=value[,value,. . . ] stress=value
length=value[,value,...] steps=value[,value,...] [tsmult=name[,name,. . . ]] region=name[,name,. . . ]
heads=name[,name,...] [Sy=name[,name,. . . ]] [T=name[,name,. . . ]] [K=name[,name,. . . ]]
[bottom=name[,name,. . . ]] [vcond=name[,name,. . . ]] [top=name[,name,. . . ]] [Syb=name[,name,. . . ]]
[recharge=name[,name,. . . ]] [wells=name[,name,. . . ]] [river_heads=name] [river_cond=name]
[river_elev=name] [drain=name[,name,. . . ]] drawdownin=name headsin=name

3 Requirements
If you are running GRASS under Linux you should not have any problems when
attempting to use GMT; as GMT links GRASS with MODFLOW you need to have
MODFLOW installed on your system. You need to download the source code
available from GRASS’ TWIKI site http://grass.gdf-hannover.de/twiki/
bin/view/GRASS/JaimeCarrera. From this site you will also need to download
the programs rddown and rheads; these files are required to import MODFLOW’s
output into GRASS. All data related to this tutorial is available from the same site.

2

string efficient values T Name of existing raster map(s) with Transmissivity. string tance top Name of an existing raster map with Top of aquifer string Syb Name of an existing raster map with Secondary Storage string Values recharge Name of an existing raster map with recharge values string wells name of sites file(s) containing WELL data string river heads Name of raster map with stage values for reaches string river cond Name of raster map containing 3 conductance values for string reaches river elev Name of the raster map containing river-bed elevation string values drain Name of site map(s) containing drain data string drawdowninName of raster map for DRAWDOWN simulation values string headsin Name of raster map for HEAD simulation values string . string ductivity. Re. Table 1: Parameters needed to run a simulation using r. string QUIRED for CONFINED aquifers or VARIABLE con- finment aquifers with CONSTANT T K Name(s) of existing raster map(s) with Horizontal Con. Required for UNCONFINED aquifers and VARIABLE confinment aquifers with VARIABLE T bottom Name of an existing raster map with aquifer bottom. RE. string quired for unconfined and variable aquifers with variable T vcond Name of an existing raster map with Vertical conduc.gmtg Parameter Description Value simulation Type of simulation 0 = Transient 1 = Steady state units Time units 1 = Seconds 2 = minutes 3 = hours 4 = days 5 = years layers Number of layers in the model int number aqtype Type of aquifer 0 = Confined 1 = Unconfined 2 = Variable with constant T 3 = Variable with variable T stress Number of stress periods int number length Length of each stress period int number steps Number of time steps for each stress period int number tsmult Time step multiplier for each stress period float number region Name of raster map with active cells string heads Name of raster map with initial heads string Sy Name of existing raster map(s) with primary storage co.

4. The heads obtained in the steady state simulation are used as the initial heads for the transient simulation. 2. First create a directory on which you will have all data and then change to it. A steady state simulation without pumping is used to determine the spatial distribution of heads in the model domain. A transient model is used to simulate the effect of pumping in a wet season while at the dry season there is no pumping at all. This tutorial only explains how to use GMT and GRASS to develop groundwa- ter flow models and the examples are quite simple.1 Example 1 The first tutorial has two parts: 1. An unconfined aquifer has a hydraulic conductivity of 160 m/day and a recharge of 7.4 Developing groundwater flow models This section shows how to use GRASS and GMT to develop groundwater flow models. then copy or download the data files into this directory. a total of nine wells are pumping water from the aquifer at a rate of 3888 m3 /day. The book by Anderson and Woessner (1992) is a very good reference for groundwater modeling.1.gmtg module. Additionaly. However.1 Steady state simulation This first example shows how to develop a groundwater flow model using the r.5 ×10−4 m/day. as shown in figure 1. to learn more about MODFLOW it is strongly suggested to read its documentation (Mc- Donald and Harbaugh. if you already know how to set up regions with GRASS you can skip this section. 1988). it is important to stress that this tool is better when using real world data and to develop groundwater flow models with a conceptual approach. [jaime@civpc-08 jaime] mkdir tutorial [jaime@civpc-08 jaime] cd tutorial [jaime@civpc-08 tutorial] 4 . The elevations of the aquifer top and bottom are 25 m and 0 m respectively. 4. Creating the region to model: The first step consists in creating the region.

Figure 1: Model domain for problem 1 5 .

After this you need to type in y and the region’s settings as exemplified in figure 5. r. Start GRASS by typing grass5 in the command line and create the region tutorial1 as shown in figure 2 and presss CTRL-ENTER. The data is available as and ASCII file named 6 .gmt should be invoked from the project’s directory. to avoid overwriting of files from different models. After the region has been created. Figure 2: GRASS’ initial window Figure 3: Available regions in current di- rectory Figure 4: Required data to set-up a region in GRASS This step is recommended because all MODFLOW files will be created on this directory. the next step consists in importing the data that will be used in this example. Type y and ENTER as you want to create a new region for which you need to know four items as illustrated in figure 4. The next screen will show the existing regions in the current database as figure 3 shows.

(a) Coordinate system for new region (b) Description of new region (c) Extents of new region (d) Created region Figure 5: Creating a region in GRASS 7 .

To create the new map. in addition the data range is also displayed.in.dat output=basemap GRASS:˜tutorial > d.resolution and projection.map. GRASS:˜tutorial > r. it should be similar to Figure 6. To find out the number of categories in a raster map as well as some extra information on it.in.ascii module and name the resultant map basemap.ascii input=basemap. in order to do this.rast basemap We do not know the values of the map that was just imported. 8 .info shows basic information about a raster map: The lim- its. To find out which areas correspond to each category you need to diplay the raster map and then use the module r. For this map the minimum value is -1 while the maximum is 2.in. If this map is displayed.start x0 GRASS:˜tutorial > d.ascii basemap. To import it use the r. Figure 6: Raster map imported with r. the category values of basemap are reclassified into a new raster file which will be called boundaries. We need to assign a value of 0 to those cells that are inactive. the r. reclassify the category value 2 into 0 and keep the values of the other two categories.what.info basemap The module r.info command can be used: GRASS:˜/MVB/MODFLOW > r.

mapcalc recharge=area*.conductivity=area*160 100% GRASS:˜ > r.00025 100% GRASS:˜ > r.heads=area*15 100% GRASS:˜ > r.reclass input=basemap output=area Enter the rule or ’help’ for the format description: > * = 1 > end GRASS:˜> The other raster maps are now created using r.GRASS:˜> r. this map will be used to create the remainder maps for the groundwater model.mapcalc as follows: GRASS:˜ > r.reclass input=basemap output=boundaries Enter the rule or ’help’ for the format description: > -1 = -1 > 1 = 1 > 2 = 0 > end GRASS:˜> We will also create a map with an uniform value of 1.mapcalc initial.mapcalc H.mapcalc bottom=area*0 100% GRASS:˜ > 9 . as the following maps are still needed: • Initial Heads • Hydraulic Conductivity • Recharge values • Aquifer bottom The basemap raster map is reclassified to map area with only one category (value 1): GRASS:˜> r.

contour input=hd.tst1 output=ss.flux input=cst.ascii: GRASS:˜ > s.0672 m3 /day/m.in.4 m3 /day.flux d=3 GRASS:˜ > Now all required data to run the groundwater flow model have been set up.5 minlevel=15 maxlevel=20 Reading data. Percent complete: 100% FPRange of data: min = 15.lay1.mon x0 using default visual which is TrueColor ncolors: 16777216 10 . To create this map the module r.000000 Continue?(y/n) [y] y Now the head values for the simulation as well as the contours at every 0. To create a well file an ASCII file is imported into GRASS using s.tst1 means that this map shows the head at layer 1.stp1.270000 Minimum level will be 15.heads step=0.contour is used as follows: GRASS:˜/tutorial > r.In order to account for this flux a well will be used at each cell with a flow of 0.heads K=H.stp1.gmt simulation=1 units=4 layers=1 aqtype=1 stress=1 length=1 steps=1 tsmult=1 region=boundaries heads=initial.flux drawdownin=dd headsin=hd The simulated head has been saved on file hd.ascii sites=cst. The southern boundary is a specified flux boundary of 0.000000 Maximum level will be 19. for stress period (stp) 1 at the first time step (tst).5 m can be displayed simultaneously to get a more representative map: GRASS:˜/tutorial > d. The remainder parts of the file name are generated automatically to facilitate the task of reading the results of each simulation: hd. Now we can create a vector map to show drawdown values at increments of 0.0672 × 200 m which equals 13.stp1.000000 max = 19. Open a text editor such as emacs and type in the values of table 2 without the header and leaving a space between each value or use the data available on the web site.lay1. Save this file as a plain text with emacs and now import it using r.tst1 where hd is the name entered for the option headsin of GMT.lay1.in.ascii. Before running the simulation we need to check if all required data is available: GRASS:˜ > r.5 m.in.conductivity bottom=bottom recharge=recharge wells=cst.

4 ”Cflux” 2500 100 1 13.4 ”Cflux” 4500 100 1 13.4 ”Cflux” 2900 100 1 13.4 ”Cflux” 3500 100 1 13.4 ”Cflux” 2300 100 1 13.4 ”Cflux” 4700 100 1 13.4 ”Cflux” 3700 100 1 13.4 ”Cflux” 3900 100 1 13.Table 2: Coordinates of wells for specified flux boundary East North Layer Flow Description 100 100 1 13.4 ”Cflux 300 100 1 13.4 ”Cflux” 500 100 1 13.4 ”Cflux” 4100 100 1 13.4 ”Cflux” 4900 100 1 13.4 ”Cflux” 4300 100 1 13.4 ”Cflux” 700 100 1 13.4 ”Cflux” 1700 100 1 13.4 ”Cflux” 3300 100 1 13.4 ”Cflux” 11 .4 ”Cflux” 2700 100 1 13.4 ”Cflux” 900 100 1 13.4 ”Cflux” 1300 100 1 13.4 ”Cflux” 3100 100 1 13.4 ”Cflux” 2100 100 1 13.4 ”Cflux” 1500 100 1 13.4 ”Cflux” 1900 100 1 13.4 ”Cflux” 1100 100 1 13.

vect ss. Figure 7: Resulting heads for steady-state simulation Graphics driver [x1] started GRASS:˜/tutorial > d.rast hd.tst1 FP map found .legend -m map=hd.lay1.stp1.grid size=200 GRASS:˜/tutorial > d.stp1.heads color=black GRASS:˜/tutorial > d.lay1.tst1 GRASS:˜/tutorial > d.switching gradient legend on Buttons: Left: Establish a corner Right: Accept box for legend The resulting image should be similar to Figure 7: 12 .

this head will be used as the initial head for the transient simulation.06 m/day 2. that is why for the Constant Flow boundary flow rates are posi- tive. Any site file that is created to be used as a well file for MODFLOW should have the following format: East North Layer (-)Flow Id The negative sign in flow is used to indicate that the flow is being extracted from the aquifer. For this problem the following data are provided: 1.2 Transient simulation The result of the steady state simulation was a map showing the head distribution on the model domain.1. Transient simulations require more data than steady-state simulations.5 × 10−4 m/day. Water is extracted from nine wells at a rate of 3888 m3 /day during the dry season. Table 3: Coordinates of extraction wells East North Layer P. Among these data are: Specific yield (Sy ) as well as extraction and recharge rates for each stress period.4. while extraction rates are negative. Recharge occurs during the wet season which lasts four months at a uniform rate of 7. rate ID 2300 6300 1 -3888 ”W-1” 3700 6300 1 -3888 ”W-2” 4700 6300 1 -3888 ”W-3” 1700 4700 1 -3888 ”W-4” 3300 4700 1 -3888 ”W-5” 4300 4700 1 -3888 ”W-6” 1700 1300 1 -3888 ”W-7” 2700 1300 1 -3888 ”W-8” 3700 1300 1 -3888 ”W-9” 13 . 3. The Specific Yield of the aquifer is estimated to be Sy =0. The coordinates of the nine extraction wells are in table 3 which have to be added to the constant flux boundary wells.

1. The output of the simulation for time step 12 of stress period one should be similar to figure 8: 4. This file has to be imported into GRASS.2=0.00075 m/day. For the first stress period a total of 12 time steps will be used while for the second stress period only 6 time steps are required.1.120 steps=12.mapcalc: GRASS:˜/MVB/MODFLOW > r. easting and layer number): GRASS:˜tutorial > s.lay1.mapcalc rch. It is important to know that more data are required for transient simulations. while the wet season lasts the remainder 4 months (120 days) with a recharge rate of 0. so we need to paste these two files and create one file.06*area 100% GRASS:˜/MVB/MODFLOW > r. These maps are created using r.ascii sites=wells input=wells d=3 GRASS:˜tutorial > There are two seasons (stress periods) in this simulation: wet and dry.gmt simulation=0 units=4 layers=1 aqtype=1 stress=2 length=240.00075*area 100% GRASS:˜/MVB/MODFLOW > The input for this simulation is: GRASS:˜tutorial> r.conductivity Sy=Sy bottom=bottom recharge=rch.in. thus the simulation will be run for 2 stress periods.1=0*area 100% GRASS:˜/MVB/MODFLOW > r. especially if more than one stress period is used: 14 .2 wells=wells.6 tsmult=1.rch.flux drawdownin=ddtr headsin=hdtr The program will import a total of 36 raster maps: For both heads and draw- down the output is 12 maps for stress period number one and 6 maps for stress period two. when water is extracted from the aquifer both the extraction wells and the constant flux boundary wells have to be in one file. As this is a transient simulation a raster map with the Specific Yield (Sy ) is needed as well as the recharge maps for each stress period.stp1.1 region=boundaries heads=hd.mapcalc Sy=0. It is important to tell grass that the file has three dimensions (northing. The dry season has a length of 240 days (8 months of the year) with a recharge rate of 0 m/day.tst1 K=H.3 Remarks for example 1 In this example both a steady-state and transient simulation of groundwater flow was undertaken.mapcalc rch.cst. Because we are using wells to simulate the constant head boundary.

timestep 6 Figure 8: Resulting heads for transient simulation. (a) Heads for stress period 1 timestep 12 15 (b) Heads for stress period 2. .

• Wells in multiple stress periods: The same principle described in the pre- vious item applies to wells. A well sites map is required for every stress period of the simulation. this value has to be used in the simulation which means that for i stress periods. 16 . i recharge maps are needed.• Transient simulations: Specific yield values (Sy ) are needed • Recharge in multiple stress periods: If recharge occurs at one stress period. the remainder stress periods have zero recharge.

5 m/day and Ky = 0. Figure 9: Modeling area for problem 2 4. Create a text file and import it into GRASS using s.ascii 17 .in.05 m/day. The confined aquifer is being exploited by three wells at a rate of 500 m3 /day which are located as shown in figure 9 and whose coordinates are in table 4. Beneath this unit is a confined aquifer of variable thickness with Kh = 2 m/day and Kv = 1 m/day. These two aquifers are separated by a silty layer 2 meters thick with Kh = 0.5 m/day. The aquifer system consists of an unconfined upper aquifer with Kh = 5 m/day and Kv = 0.2 Example 2: Three dimensional modeling This exercise is also taken from Chiang (2001) and consists of a river which flows in a valley that is bounded by granite impermeable formations both at north and south as illustrated in figure 9. for which the hydraulic heads at the upstream and down- stream boundaries consist of fixed-head boundaries which are known and avail- able as an ASCII data file.

the interaction of the river with the unconfined aquifer also has to be considered. Vertical hydraulic conductivity 3. Kv . Because this is a multi-layer simulation the following data are needed (note the differences between this example and example 1): 1. Vertical Conductance 7. which can be tutorial2. rate ID 1728 1728 3 -500 Well-1 2880 3264 3 -500 Well-2 4032 1925 3 -500 Well-3 4. Horizontal hydraulic conductivity for all layers 2. Table 4: Coordinates of extraction wells East North Layer P. east: 0. Top of aquifers 4. Bottom of aquifers 5.3. top. All data required for this example are available as ASCII files and need to be imported using the r. Location of wells and extraction rates 6.ascii module.3.gmtg module will be used. west: 6750. a resolution of 193 m will be used for a total of 26 rows and 35 columns. Following the steps outlined in section 4. 18 . River data: Location.1. south: 0. top.2. and bottom. 4.4 Required data The model to be developed in this example is a three-layer steady-state simulation in which water is extracted by three wells from the confined aquifer (third layer in the model).1.1 a region with the following boundaries is created: North: 5000. top. elevation.in.3 Creating the region The first step consists in creating a directory on which all data will be stored and from which the r. conductance and stage Download the ASCII file basemap2 for this example and using r.mapcalc de- velop the following maps: Kh .

4. one for riverbed elevation and one for conductance values. stage (head) and conductance. j. j.gmtg module requires three different maps: One for river stage values. an expected value of heads has to be used. j. In this case you can use the initial heads provided (ini.1 Vertical conductance Whenever three dimensional modeling is attempted with MODFLOW. K × L ×W CRIV = (2) M 19 . Figure 10: Vertical conductance variables 4.k+1/2) = (1) ∆Vk (Kz )i.k + (K∆V z) k+1 i. The r. bed elevation.2 River data In order to include a river in the simulation MODFLOW requires its location.4. the VCOND array needs to be determined and is computed according to figure 10 and equation 1. however.heads) or import the VCOND maps from the website. The conductance is computed according to equation 2.mapcalc.k+1 Vertical conductance can be computed using r. 2 VCONT(i. when deal- ing with an unconfined aquifer (as is the case for this example). 4.

2.ascii input=river.dat output=top.dat output=river.2 GRASS:˜/tutorial2 >r. 4.1 GRASS:˜/tutorial2 >r.mapcalc hk.reclass input=basemap output=active Enter the rule or ’help’ for the format description: > -1 = -1 > 1 = 1 > 2 = 0 > end GRASS:˜/tutorial2 > r.1.ascii input=basemap2 output=active GRASS:˜/tutorial2 >r.ascii input=river.3.bed GRASS:˜/tutorial2 >r.in.2 GRASS:˜/tutorial2 >r.bed.dat d=3 GRASS:˜/tutorial2 > r.in.in.in.mapcalc hk.in.ascii input=vcond.ascii input=top.head.head GRASS:˜/tutorial2 >r.5*area 100% GRASS:˜/tutorial2 > r.in.1=5*area 100% GRASS:˜/tutorial2 > r.in.dat output=vcond.in.3 running the simulation Considering that you have downloaded all the files for the simulation.dat output=vcond.dat output=river.ascii input=vcond.4.Where: CRIV = Hydraulic conductance of the riverbed [L2 /T] K= Hydraulic con- ductivity of the riverdeb sediment [L/T] L= Length of the river within a cell [L] W = Width of the river within a cell [L] M= Thickness of the riverbed [L] The conductance values can be computed using map algebra.3=2*area 20 .2.ascii sites=wells input=wells2.ascii input=top.in.ascii input=top.1 GRASS:˜/tutorial2 >r.mapcalc hk.dat output=initial.ascii input=initial.dat output=river.ascii input=river.1.heads.2=0.dat output=top.3 GRASS:˜/tutorial2 >r.dat output=top.reclass input=basemap output=area Enter the rule or ’help’ for the format description: > * = 1 > end GRASS:˜/tutorial2 > r.heads GRASS:˜/tutorial2 >s.cond GRASS:˜/tutorial2 >r. the required maps are created as follows: GRASS:˜/tutorial2 >r. however the data used in this example is available as ASCII files which need to be imported.in.in.cond.

3 stress=1 length=1 steps=1 tsmult=1 region=active.active heads=initial. wells.head river_cond=river. The drain package requires a sites map for every stress period and the following data: Easting Northing Layer Elevation Conductance ID 21 . recharge and drains.1.3 top=top.hk.2.top.heads K=hk.1. which should be a map similar figure 11.heads.initial.active.vcond.3 bottom=top. 5 Concluding remarks In this tutorial the usage of the module r.3.mapcalc hk.2 wells=wells river_heads=river.gmtg has been explained.2.100% GRASS:˜/tutorial2 > r.2.1=5*area 100% GRASS:˜/tutorial2 > r. This mod- ule currently supports the following MODFLOW optional packages: river.bot.bed headsin=hdtest drawdownin=ddtest Now display the heads map for the first layer.top.gmtg simulation=1 units=4 layers=3 aqtype=1.3 vcond=vcond.hk.heads.3.cond river_elev=river.initial.

Figure 11: Head distribution in the first layer of example 2 22 .

M. three dimensional fi- nite difference groundwater flow model. J. USGS Techniques of Water Resources Investigation Report.4 "Cflux" 1100 100 1 13. (1992). Open Source GIS: A GRASS GIS approach.4 "Cflux" 500 100 1 13. (2004). A modular. Carrera-Hernández. Chiang. (2004). In FEM-MODFLOW and more. W. J. 2nd edi- tion edition. (2001). (1988). G. A. S. The Kluwer international series in engineering and computer science. M. H.4 "Cflux" 1300 100 1 13. McDonald. Neteler.4 "Cflux" 23 . W. J. Proceedings of the Conference held at Karlovy Vary.References Anderson. W. and Harbaugh. M. and Gaskin. Gmt: A groundwater mod- eling tool for integrated water management. A Well file for stress period one of transient simula- tion 2300 6300 1 -3888 "W-1" 3700 6300 1 -3888 "W-2" 4700 6300 1 -3888 "W-3" 1700 4700 1 -3888 "W-4" 3300 4700 1 -3888 "W-5" 4300 4700 1 -3888 "W-6" 1700 1300 1 -3888 "W-7" 2700 1300 1 -3888 "W-8" 3700 1300 1 -3888 "W-9" 100 100 1 13. and Mitasova. H. Czech Republic. 3-D groundwater modeling with PMWIN. and Woessner. Springer Verlag. W.4 "Cflux" 700 100 1 13.4 "Cflux" 900 100 1 13. P. Groundwater flow modelling.4 "Cflux" 300 100 1 13.

4 "Cflux" 3700 100 1 13.4 "Cflux" 4500 100 1 13.4 "Cflux" 4700 100 1 13.4 "Cflux" 4300 100 1 13.4 "Cflux" 3100 100 1 13.4 "Cflux" 4900 100 1 13.4 "Cflux" 2900 100 1 13.4 "Cflux" 4100 100 1 13.4 "Cflux" 2500 100 1 13.4 "Cflux" 3300 100 1 13.4 "Cflux" 24 .1500 100 1 13.4 "Cflux" 2300 100 1 13.4 "Cflux" 3900 100 1 13.4 "Cflux" 1900 100 1 13.4 "Cflux" 2700 100 1 13.4 "Cflux" 3500 100 1 13.4 "Cflux" 1700 100 1 13.4 "Cflux" 2100 100 1 13.