Fiite Differece Derivatios for Spreadsheet Modelig Joh C. Walto Modified: November 15, 2007 jcw Figure 1. Suset with 11 swas o Little Platte Lake, Michiga. Page 1 Modificatio Date: November 15, 2007
Review of Fudametals The goal of this sectio is to teach some of the fudametal cocepts of umerical methods ad their limitatios without gettig sidetracked too deep ito applied mathematics. I umerical modelig of groud water flow ad trasport we break the system to be modeled ito a series of discrete odes or elemets. The more fiely we divide the system the more accurate our umerical model. The easiest way to uderstad the basics of the modelig process is to derive ad program simple fiite differece models i spreadsheets. This provides a overview of modelig without a lot of complex ad tedious work. At least two methods for derivatio of fiite differece equatios exist: a) the flux / coservatio method ad b) Taylor s series approximatios The flux method is much more powerful ad very ituitive although the Taylor s series method is easier for simple cases ad thus preferred by studets. If we take ode i for the cotrol volume the the cotiuity equatio is: x i-1 i i+1 i+2 Figure 2. Example oe dimesioal fiite differece grid. where: Q V A q source of water, so a well would have a egative value (m 3 /s) volume of the cotrol volume Δy Δz, ote that directios ot modeled are geerally assumed to be of uit legth (m 3 ) surface area o relevat side of cotrol volume (m 2 ) flux ito or out of a cotrol volume surface, the sig of the flux depeds upo the directio that is defied to be positive, fluxes i the positive directio are positive fluxes (m 3 /m 2 /s) -- Iput Output + ( Source Sik) -- A i q i A q out out + Q (1) (2) Page 2 Modificatio Date: November 15, 2007
At this poit we have ot specified i the equatio how may directios we will model ad/or if the model will be trasiet or steady state. With steady state models the time derivative goes to zero. The ext step is to replace the derivatives with fiite differece approximatios ad to replace the geeric flux statemets with a costitutive law, Darcy s law i this case. For the flux method we assume that the boudary betwee each ode is half way betwee two odes. Sice a derivative is merely the slope, the commo sese approximatio of a derivative is to take the slope at small steps. The small steps ca be i time ad/or i space. For time this gives: + 1 Δh ( ) - ---- Δt ( t + 1 t ) Darcy s law is used to put the fluxes i terms of hydraulic head: (3) We will provide a oe dimesioal example i the x directio. Sice fluxes are at the odal iterfaces its easiest to refer to them as North, South, East, West, Top, Bottom. For a oe dimesioal system we have oly East ad West directios. The cotiuity equatio says that the chage i storage i the cotrol volume is equal to Iput - Output + Source: For the oe dimesioal case it is more cosistet to redefie Q area per uit time i the directio beig modeled (m/s). as the source of water per uit For space we get the followig fiite differece approximatios, for output from the cotrol volume: -- A q K h W K W + A x E K E + AQ x (4) (5) Δh - x ( ) --- ( ) + 1 x i + 1 x i (6) ad for iput to the cotrol volume: Δh - x ( 1 ) -- ( x i x i 1 ) (7) where: Page 3 Modificatio Date: November 15, 2007
poit i time, is the curret time ad +1 is oe time step i the future i ode umber What are the time steps o the hydraulic heads? Substitutio gives: + 1 ( ) ( ---- (8) t + 1 t A W K -- 1 ) W ( ) ( x i x i 1 ) A K ( + h 1 i ) + --- + AQ E E ( x i + 1 x i ) This looks complicated but is ot. First cosider that if the system is homogeeous the K E K W K If the o-modeled directios are assumed to be of legth 1 ad is costat the the areas ad volumes simplify to: A1 m 2 ad V m 2. Simplifyig gives: + 1 S s ( ---- ) ---- K Δt ( 1 ) ( h - i + 1 ) --- Q 2 + 2 + (9) or: + 1 S s ( ---- ) ---- K Δt ( 1 2 + + 1 ) -- Q 2 + K (10) or: + ΔtK Q ( 1 2 + + 1 ) + -- + h K i 1 2 Ss (11) The time step o the hydraulic heads deped upo the umerical method chose for advacig the equatios i time. Explicit methods assume that the value of h at the curret (i.e., kow) time step are used. The explicit method makes solutio of the equatios very simple: Just solve the equatio for the oly ukow h at time step +1. The implicit method assumes that the value of s take at a future time step. Thus a series of equatios (i.e., a matrix) must be solved to advace the solutio i time. The explicit method is easier to program but is less powerful because it is less stable. The maximum time step for the explicit method is: KΔt -- 1 S s ( 2 -- ) 2 (12) Page 4 Modificatio Date: November 15, 2007
Fiite Differece by Taylor s Series The equatio for two dimesioal horizotal flow i a homogeeous isotropic medium is: 2 h T x 2 h x 2 + T y y 2 + R L S (13) We will show a oe dimesioal example but the same derivatio applies to multiple dimesios. The Taylor s series approximatio to a fuctio, i this case hydraulic head is: hx ( + ) hx ( ) ( ) 2 2 h ( ) 3 3 h ( ) 4 4 h + + x 2! x 2 + 3! x 3 + 4! x 4 + Error I terms of our fiite differece grid where we have odes: (14) ad + ( ) 2 2 h ( ) 3 3 h ( ) 4 4 h + + x 2! x 2 + -- 3! x 3 + 4! x 4 + Error 1 (15) ( ) 2 2 h ( ) 3 3 x 2! x 2 h ( ) 4 4 h + 3! x 3 + -- 4! x 4 + E( 4 ) 1 These are fourth order accurate. If we ca accept secod order accuracy the they ca be trucated after the first two terms: (16) ad + ( ) 2 2 h + + -- x 2! x 2 + E( 2 ) 1 (17) ( ) 2 2 h + x 2! x 2 + E( 2 ) 1 to get secod order accurate equatios. If we add the above two equatios we get: (18) 2 h h i 1 2 + + 1 (19) x 2 --- ( ) 2 + E( 2 ) Or we could get eve more crude ad just trucate the above equatios to first order accuracy: Page 5 Modificatio Date: November 15, 2007
x x + 1 + E 1 ---- + E (20) (21) Page 6 Modificatio Date: November 15, 2007
Steady State Simulatio Example Let s apply our ewly foud fiite differece equatios to the two dimesioal flow i a cofied aquifer situatio give above. But, sice I m tired, oly to the steady state situatio with o sources or siks. At steady state this becomes: 2 T x h 2 h x 2 + T y y 2 0 Pluggig ad chuggig we fially get: + + + 4 h ( i 1, j) h ( i + 1, j) h (, ij 1) h (, ij+ 1), j (22) (23) Notice that this equatio has a circular logic whe applied to multiple odes. How do we solve such a equatio? 1. Put i boudary coditios. For fixed heads this is just the value of the head at the ode. For o flux boudary coditios cosider that there is o flux if the head is the same o both sides of the ode. Make a imagiary ode ad assume it has the same head as the ode o the opposite side (show example spreadsheet). 2. Put i the basic equatio o all iterior odes. 3. Set the spreadsheet to iterate to covergece. Page 7 Modificatio Date: November 15, 2007