0% found this document useful (0 votes)
54 views

Lecture On Advanced Mathematical Technques

This document summarizes the testing of numerical methods for solving partial differential equations. It discusses using a 4th-order Runge-Kutta time integrator and varying spatial differencing methods like 2nd order and 4th order central differencing. Error analysis was performed by varying the number of grid points and estimating the order of accuracy. Both stable and unstable differencing options were tested, showing instability growing with the unstable choice. The testing followed best practices of isolating variables and checking results against theoretical predictions.

Uploaded by

Debayan Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Lecture On Advanced Mathematical Technques

This document summarizes the testing of numerical methods for solving partial differential equations. It discusses using a 4th-order Runge-Kutta time integrator and varying spatial differencing methods like 2nd order and 4th order central differencing. Error analysis was performed by varying the number of grid points and estimating the order of accuracy. Both stable and unstable differencing options were tested, showing instability growing with the unstable choice. The testing followed best practices of isolating variables and checking results against theoretical predictions.

Uploaded by

Debayan Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 39

Numerical Methods for Partial

Differential Equations
CAAM 452
Spring 2005
ecture !
"nstructor# $im %ar&urton
CAAM 452
Spring 2005
Summar' of Small $heta Anal'sis
(
$he dominant remainder term in this anal'sis
relates to a commonl' used) ph'sicall' moti*ated
description of the shortfall of the method#
( )
( )
{ }
( )
( )
{ }
( )
( )
{ }
( )
3
3
3
3
2
5
2
5
1
2
2
2
2
0
1
4
2
5
4
3!
!
!
0
0
0
0
m
m
m
m
m
m
m
t
d
t
m
O
i ct
dx
L
m m
t
m
c O
i ct
dx
L
m m
it
m
c O
i ct
dx
L
m m
i i
m
c t
i c
i
t
t
dx
t
dx
m
x
x
L
d
m
du
c u u u e e
dt
du
c u u u e e
dt
du
c u u u e e
dt
du
c u u u e e
dt

+
+
+

+
+





r
r
r
r
r
r
r
r
( )
{ }
7
m
t
O
dx

Dissipati*e
+nsta&le
Dispersi*e
Dispersi*e
CAAM 452
Spring 2005
Dissipation in Action
(
Consider the right difference *ersion#
(
%e are going to e,perimentall' determine ho-
much dissipation the solution e,periences.
( )
( )
{ }
2
3
3
1
2
0
m m
t
m
O
i ct
dx
L
m m
t
dx
du
c u u u e e
dt

+
+

r
r
CAAM 452
Spring 2005
$esting Methodolog'
/0 1educe the time2stepping error to a secondar' effect &' choosing a 4
th

order 1unge23utta 45S$0 time2integrator and a small dt.
20 6i, the method 4choose one of the difference operators for the spatial
deri*ati*e0
70 Do a parameter stud' in M) i.e. -e as8 the questions# ho- does
increasing the num&er of data points change the error.
40 %e need to understand -hat questions -e are as8ing#
/0 "s the computer code sta&le 4as predicted &' the theor'09
20 Does the computer code con*erge 4as predicted &' the theor'09
70 %hat order of accurac' in M do -e achie*e9
40 %e h'pothesi:e that if the theor' holds then -e should achie*e#
50 %hat is the actual appro,imate p achie*ed9
( ) ( )
, ,
p
m m
u T x u T x Cdx %
CAAM 452
Spring 2005
"nitial Condition
(
;ecause -e do not -ish to introduce uncertaint'
o*er the source of errors in the computation -e use
an initial condition -hich is infinitel' smooth.
( )
( )
2
4cos
, 0 with [0, 2)
x
u x e x


CAAM 452
Spring 2005
Computing Appro,imate
<rder of Accurac'
(
%e compute the error &'#
(
%e -ill compute the appro,imate order of accurac' &'
assuming#
(
-here C is independent of M
(
"f -e measure the error for t-o different M then -e can
eliminate the constant#
( "n the case -hen M
2
=2M
/
p
p
L
Cdx C
M

_


,
1
1
1
2 1 2
2 1 2
2
1
2
log
log
p
p
p
L
C
M
M
p
M M
L
C
M
M

_
_



_
,
,

)

_
,
_


,
,
( )
1
2
log
log 2
p

_

,

( ) ( ) : max , 8 , 8
m m
m
u x t u x t %
CAAM 452
Spring 2005
After 4 Periods
(
$he numerical pulses are in the right place &ut
ha*e se*erel' diminished amplitude.

du
c u
dt

+

r
r
CAAM 452
Spring 2005
After 4 Periods
M Ma,imum error at t=> ?order
20 0.@A/4A/@A4A5/!A
40 0.@A/7!5747@744! 0
>0 0.@>72A40>/24>5@ 0.0/
/@0 0.@7/@7A@04A2/>5 0.//
720 0.52!425@0@5040> 0.2@
After 4 periods the solution is totall' flattened in all &ut the last 2 results. "f -e &othered
to 8eep increasing M -e -ould e*entuall' see the error decline as /BM

du
c u
dt

+

r
r
CAAM 452
Spring 2005
$he +nsta&le eft Stencil
(
" repeated this -ith e*er'thing the same) e,cept the choice
of instead of

du
c u
dt

r
r


+
( )
( )
2
3
1 2
2!
2
0
m
m
t
d
t
m
c O
i ct
dx
L
x M
m m
du
c u u u e e
dt

+


_

,
+
' )


r
r
%e clearl' see that there is initial gro-th
near the pulses) &ut e*entuall' the
dominant feature is the highl' oscillator'
and e,plosi*e gro-th
4large m in the a&o*e red term0.
CAAM 452
Spring 2005
Cont (snapshot)
( )
( )
2
3
1 2
2!
2
0
m
m
t
d
t
m
c O
i ct
dx
L
x M
m m
du
c u u u e e
dt

+


_

,
+
' )


r
r
CAAM 452
Spring 2005
Dispersion in Action
(
Consider the central difference *ersion#
(
%ith the same time integrator &efore) M=/00)C
(
%e note that the remainder terms are dispersi*e corrections
D i.e. the' indicate that modes of different frequenc' -ill
tra*el -ith different speed.
(
6urthermore) to leading order accurac' the higher order
modes -ill tra*el more and more slo-l' as m increases.
( )
( )
{ }
3 5 2
3!
0
0
m m
it
m
i
t c O
i ct
dx
L
m m
dx
du
c u u u e e
dt


r
r
0

du
c u
dt

r
r
CAAM 452
Spring 2005
(
%e notice that the humps start to shed rear oscillations as
the higher frequenc' 6ourier components lag &ehind the
lo-er frequenc' 6ourier components.
2
nd
<rder Central Difference
After 4 Periods
0

du
c u
dt

r
r
CAAM 452
Spring 2005
Con*ergence Stud' 4t=>0
%hat should -e use as an error
"ndicator 99
0

du
c u
dt

r
r
CAAM 452
Spring 2005
2
nd
<rder Central Difference 0
du
c u
dt

r
r
M Ma,imum error at t=> ?order
20 0.A4240>0/4!450@
40 0.7502A>AA>50!77 /.42
>0 0.7>2A>5/2!!@>5A 0./7
/@0 0./A//>/2!4@@>!> /.00
720 0.054!/!705244>2 /.>0
( %e do not see a con*incing 2
nd
order accurac'
( " computed this &' log24errorEMBerrorFM2/G0
CAAM 452
Spring 2005
4
th
<rder Central Differencing
( )
( )
{ }
5 7
4
2
5!
4
0
m m
i it
m
c t O
i ct
dx dx
L
m m
du
c u u u e e
dt

+

r
r
4
du
c u
dt

r
r
CAAM 452
Spring 2005
4
th
<rder Central Difference
( %e see prett' con*incing 4
th
order accurac'
( " computed this &' log24errorEMBerrorFM2/G0
M Ma,imum error at t=> ?order
20 0.44757>!>5422!!
40 0./2>52A52A!2//@ /.!A
>0 0.02040/A0>>@!@! 2.@@
/@0 0.00/740!@4!>25A 7.A7
720 0.0000>7/A47>4/4 4.0/
4
du
c u
dt

r
r
CAAM 452
Spring 2005
@
th
<rder Central Difference 6
du
c u
dt

r
r
M Ma,imum error at t=> ?order
20 0./A40A5!5@/5520
40 0.04A57@5252@A>7 /.A!
>0 0.00/@A2AA/55@07 4.>!
/@0 0.00002>A/!24/05 5.>!
720 0.0000004@04/4/5 5.A!
( %e see prett' con*incing @
th
order accurac'
( " computed this &' log24errorEMBerrorFM2/G0
CAAM 452
Spring 2005
Summar' of $esting Procedure
/0 +nderstand -hat 'ou -ant to test
20 3eep as man' parameters fi,ed as possi&le
70 "f possi&le) perform an anal'sis &efore hand
40 1un parameter s-eeps to determine if code agrees -ith anal'sis.
50 Estimate error scaling -ith a single parameter if possi&le.
@0 "t should &e apparent here that the errors computed in the simulations
onl' appro,imate the tid' po-er la- 4d,Hp0 in the limit of small d,
4large M0.
!0 "t is quite common to refer to the range of M &efore the error scaling
applied as the Ipreasymptotic convergence rangeJ.
>0 $he preas'mptotic range is due to the other factors in the error
estimate -hich are much larger than the d,Hp term 4i.e. the pKth
deri*ati*es ma' &e *er' large) or the constant ma' &e largeC0
A0 "n this case -e heuristicall' set dt small) using a high2order 1unge2
3utta time integrator) and then performed a parameter s-eep on M.
%e could ha*e &een unluc8' and the time2stepping errors ma' ha*e
&een dominant -hich -ould mas8 the d, &eha*ior.
/00 $o &e careful -e -ould tr' this e,periment -ith e*en smaller dt and
chec8 if the scalings still hold.
CAAM 452
Spring 2005
Summar' of our Approach to Designing
6inite Difference Methods
(
%e ha*e s'stematicall' created finite difference methods &'
separating the treatment of space and time deri*ati*es.
(
$hen designing a sol*er consists of choosingBtesting#
D
a time integrator 4so far -e co*ered Euler26or-ard) eap6rog)
Adams2;ashford42)7)40) 1unge23utta0
D
a discreti:ation for spatial deri*ati*es
D a discrete differential operator -hich has all eigen*alues in the
left half of the comple, plane 4assuming the PDE onl' admits
non2gro-ing solutions0.
D
Possi&l' using LerschgorinKs theorem to locali:e the
eigen*alues of the discrete differentiation operator
D
dt so that dtMlargest eigen*alue 4&' magnitude0 of the
deri*ati*e operator sits inside the sta&ilit' region sta&ilit'.
D
4small d,0 spatial truncation anal'sis consistenc' and
accurac'.
D 6ourier anal'sis for classification of the differential operator.
D
%riting code and testing.
CAAM 452
Spring 2005
Some Classical 6inite Difference Methods
(
No-e*er) there are a num&er of classical methods
-hich -e ha*e not discussed and do not quite fit
into this frame-or8.
(
%e include these for completeness..
CAAM 452
Spring 2005
eap 6rog 4space and time0
(
%e use centered differencing for &oth space and time.
(
%e 8no- that the leap frog time stepping method is onl'
sta&le for operators -ith eigen*alues in the range#
(
No-e*er) -e also 8no- that the centered difference
deri*ati*e matri, is a s8e- s'mmetric matri, -ith
eigen*alues#
(
So -e are left -ith a condition# i.e.
1 1
1 1
2 2
n n n n
m m m m
u u u u
c
dt dx
+
+
_


,
[ ]
1,1 dt i
2
sin
ic m
dx M

_

,
1
cdt
dx

dx
dt
c

CAAM 452
Spring 2005
cont
(
%e can perform a full truncation anal'sis 4in space
and time0#
(
%e 8no- that dt O= d, so
( ) ( ) ( ) ( )
( ) ( )
1 1 1 1
3 3
, , , ,
2 2
n
m n m n m n m n
m
u x t u x t u x t u x t
T cdt
dx
cdt
O dt O dx
dx
+ +

_


,

( ) ( )
3 3 n
m
T O dt cO dx
CAAM 452
Spring 2005
a,26riedrichs Method
(
%e immediatel' conclude that the follo-ing method is not
sta&le#
(
;ecause the Euler26or-ard time integrator onl' admits one
sta&le point 4the origin0 on the imaginar' a,is) &ut the
central differencing matri, has all eigen*alues on the
imaginar' a,is.
(
No-e*er) -e can sta&ili:e this formula &' replacing the
second term in the time2stepping formula#
1
0
n n
n
m m
m
u u
c u
dt

+

( )
1
1 1
0
0.5
n n n
m m m
n
m
u u u
c u
dt

+
+
+

CAAM 452
Spring 2005
cont
(
$his formula does not quite fit into our constructi*e
process 4method of lines approach0.
(
%e ha*e admitted spatial a*eraging into the
discreti:ation of the time deri*ati*e.
(
%e can rearrange this#
( )
1
1 1
0
0.5
n n n
m m m
n
m
u u u
c u
dt

+
+
+

( ) ( )
1
1 1 1 1
1 1
1
2 2
1 1
1 1
2 2
n n n n n
m m m m m
n n
m m
dt
u u u c u u
dx
dt dt
c u c u
dx dx
+
+ +
+
+ +
_ _
+ +

, ,
CAAM 452
Spring 2005
cont
(
%e can immediatel' determine that this is a sta&le method as
long as cMdtBd, O=/
(
Li*en) this condition -e o&ser*e that the time updated
solution is al-a's &ounded &et-een the *alues of the left and
right neigh&or at the pre*ious time &ecause this is an
interpolation formula.
1
1 1
1 1
1 1
2 2
n n n
m m m
dt dt
u c u c u
dx dx
+
+
_ _
+ +

, ,
CAAM 452
Spring 2005
cont
(
A formal sta&ilit' anal'sis -ould in*ol*e#
(
%hich gi*es sta&ilit' for each mode if#
( ) ( )
{ }
1
1 1
1
1
1 1
1 1
2 2
1 1
1 1
2 2
1 1
1 1
2 2
cos sin
m m
n n n
m m m
n n n
i i n n n
m m m
n
m m m
dt dt
u c u c u
dx dx
dt dt
u c u c u
dx dx
dt dt
u c e u c e u
dx dx
dt
c i u
dx


+
+
+
+
_ _
+ +

, ,
_ _
+ +

, ,
_ _
+ +

, ,
+
R L
r r r
% % %
%
( ) ( )
cos sin 1
m m
dt
c i
dx
+
CAAM 452
Spring 2005
cont
(
$hus considering all the possi&le modes
(
%e note that the middle mode requires#
(
$his condition gi*es a sufficient condition for all modes to &e
&ounded.
(
;' the in*erti&ilit' and &oundedness of the 6ourier transform
-e conclude that the original equation is sta&le.
cos sin 1
2 2
1
dt
c i
dx
dt
c
dx

_ _
+

, ,

2
m
m
M


CAAM 452
Spring 2005
cont
(
%e can recast the a,26riedrichs method again
(
$his method consists of Euler 6or-ard) central
differencing for the space deri*ati*e and an e,tra
dissipati*e term 4i.e. a grid dependent ad*ection
diffusion equation# 0
( )
1
1 1
1 2 2
0
1 1
1 1
2 2
1
1
2
n n n
m m m
n n n
m m m
dt dt
u c u c u
dx dx
u cdt u dx u
+
+
+
_ _
+ +

, ,

+ +
2 2
2
2
u u dx u
c
t x x

+

CAAM 452
Spring 2005
C6 Num&er
(
$he ratio appears repeatedl') in particular in
the estimates for the ma,imum possi&le time step.
(
%e refer to this quantit' as the C6 4Courant2
6riedrichs2e-'0 num&er.
(
;ounds of the form# -hich result from a
sta&ilit' anal'sis are frequentl' referred to as C6
conditions.
dt
dx

dt
C
dx

CAAM 452
Spring 2005
a,2%endroff Method
(
%e are fairl' free to choose the parameter in the sta&ili:ing
term#
(
$he artificial viscosity term acts to shift the eigen*alues of
the spatial operator into the left half2plane.
(
1ecall D the Euler26or-ard sta&ilit' region is the unit circle
centered at 2/ in the comple, plane. So pushing the
eigen*alues off the imaginar' a,is allo-s us to choose a dt
small enough to push the eigen*alues of the discrete spatial
operator into the sta&ilit' regionC
( )
1 2 2
0
1
1
2
n n n
m m m
u cdt u cdt u
+
+ +
CAAM 452
Spring 2005
Class E,ercise
(
Please pro*ide a C6 condition for#
(
"n terms of#
(
%hat is the truncation error9
( ) ( )
1 1
1 1 2 2
4 1
3 6
n n n n n n
m m m m m m
u u c u u c u u
+
+ +
+
dt
dx

CAAM 452
Spring 2005
Pon Neumann Anal'sis
(
;' stealth " ha*e introduced the classical Pon
Neumann anal'sis.
(
$he first step is to 6ourier transform the finite
difference equation in space.
(
A short cut is to ma8e the follo-ing su&stitutions#
1
1
2
2
2
2
......
m
m
m
m
n n
m m
i n n
m m
i n n
m m
i n n
m m
i n n
m m
u u
u e u
u e u
u e u
u e u

%
%
%
%
%
CAAM 452
Spring 2005
Anal'sis cont
(
%e can also ma8e the su&stitutions for the
difference operators#
( )
( )
{ }
( )
2
2
1
1
2
0
2
2
2
2
1 1
1 2 sin
2
1 1
1 2 sin
2
1 1
sin
2
......
m
m
m
m
m
m
m m
m
m
i
i
m
n n
m m
i
i
m
i n n
m m
i n n
m m
i i
i n n
m
m m
i n n
m m
e ie
dx dx
u u
e ie
u e u
dx dx
u e u
e e i
u e u
dx dx
u e u


_
+
' )

,


' )

%
%
%
%
%
( )
{ }
2
2
2
1
4sin
2
2
1 cos
m
m
dx
dx

+

_

' )

,


CAAM 452
Spring 2005
Example
(
$he a,2%endroff scheme
(
&ecomes
( )
1 2 2
0
1
1
2
n n n
m m m
u cdt u cdt u
+
+ +
2 2
1 2
2
1 2
1
2 2
m m m m
i i i i
n n n
m m m
e e e e
u cdt u cdt u
dx dx

+
_ _ _ +
+ +

, , ,
% % %
CAAM 452
Spring 2005
Example cont
(
So the a,2%endroff scheme &ecomes a neat one
step method for each 6ourier coefficient#
(
%e ha*e neatl' decoupled the 6ourier coefficients
so -e are &ac8 to sol*ing a recurrence relation in n
for each m#
(
Nence -e need to e,amine the roots of the sta&ilit'
pol'nomial for the a&o*e
2 2
1 2
2
1 2
1
2 2
m m m m
i i i i
n n n
m m m
e e e e
u cdt u cdt u
dx dx

+
_ _ _ +
+ +

, , ,
% % %
n
m
u%
2 2
2
2
1 2
1
2 2
m m m m
i i i i
e e e e
z cdt cdt
dx dx

_ _ _ +
+ +
' )

, , ,
CAAM 452
Spring 2005
E,ample cont
(
$his case is tri*ial as -e Qust need to &ound the
single root &' /
(
Plot it this as a function of thetaC
( ) ( ) ( )
{ }
2 2
2
2
2
1 2
1
2 2
1 sin cos 2 1
m m m m
i i i i
m
e e e e
z cdt cdt
dx dx
c i c



_ _ _ +
+ +
' )

, , ,
+ +
CAAM 452
Spring 2005
6inal Pon Neuman Shortcut
(
%e can s8ip lots of steps &' ma8ing the direct
su&stitution#
(
Nere g is referred to as the amplification factor and
iMmMtheta is our pre*ious thetaEm
n n im
m
u g e

CAAM 452
Spring 2005
Ne,t $ime
(
Definition of consistenc'
(
a,21ichtm'er equi*alence theor'
(
$reating higher order deri*ati*es
CAAM 452
Spring 2005
Nome-or8 7
R/0 ;uild a finite2difference sol*er for
R/a0 use 'our Cash23arp 1unge23utta time integrator from N%2 for time stepping
R/&0 use the 4
th
order central difference in space 4periodic domain0
R/c0 perform a sta&ilit' anal'sis for the time2stepping 4&ased on *isual inspection of
the C3 123 sta&ilit' region containing the imaginar' a,is0
R/d0 &ound the spectral radius of the spatial operator
R/e0 choose a dt -ell in the sta&ilit' region
R/f0 perform four runs -ith initial condition
4use M=20)40)>0)/@00 and compute ma,imum error at t=>
R/g0 estimate the accurac' order of the solution.
R/h0 e,tra credit# perform adapti*e time2stepping to 8eep the local truncation error
from time stepping &ounded &' a tolerance.
u u
c
t x


( )
( )
[ ]
2
4cos
, 0 , 0, 2
x
u x e x

You might also like