<<

Overhead Slides for Chapter 6

of Fundamentals of Atmospheric Modeling

by Mark Z. Jacobson Department of Civil & Environmental Engineering Stanford University Stanford, CA 94305-4020 January 30, 2002 ODEs and PDEs

Ordinary (ODE) Equation with one independent variable

Partial differential equation (PDE) Equation with more than one independent variable

Order Highest of an equation

Degree Highest value of the highest derivative

Initial value problem Conditions are known at one end of domain but not other

Boundary value problem Conditions are known at both ends of domain

Table 6.1. Ordinary and partial differential equations. Ordinary Differential Partial Differential Equations Equations dN ¶ N ¶(uN ) First-order, first- (a) = 16- 4N2 dt (e) + = 0 degree ¶t ¶ x dN ¶ u ¶u ¶ u First-order, first- (b) = 3AB - 4NC (f) +u + v = 0 dt degree ¶ t ¶x ¶ y 2 2 2 Second-order, d N dN ¶ N ¶ N 2 (c) 2 + + 5t = 0 (g) 2 + 2 = 3t + x first-degree dt dt ¶t ¶x 2 2 Second-order, æd 2N ö dN æ¶ 2Nö ¶N (d) ç ÷ + + 4 = 0 (h) ç ÷ + = t - x second-degree è dt2 ø dt è ¶t2 ø ¶x Operator Splitting

Fig. 6.1. Operator-splitting scheme.

Time interval 1 Time interval 2

Dynamics Dynamics

Transport Transport

Gas chemistry Gas chemistry

Operator-split advection-diffusion equations

¶N ¶(uN ) ¶ æ ¶Nö + - ç K ÷ =0 (6.1) ¶t ¶x ¶x è h,xx ¶x ø

¶N ¶( vN) ¶ æ ¶Nö + - ç Kh,yy ÷ =0 (6.2) ¶t ¶y ¶y è ¶y ø

¶N ¶( wN) ¶ æ ¶Nö + - ç K ÷ =0 (6.3) ¶t ¶z ¶z è h,zz ¶z ø

Operator-split external source / sink terms

N ¶N e,t = R (6.4) ¶t å n n=1 Consistency, Convergence, Stability

Convergence of analog

¶N DN = lim (6.6) ¶x Dx® 0 Dx

Consistency

æD N ö lim T.E.ç ÷ = 0 (6.7) Dx® 0 è Dx ø

Convergence of overall solution

lim Ne,x,t - N f,x,t = 0 (6.8) Dx,Dt® 0

Stability

lim Ne,x,t - Nf ,x,t £ C (6.9) t®¥ Finite Difference

Replacement of continuous (d) with discrete difference analog (D ) written in terms of a finite number of values along a temporal or spatial direction.

Fig. 6.2. Discretization of ux u

ux

x

ui-1 ui ui+1 ui+2

i-1 i i+1

xi-1 xi xi+1 xi+2

Differences at xi

du ---> Dui = ui+1 - ui- 1 central difference ---> Dui = ui+1 - ui forward difference ---> Dui = ui - ui-1 backward difference

Central difference approximation to at xi

¶u Du u - u » i = i+1 i- 1 (6.10) ¶x Dxi xi+1 - xi- 1 Taylor Expansions

Fig. 6.3. Central (AC), forward (BC), and backward (AB) to slope of tangent at point B.

N A

B N C x Dx Dx

x-Dx x x+Dx x xi-1 xi xi+1

Taylor at point x + Dx

¶N 1 ¶2N 1 ¶3 N 1 ¶ 4N N = N + Dx x + Dx2 x + Dx3 x + Dx4 x + ... x+Dx x ¶x 2 ¶x2 6 ¶x3 24 ¶x4

(6.11)

Taylor series expansion at point x - Dx

¶N 1 ¶2N 1 ¶3N 1 ¶ 4N N = N - Dx x + Dx2 x - Dx3 x + Dx4 x - ... x-Dx x ¶x 2 ¶x2 6 ¶x3 24 ¶x4

(6.12) Finite Difference Approximations

Sum the Taylor series expansions

¶2N 1 ¶ 4N N + N = 2N + Dx2 x + Dx4 x + ... x+Dx x-Dx x ¶x2 12 ¶x4

(6.13)

Rearrange

¶ 2N N - 2N + N x = x+Dx x x-Dx + O Dx2 (6.14) ¶x2 Dx2 ( )

