Print Friendly and PDF

Dynamic Coupling of GoldSim and MODFLOW/MT3D

Jason -

The below article summarizes an application that successfully incorporates GoldSim with MODFLOW and MT3D. This work and the following article are attributed to the following authors:

Adam K. Janzen1, Cory D. Anderson1, Peter J. Hinck1, Jeré A. Mohr2, Michael F. Mechenich3 

1Barr Engineering Company, ajanzen@barr.com, canderson@barr.com, phinck@barr.com, Minneapolis, MN, USA
2Barr Engineering Company, jmohr@barr.com, Duluth, MN, USA
3Division of Geology, Department of Geosciences and Geography, University of Helsinki, Finland

 

Abstract

The widely accepted and trusted three-dimensional groundwater flow code MODFLOW and its companion three-dimensional solute transport code MT3D were dynamically linked with GoldSim, a probabilistic simulation platform used to model large and complex systems. A hypothetical yet realistic test case involving contaminant transport via groundwater to a river was developed to test the linkage. GoldSim was used to generate all random variables and to model the flow rates and quality of the contaminant source and the receiving water body. MODFLOW and MT3D were used to model the groundwater flow field and the solute transport from the contaminant source to the receiving water body. The test case was run as a transient, Monte Carlo simulation with 40-year duration, monthly time steps, and 50 random realizations. The full simulation took approximately 21 hours on a single processor, though run time reductions are possible via GoldSim’s parallel capabilities. If the model lacks feedback loops, it may also be possible to reduce run time by reducing the number of calls to MODFLOW and MT3D. The GoldSim/MODFLOW/MT3D linkage is useful as a platform for running Monte Carlo groundwater flow and transport simulations as well as integrating detailed flow and transport components into GoldSim-based hydrologic models.

 

Introduction

GoldSim is a Monte Carlo simulation package originally developed by Golder Associates for the U.S. government to simulate long-term performance of nuclear waste storage strategies (GTG, 2015). Its environmental engineering origins notwithstanding, the software is a general probabilistic simulation framework that has also found applications in business and manufacturing. The authors have used GoldSim to model, among other things, lake water balances, wastewater treatment plant performance, and complex environmental systems involving contaminant fate and transport via surface water and groundwater. Modeling the latter requires additional functionality beyond what is included with the basic GoldSim software. One option is to implement analytical solutions for groundwater flow and solute transport as functions in GoldSim. This approach has the advantage of fast run times, but many simplifications may be required to satisfy the assumptions of the analytical solutions. The applicability of such solutions may also be questioned by model reviewers.

A second option is to take advantage of GoldSim’s built-in capability to link to external programs via dynamic-link libraries, or DLLs. Inputs to the external model(s) are passed by GoldSim to the DLL, which calls the external model(s) and then sends the results back to GoldSim. The GoldSim – MODFLOW/MT3D linkage described herein offers many exciting possibilities. It allows for the integration of a detailed numerical groundwater flow and transport model within a GoldSim model of an environmental system, thereby avoiding the limitations of analytical flow and transport solutions. The linkage can also be utilized for running Monte Carlo simulations with an existing MODFLOW/MT3D model, in which case GoldSim would generate the random inputs and serve as a run manager for MODFLOW/MT3D.

MODFLOW is a groundwater flow model developed by the U.S. Geological Survey that solves the groundwater flow equation numerically using the finite difference method. The model domain is discretized using rectilinear grids with one or more layers. The version used in this study is MODFLOW-NWT, which uses a nonlinear Newton solver to better simulate unconfined aquifers. MT3D is a contaminant transport code designed specifically for use with MODFLOW that numerically solves the advection-dispersion equation.  MT3D was originally developed by S.S. Papadopulos and Associates for the U.S. EPA.

 

DLL Linkage

