download

Partial Differential Equations
11 July 2017
Metode Numerik
1
Classification of PDEs
• General form of linear second-order PDEs with
two independent variables
au xx  bu xy  cu yy  du x  eu y  fu  g  0
• linear PDEs: a, b, c,….,g = f(x,y) only
b 2  4 ac  0 , Hyperbolic (2 real roots)
 2
b  4 ac  0 , Parabolic (1 double root)
b 2  4 ac  0 , Elliptic
(2 complex roots)

11 July 2017
Metode Numerik
2
Heat Equation: Parabolic PDE
• Heat transfer in a one-dimensional rod
x=0
x=a
g1(t)
g2(t)
u
2u
c
; 0  x  a, 0  t  T
2
t
x
u(x,0)  f(x),
0 xa
11 July 2017
u(0, t)  g 1 ( t )
, 0t T

g2 ( t )
u( a , t )  Metode
Numerik
3
Discretize the solution domain in space
and time with h = x and k = t
t
10
9
8
7
6
5
4
3
Time
(j index)
2
1
0
0
11 July 2017
1
2
3
4
5
6
space
(i index)
Metode Numerik
7
8
9
10
x
4
Initial and Boundary Conditions
Explicit Euler method
10
9
8
7
u(0, t)
= g1(t)
u(a, t)
= g2(t)
6
5
4
3
2
1
0
0
1
2
3
4
5
6
7
8
9
10
Initial conditions : u(x,0) = f(x)
11 July 2017
Metode Numerik
5
Heat Equation
• Finite-difference
u(x,t)
tj+1
t
t
(i,j+1)
tj
(i-1,j) (i,j)
x
xi-1
(i+1,j)
xi xi+1
1
ut  ( ui , j  1  ui , j )
k
Central-difference
c
cu Numerik
 2 ( ui  1 , j  2 ui , j  ui 61 , j )
at time level j
11 July 2017
Metodexx
h
Forward-difference
x
Explicit Method
• Explicit Euler method for heat equation
h   x  a / n , x i  ih
let 
k   t  T / m , t j  jk
ut  cu xx
1
c
 ( ui , j  1  ui , j )  2 ( ui  1 , j  2 ui , j  ui  1 , j )
k
h
• Rearrange
ui , j  1
11 July 2017
ck
 ui , j  2 ( ui  1 , j  2 ui , j  ui  1 , j )
ck
c t
r 2 
h
h
 x2
 ru i  1 , j  ( 1  2 r )ui , j  ru i  1 , j
Stability: 0  r  0.5
Metode Numerik
7
Explicit Euler Method
ui , j  1  ru i  1 , j  ( 1  2 r )ui , j  ru i  1 , j
• Stable
r  0.01  ui , j  1  0.01 ui 1 , j  0.98 ui , j  0.01 ui  1 , j
r  0.1  ui , j  1  0.1 ui  1 , j  0.8 ui , j  0.1 ui  1 , j
r  0.4  ui , j  1  0.4 ui  1 , j  0.2 ui , j  0.4 ui  1 , j
r  0.5  ui , j  1  0.5 ui  1 , j  0.5 ui  1 , j
• Unstable (negative coefficients)
r  1  ui , j  1  ui  1 , j  ui , j  ui  1 , j

r  10  ui , j  1  10 ui 1 , j  19 ui , j  10 ui  1 , j
r  100  ui , j  1  100 ui 1 , j  199 ui , j  100 ui  1 , j

11 July 2017
Metode Numerik
8
Heat Equation: Explicit Euler Method
r = 0.5
11 July 2017
Metode Numerik
9
Example: Explicit Euler Method
• Heat Equation (Parabolic PDE)
ut  cu xx ; 0  x  1
u(x,0)  20  40 x

t
2t
u(0,
t)

20
e
,
u
(
1
,
t
)

60
e

• c = 0.5, h = 0.25, k = 0.05
2
20e
60e -2t
-t
1
11 July 2017
0
0
1
2
Metode Numerik
20 + 40 x
3
4
10
Example
• Explicit Euler method
ck ( 0.5 )( 0.05 )
r 2 
 0 .4
2
h
( 0.25 )
ui , j  1  ru i  1 , j  ( 1  2 r )ui , j  ru i  1 , j
 0 .4 u i  1 , j  0 . 2 u i , j  0 . 4 u i  1 , j
• First step: t = 0.05
 u0 ,1  20 e 0.05  19.02458849

 u1 ,1  0.4 u0 ,0  0.2 u1 ,0  0.4 u 2 ,0  0.4( 20 )  0.2( 30 )  0.4( 40 )  30

u2 ,1  0.4 u1 ,0  0.2 u2 ,0  0.4 u3 ,0  0.4( 30 )  0.2( 40 )  0.4( 50 )  40
u  0.4 u  0.2 u  0.4 u  0.4( 40 )  0.2( 50 )  0.4( 60 )  50
2 ,0
3 ,0
4 ,0
 3 ,1