Truncation error

1 ¶ 4N O Dx2 = - Dx2 x - ... (6.15) ( ) 12 ¶x4

Second-order central difference approximation of 2nd derivative

¶ 2N N - 2N + N x » x+Dx x x-Dx (6.16) ¶x2 Dx2 Finite Difference Approximations

Subtract the Taylor series expansions

¶N 1 ¶3N N - N = 2Dx x + Dx3 x + ... (6.17) x+Dx x-Dx ¶x 3 ¶x3

Rearrange

¶N N - N x = x+Dx x-D x + O Dx2 (6.18) ¶x 2Dx ( )

Truncation error

1 ¶3N O Dx2 = - Dx2 x - ... (6.19) ( ) 6 ¶x3

Second-order central difference approximation of 1st deriv.

¶N N - N N - N x » x+Dx x-D x = i+1 i- 1 (6.20) ¶x 2Dx 2Dx Finite Difference Approximations

First two terms of Taylor series

First-order forward difference approximation of 1st deriv.

¶N N - N N - N x » x+Dx x = i+1 i (6.21) ¶x Dx Dx

First-order backward difference approximation of 1st deriv.

¶N N - N N - N x » x x-Dx = i i- 1 (6.22) ¶x Dx Dx Differencing Time Derivative

Central , forward , and backward difference approximations

¶N N - N t » t+h t- h (6.23) ¶t 2h

¶N N - N t » t+h t (6.23) ¶t h

¶N N - N t » t t- h (6.23) ¶t h High Order Approximations

Finite difference approximation of ¶ mN ¶x m

o Order of derivative = m o Approximation expanded across q discrete nodes o Minimum number of nodes = m + 1 o Maximum order of approximation = q - m

Example Order of derivative: m = 1 Number of nodes q = 5 ---> Order of approximation: q - m = 4

Fig. 6.4. Grid spacing where q = 5. Derivative is taken at x3.

x x1 x2 x3 x4 x5 *

Distance between two nodes

Dxi = xi+1 - xi

Approximation to the mth derivative across q nodes

q ¶ mN » g N = g N + g N + ... + g N (6.24) ¶x m å i i 1 1 2 2 q q i=1 High Order Approximations

Taylor series expansion for each node about point x*

¶N 1 2 ¶ 2N 1 3 ¶ 3N N = N + ( x - x ) * + (x - x ) * + (x - x ) * + ... i * i * ¶x 2 i * ¶x2 6 i * ¶x3 (6.25) Combine (6.24) with (6.25) and gather terms

q q q q ¶ mN ¶N 1 2 ¶ 2N » g N = g N + g ( x - x ) * + g (x - x ) * + ... ¶x m å i i å i * å i i * ¶x å i 2 i * ¶x2 i=1 i=1 i=1 i=1 (6.26) Redefine

q ¶N ¶2N g N = B N + B * + B * + ... (6.27) å i i 0 * 1 ¶x 2 ¶x2 i=1

q 1 n B = g ( x - x ) for n = 0...q - 1 (6.28) n å i n! i * i =1

o Set Bn = 0 for all n, except n = m o Set Bn = 1 when n = m

Multiply (6.27) through by n! and set matrix (6.29)

é 1 1 1 ... 1 ù ég 1ù é 0!B0 ù ê (x - x ) (x - x ) (x - x ) ... x - x úê ú ê ú ê 1 * 2 * 3 * ( q * ) ú g2 1!B1 2 ê ú ê ú ê x - x 2 x - x 2 x - x 2 ... x - x úê g ú ê 2!B ú ê ( 1 * ) ( 2 * ) ( 3 *) ( q * ) ú 3 = 2 ê : ú ê : ú ê : : : : úê ú ê ú ê q- 1 q- 1 q- 1 q- 1úê g ú ê( q - 1)!B ú ëê( x1 - x*) (x2 - x* ) (x3 - x* ) ... ( xq - x*) ûúë qû ë q- 1û Second-Order Central Difference Approximation

Example.

Find second-order central difference approx. to ¶N ¶x

Order of derivative: m = 1 Order of approximation: q - m = 2 ---> Number of nodes q = 3

Set matrix

é 1 1 1 ùé gi- 1ù é0 ù ê úê ú ê ú ê -Dx 0 Dx úê gi ú = ê1 ú (6.32) 2 2 ëê( -Dx) 0(Dx) ûúëê g i+1ûú ëê0 ûú

Solve matrix

