0% found this document useful (0 votes)
40 views28 pages

TE2652.Finite Difference Approximation

This document discusses numerical methods for solving partial differential equations including finite difference methods. It covers Taylor series, finite difference approximations of derivatives, error analysis, and formulations for approximating higher order derivatives. Alternative derivations of the methods are also presented.

Uploaded by

Nguyễn Thịnh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views28 pages

TE2652.Finite Difference Approximation

This document discusses numerical methods for solving partial differential equations including finite difference methods. It covers Taylor series, finite difference approximations of derivatives, error analysis, and formulations for approximating higher order derivatives. Alternative derivations of the methods are also presented.

Uploaded by

Nguyễn Thịnh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Finite difference

approximation – Phương
pháp xấp xỉ Sai phân hữu
hạn

PVS.TE2652.SME.HUST 1
Ý thức:

Trần Khương Thi (-1)


Nguyễn Xuân Trường (-1)
Phạm Hữu Chánh (-1)
Phạm Thành Đạt (-1)

PVS.TE2652.SME.HUST 2
Partial differential
equations – Phương trình
vi phân đạo hàm riêng

Partial differential equations are


used to mathematically formulate,
and thus aid the solution of physical
and other problems involving
functions of several physical
variables, such as the propagation of
heat or sound, fluid flow, elasticity,
electrostatics, electrodynamics, etc.

PVS.TE2652.SME.HUST 3
Numerical simulation – mô phỏng số
Object in fluid flow (fluid flow around a ship, a
submarine, a car; fluid flow in pipes system, … ):

Fluid
flow

Numerical simulation for design and optimization!


PVS.TE2652.SME.HUST 4
How does numerical simulation
work?

PVS.TE2652.SME.HUST 5
Finite difference,
Finite element,
Finite volume,
Boundary element,
methods:

PVS.TE2652.SME.HUST 6
Numerical methods:
Finite differences - time-dependent PDEs
- seismic wave propagation
- geophysical fluid dynamics
- Maxwell’s equations
- Ground penetrating radar
-> robust, simple concept, easy to
parallelize, regular grids, explicit method

- static and time-dependent PDEs


Finite elements - seismic wave propagation
- geophysical fluid dynamics
- all problems
-> implicit approach, matrix inversion, well founded,
irregular grids, more complex algorithms,
engineering problems

Finite volumes - time-dependent PDEs


- seismic wave propagation
- mainly fluid dynamics
-> robust, simple concept, irregular grids, explicit
method
PVS.TE2652.SME.HUST 7
Other numerical methods
Particle-based - lattice gas methods
- molecular dynamics
methods - granular problems
- fluid flow
- earthquake simulations
-> very heterogeneous problems, nonlinear problems

Boundary element - problems with boundaries (rupture)


- based on analytical solutions
methods - only discretization of planes
-> good for problems with special boundary conditions
(rupture, cracks, etc)

Pseudospectral - orthogonal basis functions, special case of FD


methods - spectral accuracy of space derivatives
- wave propagation, ground penetrating radar
-> regular grids, explicit method, problems with
strongly heterogeneous media

PVS.TE2652.SME.HUST 8
Partial Differential Equations
The Acoustic
¶ 2t p = c 2 Dp + s wave equation
- seismology
D = (¶ 2x + ¶ 2y + ¶ 2z ) - acoustics
- oceanography
P pressure - meteorology
c acoustic wave speed - Wave propagation
s sources

¶ t C = kDC - v • ÑC - RC + p Diffusion, advection,


Reaction
C tracer concentration - geodynamics
k diffusivity - oceanography
- meteorology
v flow velocity
- geochemistry
R reactivity - sedimentology
p sources -geophysical fluid dynamics
- Heat transfer
- Bar bending
PVS.TE2652.SME.HUST - Fluid flow 9
Finite Difference Approximation

10

PVS.TE2652.SME.HUST
Taylor Series
Taylor series are expansions of a function f(x) for some finite distance dx to
f(x+dx)
2 3 4
dx dx dx
f ( x ± dx) = f ( x) ± dxf ' ( x) + f '' ( x ) ± f ''' ( x ) + f '''' ( x) ± ...
2! 3! 4!
Rearranging gives

f ( x + dx) - f ( x) 1 é dx 2
dx 3
ù
= êdxf ( x) +
'
f ( x) +
''
f ( x) + ...ú
'''

