groundwater flow and solute transport modelling from ... · • you have to learn matlab or python,...

1
RMODFLOW Package development is making heavy use of the Hadleyverse: RStudio IDE for R 2d visualization by ggplot2 for documentation: roxygen2 speeding up file reading with readr with additional depends: 3d visualization by rgl enabling contour plots with akima & directlabels additional optimization functionality by hydroPSO & DEoptim S3 generic-function object oriented programming style is used where possible (e.g. plot, cell_centers, node_info functions). Versioning using: git / github File reading/writing nam <- read_nam(‘input.nam’) dis <- read_dis(‘input.dis’) hob <- read_hob(‘input.hob’) pvl <- read_pvl(‘input.pvl’) huf <- read_huf(‘input.huf’,dis=dis) ba6 <- read_ba6(‘input.ba6’,dis=dis) mlt <- read_mlt(‘input.mlt’,dis=dis) kdep <- read_kdep(‘input.kdep’,dis=dis,huf=huf) hpr <- read_hpr(‘output.hpr’) hed <- read_hed(‘output.hed’,dis=dis,ba6=ba6) bud <- read_bud(‘output.bud’) write_dis(dis,‘input.dis’) write_ba6(ba6,‘input.ba6’) write_hob(hob,‘input.hob’) write_huf(huf,‘input.huf’) write_mlt(mlt,‘input.mlt’) write_pvl(pvl,‘input.pvl’) Object structure follows carefully the online guide to MODFLOW summary(dis) ## Length Class Mode ## NLAY 1 -none- numeric ## NROW 1 -none- numeric ## NCOL 1 -none- numeric ## NPER 1 -none- numeric ## ITMUNI 1 -none- numeric ## LENUNI 1 -none- numeric ## LAYCBD 14 -none- numeric ## DELR 250 -none- numeric ## DELC 180 -none- numeric ## TOP 45000 modflow_2d_array numeric ## BOTM 630000 modflow_3d_array numeric ## PERLEN 1 -none- numeric ## NSTP 1 -none- numeric ## TSMULT 1 -none- numeric ## SSTR 1 -none- character SCK•CEN || Boeretang 200 || BE-2400 Mol || www.sckcen.be || [email protected] || BRogiers RMT3DMS The RMT3DMS package depends on the RMODFLOW package, and currently provides similar basic functionality for the basic transport, advection, dispersion, gcg solver, mass balance, chemical reaction, sink & source mixing and unformatted concentration files. Package installation first install the devtools package: install.packages("devtools") load the devtools package: library(devtools) there is no major release of the packages yet, to install version 0.3.0: install RTOOLZ: install_github("rogiersbart/[email protected]") install RMODFLOW: install_github("rogiersbart/[email protected]") install RMT3DMS: install_github("rogiersbart/[email protected]") Reproducible research workflow in RStudio, using knitr, combining LaTeX, markdown, … with R one *.Rnw file for everything create and run your model load and visualize model output on file compilation everything is reevaluated you get a truly reproducible PDF/HTML/… document (see Rogiers et al. 2015 for an example) What’s next? complete the packages, so they are fully compatible with MODFLOW 2005 and MT3DMS add functions to create input files from scratch additional visualization functionality 3d profile surfaces, grids, and solute plumes animation of transient model output particle tracking result visualization extending functionality for model calibration and uncertainty estimation References Gedeon M, Mallants D, Vandersteen K, Rogiers B, Laloy E. 2011. Hydrogeological modelling of the Dessel site. Overview report. Project near surface disposal of category A waste at Dessel, NIROND-TR 2008-15 E V2, 227 pp. Harbaugh, A. (2005). MODFLOW-2005: The US Geological Survey Modular Ground-water Model--the Ground-water Flow Process, U.S. Geological Survey Techniques and Methods 6–A16 (p. 253). Rogiers B, Lermytte J, De Bie E, Batelaan O. 2011. Evaluating the impact of river restoration on the local groundwater and ecological system: a case study in NE Flanders. Geologica Belgica 14(3-4): 265-276. Rogiers B, Labat S, Gedeon M. 2015. An assessment of dilution tests and ambient temperature logging for quantifying groundwater flow in the Neogene aquifer. External Report, SCK•CEN-ER-276, in review. Vandersteen K, Gedeon M, Rogiers B. 2012. Transient model of the confined aquifers below the Boom Clay: 2011 update. Regional Hydrogeological Modelling of the Mol Site. External Report, SCK•CEN- ER-199. - ISSN 1782-2335. Vandersteen K., M. Gedeon, J. Marivoet and L. Wouters. 2014. Regional groundwater flow modelling of the confined aquifers below the Boom Clay in NE Belgium. The Geological Society of London, v. 400, doi:10.1144/SP400.22 Zheng, C. (2010). MT3DMS v5.3, a modular three-dimensional multispecies transport model for simulation of advection, dispersion and chemical reactions of contaminants in groundwater systems. Supplemental User’s Guide. (p. 56). All mentioned R packages can be found at the Comprehensive R Archive Network (cran.r-project.org). Introduction Existing pre- and post-processing packages for MODFLOW (Harbaugh 2005) and MT3DMS (Zheng 2010): mflab (code.google.com/p/mflab/; MATLAB) flopy (github.com/modflowpy/flopy; python) Advantages workflow is scripted and therefore reproducible modelling environment with increased flexibility and power, going beyond the capabilities of currently available GUIs Disadvantages MATLAB is not free you have to learn MATLAB or python, no packages for other languages are available my experience is that geoscience students used to learn some MATLAB, but knowadays, they (also) learn to use R in different courses R, hydrology, and subsurface hydrology An increasing number of contributed R packages is becoming available, in the field of hydrology: hydrological time series analysis packages (hydroTSM, waterData, …) lumped conceptual rainfall-runoff models (hydromad, TUWmodel, RHydro, …) distributed hydrological models (topmodel, …) weather generators or related packages (RMAWGEN, SPEI, …) soil water packages (soiltexture, soilwaterfun, soilwaterptf, soilwater, HydroMe, …) Other useful things available in R mapping (OpenStreetMap, ggmap, rgdal, sp, …) 3d viewing (rgl, …) geostatistics (gstat, RandomFields, geoR, …) machine learning (RGLUEANN, …) reproducible research (knitr, xtable, …) time series analysis (TSA, …) spreadsheets & data bases (xlsx, RPostgreSQL, …) data manipulation (reshape2, lubridate, plyr, …) calibration & uncertainty estimation (hydroPSO, dream, DEoptim, …) solving partial differential equations (deSolve, ReacTran, …) Despite the availability of all these tools, subsurface hydrological modelling is still seldomly performed in R, or with codes interfaced with R. Goal Design an R interface to MODFLOW and MT3DMS to facilitate groundwater flow and solute transport modelling from within R. Groundwater flow and solute transport modelling from within R: The RMODFLOW and RMT3DMS packages. Rogiers Bart Institute for Environment, Health and Safety, Belgian Nuclear Research Centre (SCK•CEN), Boeretang 200, BE-2400 Mol, Belgium. [email protected] Find PDF at Model running and optimization A model can be run by run_modflow(‘input.nam’) and its performance can be evaluated by hpr <- read_hpr(‘output.hpr’) plot(hpr);performance(hpr) which returns e.g. the figure on the left and mse mae me r2 nseff rmse 1 7.01 1.18 0.09 0.88 0.88 2.65 Different model optimization options are available in the function run_modflow_opt Visualization capabilities using ggplot2 and rgl, with R base-type syntax two main S3 functions: plot.modflow_2d_array() plot.modflow_3d_array() Some examples are provided below for different MODFLOW models (Rogiers et al. 2011; Gedeon et al. 2011; Vandersteen et al. 2012, 2014): str(dis) ## List of 15 ## $ NLAY : num 14 ## $ NROW : num 180 ## $ NCOL : num 250 ## $ NPER : num 1 ## $ ITMUNI: num 4 ## $ LENUNI: num 2 ## $ LAYCBD: num [1:14] 0 0 0 0 0 0 0 0 0 0 ... ## $ DELR : num [1:250] 50 50 50 50 50 50 50 50 50 50 ... ## $ DELC : num [1:180] 50 50 50 50 50 50 50 50 50 50 ... ## $ TOP : modflow_2d_array [1:180, 1:250] 20 20 20 20 20 ... ## $ BOTM : modflow_3d_array [1:180, 1:250, 1:14] 12 12 12 12 12 ... ## $ PERLEN: num 1 ## $ NSTP : num 1 ## $ TSMULT: num 1 ## $ SSTR : chr "SS" plot(dis$TOP,dis=dis) ba6 <- read_ba6('input.ba6',dis=dis) plot(dis$TOP,dis=dis,mask=ba6$IBOUND[,,1]) plot(dis$TOP,dis=dis,mask=ba6$IBOUND[,,1],type='contour') library(OpenStreetMap);library(ggplot2);library(RTOOLZ) map <- openmap(c(51.1,5),c(50.95,5.3),zoom=11, type='osm', mergeTiles=FALSE) autoplot(map) + plot(dis$TOP,dis=dis,mask=ba6$IBOUND[,,1],prj=prj, target_CRS=osmmerc(),alpha=0.5,add=TRUE) plot(dis$BOTM,dis=dis,mask=ba6$IBOUND,k=1) plot(dis$BOTM,dis=dis,mask=ba6$IBOUND,j=1) plot(dis$BOTM,dis=dis,mask=ba6$IBOUND,i=1)

