MODFLOW 00 and Other Modeling Odysseys Proceedings, 00, International Ground Water Modeling Center, Colorado School of Mines, Golden, CO, p. 85-8 The Power of Spreadsheet Models Mary P. Anderson, E. Scott Bair University of Wisconsin, andy@geology.wisc.edu, Madison, WI, USA Ohio State University, bair.@osu.edu, Columbus, OH, USA ABSTRACT Prior to using MODFLOW, students need experience with simpler codes that provide hands-on experience setting up boundary and initial conditions, coding simple solution algorithms, and handling numerical errors. The best way to do this is using spreadsheet models; faculty no longer can expect students to know a common computer language, but students are familiar with spreadsheets. Many aspects of flow and transport modeling may be taught using spreadsheets. Students can quickly set up a spreadsheet model of a simple problem (e.g, the two-dimensional Toth regional flow system problem), watch the iterative solution on-screen, and view the final distributions of heads or concentrations. The same problem may be solved later using MODFLOW. Spreadsheets can be set up to calculate water balances, compute and graph calibration statistics, and perform sensitivity analyses. With the basic principles of modeling in hand, students are introduced to more complex concepts used in MODFLOW such as conductances and head dependent fluxes. Spreadsheets can be designed to mimic packages in MODFLOW such as Zonebudget, River, Well, and Recharge. Thus, spreadsheets provide an easy way to teach finite-difference theory and modeling concepts, as well as their implementation in MODFLOW. INTRODUCTION One of the challenges of teaching numerical techniques applied to groundwater modeling is that students no longer know a common computer language. With the keen interest in graphically-oriented languages like C++, languages like Fortran, the stalwart for scientific computation for the past three decades, are no longer taught at many colleges and universities. Most students are familiar with spreadsheets. The ease with which a spreadsheet can be set up, programmed, solved, and the results statistically analyzed and graphically displayed makes the concepts and notations used in finite-difference modeling easier to understand. In fact, spreadsheet models provide a more effective way to teach finite-difference methods and the hydrologic concepts and argon underlying groundwater modeling than the use of programming languages such as Fortran. Furthermore, an introduction to modeling via spreadsheets eases the transition to using MODFLOW. Olsthoorn (985) and Ousey (986) first described how spreadsheets are used to solve simple finitedifference problems. Olsthoorn (998) provided a summary and additional discussion. The initial excitement over the potential of the method (e.g., Campbell, 985), however, did not lead to widespread use of spreadsheet models in the literature or in practice. This is probably owing to the fact that while ideal for solving simple problems, the use of spreadsheets is awkward for solving the complex models typically needed to represent field situations. Furthermore, pre- and post-processing programs for MODFLOW now allow for a more user-friendly environment than in the mid-980s. Nevertheless, for pedagogical purposes, spreadsheet models are far superior to complex codes such as MODFLOW. Furthermore, spreadsheets like EXCEL not only solve the finite-difference equations but also contain a built in pre-processor of geologic and hydrologic data and a post-processor of results. SIMPLE BEGINNINGS The two-dimensional Laplace equation is written as follows:
h + h y 0 () When approximated using finite differences and assuming that x y, the equation becomes: h h + h + h h 0 () i+, + i, i, + i, 4 i, Solving for h i, yields: m m+ m m+ m+ hi+, + hi, + hi, + + hi, h i, (3) 4 where iteration indices (m, m+) have been introduced. Gauss-Seidel iteration is invoked if we always use the most recently computed head values (m+ values) in the solution and if the calculation progresses through the grid from top to bottom and from left to right. (The spreadsheet automatically uses Gauss-Seidel iteration when the iteration option is selected.) When implemented in a spreadsheet solution for a typical cell, D3 for example, the solution is written as follows: D4 + D + C3 + E3 D3 (4) 4 Specified head boundary conditions are represented by simply entering the appropriate head value in the boundary cell. Specified flux conditions are also easily represented; a spreadsheet model with specified flux boundary conditions can be used to illustrate the difference between mesh-centered and blockcentered models. Consider the two-dimensional spreadsheet model shown in Figure, which represents a version of the Toth regional flow problem (Toth, 96). The top boundary represents the water table under specified head conditions whereas the side boundaries are under no flow conditions representative of groundwater divides and the bottom boundary is a no flow boundary reflecting the presence of an impermeable layer. Figure. Mesh-centered grid for the Toth regional flow problem In a mesh-centered grid, a flux boundary is located directly on a node. For the model shown in Figure, the boundary condition for cells that lie along the side boundaries is represented by a central difference h approximation of 0, or
h h 0 (5) i+, i, For the boundary cells in column A in Figure, this implies that h i+, h i-, and for cell A3, this means that the head in the node to the left of A3 equals the head in B3. Hence, equation 3 simplifies to * B3 + A + A4 A3 (6) 4 In a block-centered grid, the no flow boundary is at the edge of the cell, or half way between two nodes. For the model shown in Figure, which represents a version of the Toth regional flow problem with a block-centered grid, the left-hand side boundary is located between the nodes in column A and B, so that the head in A3 equals the head in B3. When set up with imaginary nodes that are outside the problem domain (located in columns A and M and row 7) the standard finite difference equation (equation 3) is written for all cells inside the problem domain. Figure. Block-centered grid for the Toth regional flow problem In Figures and above, a simple water balance accounting scheme was introduced, where K is hydraulic conductivity and Q is the flux across the water table. Total recharge (R) into the model equals total discharge (D) leaving the model and a simple error is computed as the difference between R and D. In another assignment, distributed recharge and point withdrawals from wells can be introduced using a finite-difference approximation to Poisson s equation, which can be written for both confined aquifers and for unconfined aquifers under the Dupuit assumptions (e.g., the Island Recharge Problem in Wang and Anderson, 98, p. 44-46, 66). For a confined aquifer, where T is transmissivity and R is a sink/source term, the Poisson equation is written as h h R + (7) y T and the spreadsheet equation is modified by the addition of the term, a R/T, where x y a. Both distributed recharge and point sources and sinks (pumping wells) can be introduced and the students can test the effects of varying R and T and changing the boundary conditions. Water balance calculations must be modified to include the sink/source terms, thereby giving students hands on experience formulating water balance equations. An SOR iterative solution procedure can also be introduced.
One-dimensional problems can be used to convey complex concepts while maintaining mathematical simplicity. For example, a one-dimensional transient problem can be used to introduce transient solution techniques (i.e., explicit and implicit solutions) and illustrate how storage is introduced into a transient water budget. Figure 3 shows a spreadsheet model set up to solve the one-dimensional transient reservoir problem in Wang and Anderson (98, p. 70-76). The governing equation is h S h (8) T t Each line of the spreadsheet, starting with line 5 represents the solution at a given time level. A time step of 5 minutes is used in this simulation (cell B and column L). The initial conditions are shown in line 4. Boundary conditions are specified head at both ends of the system (columns A and K). Notice the instantaneous drop in water level in the boundary cell K4 to meters. An implicit solution with Gauss-Seidel iteration is used; the solution at t5 minutes is shown in line 5 with subsequent time steps following line 5. Figure 3. Spreadsheet model of a one-dimensional transient flow problem using an implicit finite difference approximation
Figure 4. Water balance computation for the spreadsheet model shown in Figure 3 A water balance also can be introduced as shown in Figure 4. Columns R through Z contain the computed release of water from storage for each node. Column N contains the flow into the model from the left-side constant head boundary, whereas column O contains the flow out of the model through the right-side constant head boundary. Column P is column N plus the total amount of water released from storage (the sum of columns R through Z) and represents the total amount of water flowing into the model. The values in column P should equal the amounts in column O for each time step. The percent error in the water balance is shown in column Q. ADVANCED TOPICS The Block-Centered Flow (BCF) Package in MODFLOW, among other functions, computes the conductance components of the finite-difference equations and the flux between adacent cells. The flux between adacent cells (i, ) and (i+, ) along a row can be written as q Kb y( hi, hi x ) +, i, qi+, (9) This formulation is applicable only when x is constant and the aquifer is isotropic and homogeneous. If K i, K i+, a weighted average value of K must be used. This requires the concepts of harmonic mean and conductance to be introduced. The harmonic mean hydraulic conductivity between nodes (i, ) and (i+, ) is Harmonic Mean K i, i +, (0) and is equal to the conductance, C, across the interface between x i, and x i+, when x y and b. In this case, the flux is computed as K i, K + K q i, qi +, i, i+, i +, C( h h ) ()
Conductances must be computed for every shared cell face. In a one-dimensional model conductances are computed for every cell face in the positive x direction (q i, q i+, ) and for every cell face in the negative x direction (q i-, q i, ) to account for water entering and exiting the two faces of the cell. In a two-dimensional model conductances are computed at all four cell faces and in a three-dimensional model conductances at all six cell faces. Again we can use a one-dimensional problem to introduce complex concepts. The left side of Figure 5 shows a spreadsheet of a one-dimensional, steady-state, heterogeneous flow system bounded by two specified head nodes and solved using a Laplace formulation modified for heterogeneous conditions. The spreadsheet computes conductances and fluxes between cells in the positive x direction (C >>> and q >>>) and in the negative x direction (<<< C and <<< q). In the simulation shown, the values of hydraulic conductivity, K, change from 00 (columns B through F), to 0 (column G), to 00 (columns H through L). The graph at the bottom of the spreadsheet shows the effect of the heterogeneities on the computed heads. The spreadsheet also is programmed to compute the difference in flux across the right face and the left face of each cell (q diff), a water balance, and the error. Once the concept of conductance is understood in one dimension, it is relatively easy to expand the model to two dimensions. The logistics of creating two-dimensional models lends itself to linking spreadsheets so that conductances and fluxes are computed on separate spreadsheets that are linked to the main spreadsheet that is used to compute heads and to display results. Linking spreadsheets also is a convenient way to add source and sink terms such as recharge, wells, and the effects of rivers and drains. If each of these sources/sinks is assigned a separate linked spreadsheet, the structure of the spreadsheet model is similar to the modular structure of MODFLOW. Figure 5. Advanced topics introduced using a simple one-dimensional spreadsheet model
For example, the right side of Figure 5 shows the same one-dimensional flow system shown on the left side except sources/sinks from recharge, wells, and river interaction are added and a Poisson formulation is used. The volumetric rate of well withdrawal (-00 in cell Q5) is specified on the main spreadsheet. The volumetric rates of recharge and water entering or exiting river cells are computed on linked spreadsheets. The total volumetric rate of water entering or exiting each cell is calculated in the main spreadsheet (cells P7-X7) and is used as the R term in the finite-difference equation for each cell. This type of spreadsheet model enables students to learn more MODFLOW argon and to see how MODFLOW computes different source/sink terms. The linked spreadsheet used to compute volumetric rates of water entering or exiting the model from river cells (Figure 5, right side) is set up as five onedimensional arrays: one array for the head in each river cell (H riv ), one array for the vertical hydraulic conductivities of the riverbed (K riv ), arrays for the width (W) and length (L) of the river in each cell, and one array for the riverbed thickness (M). The values in these arrays are combined according to the same formulae used in MODFLOW to compute riverbed conductance (C riv ) C K rivlw M riv () and then used to compute the volumetric rate of flow into or out of the model from the river q riv C ) (3) riv ( hriv hcell It is also easy to program the main spreadsheet to compute water balances of specific zones, like Zonebudget in MODFLOW, to make contour plots of simulated heads and residuals, to compute calibration statistics such as mean absolute error and root mean squared error, and to make a graph of simulated versus measured heads. As a term proect, students in the second author s flow modeling class develop a two-dimensional, steady-state, spreadsheet model of the flow system in the Aberona River valley at Woburn, Massachusetts. The leukemia cases associated with water from municipal wells G and H at this site are the focus of the book A Civil Action (Harr, 995). The geology and hydrology of the site including synoptic sets of water levels and measured streamflow gains/losses (Myette and others, 987) are used to incorporate some of the complexity of the buried valley aquifer, riparian wetland, and outwash and icecontact deposits into the model. Linked spreadsheets incorporate pumping wells, river/aquifer interaction, and spatially variable hydraulic conductivity, layer thickness, and recharge. To calibrate their models, students statistically and graphically compare simulated and measured heads and calculate a local water balance to compute simulated streamflow gains/losses along the same reach of the Aberona River gaged by the USGS (Myette and others, 987). In a follow-up course on solute transport modeling, students develop a one-dimensional, explicit, finitedifference solution to the advection-dispersion equation incorporating chemical retardation (R f ) R f C t D x C ( v C) x (4) The solution addresses transport in a steady-state, heterogeneous flow field with spatially variable recharge, where the velocity field is determined using a Poisson formulation. The concentration (C) at cell i at time step t is determined by
C t i C t α v t t t t ( Ci+ Ci ) α xvi / ( Ci Ci ) t t t ( v C v C ) t x i+ / i + / + / i i i i R f x x R f x (5) where Di α xv is hydrodynamic dispersion (molecular diffusion is ignored) and the terms i v and i / v i+/ are flow velocities at the interfaces between cells i and i- and cells i and i+, respectively (modified from Zheng and Bennett, 995, p. 6). This introduces students to the concepts of stability and numerical dispersion as the solution is unstable if Peclet and Courant constraints are not met. Students apply the model to the movement of TCE from the W.R. Grace site toward wells G and H at Woburn, Massachusetts. The attempt is made to calibrate the one-dimensional model to water levels measured along a flowpath from W.R. Grace to the Aberona River, to measured streamflow gains, and to (limited) historic TCE data by adusting values of hydraulic conductivity, aquifer thickness, recharge rates, dispersivity, and chemical retardation. Students then compare their numerical results to those computed using an Ogata-Banks analytical solution, which assumes a uniform velocity field (i.e. hydraulic conductivity, aquifer thickness, and porosity are constants). CONCLUSIONS AND LIMITATIONS Spreadsheets can be used to introduce students to many concepts involved in numerical modeling of flow and transport, including mesh and block-centered grids, Gauss-Seidel and SOR iteration, explicit and implicit solutions to transient equations, water budgets, and stability and numerical dispersion. Spreadsheets also offer a convenient and easy way to analyze and graph results. Linked spreadsheets allow students to create sophisticated two-dimensional models that mimic the structure and equations of parts of MODFLOW including the BCF, Well, River, Recharge, and Zonebudget packages. There are few limitations to the creativity and types of small problems that can be addressed using spreadsheet models. Spreadsheet models, like all model codes, need to be verified by reproducing analytical solutions. The graphical displays and statistical calculations created for spreadsheet models also must be verified to check for proper assignment of cells and programming. Verification of spreadsheet models is mandatory because of the ease with which small but significant programming errors can be introduced and propagated using the copy and paste command. Developing code verification tests is a creative exercise that challenges students to use the breadth and depth of their hydrogeologic knowledge. The biggest difficulty with using spreadsheet models is associated with managing, linking, and debugging large numbers of arrays. This is particularly true for two-dimensional models of transient flow and solute transport. Once the maor numerical techniques have been presented and implemented using simple spreadsheet models, students can be introduced to professional codes like MODFLOW. Many of these codes have steep learning curves, but allow for three-dimensional problems and processes that are not computationally tractable using spreadsheets such as variable-density flow, multi-phase flow, and partially saturated flow. Although use of professional codes as part of a graduate curriculum in groundwater hydrology is subect to pedagogical debate, it does provide students with experience using tools they may later use as groundwater professionals. This experience is very appealing to some employers. As professional educators, however, it is the hands-on knowledge of the underlying concepts of numerical modeling techniques developed by constructing simple spreadsheet models that we believe improves and enhances the learning process. REFERENCES Campbell, A. M., 985, Discussion of: The power of the electronic worksheet: modeling without special programs and reply by T.N. Olsthoorn, Ground Water, 3(4), 36-37. Harr, J., 995, A Civil Action, Random House, New York, 500 p.
Myette, C.F., J.C. Olympio, and D.G. Johnson, 987, Area of influence and zone of contribution to Superfund-site Wells G and H, Woburn, Massachusetts; U. S. Geological Survey, Water- Resources Investigations Report 87-400, p. Olsthoorn, T.N., 985. The power of the electronic worksheet: modeling without special programs, Ground Water, 3(3), 38-390. Olsthoorn, T.N., 998. Groundwater modelling: calibration and the use of spreadsheets, Delft University Press, 4 p. Ousey, J.R., 986. Modeling steady-state groundwater flow using microcomputer spreadsheets, Journal Geological Education, 34, 305-3. Toth, J., 96, A theory of groundwater motion in small drainage basins in central Alberta, Canada, Journal of Geophysical Research, 67(), 4375-87. Wang, H.F., and M.P. Anderson, 98, Introduction to Groundwater Modeling: Finite Difference and Finite Element Methods, W.H. Freeman, 56 p. Zheng, C., and G.D. Bennett, 995, Applied Contaminant Transport Modeling, Theory and Practice: van Nostrand Reinhold, New York, New York, 440 p.