DLL templates in C++ and Fortran are included with the GoldSim software. The template provides the basic structure of the necessary functions and classes, but the user is responsible for the details of the implementation. The GoldSim – MODFLOW/MT3D linkage was coded in C++ and compiled with Microsoft Visual Studio. A primary objective was to make the DLL as general as possible so it could be used without modification for different models. The DLL contains three functions: a function to process the model input data from GoldSim, a function that calls MODFLOW/MT3D, and a function that processes the model output to return to GoldSim.  GoldSim can only pass a single array of double precision floating point numbers to the DLL and receive the same back from the DLL. In order to keep the DLL general, the input array must include parameter type and identifier information in addition to the values themselves. 

The model input function in the DLL was set up to receive a set of three-value sequences from GoldSim where the first value is a parameter type code (e.g., 1 for horizontal hydraulic conductivity, 2 for specific yield, etc.), the second is a numeric identifier (e.g., zone number), and the third is the parameter value. The DLL then uses this information to write a parameter file in the PEST .par format (Watermark Numerical Computing, 2005).  The model call function in the DLL was coded to call a Windows batch file named “model_runner.bat”. The batch file contains the commands for construction of model input files, the calls to MODFLOW and MT3D, the extraction of necessary values from the MODFLOW/MT3D output files, and the assembly of the output into the correct format to return to GoldSim. PEST utility programs such as TEMPCHEK, INSCHEK, and MOD2OBS (Watermark Numerical Computing, 2012) were utilized wherever possible for writing and reading the MODFLOW/MT3D input and output files. Python scripts were used for all other pre- and post-processing operations. In order to avoid having to hard-code the number of output arguments into the DLL, the model output must be returned to GoldSim in a lookup table format. For maximum flexibility, proper formatting of the MODFLOW/MT3D output for GoldSim was implemented in a Python script instead of the DLL. The model output function in the DLL simply reads the correctly formatted output from this Python script and writes it to the array to be returned to GoldSim. The linkage workflow is illustrated in Figure 1.

Figure 1 - GoldSim - DLL Linkage Workflow

 

Example Problem 

A transient example problem involving groundwater flow and contaminant transport to a river was developed to test the GoldSim – MODFLOW/MT3D linkage. The example problem simulated a constituent leaching into a shallow unconfined aquifer from a mining stockpile and then flowing via groundwater to a river. Figure 2 shows plan and cross section views of the model domain. The aquifer was divided into five hydraulic conductivity zones, had variable width and thickness, and had a sloping bottom. Fourteen parameters were passed from GoldSim to the DLL: five horizontal hydraulic conductivities, horizontal anisotropy (Kx/Ky), vertical anisotropy (Kx/Kz), specific storage, specific yield, porosity, areal recharge rate, leaching rate through the stockpile, background concentration of the constituent, and leachate constituent concentration. The leaching rate was modeled in GoldSim as a function of precipitation and mining progress. River flow and water quality were modeled in GoldSim; upstream flow and constituent concentration were combined with the flow and constituent mass discharge from the groundwater model to compute the downstream flow and constituent concentration. The model used MODFLOW-NWT (Niswonger et al., 2011) and MT3DMS version 5.3 (Zheng and Wang, 1999; Zheng, 2010) with the TVD solver for the advective terms.

Figure 2 - Example problem model domain and hydraulic conductivity field

 

Below is a video showing the contamination changing over time and space:


 
The test Monte Carlo run consisted of 50 random realizations, with the example problem run for 40 years on monthly timesteps for each realization. Mining was active for the first 20 years of each realization only. The DLL linkage to MODFLOW/MT3D was incorporated into the GoldSim model in a fully coupled configuration. GoldSim called a 1-month-long MODFLOW/MT3D run via the DLL on every timestep. This is the most flexible configuration for using the MODFLOW/MT3D linkage, but calling the DLL on every timestep results in slow model run times. Depending on the structure of the GoldSim model, the number of calls to the DLL could potentially be reduced. If the output from MODFLOW/MT3D does not feed back into the GoldSim model, MODFLOW/MT3D could be called as a single transient run with many stress periods after first running the GoldSim model to completion to obtain time-series inputs for MODFLOW/MT3D. Such a configuration would likely run faster than the fully coupled version, though DLL input and output would be more burdensome for the single-call version. While the fully coupled version was used for the example problem, the single-call configuration could have been used due to the lack of feedback loops in the model. The entire test Monte Carlo run took approximately 21 hours to run on a single processor. 