Upload: lytram

Post on 04-May-2018

216 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Groundwater flow and solute transport modelling from ... · • you have to learn MATLAB or python, no packages for other languages are available • my ... (topmodel, …) • weather

RMODFLOW Package development is making heavy use of the Hadleyverse:

• RStudio IDE for R • 2d visualization by ggplot2

• for documentation: roxygen2

• speeding up file reading with readr

with additional depends: • 3d visualization by rgl

• enabling contour plots with akima & directlabels

• additional optimization functionality by hydroPSO &

DEoptim

S3 generic-function object oriented programming style is used where possible (e.g. plot, cell_centers,

node_info functions).

Versioning using:

• git / github

File reading/writing nam <- read_nam(‘input.nam’)

dis <- read_dis(‘input.dis’)

hob <- read_hob(‘input.hob’)

pvl <- read_pvl(‘input.pvl’)

huf <- read_huf(‘input.huf’,dis=dis)

ba6 <- read_ba6(‘input.ba6’,dis=dis)

mlt <- read_mlt(‘input.mlt’,dis=dis)

kdep <- read_kdep(‘input.kdep’,dis=dis,huf=huf)

hpr <- read_hpr(‘output.hpr’)

hed <- read_hed(‘output.hed’,dis=dis,ba6=ba6)