1 1 g = - g = 0 g = i- 1 2Dx i i+1 2Dx

Apply the g's to (6.24)

¶N » g N + g N + g N = g N + g N + g N ¶x 1 1 2 2 3 3 i-1 i- 1 i i i+1 i+1

Substitute g's to obtain central difference approximation

¶N N - N » i+1 i-1 Table 6.2 (c) ¶x 2Dx First-Order Backward Difference Approximation

Example.

Find first-order backward difference approx. to ¶N ¶x

Order of derivative: m = 1 Order of approximation: q - m = 1 ---> Number of nodes q = 2

Set matrix

é 1 1ùé g i-1ù é0 ù ê ú ê ú= ê ú (6.30) ë-D x 0ûë gi û ë1 û

Solve matrix

1 1 g = - g = i- 1 Dx i Dx

Applying the g's to (6.24)

¶N » g N + g N (6.31) ¶x i- 1 i-1 i i

Substitute g's to obtain backward difference approximation

¶N N - N » i i- 1 Table 6.2 (a) ¶x Dx Second-Order Backward Difference Approximation

Example

Find second-order backward difference approx. to ¶N ¶x

Order of derivative: m = 1 Order of approximation: q - m = 2 ---> Number of nodes q = 3

Set matrix

é 1 1 1ùé g i- 2ù é0 ù ê úê ú ê ú ê - 2Dx -Dx 0úê gi- 1ú = ê1 ú (6.32) 2 2 ëê( -2Dx ) (-Dx) 0ûúëê gi ûú ëê0 úû

Solve matrix

1 2 3 g = g = - g = i- 2 2Dx i- 1 Dx i 2Dx

Applying the g's to (6.24)

¶N » g N + g N + g N ¶x i- 2 i- 2 i- 1 i-1 i i

Substitute g's to obtain backward difference approximation

¶N N - 4N + 3N » i- 2 i- 1 i Table 6.2 (d) ¶x 2Dx Higher-Order Approximations

Third-order backward difference (m = 1, q = 4)

¶N N - 6N +3N + 2N » i- 2 i- 1 i i+1 Table 6.2 (f) ¶x 6Dx

Third-order forward difference (m = 1, q = 4)

¶N - 2N - 3N +6N - N » i -1 i i+1 i+2 Table 6.2 (g) ¶x 6Dx

Fourth-order backward difference (m = 1, q = 5)

¶N - N + 6N - 18N + 10N +3N » i - 3 i - 2 i- 1 i i+1 Table 6.2 (i) ¶x 12Dx

Fourth-order forward difference (m = 1, q = 5)

¶N - 3N - 10N +18N - 6N + N » i- 1 i i+1 i+2 i+3 Table 6.2 (j) ¶x 12Dx Fourth-Order Approximations

Discretize around furthest cell

Fourth-order backward diff. scheme (m = 1, q = 5)

é 1 1 1 1 1ùé g i- 4ù é0 ù ê úê ú ê ú - 4Dx -3Dx -2Dx -Dx 0 gi- 3 1 ê 2 2 2 2 úê ú ê ú ê( -4Dx) (- 3Dx) (- 2Dx) (-Dx) 0úê g i- 2ú = ê0 ú ê 3 3 3 3 úê ú ê ú (- 4Dx) (- 3Dx) (-2Dx) (-Dx) 0 gi- 1 0 ê 4 4 4 4 úê ú ê ú ëê( - 4Dx) (-3Dx) (-2Dx) (-Dx) 0ûúëê gi ûú ëê0 ûú

¶N - 3N +16N - 36N + 48N - 25N » i- 4 i- 3 i- 2 i- 1 i Table 6.2 (k) ¶x 12Dx

Fourth-order forward difference (m = 1, q = 5)

¶N 25N - 48N + 36N - 16N + 3N » i i+1 i+2 i+ 3 i+4 Table 6.2 (l) ¶x 12Dx Fourth-Order Central Difference Approximations

Fourth-order central difference of ¶N ¶x (m = 1, q = 5)

é 1 1 1 1 1 ùé g i- 2ù é0 ù ê úê ú ê ú - 2Dx -Dx 0 Dx 2Dx gi- 1 1 ê 2 2 2 2 úê ú ê ú ê( -2Dx) (-Dx) 0 (Dx) (2Dx) úê gi ú = ê0 ú (6.33) ê 3 3 3 3 úê ú ê ú (- 2Dx ) (-D x) 0(Dx ) (2Dx) gi+1 0 ê 4 4 4 4 úê ú ê ú ëê( - 2Dx) (-Dx ) 0(Dx) (2Dx) ûúëê g i+ 2ûú ëê0 ûú

