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

Computational Aerodynamics: Instructor: Prof. Marco Panesi

1. The lecture summarized finite difference schemes constructed using Taylor tables, Lagrange polynomials, and Hermite polynomials. 2. Lagrange interpolation was shown to connect to finite difference schemes, where assuming a function is represented by a polynomial interpolation gives specific finite difference approximations. 3. Hermite interpolation using values and derivatives was presented, giving implicit or Pade finite difference schemes with higher accuracy using only nearby points. 4. Matrix operators were introduced that discretize spatial derivatives using common finite difference approximations, allowing the derivatives to be expressed in matrix-vector form.

Uploaded by

Jeb Kerman
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)
38 views

Computational Aerodynamics: Instructor: Prof. Marco Panesi

1. The lecture summarized finite difference schemes constructed using Taylor tables, Lagrange polynomials, and Hermite polynomials. 2. Lagrange interpolation was shown to connect to finite difference schemes, where assuming a function is represented by a polynomial interpolation gives specific finite difference approximations. 3. Hermite interpolation using values and derivatives was presented, giving implicit or Pade finite difference schemes with higher accuracy using only nearby points. 4. Matrix operators were introduced that discretize spatial derivatives using common finite difference approximations, allowing the derivatives to be expressed in matrix-vector form.

Uploaded by

Jeb Kerman
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/ 30

Lecture 4

AE 410 / CSE 461

Computational Aerodynamics
Instructor: Prof. Marco Panesi

1. 1
AE 410
Summary of the Previous Lecture

1. Construction of the Finite Difference Schemes using Taylor Tables.

2. Construction of Finite Difference Schemes using Lagrange polynomials

3. Construction of Finite Difference Scheme using Hermite polynomials

4. Difference between implicit and explicit Finite Difference schemes.

1. 2
AE 410
Taylor Table
@u 1
Example: (a2 ui 2 + a1 ui 1 + bui ) = erT
@x i x
Each term expanded in Taylor Series and placed in a table simplifying the algebra:
@u 2
2 @ u
@3u
3
ui x ( x) ( x)
@x i @x2 i
@x3 i
@u
x
@x
0 1 0
i
1 1 2 3 1
a 2 ui 2 a2 a2 ( 2) a2 ( 2) a2 ( 2)
1! 2! 3!
a1 1 2 1
a 1 ui a1 ( 1) 3 1
1 a1 ( 1) a ( 1)
1! 2! 1 3!
bui b 0 0 0
x erT
1. 3
AE 410
Taylor Table

In this case the fourth column provides the leading truncation:

✓ ◆ ✓ ◆
@u 1 1 3 1 8a2 a1 3 @3u
ui 2 + 2ui 1 + ui = + ( x)
@x i x 2 2 x 6 6 @x3 i

2 3
( x) 3 @ u
erT = ( x)
3 @x3 i

Thus we have derived a second-order backward-difference approximation of a


first derivative:

@u 1 2
= (ui 2 + 4ui 1 + 3ui ) + O ( x)
@x i 2 x
1. 4
AE 410
Lagrange Interpolation

There is a connection between Finite Difference and Lagrangian


Interpolation.

For example:

Suppose Irepresent u(x) by a quadratic


polynomial
f (x) = ax2 + bx + c between points {xi 1 , xi , xi+1 } and
I require

f (xi 1) = u(xi 1)
f (xi ) = u(xi )
f (xi+1 ) = u(xi+1 )

1. 5
AE 410
Lagrange Interpolation

If we take the derivative we get:

df ui+1 ui 1
= 2a x + b =
dx i 2h

Which is second order in accuracy.

1. 6
AE 410
Lagrange Interpolation

The second derivative is:

d2 f ui+1 2ui + ui 1
= 2a =
dx2 i h2
Which is second order in accuracy.

We see that assuming:


X
u(x) = ak (x) uk
k=0

gives rise to specific finite difference schemes. The ak(x) can be taken from
simple Lagrangian for a quadratic interpolation.

1. 7
AE 410
Lagrange Interpolation

Lagrangian interpolation formula:

a0 a1

a2
X
u(x) = ak (x) uk
k=0

1. 8
AE 410
Pade’ Finite Difference Schemes

A generalization of the Lagrangian approach is brought about by using Hermitian interpolation.


To construct a polynomial in u(x) Hermite formulas use values of the functions and at its
derivative at a given point in space.

