Professional Documents
Culture Documents
for
Chapter 6
of
Fundamentals of Atmospheric Modeling
2nd Edition
Mark Z. Jacobson
Department of Civil & Environmental Engineering
Stanford University
Stanford, CA 94305-4020
jacobson@stanford.edu
March 10, 2005
ODEs and PDEs
Ordinary differential equation (ODE)
Equation with one independent variable
Fig. 6.1
Operator Splitting
Operator-split advection-diffusion equations (6.1-6.3)
N uN N
Kh,xx 0
t x x x
N vN N
Kh,yy 0
t y y y
N wN N
Kh,zz 0
t z z z
Examples:
dN DN N DN u Du
dt Dt x Dx x Dx
Finite Difference Example
First, replace continuous function ux with a finite number of
values in the x direction.
Fig. 6.2
Finite Difference Approximation
Second, define differences of du at point xi
--> Dui ui 1 ui1 central difference
Fig. 6.3
Taylor Series Expansion
Taylor series expansion at point x+Dx (6.11)
Nx 1 2 2 N x 1 3 3 Nx 1 4 4N
x ...
Nx Dx Nx Dx Dx Dx Dx
x 2 x
2 6 x
3 24 x
4
1 4N
O Dx 2 Dx 2 4
x ...
12 x
2nd-order central difference approx. of 2nd derivative (6.16)
2N x Nx Dx 2Nx Nx Dx
2 2
x Dx
Finite Difference Approximations
Subtract the Taylor series expansions (6.17)
N x 1 3 3 N x
Nx Dx Nx Dx 2Dx Dx ...
x 3 x
3
Rearrange (6.18)
N x N x Dx N x Dx
x
2Dx
O Dx 2
1 3N
O Dx 2 Dx 2 3
x ...
6 x
2nd-order central difference approx. of 1st derivative (6.20)
N x NxDx N xDx Ni1 Ni1
x 2Dx 2Dx
Finite Difference Approximations
First two terms of Taylor series
N x Nx Nx Dx Ni Ni1
x Dx Dx
Differencing Time Derivative
Central, forward, backward difference approximations (6.23)
Nt Nt h Nt h
t 2h
Nt Nt h Nt
t h
Nt Nt Nt h
t h
Consistency, Convergence
Convergence of finite difference analog (6.6)
N DN
lim
x Dx 0 Dx
Unbounded scheme:
Transported values artificially rise above the largest existing value
or fall below the smallest existing value in domain.
Nonmonotonic scheme:
Gradients are not preserved during transport
High Order Approximations
Finite difference approximation of ∂mN/∂xm
• Order of derivative = m
• Approximation expanded across q discrete nodes
• Minimum number of nodes = m + 1
• Maximum order of approximation = q - m
Example
Order of derivative: m=1
Number of nodes: q=5
--> Order of approximation: q-m=4
High Order Approximations
Grid spacing where q=5. Derivative is taken at x3. Fig. 6.4
x m i Ni i N* i xi x*
N*
x
i x i x*
1
2
2 N*
x 2 ...
i 1 i 1 i1 i1
Redefine (6.27)
q q
i Ni B0 N* B1
N*
x
B2
2 N*
x 2 ... Bn i x i x*
1
n!
n
i 1 i1
High Order Approximations
q
Bn i x i x*
1
n!
n
for n = 0…q - 1 (6.28)
i1
Multiply (6.28) through by n! and set matrix (6.29)
1 1 1 ... 1 0!B0
x x 1
1 *
x2 x* x3 x* ... x q x*
2
1!B
1
x x 2
2
1 *
x2 x* 2 x3 x* 2 ... x q x* 3
2!B2
: : : : :
:
x
1
x * q1
x 2 x * q1 x3 x* q1 ...
xq x *
q1
q
q 1!Bq1
1 1 i 1 0
Dx 0 i 1
st
1 -Order Backward Diff. Approx.
Solve matrix
1 1
i1 i
Dx Dx
1 1 1 1 1 i 2 0
2Dx Dx 0 Dx 2Dx i1 1
2
2Dx 2
Dx 2 0 Dx 2 2Dx i 0
2Dx 3 Dx 3 0 Dx 3 2Dx 3 0
i1
2Dx 4
Dx 4 0 Dx 4 2Dx 4
i 2
0
1 1 1 1 1 i 2 0
2Dx Dx 0 Dx 2Dx i1 0
2
2Dx 2
Dx 2 0 Dx 2 2Dx i 2
2Dx 3 Dx 3 0 Dx 3 2Dx 3 0
i1
2Dx 4
Dx 4 0 Dx 4 2Dx 4
i 2
0
u K
Di h 2
2Dx Dx i1
Advection-Diffusion Eqn. Solutions
Rearrange and write in tridiagonal matrix form (6.39)
R1 Ri Ai i1
1 i i=
B1 Bi Ai i1 2..I
c = Crank-Nicolson parameter
= 0.5 --> Crank-Nicolson solution (unconditionally stable all u, K)
2nd-order approximation in time
= 0. --> explicit (FTCS) solution
= 1 --> implicit solution
Crank-Nicolson Scheme
Tridiagonal form (6.45)
Ai Ni1,t Bi Ni,t Di Ni1,t Ei Ni1,t h Fi Ni,t h Gi Ni1,t h
u K u K
Ai c h 2 Ei 1 c h 2
2Dx Dx i1 2Dx Dx i 1
2K 2K
Bi 1 ch 2 Fi 1 1 c h 2
Dx i Dx i
u K u K
Di ch 2 Gi 1 c h 2
2Dx Dx i1 2Dx Dx i1
Leapfrog Scheme
2nd-order approximation in time (6.48)
Ni,est3 Ni,t h k3
10 -3
st
1 -order
-5 nd
Error
10 2 -order
Error
-7 th th
10 Runge-Kutta 5 -6
Adams-Bashforth order
-9 M atsuno
10
Forward Euler
-11
10
0.1 1 10
Time step (s)
(Ketefian and Jacobson 2004b) Fig. 6.5
Fourth-Order in Space Solution
Central difference implicit solution (6.56)
Ni,t Ni,t h uN i 2,t 8uN i1,t 8uNi1,t uNi 2,t
h 12Dx
Ni 2,t 16Ni1,t 30Ni,t 16Ni 1,t Ni 2,t
K 2 0
12Dx
uN
a,i1uNi1 a,i uN i a,i1 uNi 1
x
a,i
x i1 x i x i x i1
x i1 xi x i xi 1
xi x i1
a,i1
xi1 x i xi 1 xi1
Variable Grid Spacing, Diffusion
Expand analytical diffusion term (6.60)
N K N 2 N
K K 2
x x x x x
Second-order central-difference approx. to terms (6.61)
K
a,i1 Ki 1 a,i Ki a,i 1 Ki1
x
N
a,i1 Ni1 a,i Ni a,i1 Ni 1
x
2N
K
x
2 Ki d,i1 Ni 1 d,i Ni d,i 1 Ni1
Variable Grid Spacing, Diffusion
Solve matrix equation to obtain coefficients (6.63)
2
d,i1
x i x i1 x i1 x i1
2
d,i
xi 1 x i x i x i1
2
d,i1
x i1 xi x i1 x i1
Variable Grid Spacing Solution
Crank-Nicolson form (c=0.5--> 2nd order time, space) (6.66)
Ni,t Ni,th
h
c au K Ni 1 au K N i au K Ni1t
1 c a u K N i 1 a u K N i a u K N i1
th
Coefficients for diffusion term (6.65)
K,i1 a,i1Ki 1 a,i Ki a,i 1Ki1 a,i1 Ki d,i1
Nx,t Nx uh,t h
N i Ni x N j e j x
j
x Ri xei xdx 0
ei(x) = weight function
ei(x) = ej(x) --> Galerkin method of weighted residuals
ei(x) ≠ ej(x) --> Petrov-Galerkin technique
Finite Element Method
Substitute
Ri x
Ni x
t
u
N i x
x
N i x N j e j x
j
into
x Ri xei xdx 0
to obtain (6.74)
N i x Ni x
x t
u
x
ei x dx
x t
N j e j x u
x
N e
j j x e x dx
i
j j
N j de j x
t
x
e j x ei x dx u N j
x dx
ei x dx 0
j j
Finite Element Method
Take time difference of (6.74) over three nodes (6.75)
Ni1,t Ni1,t h xi Ni,t Ni,t h xi 1
xi 1 e i1 x e i x dx xi 1 e i x e i x dx
h h
Ni1,t Ni1,t h xi 1
xi ei 1x e i x dx
h
xi de x xi 1 de x
Ni 1,t
xi 1
i 1
dx
e i x dx Ni,t
xi 1 dx
i ei x dx
0
u
x i1 de x
i1,t
N
xi i1
dx
e i x dx
Finite Element Method
Define basis functions as chapeau functions (6.76)
x xi 1 xi 1 x x i
x i xi1
xi 1 x
e i x xi x xi 1
x i1 xi
0 all other cases
Ni1,t Ni1,t
u 0
2
1200
1000
Concentration
800
600
400
200
0
-200
0 5 10 15 20 25 30
Grid cell number
Fig. 6.8
Tests with a Finite Element Method
Preservation of a Gaussian peak during finite element transport after
Concentration (generic)
eight revolutions around a circular grid when uh/Dx= 0.6
1200
1000
Concentration
800
600
400
200
0
-200
-400
0 5 10 15 20 25 30
Grid cell number Fig. 6.8
Pseudospectral Method
Advection equation (6.87)
N N
u 0
t x
Represent solution with infinite Fourier series (6.88)
Nx,t ak te ik2x L
k0
For t=0, integrate both sides of (6.88) from 0≤x≤L (6.89)
1 L
ik 2x L
ak 0 N x, 0e dx
L 0
Pseudospectral Method
Truncate infinite series (6.90)
K
Nx,t ak te ik2x L
k0
Central time-difference approximation of (6.90) (6.91)
K K
N 1
ak,t e ik2x L ak,t 2h eik2x L
t 2h
k0 k0
Partial derivative of (6.90) with respect to space (6.92)
K
N
ik2ak,th ik2x L
e
x L
k0
Pseudospectral Method
Substitute (6.91) and (6.92) into (6.87) (6.93)
K K
ak,t ak,t 2h e
1 ik2x L ik2ak,t h ik2x L
u e
2h L
k0 k0
Fig
6.9
Bounded
Nonoscillatory
Monotonic
Final shape after six rotations around a 2-D grid. Walcek (2000)