¶N N - 8N + 8N - N » i- 2 i- 1 i+1 i+2 Table 6.2 (h) ¶x 12Dx

Fourth-order central difference of ¶ 2N ¶x2 (m = 2, q = 5)

é 1 1 1 1 1 ùé g i- 2ù é0 ù ê úê ú ê ú - 2Dx -Dx 0 Dx 2Dx gi- 1 0 ê 2 2 2 2 úê ú ê ú ê( -2Dx) (-Dx) 0 (Dx) (2Dx) úê gi ú = ê2 ú ê 3 3 3 3 úê ú ê ú (- 2Dx ) (-D x) 0(Dx ) (2Dx) gi+1 0 ê 4 4 4 4 úê ú ê ú ëê( - 2Dx) (-Dx ) 0(Dx) (2Dx) ûúëê g i+ 2ûú ëê0 ûú

¶2N - N +16N - 30N +16N - N » i - 2 i- 1 i i+1 i+2 Table 6.2 (n) ¶x 2 12Dx2 Solutions to the Advection-Diffusion Equation

Species continuity equation in west-east direction

¶N ¶(uN ) ¶ æ ¶Nö + - ç K ÷ =0 (6.1) ¶t ¶x ¶x è h,xx ¶x ø

CFL stability criterion for advection

h < Dxmin umax

Stability criterion for diffusion

2 h < Dxmin Kmax

Forward in time, centered in space (FTCS) solution (6.35)

Ni,t - Ni,t- h (uN )i+1,t - h - (uN)i- 1,t- h Ni+1,t - h - 2 Ni,t - h + Ni - 1,t - h + - K = 0 h 2Dx Dx 2 Implicit Solution

Implicit solution (6.36)

Ni,t - Ni,t- h (uN )i+1,t - (uN)i- 1,t Ni+1,t - 2 Ni, t + Ni- 1,t + - K = 0 h 2Dx Dx2

Rearrange and write in tridiagonal matrix form

AiNi- 1,t + BiNi,t + DiNi+1,t = Ni ,t - h (6.37)

u K 2K u K çæ ÷ö çæ ÷ö çæ ÷ö Ai = - h + 2 Bi = 1+h 2 Di = h - 2 è 2Dx Dx øi - 1 è Dx øi è 2Dx Dx øi +1

(6.38)

é B1 D1 0 0 ... 0 0 0 ù é N1,t ù é N1,t- h ù é A1N0,t ù êA B D 0 ... 0 0 0 úê N ú ê N ú ê 0 ú ê 2 2 2 ú ê 2,t ú ê 2,t- h ú ê ú ê 0 A3 B3 D3 ... 0 0 0 úê N3,t ú ê N3,t - h ú ê 0 ú ê úê ú ê ú ê ú 0 0 A4 B4 ... 0 0 0 N4,t N4,t- h 0 ê ú ê ú = ê ú - ê ú ê : : : : : : : úê : ú ê : ú ê : ú ê 0 0 0 0 ... B D 0 úê N ú êN ú ê 0 ú ê I- 2 I- 2 ú ê I - 2,tú ê I- 2,t- h ú ê ú ê 0 0 0 0 ... AI- 1 BI- 1 DI- 1úê NI- 1,t ú ê NI- 1,t - h ú ê 0 ú ê úê ú ê ú ê ú ë 0 0 0 0 ... 0 AI BI ûë NI,t û ë N I ,t - h û ë DI N I +1, t û

(6.39) Tridiagonal Matrix Solution

Decomposition:

D1 Di g1 = - gi = - i = 2...I B1 Bi + Aigi- 1

R1 Ri - Aia i- 1 a 1 = a i = i = 2...I (6.40) B1 Bi + Aigi- 1

Backsubstitution:

NI,t =a I Ni,t = a i +gi Ni +1,t i = I - 1..1, -1 (6.41)

Matrix for solution over a global domain

éB 1 D1 0 0 ... 0 0 A1 ùé N1,t ù é N1,t - h ù êA B D 0 ... 0 0 0 úê N ú ê N ú ê 2 2 2 úê 2,t ú ê 2,t- h ú ê 0 A3 B3 D3 ... 0 0 0 úê N3,t ú ê N3,t - h ú ê úê ú ê ú 0 0 A4 B4 ... 0 0 0 N4,t N 4,t- h ê úê ú = ê ú ê : : : : : : : úê : ú ê : ú ê 0 0 0 0 ... B D 0 úê N ú êN ú ê I- 2 I- 2 úê I- 2,t ú ê I - 2,t- h ú ê 0 0 0 0 ... AI- 1 BI -1 DI -1 úê N I -1,t ú ê NI - 1,t- h ú ê úê ú ê ú ëD I 0 0 0 ... 0 AI BI ûë N I ,t û ë NI,t- h û (6.42)

DI = D0 A1 = AI+1 Crank-Nicolson Scheme

Crank-Nicolson form (6.44)

Ni,t - Ni,t- h é (uN )i+1,t - (uN)i- 1,t (uN )i+1,t - h - (uN )i- 1,t - h ù + êm c + (1 -mc ) ú h ë 2Dx 2Dx û é Ni+1,t - 2Ni,t + Ni- 1,t Ni+1,t- h - 2Ni,t- h + Ni- 1,t- h ù - Kêm c + (1 -mc) ú =0 ë Dx 2 Dx2 û

mc = Crank-Nicolson parameter

= 0.5 --> Crank-Nicolson solution = 0. --> explicit solution = 1 --> implicit solution

Tridiagonal form

AiNi- 1,t + BiNi,t + DiNi+1,t = Ei N i- 1,t - h + Fi N i, t - h + Gi Ni +1,t - h (6.45)

u K u K çæ ÷ö çæ ÷ö Ai = -mch + 2 Ei = (1 -m c)h + 2 è 2Dx Dx øi - 1 è 2Dx Dx øi - 1

2K 2K çæ ÷ö çæ ÷ö Bi = 1+mch 2 Fi = 1- (1- mc )h 2 è Dx ø i è Dx øi

u K u K çæ ÷ö çæ ÷ö Di = mch - 2 Gi = - (1- mc)h - 2 è2 Dx Dx øi +1 è 2Dx Dx øi +1 (6.46) Leapfrog Scheme

Ni,t - Ni,t- 2h (uN)i+1,t - h - (uN)i - 1,t- h Ni+1,t- h - 2Ni,t- h + Ni- 1,t- h + - K = 0 2h 2Dx Dx2

(6.48)

Matsuno Scheme

Prediction step (6.49)

Ni,est - Ni,t- h (uN)i +1,t- h - (uN )i- 1,t - h Ni +1,t- h - 2 Ni, t - h + Ni - 1,t- h + - K = 0 h 2 Dx Dx2

Correction step (6.50)

Ni,t - Ni,t- h (uN )i+1,est - (uN)i -1,est Ni+1,est - 2Ni,est + Ni- 1,est + - K = 0 h 2Dx Dx2 Heun Scheme

Ni,t - Ni,t- h 1 (uN)i+1,est - (uN)i- 1,est K Ni+1,est - 2Ni,est + Ni- 1,est + - h 2 2Dx 2 Dx2

1 (uN )i+1,t - h - (uN)i- 1,t- h K Ni+1,t - h - 2Ni ,t - h + Ni - 1,t - h + - = 0 2 2Dx 2 Dx 2

(6.51) Adams-Bashforth Scheme

Ni,t - Ni,t- h 3 (uN)i+1,t - h - (uN )i- 1,t- h 3 Ni+1,t - h - 2Ni,t- h + Ni- 1,t - h + - K h 2 2Dx 2 Dx 2

1 (uN )i+1,t - 2h - (uN)i - 1,t- 2h 1 Ni+1,t - 2h - 2Ni,t- 2h + Ni- 1,t - 2h - + K = 0 2 2Dx 2 Dx2

(6.52) Fourth-Order in Space Equation

Fourth-order central difference explicit solution

Ni,t - Ni,t- h (uN )i- 2,t - 8(uN )i- 1,t + 8(uN)i+1,t - (uN)i+2,t + h 12Dx

- Ni- 2,t +16Ni- 1,t - 30Ni,t +16Ni+1,t - N i+ 2,t - K = 0 12Dx2

(6.53)

Write in Crank-Nicolson and pentadiagonal form

AiNi- 2,t + Bi Ni -1,t + Di N i, t + EiN i+1,t + Fi Ni +2,t

