BVPs

advertisement
10.34, Numerical Methods Applied to Chemical Engineering
Professor William H. Green
Lecture #21: TA Tutorial on BVPs, FEMLAB®.
BVPs
What methods to use for each situation:
•
•
•
1D
o
Finite Differences
o
ODE’s
ƒ 2nd order: Î Two 1st order
ƒ 1st order: Æ Shooting
2D
o
Finite Differences
o
Method of Lines
ƒ Stiff
o
Non-uniform grid
o
Finite Element
o
Finite Volume
x
x
Figure 1. Boundary layer.
Capture the fast
portion of reaction
with adaptive
time stepping
Rxn
fast
3D
Figure 2. Adaptive time stepping.
Generally use commercial code
Coding Boundary Conditions
Linear: A·x = b
⎛%
⎜
⎜%
⎜
⎜
⎜
⎜
⎜
⎜
⎜
⎜%
⎜
⎜⎜ 0
⎝
state variables
at grid points
0⎞
⎟
⎟
0
%⎟
⎟
% % %
⎟
⎟
% % %
⎟
⎟
% % %
⎟
% % %
0
⎟
%
% % %⎟
⎟
%
% %⎟⎠
%
%
% %
% % %
%
BC: x1,j = 1
1
⎡
⎢
⎢
⎢
⎢
⎣
1
4
⎡
1
−
⎢
3
⎢
⎢
⎢
⎢
⎣
⎡ x1,1 ⎤
⎢ x
⎥
⎢ i, j ⎥
⎢ # ⎥
⎥
⎢
⎢⎣ x N x , N y ⎥⎦
=0
⎛ 3θ1, j − 4θ 2, j − θ 3, j
≅ −⎜⎜
2Δx
1, j
⎝
⎤ ⎡ x1,1 ⎤ ⎡1⎤
⎥⎢ # ⎥ ⎢# ⎥
⎥⎢ ⎥ = ⎢ ⎥
⎥ ⎢ x1, 2 ⎥ ⎢1⎥
⎥⎢ ⎥ ⎢ ⎥
⎦⎣ ⎦ ⎣ ⎦
dθ
dx
1
⎤
"⎥ ⎡ x1,1 ⎤ ⎡0⎤
3
⎢ ⎥ ⎢ ⎥
⎥ ⎢ x 2,1 ⎥ ⎢ ⎥
⎥⎢x ⎥ = ⎢ ⎥
⎥ ⎢ 3,1 ⎥ ⎢ ⎥
⎥⎣ # ⎦ ⎣ ⎦
⎦
for
dθ
dx
⎞
⎟
⎟
⎠
=0
1, j
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical
Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of
Technology. Downloaded on [DD Month YYYY].
Nonlinear
use fsolve
BC: x1,j = 1
x1,j – 1 = 0
{set to zero}
Non-Uniform Grid
Throw out all original equations
polynomial between three points
f
⎡ x − xk ⎤
⎥
k =0 ⎣ i − x k ⎦
N
p(x) = ΣfiLi(x)
Li(x) =
∏⎢x
k ≠i
x
f ( x) = f1
df
dx
df
dx
Figure 3. A graph of a polynomial fit of three points.
( x − x 2 )( x − x3 )
( x − x1 )( x − x3 )
( x − x1 )( x − x 2 )
+ f2
+ f3
( x1 − x 2 )( x1 − x3 )
( x 2 − x1 )( x 2 − x3 )
( x3 − x1 )( x3 − x 2 )
: differentiate the above expression f(x) and evaluate at x2.
x2
= f1
x2
d2 f
dx 2
=
x2
( x 2 − x3 )
+
(x1 − x2 )(x1 − x3 )
f2
2 x 2 − x3 − x1
(x2 − x1 )
+ f3
(x3 − x1 )(x3 − x 2 )
(x2 − x1 )(x2 − x3 )
2 f3
2 f1
2 f2
+
+
(x1 − x2 )(x1 − x3 ) (x2 − x1 )(x2 − x3 ) (x3 − x1 )(x3 − x2 )
MatLAB Equation: *nonuniform_example*
} huge jump
Figure 4. Graph of
a function that is
steep in the
beginning.
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 21
Page 2 of 4
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical
Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of
Technology. Downloaded on [DD Month YYYY].
Scaling
vz
⎡ ∂ 2C
∂C A
∂ 2C A ⎤
= D ⎢ 2A +
+ k (C AC B − C AB / K )
2 ⎥
∂z
z
y
∂
∂
⎣
⎦
Z=z
Y=y
y
b
z
L
L
b
∂C A ⎛ DL ⎞ ∂ 2 C A ⎛ D ⎞ ∂ 2 C A ⎛ L
⎟
⎟⎟
= ⎜⎜
+ ⎜⎜
+ ⎜⎜
2 ⎟
2
2
v
L
∂Z
v
b
Y
Z
∂
∂
z
⎝
⎠
⎝ vz
⎝ z ⎠
⎞
⎟⎟ R
⎠
∂C A
∂ 2C A
= 10 −3
⇒ (dy )2 = 10 −3 δz
2
∂Z
∂Y
−1
so if δz = 10 , choose δy = 10 −2
Figure 5. Diagram
of pipe flow with
reaction and
diffusion.
CAo
} divide into 100
Figure 6. Non-uniform grid.
y
(b-δ)
Figure 7. Division of problem into δ and (b-δ) regions.
2
∂C A
−9 ∂ C A
= 10
∂z
∂z 2
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 21
Page 3 of 4
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical
Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of
Technology. Downloaded on [DD Month YYYY].
Problem 1
Using FEMLAB®
* space dimension: axial symmetry 2D
axis/grid setting:
18
rmin = -0.01
rmax = 0.06
zmin = -1
zmax = 20
0.03
Subdomain settings:
Figure 8. Diagram of
FEMLAB Example.
r = 0.001(r-(r/0.05)^2)
Boundary settings:
mesh mode puts in finite elements.
Solve the problem.
DONE IN UNDER 3 MINUTES!!!
10.34, Numerical Methods Applied to Chemical Engineering
Prof. William Green
Lecture 21
Page 4 of 4
Cite as: William Green, Jr., course materials for 10.34 Numerical Methods Applied to Chemical
Engineering, Fall 2006. MIT OpenCourseWare (http://ocw.mit.edu), Massachusetts Institute of
Technology. Downloaded on [DD Month YYYY].
Download