dx dx ë 2! 3! û
= f ' ( x) + O(dx)
Thus, it form an approximation for the first derivative:

+ f ( x + dx) - f ( x) “The error of the first derivative using the


¶x f » forward formulation is of order dx”
dx
(the forward formulation) PVS.TE2652.SME.HUST 11
Taylor Series
The centered formulation for the first derivative approximation:

f ( x + dx / 2) - f ( x - dx / 2) 1 é dx 3
ù
= êdxf ( x) +
'
f ( x) + ...ú
'''

dx dx ë 3! û
= f ' ( x) + O(dx 2 )

The error of the first derivative using the centered approximation is of order dx2.

Important note: it DOES matter which formulation we use! The centered scheme is
more accurate!

PVS.TE2652.SME.HUST 12
Approximations of the first derivatives

f ( x + dx) - f ( x) f ( x) - f ( x - dx) f ( x + dx) - f ( x - dx)


+
¶x f » -
¶x f » ¶x f »
dx dx 2dx

PVS.TE2652.SME.HUST 13
Error
Truncation/Discretization Error:
introduced in the solution by the
approximation of the derivative
Local Error: from each term of
the equation
Global Error: from the
accumulation of local error
Roundoff Error: introduced in the
computation by the finite number
of digits used by the computer

PVS.TE2652.SME.HUST 14
Approximations of the 2nd, 3rd, 4th
derivatives

PVS.TE2652.SME.HUST 15
Alternative Derivation
Consider an arbitrary x location:
+ What is the (approximate) value of the function or its (first, second ..) derivative
at the desired location?
+ How can we calculate the weights for the neighboring points?

f(x) f ( xj )

dx h
x
xj - 1 xj xj + 1 xj + 2 xj + 3
desiredPVS.TE2652.SME.HUST
x location 16
Alternative Derivation

f ( x)

f(x) dx
x
f ( x + dx) » f ( x) + f ' ( x)dx
f ( x - dx) » f ( x) - f ' ( x)dx
We are looking for something like

f (i )
( x ) » å w f ( xindex ( j ) )
(i )
j
j =1, L
PVS.TE2652.SME.HUST 17
2nd order weights
Deriving the second-order scheme:

+
af » af + af ' dx
-
bf » bf - bf ' dx
+ -
Þ af + bf » ( a + b) f + ( a - b) f ' dx

the solution to this equation for a and b leads to a system of


equations that can be cast in matrix form

Interpolation Derivative
a +b =1 a+b = 0
a -b = 0 a - b = 1 / dx

PVS.TE2652.SME.HUST 18
Interpolation and difference
weights
Interpolation Derivative

æ1 1 öæ a ö æ 1 ö æ1 1 öæ a ö æ 0 ö
çç ÷÷çç ÷÷ = çç ÷÷ çç ÷÷çç ÷÷ = çç ÷÷
è1 - 1øè b ø è 0 ø è1 - 1øè b ø è1 / dx ø
The solution for the weights:
-1 -1
æ a ö æ1 1 ö æ1ö æ a ö æ1 1 ö æ 0 ö
çç ÷÷ = çç ÷÷ çç ÷÷ çç ÷÷ = çç ÷÷ çç ÷÷
è b ø è1 - 1ø è0ø è b ø è1 - 1ø è1 / dx ø

æ a ö æ1 / 2 ö æaö 1 æ 1ö
çç ÷÷ = çç ÷÷ çç ÷÷ = çç ÷÷
è b ø è1 / 2 ø è b ø 2dx è - 1ø
Can we generalize this idea to longer operators?
PVS.TE2652.SME.HUST 19
Higher order operators
Start by extending the Taylor expansion beyond f(x±dx):
(2dx) 2 (2dx) 3
a*| f ( x - 2dx) » f - (2dx) f '+ f ' '- f ''' + 𝑂(𝑑𝑥 ! )
2! 3!

b*| (dx) 2 (dx) 3


f ( x - dx) » f - (dx) f '+ f ' '- f ''' + 𝑂(𝑑𝑥 ! )
2! 3!

c*| (dx) 2 (dx) 3 + 𝑂(𝑑𝑥 ! )