= Pi Ni- 2,t - h + Qi Ni- 1,t- h + SiNi,t- h + TiNi+1,t - h + UiNi+2,t - h Second-Order Central Difference Form of Diffusion Term

Variable diffusion coefficient, variable grid spacing

K (N - N ) K (N - N ) i+1 2 i+1 i - i- 1 2 i i- 1 ¶ æ ¶N ö x - x x - x ç K ÷ = i+1 i i i- 1 (6.54) ¶x è ¶x ø xi+1 2 - xi- 1 2

Ki +12 = 0.5(Ki + K i+1) Ki - 1 2 = 0.5(Ki - 1 + Ki )

xi +1 2 = 0.5(xi + xi +1) xi - 1 2 = 0.5(xi - 1 + xi )

Simplified form

¶ æ ¶N ö ç K ÷ =b N +b N + b N (6.55) ¶x è ¶x ø K,i- 1 i- 1 K,i i K,i+1 i +1

2Ki - 12 b K,i- 1 = (6.56) (xi - xi- 1)(xi +1- xi- 1)

- 2[(xi+1 - xi )Ki- 1 2 + (xi - xi- 1)Ki +1 2 ] b K,i = (xi+1 - xi )(xi - xi -1)( xi+1 - xi- 1)

2Ki+1 2 b K,i+1 = (xi+1 - xi )( xi +1 - xi -1) Second-Order Central Difference Form of Advection Term

Variable wind speed, variable grid spacing

¶(uN) = g (uN) + g (uN ) + g (uN) (6.57) ¶x a,i- 1 i- 1 a,i i a,i+1 i +1

( xi+1 - xi )- 2( xi - xi- 1 ) ga,i- 1 = (6.58) (xi - xi- 1)(xi+1 - xi- 1)

(xi+1 - xi) - (xi - xi- 1) ga,i = (xi+1 - xi )(xi - xi -1)

xi - xi- 1 ga,i+1 = (xi+1 - xi )(xi+1 - xi- 1)

Coefficients from matrix

é ù 1 1 1 ég a,i- 1ù é0 ù ê úê ú ê ú ê- (xi - xi-1) 0 (xi+1 - xi) úê ga,i ú =ê1 ú (6.59) ê 2 2 úê ú ê ú ë( xi - xi-1) 0 (xi+1 - xi) ûë g a,i+1û ë0 û Second-Order Advection-Diffusion Equation With Variable Diffusion Coefficient and Grid Spacing

Crank-Nicolson form (6.60)

Ni,t - Ni,t- h = -mc [(gau -b K)N] +[(gau -b K)N] +[(gau - bK )N] h { i- 1 i i+1}t

- (1- mc ) [(gau - bK )N] + [(gau - b K )N ] +[(gau - bK )N ] { i - 1 i i+1}t- h

Write in tridiagonal form

AiNi- 1,t + BiNi,t + DiNi+1,t = Ei N i- 1,t - h + Fi N i, t - h + Gi Ni +1,t - h Two Dimensional Solution

Advection-diffusion equation in two dimensions

¶N ¶(uN ) ¶(vN) ¶ æ ¶Nö ¶ æ ¶Nö + + - ç Kh,xx ÷ - ç Kh,yy ÷ = 0 ¶t ¶x ¶y ¶x è ¶x ø ¶y è ¶y ø

(6.61)

Central difference approximation

Ni, j,t - Ni,j,t- h é (uN )i +1, j - (uN)i- 1,j ( vN)i, j+1 - ( vN)i,j - 1 ù + ê + ú h ê 2 Dx 2Dy ú ë ût

æ Ni- 1, j - 2 N i, j + Ni +1, j Ni, j-1 - 2Ni, j + Ni,j +1ö - ç Kh,xx 2 + Kh, yy 2 ÷ = 0 è Dx Dy ø t

(6.62)

Solve

Ai, j Ni- 1, j,t + Bi, j Ni, j ,t + Di, j Ni +1,j ,t + Ei, j Ni , j- 1,t + Fi,jNi, j+1,t = Ni, j ,t - h Semi-Lagrangian Method

Nx,t = Nx- uh,t - h (6.63) Finite Element Method

Advection equation at node i

¶N ¶(uN) i + i = 0 (6.64) ¶t ¶x

Trial = series expansion approximation to N = linear combination of basis functions

Ni » Ni (x) = å Nj ej (x) (6.65) j ej(x) = basis function j = trial space

Minimize residual by forcing its weighted average to zero over domain