Below is a summary of the components of the hypothetical example problem

  • Simulated a constituent leaching into a shallow unconfined aquifer from a mining stockpile and then flowing via groundwater to a river
  • Fourteen stochastic parameters (e.g., K, S, recharge, porosity, leachate concentration) defined with probability distributions in GoldSim, then randomly sampled and passed to the DLL on each realization
  • Leaching rate modeled in GoldSim as a function of precipitation and mining progress 
  • River flow and water quality modeled in GoldSim
  • 50 random realizations; each realization run for 40 years with monthly timesteps
  • Mining active for the first 20 years of each realization
  • Fully coupled linkage configuration
  • Entire test Monte Carlo run took approximately 21 hours to run on a single processor.

Figure 3 is a time history plot showing the range of constituent concentration in the river through time.



Figure 3 shows the time series of leached constituent concentration in the river.


For comparison purposes, the groundwater system was approximated in GoldSim with analytical solutions to eliminate the DLL. The test Monte Carlo simulation ran in 15 seconds with this GoldSim-only version. Figure 4 shows a comparison of median river constituent concentration for the DLL and non-DLL versions. They are similar, though the concentration ramps up more quickly and cleans up more quickly after mining ends when using MODFLOW and MT3D instead of the analytical approximations. The faster GoldSim-only model might be useful as a screening tool, but the DLL version of the model with its use of industry-standard groundwater flow and transport models would likely fare better in a model review if the model is subject to regulatory approval.   

Though not explored in this project, GoldSim does offer parallel processing capability that could be utilized to decrease run times. Up to four slave processes may be used with the basic GoldSim license; an unlimited number of slave processes may be used with the Distributed Processing Plus module. Since large amounts of data may be passed between the master and the slaves, parallel runs require multiprocessor computers or fast network connections.



Figure 4. Time series of median downstream constituent concentration in river for GoldSim – MODFLOW/MT3D coupled model (blue line) and GoldSim-only model with analytical approximations for groundwater flow and solute transport (black line).

 

Summary

The groundwater flow code MODFLOW and solute transport code MT3D were dynamically linked with the probabilistic simulation platform GoldSim. The combined model was tested with a hypothetical example problem simulating groundwater flow and solute transport to a river. A 50-realization Monte Carlo simulation took approximately 21 hours to run using a single processor. It may be possible to reduce run times by reducing the number of calls to MODFLOW/MT3D and/or utilizing GoldSim’s parallel processing capabilities. The combined model is useful for integrating accurate groundwater flow and transport models within GoldSim models of large and complex hydrologic systems as well as providing a platform for running Monte Carlo simulations of MODFLOW and MT3D models.  

 

Acknowledgements

This project was funded by Barr Engineering Company’s Innovation Grants program. For more information, please contact Adam Janzen (ajanzen@barr.com).

 

References

GoldSim Technology Group (GTG), 2015. History – GoldSim. Accessed from http://www.goldsim.com/Web/Company/History/

GoldSim Technology Group (GTG), 2013. User’s Guide, GoldSim, Probabilistic Simulation Environment, Version 11.

Niswonger, R.G., Panday, S., Ibaraki, M., 2011. MODFLOW-NWT, A Newton formulation for MODFLOW2005. U.S. Geological Survey Techniques and Methods 6-A37, 44 p.

Watermark Numerical Computing, 2012. Groundwater Data Utilities, Part B: Program Descriptions.

Watermark Numerical Computing, 2005. PEST: Model-independent parameter estimation. User Manual, 5th Edition.  

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. Technical Report prepared for US Army Corps of Engineers, 51 p.

Zheng, C. and Wang, P.P., 1999. MT3DMS: A Modular Three-Dimensional Multispecies Transport Model for Simulation of Advection, Dispersion, and Chemical Reactions of Contaminants in Groundwater Systems; Documentation and User’s Guide. US Army Corps of Engineers Contract Report SERDP-99-1, 221 p.

Tags:

  • probabilistic
  • groundwater
  • Contaminant Transport
  • link
  • MODFLOW
Have more questions? Submit a request

Comments