bud <- read_bud(‘output.bud’)

write_dis(dis,‘input.dis’)

write_ba6(ba6,‘input.ba6’)

write_hob(hob,‘input.hob’)

write_huf(huf,‘input.huf’)

write_mlt(mlt,‘input.mlt’)

write_pvl(pvl,‘input.pvl’)

Object structure follows carefully the online guide to MODFLOW

summary(dis) ## Length Class Mode

## NLAY 1 -none- numeric

## NROW 1 -none- numeric

## NCOL 1 -none- numeric

## NPER 1 -none- numeric

## ITMUNI 1 -none- numeric

## LENUNI 1 -none- numeric

## LAYCBD 14 -none- numeric

## DELR 250 -none- numeric

## DELC 180 -none- numeric

## TOP 45000 modflow_2d_array numeric

## BOTM 630000 modflow_3d_array numeric

## PERLEN 1 -none- numeric

## NSTP 1 -none- numeric

## TSMULT 1 -none- numeric

## SSTR 1 -none- character

SCK•CEN || Boeretang 200 || BE-2400 Mol || www.sckcen.be || [email protected] || BRogiers

RMT3DMS The RMT3DMS package depends on the RMODFLOW

package, and currently provides similar basic functionality

for the basic transport, advection, dispersion, gcg solver,

