Download - MA557/MA578/CS557 Lecture 5
2
Homework 2 correctionQ4) Implement the numerical approximation of:
By:
2
3 0
( , 0) x
t x
x t e
1 1
11
0 1
00
Geometry:
14, 4,
1 1
Scheme:
1
3
Initial Condition :
, 02
Boundary Condition :
0
N i N
n n ni i i
i ii
N i ix x x x x
N N
dt
dx
x xt
3
Homework 2 contQ4 cont)
For N=10,40,160,320,640,1280 run to t=10, with: dx = (8/(N-1)) dt = dx/6
Use
On the same graph, plot t on the horizontal axis and error on the vertical axis. The graph should consist of a sequence of 6 curves – one for each choice of dx.
Comment on the curves.
NOTE: For the purposes of this test we define error as:
1
1max ,
2n n i i
ii N
x xerror ndt
10 0 11n n n
N
dt dtu udx dx
4
Lecture 5
• We will define stability for a numerical scheme and investigate stability for the upwind scheme.
• We will compare this scheme with a finite difference scheme.
• We will consider alternative ways to approximate the flux functions.
5
Basic Upwind Finite Volume Method
1
1
n ni i n n
i i
dxu u
dt
Approximate time derivative and look forsolution
dtudx
111n n n
i i i
Note we must supply a value for the left most average at each time step: 0n
Recall
1, ,i i i
dq dx uq x t uq x t
dt
Approximate fluxes with upwind flux
1i i i
dq dx uq uq
dt
n ni iq
6
Convergence• We have constructed a physically reasonable numerical scheme to
approximate the advection equation.
• However, we need to do some extra analysis to determine how good at approximating the true PDE the discrete scheme is.
• Let us suppose that the i’th subinterval cell average of the actual solution to the PDE at time T=n*dt is denoted by
1 1
1
1
1
1 1, ,
where q satisfies:
, , ,
i i
i i
i
i
x xni
i i x x
x
i i i
x
q q x ndt q x ndtx x dx
d dq x t dx dxq uq x t uq x t
dt dt
7
Error Equation• The goal is to estimate the difference of the exact
solution and the numerically obtained solution at some time T=n*dt.
• So we are interested in the error:
• For the given finite volume scheme dt and dx will be related in a fixed manner (i.e. dt = Cdx for some C, independent of dx).
• Suppose we let and then
the scheme is said to be of order s.
, nn n ni i i
TE q
dt
0dt n sE O dt
8
Norms and Definitions
• We define the discrete p-norms:
• We say that the scheme is convergent at time T in the norm ||.|| if:
• It is said to be accurate of order s if:
1/ pip
ipi
E dx E
0lim 0n
dtndt T
E
as 0n sE O dt dt
9
Local Truncation Error• Suppose at the beginning of a time step we actually have the exact
solution -- one question we can ask is how large is the error committed in the evaluation of the approximate solution at the end of the time step.
• i.e. choose
• Then
• We expand about xi,tn with Taylor series:
11
1 1
1
1:
n ni i
n n ni i i
n n ni i i
q
dt dtu q u q
dx dx
R qdt
11,n ni iq q
2 23
1 2
2 21 3
2
, , ( )2
, , ( )2
n ni i i n i n
n ni i i n i n
q dx qq q dx x t x t O dx
x x
q dt qq q dt x t x t O dt
t t
10
Estimating Truncation Error
• Inserting the formulas for the expanded q’s:
11
2 23
2
2 23
2
1: 1
1
1, , ( )
2
, , ( )2
n n n ni i i i
ni
ni i n i n
ni i n i n
dt dtR u q u q q
dt dx dx
dtu q
dx
dt q dx qu q dx x t x t O dx
dt dx x x
q dt qq dt x t x t O dt
t t
11
Estimating Truncation Error
• Removing canceling terms:
11
2 23
2
2 23
2
1: 1
1
1, , ( )
2
, , ( )2
n n n ni i i i
ni
ni i n i n
ni i n i n
dt dtR u q u q q
dt dx dx
dtu q
dx
dt q dx qu q dx x t x t O dx
dt dx x x
q dt qq dt x t x t O dt
t t
12
Estimating Truncation Error
• Simplifying:
2 23
2
22
2
1, , ( )
2:
, , ( )2
i n i n
ni
i n i n
q dx qu dx x t x t O dx
dx x xR
q dt qx t x t O dt
t t
2 2
2 22 2
, ,
:
, ( ) , ( )2 2
i n i n
ni
i n i n
q qx t u x t
t xR
dx q dt qu x t O dx x t O dt
x t
13
Final Form
• Using the definition of q
2 2
2 22 2
, ,
:
, ( ) , ( )2 2
i n i n
ni
i n i n
q qx t u x t
t xR
dx q dt qu x t O dx x t O dt
x t
2 2
2 22 2
: , ( ) , ( )2 2
ni i n i n
dx q dt qR u x t O dx x t O dt
x t
2
22
: 1 , ( )2
ni i n
udx udt qR x t O dx
dx x
Using that:2 2
22 2
q qu
t x
14
Interpretation of Consistency
2
22
: 1 , ( )2
ni i n
udx udt qR x t O dx
dx x
So the truncation error is O(dx) under the assumption that dt/dx is a constant..
This essentially implies that the numerical solution diverges from the actual solution by an error of O(dx) every time step.
If we assume that the solution q is smooth enough then the truncation error converges to zero with decreasing dx. This property is known as consistency.
15
Error Equation• We define the error variable:
• We next define the numerical iterator N:
• Then:
• So the new error consists of the action of the numerical scheme on the previous error and the error commited in the approximation of the derivatives.
n n ni i iq E
1n nN
1 1
1
n n n n
n n n n n
n n n n
E N q E q
N q E N q N q q
N q E N q dtR
16
Abstract Scheme• Without considering the specific construction of the
scheme suppose that the numerical N operator satisfies:
• i.e. N is a contraction operator in some norm then…
N P N Q P Q
17
Estimating Error in Terms of Initial Error and Cumulative Truncation Error
1
1
1
1
1 1
1 0
1
triangle inequality
contraction property of
.....
n n n n n
n n n n n
n n n n n
n n n
n n n
m nn m
m
E N q E N q dtR
E N q E N q dt R
E q E q dt R N
E E dt R
E dt R dt R
E E dt R
by induction
18
Error at a Time T (independent of dx,dt)
• If the method is consistent (and the actual solution is smooth enough) then:
• As dx -> 0 the initial error ->0 and consequently the numerical error at time T tends to zero with decreasing dx (and dt).
1 0
1
1 0
1,..max
m nn m
m
n m
m n
E E dt R
E E T R
1 0 nE E T O dx
19
Specific Case: Stability and Consistency for the Upwind Finite Volume Scheme
• We already proved that the upwind FV scheme is consistent.
• We still need to prove stability of.
111n n n
i i i
20
Stability in the Discrete 1-norm
11
11 1
11
1
11
1 1
11 1
1
01
0 1
1
1 triangle inequality
1 assuming 0 1
n n ni i i
Nn n
ii
Nn ni i
i
N Nn ni i
i i
Nn n
ii
n n
dx
dx
dx dx
dx dx
dx
So here’s the interesting story. In the case of a zero boundarycondition then we automatically observe that the operator is a contraction operator.
21
Relaxation on Stability Condition
• Previous contraction condition on the numerical iterator N
• A less stringent condition is:
• Where alpha is a constant independent of dt as dt->0
N P N Q P Q
1N P N Q dt P Q
22
Relaxation on Stability Condition
• In this case the stability analysis yields:
1
1
1
1 1
11 0
1
0
1,..
1
1 1
.....
1 1
max Ndt=T
n n n n n
n n n n n
n n n
n n n
m nn n mn m
m
T m
m n
E N q E N q dtR
E q E q dt R
E dt E dt R
dt dt E dt R dt R
E dt E dt dt R
e E T R
23
Interpretation
• Relaxing the stability yields a possible exponential growth – but this growth is independent of T so if we reduce dt (and dx) then the error will decay to zero for fixed T.
1 0
1,..max , Ndt=Tn T m
m nE e E T R
24
Next Lecture (6)
• Alternative flux formulations
• Alternative time stepping schemes