05-lecture 411.50KB

advertisement
LECTURE 5
Parabolic PDEs
1
Aim of Lecture
• So far in previous lectures we have discussed:
– Elliptic partial differential equations - Laplace and
Poisson’s Equations
– Discretisation using Finite Differences
– Use of Excel to solve Elliptic PDEs
• This week we will discuss
– Parabolic PDEs
– Solution of Parabolic PDEs using Finite Difference
Methods
– Explicit and Implicit Methods
– Solving Parabolic PDEs using Excel
2
Parabolic PDEs
• General Parabolic Equation
u
 2u
 2  f
t
x
where t is time and u(x,t) is the dependent variable and f(x,t)
is a source term.
• Parabolic PDEs are evolution equations, for example, they
represent phenomena that is changing in time. In this course
we will only look at equations with two independent
variables: space (x) and time (t).
• Finite Difference Methods will be used to solve Parabolic
PDEs
3
Finite Difference Method
• Method based on truncated Taylor series
ui 1, j  ui , j
u

x i , j
h
ui , j  ui 1, j
u

x i , j
h
ui 1, j  ui 1, j
u

x i , j
2h
ui 1, j  2ui , j  ui 1, j
 2u

x 2 i , j
h2
- Forward difference
j+1
j
j -1
i -1
- Backward difference
i
i+1
- Central difference
- Central difference
• Above approximations can be substituted for differentials in the PDE.
4
 : scalar
2
u
 2u
 2
t
x
j=1
• Consider one-dimensional PDE
3
4
Finite Difference Method for
Parabolic PDEs
i=1
2
space
3
4
ui , j 1  ui , j
u

 O(t ) - Forward difference in time
t i , j
t
ui 1, j  2ui , j  ui 1, j
 2u
2


O(

x
) - Central difference in space
2
2
x i , j
x
5
Explicit Method
u
 2u
 2
t
x
ui , j 1  ui , j
ui 1, j  2ui , j  ui 1, j
x 2
t
Therefore parabolic equation can be written as:
ui , j 1  ui , j
t

ui 1, j  2ui , j  ui 1, j
x 2
Difference equation is:
ui , j 1  ui , j  r (ui 1, j  2ui , j  ui 1, j )
Time (j+1)
r
t
x 2
Time (j)
SCHEME is ORDER (t, x2)
6
Example - Explicit Method
Consider the following rod (length 1m) between two pieces of ice.
ICE
ICE
The partial differential equation governing heat loss from this rod is
given by
u  2u
 2
0  x 1
t x
u (0, t )  u (1, t )  0
u ( x,0)  2 x
0  x  0.5
u ( x,0)  2(1  x)
0.5  x  1
Boundary Conditions
Initial Conditions
7
Example
Use x = 0.1 and t = 0.001. Therefore r = 0.1. Also we can
assume symmetry around x = 0.5.
u
0
x
ICE
i=0
1
2
3
4
5
6
Symmetry at i=5 means that u6,j = u4,j.
The finite difference approximation for each node is given by.
ui, j 1  ui , j  0.1(ui 1, j  2ui, j  ui 1, j )
8
Example
Use previous approximation to find changes in temperature
for first ten time steps.
i=0
x=0
t=0
t=0.001
t=0.002
t=0.003
t=0.004
t=0.005
.
.
t=0.01
.
.
t=0.02
1
0.1
2
0.2
3
0.3
4
0.4
5
0.5
6
0.6
0
0
0
0
0
0
0.2
0.2
0.2
0.2
0.2
0.2
0.4
0.4
0.4
0.4
0.4
0.3999
0.6
0.6
0.6
0.5996
0.5986
0.5971
0.8
0.8
0.796
0.7896
0.7818
0.7732
1
0.96
0.928
0.9016
0.8792
0.8597
0.8
0.8
0.796
0.7896
0.7818
0.7732
0
0.1996
0.3968
0.5822
0.7281
0.7867
0.7281
0
0.1938
0.3781
0.5373
0.6486
0.6891
0.6486
9
Courant Number = 1
Now let t = 0.01. Therefore r = 1. In this case the solution is
unstable: .
I=0
x=0
t=0
t=0.01
t=0.02
t=0.03
t=0.04
0
0
0
0
0
1
0.1
0.2
0.2
0.2
0.2
0.2
2
0.2
3
0.3
4
0.4
5
0.5
6
0.6
0.4
0.4
0.4
0.4
0.0
0.6
0.6
0.6
0.2
1.4
0.8
0.8
0.4
1.2
-1.2
1
0.6
1.0
-0.2
2.6
0.8
0.8
0.4
1.2
-1.2
10
Explicit Method
• It can be shown (later lecture) that the Explicit
Scheme is only stable when the Courant number
(r) :
0.5x 2
r  0.5
i.e
t 

• Therefore for a given mesh density we have a
restriction on the time step size. To overcome
this limitation on the time step size we use
implicit methods.
11
Implicit Methods
u
 2u
 2
t
x
• For explicit methods the space derivative is
approximated at the previous time step.
• For implicit methods the space derivative is
approximated at the latest time step.
• An example of an implicit method is CrankNicholson
12
Implicit Methods
ui , j 1  ui , j
t
u
 2u
 2
t
x
ui 1, j 1  2ui , j 1  ui 1, j 1
x 2
Therefore parabolic equation can be written as:
ui , j 1  r (ui 1, j 1  2ui , j 1  ui 1, j 1 )  ui , j
Time (j+1)
r
t
x 2
Time (j)
• Requires Matrix Solvers.
• Known as the Fully Implicit Method.
SCHEME is ORDER (t, x2)
13
Implicit Method - Crank Nicholson
For the explicit scheme we approximated the derivatives at (i,j)
using:
2
u
u
 2
t
x
ui , j 1  ui , j
t
ui 1, j  2ui , j  ui 1, j
x 2
Central difference
Forward difference
Approximating the derivatives at mid-point in time (i,j+0.5) we
have:
2
ui , j 1  ui , j
u
u
 2
t
x
2(0.5t )
Central difference
at (i,j+0.5)
1  ui 1, j  2ui , j  ui 1, j ui 1, j 1  2ui , j 1  ui 1, j 1 



2
2
x
x 2

Central difference Central difference
at (i,j)
at (i,j+1)
14
Implicit Method - Crank Nicholson
Crank Nicholson in 1947 proposed the above method to allow
greater time steps in their calculations. The resulting difference
equation is:
 rui 1, j 1  (2  2r)ui, j 1rui 1, j 1  rui 1, j  (2  2r)ui, j  rui 1, j
r
t
x 2
Time (j+1)
Time (j)
SCHEME is ORDER (t2, x2)
In this case we have three unknowns on the RHS of the equation.
Therefore the new value ui,j+1 is not given directly in terms of
known values as is the case of the Explicit method.
15
Explicit / Implicit Comparisons
i-1
i
i+1
Explicit
O(t, x2)
j+1
j
j-1
j-1
j-1
j
j
j+1
j+1
• Computational molecules show differences between the schemes
• If there is more than one node at timestep j+1 the scheme is implicit
i-1
i
i+1
Crank-Nicholson
O(t2, x2)
i-1
i
i+1
Fully Implicit
O(t, x2)
16
Explicit - Implicit Methods
Comparisons
Explicit methods are suitable for large scale problems where the
phenomena occurs quickly. For example a car crash simulation. In
this case, at time t, we do not need to solve a matrix system as:
ui , j 1  uij  r (ui 1, j  2ui , j  ui 1, j )
r
t
x 2
Advantage of implicit methods is that we can use larger time
steps, but we also need to store and solve a matrix system.as:
 rui 1, j 1  (2  2r)ui, j 1rui 1, j 1  rui 1, j  (2  2r)ui, j  rui 1, j
17
Example
Use Crank-Nicholson scheme to find system of equations for time
= 0.01.Show that they give the results given in the table below.
u
0
x
ICE
i=0
i=0
x=0
t=0
t=0.01
0
0
1
0.1
0.2
0.1989
1
2
3
4
5
6
2
0.2
3
0.3
4
0.4
5
0.5
0.4
0.3956
0.6
0.5834
0.8
0.7381
1
0.7681
6
0.6
0.8
0.7381
18
Solvers for Parabolic PDEs
• Equations resulting from an explicit scheme are easy to
solve as the variable at the latest time step is dependent on
variables ALL at the previous time step. For example
ui , j 1  uij  r(ui1, j  2ui , j  ui1, j )
• Equations resulting from an implicit scheme require Matrix
solvers (Direct or Iterative) as the variable at the latest time
also depends on unknown values at that time step. For
example
 rui 1, j 1  (2  2r)ui, j 1rui 1, j 1  rui 1, j  (2  2r)ui, j  rui 1, j
• For the Implicit method we can use the Gauss Seidel
iterative method to solve the matrix system.
19
Excel for Solving Parabolic
PDEs using Finite Difference
Equations
20
USING EXCEL
• Ideal for solving Finite Difference Equations
i-1
i
j-1
j
j+1
TIME
i+1
DISTANCE (X)
21
Explicit Formulation
• No need for iteration. One press of F9
solves equations
22
Explicit Scheme
Courant Number (r)
Parameters:
rr (= dt/dx^2)
dx
dt
Time (=A25+dt)
Explicit Equation
D30=D29+rr*(C29-2*D29+E29)
23
Implicit Scheme
• Need to use Iterative
Methods
• IF Command
FLAG Parameter (1 or 0)
– IF(CONDITION,
THEN DO THIS,
ELSE DO THIS)
– e.g if(flag=0,0,…)
Implicit Equation
=if(flag=0,0,(rr*B27+(2-2*rr)*C27+rr*D27+rr*B28+rr*D28)/(2+2*rr))
[B28 & D28 are at current time-step]
24
Download