R (x )e (x )dx = 0 (6.66) òx i i ei(x) = weight function ei(x) = ej(x)à Galerkin method of weighted residuals ei(x) ¹ ej(x)à Petrov-Galerkin technique

Residual in advection equation

é ¶Ni (x) ¶Ni(x) ù é¶ Ni ¶Niù é¶ Ni(x) ¶Ni(x)ù Ri (x ) = + u - +u = +u - 0 êë ¶t ¶x úû êë ¶t ¶x úû êë ¶t ¶x úû

(6.67) Finite Element Method

Substitute (6.67) and (6.65) into (6.66) (6.68)

é¶ Ni (x ) ¶Ni(x) ù + u ei(x)dx òx êë ¶t ¶x úû é æ ö æ öù ¶ ¶ = ê ç N e (x)÷ + u ç N e (x)÷ú e (x)dx òx ê ¶t çå j j ÷ ¶x çå j j ÷ú i ë è j ø è j øû

æ¶ Nj ö æ dej (x) ö = e (x)e (x)dx +u N e (x)dx = 0 å ç ¶t òx j i ÷ å ç j òx dx i ÷ j è ø j è ø

Take time difference of (6.68) over three nodes

Ni- 1,t - Ni- 1,t - h x Ni,t - Ni,t- h x ò i ei- 1(x)ei (x)dx + ò i +1ei (x)ei(x)dx h xi - 1 h xi - 1

Ni+1,t - Ni+1,t- h x + ò i +1 ei +1( x) ei( x)dx (6.69) h xi

æ xi dei- 1(x) xi +1 dei(x) ö ç Ni- 1,t ei(x )dx + Ni,t ei(x)dx÷ òx i- 1 dx òx i- 1 dx +uç ÷ =0 ç xi +1 dei +1(x ) ÷ ç +Ni+1,t ei(x )dx ÷ è òxi dx ø Finite Element Method

Define basis functions as chapeau functions

ì x - x i -1 x £ x £ x ï x - x i- 1 i ï i i- 1 ï xi+1 - x ei (x) = í xi £ x £ xi +1 (6.70) ï xi+1 - xi ï 0 all other cases îï

Solve each

x i xi æ xi - x öæ x - xi- 1 ö x - xi- 1 ò ei- 1(x)ei (x)dx = ò ç ÷ç ÷d x = xi - 1 xi-1 è xi - xi- 1 øè xi - xi-1 ø 6

(6.71)

Solution obtained once have been solved

(Ni- 1,t - Ni - 1,t - h)Dxi + (Ni,t - Ni,t - h )2(Dxi+1 + Dxi) + ( Ni+1,t - Ni+1,t - h )Dxi +1 6h

Ni+1,t - Ni- 1,t +u = 0 (6.72) 2 Tests With a Finite Element Method

Fig. 6.7. Preservation of a Gaussian peak during finite element transport after eight revolutions around a circular grid when

(a) uh Dx = 0.02. 1200 1000 800 600 400 200 0 Concentration (generic) -200 0 5 10 15 20 25 30 Grid cell number

(b) uh Dx = 0.6. 1200 1000 800 600 400 200 0 -200 Concentration (generic) -400 0 5 10 15 20 25 30 Grid cell number Pseudospectral Method

Advection equation

¶N ¶N + u = 0 (6.81) ¶t ¶x

Represent solution with infinite

¥ ik2px L N(x,t ) = å ak (t )e (6.82) k=0

Integrate both sides of (6.82) from 0 £ x £ L

1 L a (0 )= N(x,0)e- ik2p x Ldx (6.83) k L ò0

Truncate infinite series

K ik2px L N(x,t ) = å ak (t )e (6.84) k=0 Pseudospectral Method

Central time-difference approximation of (6.84)

¶N 1 æ K K ö » ç a eik2px L - a eik2px L÷ (6.85) ¶t 2h ç å k,t å k,t- 2h ÷ èk =0 k=0 ø

Partial derivative of (6.84) with respect to space

K ¶N ik2p ak,t- h = eik2px L (6.86) ¶x å L k=0

Substitute (6.85) and (6.86) into (6.81)

K K 1 ik2pak,t- h a - a eik2px L = - u eik2px L 2h å ( k,t k,t- 2h) å L k=0 k=0

(6.87)

Separate into K equations --> solve

ak,t - ak,t- 2h uik2pak,t- h = - (6.88) 2h L