f ( x + dx) » f + (dx) f '+ f ' '+ f '''
2! 3!
(2dx) 2 (2dx) 3 + 𝑂(𝑑𝑥 ! )
d*| f ( x + 2dx) » f + (2dx) f '+ f ' '+ f '''
2! 3!

We are looking for the coefficients a,b,c,d with which the function values at
x±(2)dx must be multiplied to obtain the interpolated value or the first (or
second) derivative!

PVS.TE2652.SME.HUST 20
Higher order operators
Adding up all these above equations:

af -- - +
+ bf + cf + df ++
» f (a + b + c + d ) +
dxf ' (-2a - b + c + 2d ) +
b c
dx f ' ' (2a + + + 2d ) +
2

2 2
8 1 1 8
dx f ' ' ' (- a - b + c + d )
3

6 6 6 6
We are going to find the coefficients a,b,c,d, so that the left-hand-side
yields either f, f’, f’’, f’’’

PVS.TE2652.SME.HUST 21
High-order interpolation
If you want the interpolated value:a +b + c + d =1
- 2a - b + c + 2d = 0
b c
2a + + + 2d = 0
2 2
8 1 1 8
- a- b+ c+ d =0
6 6 6 6
You need to solve the matrix system:

æ 1 1 1 1 öæ a ö æ 1 ö æ a ö æ -1/ 6ö
ç ÷ç ÷ ç ÷ ç ÷ ç ÷
ç -2 -1 1 2 ÷ç b ÷ ç 0 ÷ çb÷ ç 2/3 ÷
ç 2 1/ 2 1/ 2 2 ÷ç c ÷ =ç ÷
0 çc÷ = ç 2/3 ÷
ç ÷ç ÷ ç ÷ ç ÷ ç ÷
ç - 8 / 6 - 1 / 6 1 / 6 8 / 6 ÷ç d ÷ ç 0 ÷ ç d ÷ ç -1/ 6÷
è øè ø è ø è ø è ø
The approximation error is of order 𝒅𝒙𝟒 𝑶 (𝒅𝒙𝟒 )
PVS.TE2652.SME.HUST 22
High-order First derivative
æ 1 1 1 1 öæ a ö æ 0 ö
ç ÷ç ÷ ç ÷
ç -2 -1 1 2 ÷ç b ÷ ç1 / dx ÷
ç 2 ÷ç ÷ =ç
1/ 2 1/ 2 2 c 0 ÷
ç ÷ç ÷ ç ÷
ç - 8 / 6 - 1 / 6 1 / 6 8 / 6 ÷ç d ÷ ç 0 ÷
è øè ø è ø

æaö æ 1/ 6 ö
ç ÷ ç ÷
çb÷ 1 ç - 4 / 3÷
ç c ÷ = 2dx ç 4 / 3 ÷
ç ÷ ç ÷
çd ÷ ç -1/ 6 ÷
è ø è ø

The approximation error is of order 𝒅𝒙𝟒 𝑶 (𝒅𝒙𝟒 )


PVS.TE2652.SME.HUST 23
Solving the heat equation
Consider the following initial-boundary value problem for the heat equation:

Idea: replace the derivatives in the heat equation with finite difference
approximations. We consider the relationships between u at (x, t) and its
neighbors a distance ∆x apart and at a time ∆t later.

PVS.TE2652.SME.HUST 24
Solving the heat equation

Forward Difference in Time

After re-arrangement and division by ∆t:

Central Differences in Space:

Substituting gives:

PVS.TE2652.SME.HUST 25
Solving the heat equation
Re-arranging:

Implementation:
+ Subdivide the spatial interval [0, 1] into N + 1 equally spaced sample points xn = n∆x.
+ Subdivide the time interval [0, T] into M + 1 equal time levels tk = k∆t.

At each of these space-time sample points, we introduce approximations:

PVS.TE2652.SME.HUST 26
Solving the heat equation
At each of these space-time sample points, we introduce approximations:

PVS.TE2652.SME.HUST 27
Solving the heat equation
Implementing Boundary Conditions:

"
→ 𝑢!" = 0; 𝑢# = 0;

Now, it’s programming time!


but…
HOW?

PVS.TE2652.SME.HUST 28

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy