Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Lecture 2

AE 410 / CSE 461

Computational Aerodynamics
Instructor: Prof. Marco Panesi

1. 1
AE 410
Finite Difference Method

Our goal is to approximate solutions to differential equations, i.e. , to find a


function (or some discrete approximation to this function) which satisfies a
given relationship between various of its derivatives on some given region
of space and/or time, along with some boundary conditions along the edges
of this domain.

The finite difference method proceeds by replacing the derivatives in the


differential equations by finite difference approximations. This gives a large
algebraic system of equations to be solved in place of the differential
equation, something that is easily solved on a computer.

1. 2
AE 410
Calculus Definition of a Derivative

In calculus you learned that:

This is exact if we take the limit

1. 3
AE 410
Finite Difference approximation of Derivative

1. 4
AE 410
Finite Difference Approximation

Our goal is to approximate the derivative operators:

By some linear combination of

1. 5
AE 410
Finite Difference Approximation

Let us start with something simple:

We want to find which approximate:

Using Taylor expansion about ui to express ui-1 and ui+1:

1. 6
AE 410
Finite Difference Approximation

Multiply both sides by a:

Let us repeat the procedure for the other terms:

cui+1

1. 7
AE 410
Finite Difference Approximation

If we substitute in the original equation

1. 8
AE 410
Finite Difference Approximation

In order for the equation above to be satisfied we must impose conditions


on the a, b, c coefficients.

1. 9
AE 410
Finite Difference Method

This can be recast in this form:

1. 10
AE 410
Finite Difference Method

This admits as a solution:

If we substitute in the original equation

1. 11
AE 410
Finite Difference Method

This admits as a solution:

Or equivalently:

1. 12
AE 410
Truncation Error

To find the truncation error we substitute a, b and c:

And we retrieve the first derivative:

1. 13
AE 410
Truncation Error

The method is second order accurate!

1. 14
AE 410
Remarks on the Truncation Error

The truncation error is composed of three parts:

1. The coefficient -1/6

1. The power of

1. The derivative in u

All three are important BUT we will focus on the second in


this class.

1. 15
AE 410
Finite Difference

Following the same approach we can build approximation of


any order. Here we will see few examples:

FIRST ORDER (Backward and Forward)

1. 16
AE 410
FORWARD Finite Difference

1. 17
AE 410
Backward Finite Difference

1. 18
AE 410
Central Finite Difference

1. 19
AE 410
Remarks

The truncation error in finite difference is proportional to the second


derivative in the forward and backward approximation (1st order). So we
can say that FD (1st order forward and backward) are exact for linear
functions.

The central FD approximation is exact for a parabolic function.

1. 20
AE 410
Example Finite Difference 2nd Order

• Compute the truncation error for these two functions (leading


term in the Taylor expansion)

• Compare the truncation error obtained as a difference of the


analytical solution and approximate derivative

• The Function are: sin(mx) with m = 1 and m = 20

1. 21
AE 410
Functions

0.5
u(x)

-0.5

-1
0 1 2 3 4 5 6 7
x
1. 22
AE 410
EXAMPLE – Sin (x)

sin(x) ( x)2 @ 3 u
6 @x3
0.1

@u ui+1 ui 1
ert


@x i 2 x
0.05

0
0 0.2 0.4 0.6 0.8 1
Δx
1. 23
AE 410
Error as function of Grid Spacing
0
10

10
-1
sin(x)
-2
10

2
-3
10
ert

-4
10

10
-5 1
-6
10
-7
10
-8
10 -4 -3 -2 -1 0
10 10 10 10 10
Δx
1. 24
AE 410
EXAMPLE – Sin (20x)
1500

sin(20x) ( x)2 @ 3 u
6 @x3
1000 @u ui+1 ui 1

@x 2 x
ert

500

0
0 0.2 0.4 0.6 0.8 1
Δx
1. 25
AE 410
Sin(20x)

0
10
-1
10
-2
10
-3
10
ert

-4
10
-5
10
-6
10
-7
10
-8
10 -4 -3 -2 -1 0
10 10 10 10 10
Δx
1. 26
AE 410
What have we learned?

1. Numerical Differentiation using Finite Different method

1. Use of undetermined coefficients and Taylor expansion to build


approximation of any order to the derivative.

1. Concept of Truncation Error

1. 27
AE 410

You might also like