u2017 60 e 0.10  54.29024508
11 July
Metode Numerik
11
 4 ,1
• Second step: t = 0.10
 u0 , 2

 u1 , 2


u2 ,2
u
 3 ,2


u4 ,2
 20 e 0.10  18.09674836
 0.4 u0 ,1  0.2 u1 ,1  0.4 u 2 ,1
 0.4( 19.02458849 )  0.2( 30 )  0.4( 40 )  29.6098354
 0.4 u1 ,1  0.2 u2 ,1  0.4 u3 ,1  0.4( 30 )  0.2( 40 )  0.4( 50 )  40
 0.4 u 2 ,1  0.2 u3 ,1  0.4 u4 ,1
 0.4( 40 )  0.2( 50 )  0.4( 54.2924508 )  47.71609803
 60 e 0.20  49.12384518
29.61
20e -t
11 July 2017
40
30
0
1
47.72
40
2
Metode Numerik
20 + 40 x
50
3
60e -2t
4
12
Heat Equation: Time-dependent BCs
r = 0.4
11 July 2017
Metode Numerik
13
Numerical Stability
• Stability for Explicit Euler Method
• It can be shown by Von Neumann
analysis that
1
r
2
1x
or  t 
2 c
2
• Switch to Implicit method to avoid
instability
11 July 2017
Metode Numerik
14
Explicit Euler Method: Stability
r=1
Unstable !!
11 July 2017
Metode Numerik
15
Implicit Euler method
Unconditionally Stable
10
9
8
7
u(a, t)
= g2(t)
6
u(0, t)
= g1(t)
5
4
3
2
1
0
0
1
2
3
4
5
6
7
8
9
10
Initial conditions : u(x,0) = f(x)
11 July 2017
Metode Numerik
16
Implicit Method
• Finite-difference
T(x,t)
tj+1
t (i-1,j+1) (i,j+1) (i+1,j+1)
tj
t
(i,j)
x
xi-1
xi xi+1
x
Forward-difference u  1 ( u
t
i , j  1  ui , j )
k
Central-difference
c
( ui  1 , j  1  2 ui , j  1  ui  1 , j  1 )
at2017
time level j+1 cu
xx 
11 July
2
Metode Numerik
17
h
Implicit Euler Method
• Implicit Euler method for heat equation
1
c
( ui , j  1  ui , j )  2 ( ui  1 , j  1  2 ui , j  1  ui  1 , j  1 )
k
h
 ru i  1 , j  1  ( 1  2 r )ui , j  1  ru i  1 , j  1  ui , j
• Tridiagonal matrix (Thomas algorithm)
1  2 r
 r





11 July 2017
r
1  2r
r
r
1  2r
r


r
  u1 , j  1   u1 , j  ru0 , j  1 
 

 u
u
2,j

  2 , j  1  
u3 , j
  u3 , j 1   



 r    

 

1  2 r  un  1 , j  1  un  1 , j  ru n , j  1 
• Unconditionally stable
Metode Numerik
18
Implicit Euler Method
r=2
Unconditionally stable
11 July 2017
Metode Numerik
19
Example: Implicit Euler Method
• Heat Equation (Parabolic PDE)
ut  cu xx ; 0  x  1
u(x,0)  20  40 x

t
2t
u(0,
t)

20
e
,
u
(
1
,
t
)

60
e

• c = 0.5, h = 0.25, k = 0.1
1
20e
60e -2t
-t
11 July 2017
0
0
1
2
Metode Numerik
20 + 40 x
3
4
20
Example
• Implicit Euler method
ck ( 0.5 )( 0.10 )
r 2 
 0.8
2
h
( 0.25 )
(  r )ui  1 , j  1  ( 1  2 r )u i , j  1  (  r )ui  1 , j  1  ui , j
( 0.8 )ui  1 , j  1  ( 2.6 )u i , j  1  ( 0.8 )ui  1 , j  1  ui , j
1  2 r
 r

 0
11 July 2017
r
1  2r
r
  u1,1  u1,0  ru0 , 1 

 


 r  u 2 , 1   u 2 ,0

1  2 r  u3 , 1  u3 ,0  ru 4 , 1 
0
Metode Numerik
21
• Solve the tridiagonal matrix
0   u1 ,1   30  0.8( 20 e 0.1 )
 2.6  0.8

  0.8 2.6  0.8  u   40


  2 ,1  
 0
 0.8 2.6  u 3 ,1  50  0.8( 60 e 0.2 )
 u1 ,1   28.95515793 

 

 u 2 ,1    38.50751457 
u  46.19426454 

 3 ,1  