This give rise to implicit finite differences (or Pade’ Finite Differences). For example, assuming
quadratic interpolation for both u(x) and u’(x) yields

✓ ◆
@u @u @u 3 ( x)4 @5u
+4 + = (ui+1 ui 1 ) +
@x i 1 @x i @x i+1 x 120 @x5

1. 9
AE 410
Pade’ Finite Differences

i-1 i i+1

This scheme is 4th order accurate using only 3 points stencil.

1. The determination of the derivative of the point i requires the knowledge of the derivative at
the point i-1 and i+1. Hence, it is implicit!

1. 10
AE 410
Matrix Operators

Common example of finite-difference formulas are the three point centered finite
difference approximations for the first and second derivatives:

These are the basis for the point difference operator since they give an approximation to
a derivative at one discrete point in the mesh in terms of the surrounding points.

See Textbook page 25-29

1. 11
AE 410
Matrix Operators

We are now ready to construct matrix operators which are the discrete approximations of the
spatial derivatives.

1 i-1 i i+1 Nx

0 h 1

Suppose ~u = [u1 , u2 , . . . , uN ] is a discrete vector of u(x) evaluated at N


x
{xi }i=1
Then we want to find the matrix M such that

M~u = [u01 , u02 , . . . , u0N ]

1. 12
AE 410
Matrix Operators

It is easy to do:

u2 u1 Forward Finite Difference


u01 = 1 2 3
h
u3 u2
u02 =
2h
Central Finite Difference
ui ui 2 i-2 i-1 i
u0i 1 =
2h
Forward Finite Difference
uN uN 1 N-1 N
u0N =
h

1. 13
AE 410
Matrix Operators
We can express the previous equations in matrix vector form:

0 1 0 1 1
10 1
u01 h h ··· ··· 0 u1
B C B
u02 1
0 1
··· 0C B u2 C
B C B 2h 2h CB C
B .. C B .. .. .. C B .. C
B . C=B 0 . . . 0C B . C
B C B CB C
@u 0 A @ 0 ··· 1
0 1 A@
u N 1
A
N 1 2h 2h
u0N 0 ··· ··· 1
h
1
h
uN
M is a banded sparse
0 1 1
1
h h ··· ··· 0
B 1
0 1
··· 0C
B 2h 2h C
B .. .. .. C
M =B 0 . . . 0C
B C
@ 0 ··· 1
0 1 A
2h 2h
1 1
0 ··· ··· h h
1. 14
AE 410
Matrix Operators
Collecting 1/h
0 1
1 1 ··· ··· 0
B 1 0 1
··· 0C
1B C
2 2
B .. .. .. C
M= B 0 . . . 0C
hB C
@ 0 ··· 1
0 1A
2 2
0 ··· ··· 1 1

1. This example illustrates the use of the matrix operator.


2. Each line of the matrix is based on a point difference operator.
3. The point operators from line to line do NOT have to be the same.
4. The boundary condition may dictate that the lines at the top and at the
bottom be modified.

1. 15
AE 410
Matrix Operators: Implicit FD Schemes

Consider the following implicit (Pade’) FD scheme:


✓ ◆
1 17 3 3 1
u01 + 3u02 = u1 + u2 + u3 u4
h 6 2 2 6

1
u0i 1 + 4u0i + u0i+1 = ( 3ui 1 + 3ui+1 )
h
✓ ◆
1 1 3 3 17
3u0N 1 + u0N = uN 3 uN 2 uN 1+ uN
h 6 2 2 6

1. 16
AE 410
Implicit FD Matrix Operator

This can be cast in matrix form as done before:

0 10 0 1 0 17 3 3 1 10 1
1 3 0 0 ··· 0 u1 6 2 2 6 ··· 0 u1
B1 4 1 0 ··· C B 0 C
0C B u2 C B ··· 0 C B C
B B 3 0 3 0 C B u2 C
B .. .. .. .. C B .. C B .. .. .. .. C B .. C
B0 . . . . 0C B . C 1B 0 . . . . 0 C B C
B CB C B CB . C
B .. .. .. CB . C = h B .. .. .. .. C B . C
B0 0 . . . 0C B . C B 0 . . . .C B . C
B CB . C B 0 CB . C
@0 ··· ··· 1 4 1A @ 0
uN 1 A @ 0 ··· 0 3 0 3 A @uN 1 A
1 3 3 17
0 ··· ··· ··· 3 1 u0N 0 ··· 6 2 2 6 uN