mass balance, chemical reaction, sink & source mixing and

unformatted concentration files.

Package installation • first install the devtools package:

install.packages("devtools")

• load the devtools package: library(devtools)

• there is no major release of the packages yet, to install

version 0.3.0: • install RTOOLZ:

install_github("rogiersbart/[email protected]")

• install RMODFLOW: install_github("rogiersbart/[email protected]")

• install RMT3DMS: install_github("rogiersbart/[email protected]")

Reproducible research • workflow in RStudio, using knitr, combining LaTeX,

markdown, … with R

• one *.Rnw file for everything

• create and run your model

• load and visualize model output

• on file compilation everything is reevaluated

• you get a truly reproducible PDF/HTML/… document

(see Rogiers et al. 2015 for an example)

What’s next? • complete the packages, so they are fully compatible

with MODFLOW 2005 and MT3DMS

• add functions to create input files from scratch

• additional visualization functionality

• 3d profile surfaces, grids, and solute plumes

• animation of transient model output

• particle tracking result visualization

• extending functionality for model calibration and

uncertainty estimation

References Gedeon M, Mallants D, Vandersteen K, Rogiers B, Laloy E. 2011. Hydrogeological modelling of the

Dessel site. Overview report. Project near surface disposal of category A waste at Dessel, NIROND-TR

2008-15 E V2, 227 pp.

Harbaugh, A. (2005). MODFLOW-2005: The US Geological Survey Modular Ground-water Model--the

Ground-water Flow Process, U.S. Geological Survey Techniques and Methods 6–A16 (p. 253).

Rogiers B, Lermytte J, De Bie E, Batelaan O. 2011. Evaluating the impact of river restoration on the local

groundwater and ecological system: a case study in NE Flanders. Geologica Belgica 14(3-4): 265-276.

Rogiers B, Labat S, Gedeon M. 2015. An assessment of dilution tests and ambient temperature logging

for quantifying groundwater flow in the Neogene aquifer. External Report, SCK•CEN-ER-276, in

review.

Vandersteen K, Gedeon M, Rogiers B. 2012. Transient model of the confined aquifers below the Boom

Clay: 2011 update. Regional Hydrogeological Modelling of the Mol Site. External Report, SCK•CEN-

ER-199. - ISSN 1782-2335.

Vandersteen K., M. Gedeon, J. Marivoet and L. Wouters. 2014. Regional groundwater flow modelling of

the confined aquifers below the Boom Clay in NE Belgium. The Geological Society of London, v. 400,

doi:10.1144/SP400.22

Zheng, C. (2010). MT3DMS v5.3, a modular three-dimensional multispecies transport model for

simulation of advection, dispersion and chemical reactions of contaminants in groundwater systems.

Supplemental User’s Guide. (p. 56).

All mentioned R packages can be found at the Comprehensive R Archive Network (cran.r-project.org).

Introduction Existing pre- and post-processing packages for MODFLOW (Harbaugh 2005)

and MT3DMS (Zheng 2010):

• mflab (code.google.com/p/mflab/; MATLAB)

• flopy (github.com/modflowpy/flopy; python)

Advantages • workflow is scripted and therefore reproducible

• modelling environment with increased flexibility and

power, going beyond the capabilities of currently

available GUIs

Disadvantages • MATLAB is not free

• you have to learn MATLAB or python,

no packages for other languages are available

• my experience is that geoscience students used to learn

some MATLAB, but knowadays, they (also) learn to use

R in different courses

R, hydrology, and subsurface hydrology An increasing number of contributed R packages is

becoming available, in the field of hydrology:

• hydrological time series analysis packages (hydroTSM, waterData, …)