28.96
1
38.51
46.19
20e -t
11 July 2017
0
60e -2t
0
1
2
Metode Numerik
20 + 40 x
3
4
22
Crank-Nicolson method
Implicit Euler method : first-order in time
Crank-Nicolson : second-order in time
10
9
8
u(0, t)
= g1(t)
u(a, t)
= g2(t)
7
6
5
4
3
2
1
0
0
11 July 2017
1
2
3
4
5
6
7
8
9
10
Initial conditions
Metode Numerik: u(x,0) = f(x)
23
Crank-Nicolson Method
• Crank-Nicolson method for heat equation
• Average between two time levels
1
c
( ui , j  1  ui , j ) 
( ui  1 , j  2 ui , j  ui  1 , j )
2
k
2h
c
 2 ( ui  1 , j  1  2 ui , j  1  ui  1 , j  1 )
2h
• Tridiagonal matrix

r
r
r
r
ui  1 , j  1  ( 1  r )ui , j  1  ui  1 , j  1  ui  1 , j  ( 1  r )ui , j  ui  1 , j
2
2
2
2
• Unconditionally stable (neutrally stable)
• 2017
Oscillation may
occur
11 July
Metode Numerik
24
General Two-Level Method
• General two-stage method for heat equation
1
c
( ui , j  1  ui , j )  2 ( ui  1 , j  2 ui , j  ui  1 , j )
k
h
c( 1   )

( ui  1 , j  1  2 ui , j  1  ui  1 , j  1 )
2
h
• Weighted-average of spatial derivatives
between two time levels n and n+1
 λ  0 : implicit Euler scheme

 λ  1 : explicit Euler scheme
 λ  1/2 : Crank
- Nicolson scheme 25
11 July 2017
Metode Numerik
Example: Crank-Nicolson Method
• Heat Equation (Parabolic PDE)
ut  cu xx ; 0  x  1
u(x,0)  20  40 x

t
2t
u(0,
t)

20
e
,
u
(
1
,
t
)

60
e

• c = 0.5, h = 0.25, k = 0.1
1
20e
60e -2t
-t
11 July 2017
0
0
1
2
Metode Numerik
20 + 40 x
3
4
26
Example
• Crank-Nicolson method
r
ck ( 0.5 )( 0.10 )

 0.8
2
2
h
( 0.25 )
r
r
r
r
 ui  1, j  1  (1  r)u i, j  1  ui  1, j  1  ui  1, j  (1  r)u i, j  ui  1, j
2
2
2
2
 0.4ui  1, j  1  1.8ui, j  1  0.4ui  1, j  1  0.4ui  1, j  0.2ui, j  0.4ui  1, j
• Tridiagonal matrix (r = 0.8)
r

1

r


2
 r

1 r
 2
r
 0
 2017  2
11 July
r
r

r

0 
u

(
1

r
)
u

u

u
0 ,0
1 ,0
2 ,0
0 ,1 

2
2
2
 u 1 ,1  


r 
r
 r
  u 2 ,1    u1 ,0  ( 1  r )u 2 ,0  u 3 ,0

2 
2
2
 

u
r
r
r
3
,
1

 
1  r 
u 2 ,0  ( 1  r )u 3 ,0  u4 ,0  u4 ,1 
 2

27
2
2
 Metode Numerik
• Solve the tridiagonal matrix
0   u1 ,1  0.4 ( 20 )  0.2( 30 )  0.4 ( 40 )  0.4 ( 20 e 0.1 )
 1.8  0.4

  0.4 1.8  0.4  u   0.4 ( 30 )  0.2( 40 )  0.4 ( 50 )


  2 ,1  
 0
 0.4 1.8  u 3 ,1  0.4 ( 40 )  0.2( 50 )  0.4 ( 60 )  0.4 ( 60 e 0.2 ) 
 u1 ,1   29.42144598 

 

 u 2 ,1    39.29975855 
u  47.42746748 

 3 ,1  
 37.23869934 


 40

69.64953807 


29.42
1
39.30
47.43
20e -t
11 July 2017
0
60e -2t
0
1
2
Metode Numerik
20 + 40 x
3
4
28
Implicit Euler method
r=2
Unconditionally stable
11 July 2017
Metode Numerik
29
Heat Equation with Insulated
Boundary
• No heat flux at x = 0 and x = a
x=0
ux(0,t) = 0
x=a
ux(a,t) = 0
u
2u
c
; 0  x  a, 0  t  T
2
t
x
u(x,0)  f(x),
0 xa
11 July 2017
u x (0, t)  0
,
0  t T

0 Numerik
u x ( a , t ) Metode
30
Insulated Boundary
• No heat flux at x = a
ux ( a ,t ) 
un  1 , j  un  1 , j
x n 1  x n1
 0  un  1  un  1
ux(a,t)=0
xn-1
xn
xn+1
x=a
un , j  1  run1 , j  ( 1  2 r )un , j  run 1 , j
11 July 2017
 2 run1 , j  ( 1  2 r )un , j
Metode Numerik
31
Terima kasih
11 July 2017
Metode Numerik
32