A B
To get the matrix operator M we must invert A!

~u0 = A 1
B~u = M~u
Note: Now M is DENSE but A and B are sparse and BANDED

1. 17
AE 410
Periodic Domains

We will find it convenient to use periodic domains for discussing the basic
behavior of the Finite Difference schemes w/o the influence of the boundary
conditions.

Periodic Function:

A function is called defined as periodic if it satisfies the following relation:

u(x + L) = u(x)

1. 18
AE 410
Periodic Domains
Periodic Function:
A function is called defined as periodic if it satisfies the following relation:

u(x +LL) = u(x)


h

1. 19
AE 410
Periodic Domains
Because of the periodicity, u(x + L) = u(x) so we modify our
discretization as follows:
L
xi = (i 1)h, h= , i = 1, . . . , N
N
1 i-1 i i+1 Nx L

0 h 1
8
>
> x1 = 0
>
>
< x2 = h
.. NOTE: XN is NOT L
>
> .
>
>
: N 1
xN = (N 1)h = N L 6= L

1. 20
AE 410
Periodic Domains
Why is that? Because: u(xN +1 ) = u(L) = u(0)
Furthermore:

u(xi+N ) = u(i) 8i
The Finite difference stencil is “modified near the boundaries”. For example:

u2 u0 u2 uN
u01 = = Since u0 is equal to uN by periodicity.
2h 2h
uN +1 uN 1 u1 uN 1
u0N = =
2h 2h
Since uN+1 is equal to u1 by periodicity

1. 21
AE 410
The Matrix Operator Periodic Domains

The matrix operator then appears as:


2 3
0 1 0 ··· 1
6 1 0 1 0 · · ·7
1 6
6 .. .. ..
7
7
M= 60 . . . · · ·7
2h 6 7
40 0 1 0 15
1 0 0 1 0
Which is called circulant matrix. Circulant matrices have several useful
properties. Consider the general circulant matrix:

1.
AE 410
The Matrix Operator Periodic Domains

The matrix operator then appears as:

2 3
b0 b1 b2 ··· bN 1
6 bN 1 b0 b1 ··· bN 2 7
6 7
1 6
6 .. .. .. .. .. 7
M= 6 . . . . . 7
7
2h 6 . .. .. .. .. 7
4 .. . . . . 5
b1 b2 ··· bN 1 b0

1.
AE 410
The Matrix Operator Periodic Domains

Then the N eigenvalues are:

N
X1
m = bj exp [i(2⇡j(m 1)/N )], m = 1, . . . , N
j=0
p
Note that: i= 1
With the corresponding ~xm eigenvectors:
2 3
exp [i(2⇡(m 1)/N )]
6 7
6 exp [i(2⇡(m 1)/N ) · 2] 7
~xm =6
6 ..
7,
7 8m = 1, . . . , N
4 . 5
exp [i(2⇡(m 1)/N ) · N ]
1.
AE 410
Circulant Matrix

For those who know, the matrix X = [~x1 , ~x2 , . . . , ~xN ] is related to the
Fourier transform.

1.
AE 410
Programming Matrix Operators

Linspace: The linspace function generates a row


vector of Nx points equally spaced between and
including 0 and Nx-1.

User’s Defined Function:

Sparse: converts a full matrix


to sparse form by squeezing
out any zero elements.

Differentiation

1.
AE 410
Programming Matrix Operators

SPARSE MATRIX

Loop

1.
AE 410
Programming Matrix Operators

Diag(v,k): when v is a vector of n


components, returns a square matrix X
of order n+abs(k), with the elements of
v on the kth diagonal

1.
AE 410
Example 0

Why are the timing this way?

1.Full Matrix operators multiply zeros as well as non-zeros. Waste of time!


2.Sparse matrix: only multiply non-zeros, but must keep track of the non-zero
entries.
3.Loop: only multiply non-zeros, but Matlab’s loops are slow.
4.Use the fact that matrices are sparse and banded.

1.
AE 410
What have we learned?

1. Matrix Operators for non-periodic domains

1. Matrix Operators for periodic domains

1. Properties of circulant matrices

2. Example on how to code Matrix Operators

1. 30
AE 410

You might also like