• lumped conceptual rainfall-runoff models (hydromad, TUWmodel, RHydro, …)

• distributed hydrological models (topmodel, …)

• weather generators or related packages (RMAWGEN, SPEI, …)

• soil water packages (soiltexture, soilwaterfun,

soilwaterptf, soilwater, HydroMe, …)

Other useful things available in R • mapping (OpenStreetMap, ggmap, rgdal, sp, …)

• 3d viewing (rgl, …)

• geostatistics (gstat, RandomFields, geoR, …)

• machine learning (RGLUEANN, …)

• reproducible research (knitr, xtable, …)

• time series analysis (TSA, …)

• spreadsheets & data bases (xlsx, RPostgreSQL, …)

• data manipulation (reshape2, lubridate, plyr, …)

• calibration & uncertainty estimation (hydroPSO, dream, DEoptim, …)

• solving partial differential equations (deSolve, ReacTran, …)

Despite the availability of all these tools, subsurface

hydrological modelling is still seldomly performed in R, or

with codes interfaced with R.

Goal Design an R interface to MODFLOW and

MT3DMS to facilitate groundwater flow and

solute transport modelling from within R.

Groundwater flow and solute transport modelling from within R: The RMODFLOW and RMT3DMS packages. Rogiers Bart Institute for Environment, Health and Safety, Belgian Nuclear Research Centre (SCK•CEN), Boeretang 200, BE-2400 Mol, Belgium.

[email protected]

Find PDF at

Model running and optimization A model can be run by run_modflow(‘input.nam’)

and its performance can be evaluated by hpr <- read_hpr(‘output.hpr’)

plot(hpr);performance(hpr)

which returns e.g. the figure on the left and mse mae me r2 nseff rmse

1 7.01 1.18 0.09 0.88 0.88 2.65

Different model optimization options are available in the function run_modflow_opt

Visualization capabilities • using ggplot2 and rgl, with R base-type syntax

• two main S3 functions: plot.modflow_2d_array()

plot.modflow_3d_array()

Some examples are provided below for different

MODFLOW models (Rogiers et al. 2011; Gedeon et al.

2011; Vandersteen et al. 2012, 2014):

str(dis) ## List of 15

## $ NLAY : num 14

## $ NROW : num 180

## $ NCOL : num 250

## $ NPER : num 1

## $ ITMUNI: num 4

## $ LENUNI: num 2

## $ LAYCBD: num [1:14] 0 0 0 0 0 0 0 0 0 0 ...

## $ DELR : num [1:250] 50 50 50 50 50 50 50

50 50 50 ...

## $ DELC : num [1:180] 50 50 50 50 50 50 50

50 50 50 ...

## $ TOP : modflow_2d_array [1:180, 1:250] 20

20 20 20 20 ...

## $ BOTM : modflow_3d_array [1:180, 1:250,

1:14] 12 12 12 12 12 ...

## $ PERLEN: num 1

## $ NSTP : num 1

## $ TSMULT: num 1

## $ SSTR : chr "SS"

plot(dis$TOP,dis=dis)

ba6 <- read_ba6('input.ba6',dis=dis)

plot(dis$TOP,dis=dis,mask=ba6$IBOUND[,,1])

plot(dis$TOP,dis=dis,mask=ba6$IBOUND[,,1],type='contour')

library(OpenStreetMap);library(ggplot2);library(RTOOLZ)

map <- openmap(c(51.1,5),c(50.95,5.3),zoom=11,

type='osm', mergeTiles=FALSE)

autoplot(map) +

plot(dis$TOP,dis=dis,mask=ba6$IBOUND[,,1],prj=prj,

target_CRS=osmmerc(),alpha=0.5,add=TRUE)

plot(dis$BOTM,dis=dis,mask=ba6$IBOUND,k=1)

plot(dis$BOTM,dis=dis,mask=ba6$IBOUND,j=1)

plot(dis$BOTM,dis=dis,mask=ba6$IBOUND,i=1)