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

chapter 3 (1)

This document discusses the Finite Difference Method (FDM) for solving differential equations by approximating derivatives with finite differences. It outlines the steps involved in applying FDM, including discretizing the solution region and approximating differential equations, and describes three basic finite difference methods: forward, backward, and central differences. Additionally, it provides an example comparing numerical differentiation with analytical differentiation for a specific function.
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)
9 views

chapter 3 (1)

This document discusses the Finite Difference Method (FDM) for solving differential equations by approximating derivatives with finite differences. It outlines the steps involved in applying FDM, including discretizing the solution region and approximating differential equations, and describes three basic finite difference methods: forward, backward, and central differences. Additionally, it provides an example comparing numerical differentiation with analytical differentiation for a specific function.
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/ 39

Lectures on

Numerical Analysis
Chapter 3
Finite Difference Method
Assistant prof. Dr. Eng. Ibrahim Thamer Nazzal
1
15.03.2023
Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
What is a Finite Difference Equation?
A finite difference method (FDM) is is one of the available numerical methods for solving
differential equations by approximating derivatives with finite differences. Both the spatial
domain
. and time interval (if applicable) are discretized, or broken into a finite number of steps.
In general real life EM problems cannot be solved by using the analytical methods, because:
1. The PDE is not linear,
2. The solution region is complex,
3. The boundary conditions are of mixed types,
4. The boundary conditions are time dependent,

The numerical methods are based on replacing the differential


equations by algebraic equations (finite difference equations).

For finite difference method, this is done by replacing the derivatives by differences.
A function f that depends on x.
The first derivative of f(x) at a point is equivalent to the slope of a line tangent to the curve at
that point.
𝑑𝑓(𝑥) ∆𝑓 𝑓 𝑥+∆𝑥) −𝑓(𝑥)
= lim = lim
𝑑𝑥 ∆𝑥
∆𝑥→0 ∆𝑥→0 ∆𝑥
If we don’t take the indicated limit, we will have the following approximate relation for the derivative:
𝑑𝑓(𝑥) 𝑓 𝑥 + ∆𝑥) − 𝑓(𝑥) 𝑑(𝑓) ∆𝑓
≅ The differential ≈ the difference
𝑑𝑥 ∆𝑥 𝑑𝑥 ℎ
2
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Finite Difference Approximation Of The Derivative
Steps of finite difference solution:
 Divide the solution region into a grid of nodes,
 Approximate the given differential equation by finite difference equivalent,
 Solve the differential equations subject to the boundary conditions and/or initial conditions.
The rate of the change of the function with respect to the variable x is accounted between the
current value at: 𝑥 = 𝑥𝑖 f(x)
and the step forward at 𝑥 𝑖 + 1 = 𝑥𝑖 + Δ𝑥
f(x)
f(xi+1) f(xi+1
fi+1 at x = xi+1 fi at x = xi fi-1 at x = xi-1 )
Tangent of
x i+1 = xi + Δx, and x i-1 = x – Δx,
f(xi) f(x) at xi
The derivative 𝑓′(𝑥) of a function 𝑓(𝑥) f(xi-1) f(xi)
at the point 𝑥 = xi is defined by: f(xi-1)
f\’(xi)
𝑑(𝑓)
= lim
𝑓 𝑥𝑖 +∆𝑥) −𝑓(𝑥𝑖 ) Dx Dx x
𝑑𝑥 𝑥=𝑥𝑖 ∆𝑥→0 ∆𝑥
xi-1 xi xi+1
= lim
𝑓 𝑥𝑖 +∆𝑥) −𝑓(𝑥𝑖 )
=
∆𝑓
lim ∆𝑥 =
∆𝑓 ∆𝑓 𝑑(𝑓) ∆𝑓
∆𝑥→0 ∆𝑥 ∆𝑥→0 ∆𝑥 = The differential ≈ the difference
ℎ 𝑑𝑥 ℎ
where h = Δx
It is important to be aware of the fact that smaller the steps Δx the closer the values between the
differential and difference of the rate change of the function 15.03.2023
3
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Numerical Analyses
Three Basic Finite Difference Methods
In finite difference approximations of the slope, we can use values of the function in the
neighborhood of the point to achieve the goal. There are 3 ways to express differentials of a function:
1. Forward difference is the rate of change of the function
values between the “current” step at 𝑥𝑖 , and the function
value at a step “forward” at 𝑥𝑖+1 and equal to the slope of
the line that connects points: 𝑥𝑖 , 𝑓 𝑥𝑖 and
(𝑥𝑖+1 , 𝑓 𝑥𝑖+1 ):
𝒉
𝑑(𝑓)
ቚ =
𝑓 𝑥𝑖+1 −𝑓(𝑥𝑖 ) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖 )
𝑑𝑥 𝑥=𝑥𝑖 𝑥𝑖+1 −𝑥𝑖 =

𝒙𝒊−𝟏 𝒙𝒊 𝒙𝒊+𝟏 𝒙
𝑑(𝑓) 𝑓 𝑥𝑖+2 − 𝑓(𝑥𝑖+1 )
ቤ = Forward difference
𝑑𝑥 𝑥=𝑥 +1 ℎ
𝑖
𝑑(𝑓) 𝑓 𝑥𝑖+3 − 𝑓(𝑥𝑖+2 ) 𝒇(𝒙)
ቤ =
𝑑𝑥 𝑥=𝑥 +2 ℎ
𝑖
2. Backward difference is the rate of change of the function
values between the “current” step at 𝑥𝑖 , and the function value
at a step “back” at 𝑥𝑖−1 , which is the slope of the line that
𝒉
connects points: ((𝑥𝑖 , 𝑓(𝑥𝑖 ))and (𝑥𝑖−1 , 𝑓(𝑥𝑖−1 ):
𝑑(𝑓) 𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 )
ቚ = 𝒙𝒊−𝟏 𝒙 𝒙𝒊+𝟏
𝑑𝑥 𝑥=𝑥𝑖 𝑥𝑖 −𝑥𝑖−1 𝒊 𝒙
𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 ) Backward difference
4
= 15.03.2023
ℎ Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
3. Central difference is the rate of change of function f(x) is accounted for between the step at
back at (x-Δx) and the step ahead of x, i.e. (x+Δx), which is the slope of the line that connects
points:(𝑥𝑖−1 , 𝑓(𝑥𝑖−1 )and (𝑥𝑖+1 , 𝑓(𝑥𝑖+1 ): 𝒇(𝒙)
Central difference
𝑑(𝑓)
ቚ =
𝑓 𝑥𝑖+1 −𝑓(𝑥𝑖−1 ) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖−1 )
𝑑𝑥 𝑥=𝑥𝑖 𝑥𝑖+1 −𝑥𝑖−1 =
2ℎ
The step size in above is “2h” which is “big” in
compromising the accuracy.
𝒉

A more accurate “central difference scheme” is to


reduce the step size in each forward and backward
direction by half as show

We will have the corresponding expressions:

𝑓 𝑥 1 − 𝑓(𝑥 1 )
𝑑(𝑓) 𝑖+
2 𝑖− 2
ቚ =
𝑑𝑥 𝑥=𝑥𝑖 ℎ

5
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
The second order derivative

1. The forward difference scheme


The second order derivative of the function at 𝑥𝑖 can be derived by the following procedure
𝜕2 𝑓 𝑑 𝑑(𝑓) 𝛻 𝑓ȁ𝑥𝑖+1 −𝛻 𝑓ȁ𝑥𝑖 𝛻 𝑓ȁ𝑥𝑖+1 −𝛻 𝑓ȁ𝑥𝑖 𝛻 𝑓ȁ𝑥𝑖+1 −𝛻 𝑓ȁ𝑥𝑖
ቚ = 𝑑𝑥 ቚ = lim ≈ =
𝜕𝑥 2 𝑥=𝑥𝑖 𝑑𝑥 𝑥=𝑥𝑖 ∆𝑥→0 Δ𝑥 Δ𝑥 ℎ

𝑓 𝑥𝑖+2 −𝑓(𝑥𝑖+1 ) 𝑓 𝑥𝑖+1 −𝑓(𝑥𝑖 )


− 𝑓 𝑥𝑖+2 −2𝑓 𝑥𝑖+1 +𝑓(𝑥𝑖 )
ℎ ℎ
=
ℎ ℎ2
2. The backward difference scheme
and the send order derivatives in the form:
𝛻 𝑓ȁ𝑥𝑖 − 𝛻 𝑓ฬ 𝛻 𝑓ȁ𝑥𝑖 − 𝛻 𝑓ฬ 𝛻 𝑓ȁ𝑥𝑖 − 𝛻 𝑓ฬ
𝑑 𝑑(𝑓) 𝑥𝑖−1 𝑥𝑖−1 𝑥𝑖−1
ቚ = lim ≈ =
𝑑𝑥 𝑑𝑥 𝑥=𝑥𝑖 ∆𝑥→0 Δ𝑥 Δ𝑥 ℎ
𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 ) 𝑓 𝑥𝑖−1 −𝑓(𝑥𝑖−2 )
𝜕2 𝑓 𝑑 𝑑(𝑓) − 𝑓 𝑥𝑖 −2𝑓 𝑥𝑖−1 +𝑓(𝑥𝑖−2 )
ℎ ℎ
ቚ = ቚ = =
𝜕𝑥 2 𝑥=𝑥𝑖 𝑑𝑥 𝑑𝑥 ℎ ℎ2
𝑥=𝑥𝑖
3. The central difference scheme
𝛻 𝑓 ȁ𝑥 1 − 𝛻 𝑓 𝛻 𝑓 ȁ𝑥 1 − 𝛻 𝑓 𝛻 𝑓ȁ − 𝛻 𝑓ฬ
𝑖+ ቤ 𝑖+ ቤ 1
𝑥𝑖 +2
2 2
𝑥 1 𝑥 1 𝑥 1
𝑑 𝑑(𝑓) 𝑖−
2
𝑖−
2
𝑖−
2
ቚ = lim ≈ =
𝑑𝑥 𝑑𝑥 𝑥=𝑥𝑖 ∆𝑥→0 Δ𝑥 Δ𝑥 ℎ
𝑓 𝑥𝑖+1 −𝑓(𝑥𝑖 ) 𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 )
𝜕2 𝑓 𝑑 𝑑(𝑓) − 𝑓 𝑥𝑖+1 −2𝑓 𝑥𝑖 +𝑓(𝑥𝑖−1 )
ℎ ℎ

𝜕𝑥 2 𝑥=𝑥𝑖
= 𝑑𝑥 𝑑𝑥
ቚ = ℎ
= ℎ2
𝑥=𝑥𝑖 6
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
Example : Comparing numerical and analytical differentiation.
Consider the function 𝑓 𝑥 = 𝑥 3 .Calculate its first derivative at point x = 3 numerically with
the forward, backward, and central finite difference formulas and using:
(a) Points x = 2, x = 3, and x = 4. (b) Points x = 2.75, x = 3, and x = 3.25.
Compare the results with the exact (analytical) derivative.
SOLUTION
Analytical differentiation: The derivative of the function is 𝑓 ′ (𝑥) = 3 𝑥 2 , and the value of
the derivative at x = 3 is𝑓 ′ (3) = 3 (32 ) = 27 .
The points used for numerical differentiation are:
𝑥 2 3 4
𝑓 𝑥 8 27 64
Using the derivatives the forward, backward, and central finite difference formulas are:
Forward finite difference
𝑑(𝑓) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖 ) 𝑑(𝑓) 𝑓 4 −𝑓(3) 64 −27 37 − 27
ቤ = ቚ = = = 37 𝑒𝑟𝑟𝑜𝑟 = × 100 = 37.04%
𝑑𝑥 𝑥=𝑥 ℎ 𝑑𝑥 𝑥=3 4−3 1 27
𝑖

Backward finite difference


𝑑(𝑓) 𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 ) 𝑑(𝑓) 𝑓 3 −𝑓(2) 27 −8 19 − 27

𝑑𝑥 𝑥=𝑥𝑖
= ℎ
ቚ = = = 19 𝑒𝑟𝑟𝑜𝑟 = × 100 = 29.63%
𝑑𝑥 𝑥=3 3−2 1 27
Central finite difference
𝑑(𝑓) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖−1 ) 𝑑(𝑓) 𝑓 4 −𝑓(2) 64 −8 28 − 27
ቤ = ቚ = = = 28 𝑒𝑟𝑟𝑜𝑟 = × 100 = 3.704%
𝑑𝑥 𝑥=𝑥 2ℎ 𝑑𝑥 𝑥=3 4−2 2 27
7
𝑖 15.03.2023
Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
(b)The points used for numerical differentiation are:
𝑥 2.75 3 3.25
𝑓 𝑥 2.75 3 27 3.25 3

Using the derivatives the forward, backward, and central finite difference formulas are:
Forward finite difference

𝑑(𝑓) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖 ) 𝑑(𝑓) 𝑓 3.25 −𝑓(3) 3.253 −27


ቤ = ቚ = = = 29.3125
𝑑𝑥 𝑥=𝑥 ℎ 𝑑𝑥 𝑥=3 3.25−3 0.25
𝑖

29.3125 − 27
𝑒𝑟𝑟𝑜𝑟 = × 100 = 8.565%
27
Backward finite difference
𝑑(𝑓) 𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 ) 𝑑(𝑓) 𝑓 3 −𝑓(2.75) 27 −2.753
ቚ = ቚ = = = 24.8125
𝑑𝑥 𝑥=𝑥𝑖 ℎ 𝑑𝑥 𝑥=3 3−2.75 0.25
24.8125 − 27
𝑒𝑟𝑟𝑜𝑟 = × 100 = 8.102 %
27
Central finite difference
𝑑(𝑓) 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖−1 ) 𝑑(𝑓) 𝑓 3.25 −𝑓(2.75) 3.253 −2.753
ቚ = = = 27.0625
ቤ = 𝑑𝑥 𝑥=3 3.25 −2.75 0.5
𝑑𝑥 𝑥=𝑥 2ℎ
𝑖

27.0625 − 27
𝑒𝑟𝑟𝑜𝑟 = × 100 = 0.2315% 8
27 Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Finite Difference Schemes of partial derivatives
For a function f(x,y) with two independent variables, the partial derivatives with respect to x and
y at the point (𝑥𝑖 , 𝑦𝑖 ) can be approximated into three basic scheme :
1. Forward difference is the rate of change of the function
values between the “current” step at (𝑥𝑖 , 𝑦𝑗 ) , and the function
value at a step “forward” at 𝑥𝑖+1 , 𝑦𝑗 ):

𝜕𝑓 𝑓 𝑥𝑖+1 ,𝑦𝑗 −𝑓(𝑥𝑖 ,𝑦𝑗 ) 𝑓 𝑥𝑖+1 , 𝑦𝑗 − 𝑓(𝑥𝑖 , 𝑦𝑗 )



𝜕𝑥 𝑥=𝑥𝑖
= 𝑥𝑖+1 −𝑥𝑖 =
𝑦=𝑦𝑗 ℎ𝑥
𝜕𝑓 𝑓 𝑥𝑖 ,𝑦𝑗+1 −𝑓(𝑥𝑖 ,𝑦𝑗 ) 𝑓 𝑥𝑖 , 𝑦𝑗+1 − 𝑓(𝑥𝑖 , 𝑦𝑗 )

𝜕𝑦 𝑥=𝑥𝑖
= 𝑦𝑗+1 −𝑦𝑗 =
𝑦=𝑦𝑗 ℎ𝑦

2. Backward difference is the rate of change of the function


values between the “current” step at 𝑥𝑖 , 𝑦𝑗 𝑖 , and the function
value at a step “back” at 𝑥𝑖−1 , 𝑦𝑗 , ∶

𝜕𝑓 𝑓 𝑥𝑖 ,𝑦𝑗 −𝑓(𝑥𝑖−1 ,𝑦𝑗 ) 𝑓 𝑥𝑖 , 𝑦𝑗 − 𝑓(𝑥𝑖−1 , 𝑦𝑗 )


ቚ = =
𝜕𝑥 𝑥=𝑥𝑖 𝑥𝑖 −𝑥𝑗 −1
𝑦=𝑗 ℎ𝑥

𝜕𝑓 𝑓 𝑥𝑖 ,𝑦𝑗 −𝑓(𝑥𝑖 ,𝑦𝑗−1 ) 𝑓 𝑥𝑖 , 𝑦𝑗 − 𝑓(𝑥𝑖 , 𝑦𝑗−1 )


ቚ = =
𝜕𝑦 𝑥=𝑥𝑖 𝑦 −𝑦𝑗−1 ℎ𝑦
𝑦=𝑦𝑗

9
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
3. Central difference is the rate of change of function f(x) is accounted for between the step at
𝜕𝑓
back at (𝑥𝑖−1 , 𝑦𝑗 ) and the step ahead of 𝑥𝑖+1 , 𝑦𝑗 𝑓𝑜𝑟 𝜕𝑥ቚ 𝑥=𝑥𝑖
𝑦=𝑦𝑗
𝜕𝑓 𝑓 𝑥𝑖+1 ,𝑦𝑗 −𝑓(𝑥𝑖−1 ,𝑦𝑗 ) 𝑓 𝑥𝑖+1, 𝑦𝑗 − 𝑓(𝑥𝑖−1,𝑦𝑗 )
ቚ =
𝜕𝑥 𝑥=𝑥𝑖 𝑥𝑖+1 −𝑥𝑖−1 =
𝑦=𝑦𝑗 2ℎ𝑥
And is accounted for between the step atback at
𝜕𝑓
(𝑥𝑖 , 𝑦𝑗−1 ) and the step ahead of 𝑥𝑖 , 𝑦𝑗+1 𝑓𝑜𝑟 𝜕𝑦ቚ 𝑥=𝑥𝑖
𝑦=𝑦𝑗
𝜕𝑓 𝑓 𝑥𝑖 ,𝑦𝑗+1 −𝑓(𝑥𝑖 ,𝑦𝑗−1 )
ቚ = 𝑓 𝑥𝑖 , 𝑦𝑗+1 − 𝑓(𝑥𝑖 , 𝑦𝑗−1 )
𝜕𝑦 𝑥=𝑥𝑖 𝑦𝑗+1 − 𝑦𝑗−1 =
𝑦=𝑦𝑗 2ℎ𝑦
The step size in above is “2h” which is “big” in 𝑦 𝑛
compromising the accuracy. 𝑖,𝑗+1
A more accurate “central difference
scheme” is to reduce the step size in 𝑖−1,𝑗 𝑖+1,𝑗
each forward and backward direction by 𝑖,𝑗
half as show
We will have the corresponding expressions: 𝑦𝑖 𝑖,𝑗−1
𝑓 𝑥 1 ,𝑦𝑗 −𝑓(𝑥 1 ,𝑦𝑗 )
𝑖+ 𝑖−
∆𝑦
𝜕𝑓 2 2
ቚ =
𝜕𝑥 𝑥=𝑥𝑖 ℎ𝑥 𝑦2
𝑦=𝑦𝑗
∆𝑥
𝑓 𝑥𝑖 ,𝑦 1 −𝑓(𝑥𝑖 ,𝑦 1)
𝜕𝑓 𝑗+2 𝑗−2 𝑦1
ቚ = 𝑥1 𝑥2 𝑥𝑖 𝑥𝑚
𝜕𝑦 𝑥=𝑥𝑖 ℎ𝑦 10
𝑦=𝑦𝑗 15.03.2023
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Engineering Analysis
The second order derivative
The second order derivative of the function 𝑦𝑛
at x and y can be derived by the following 𝑖,𝑗+1
procedure
𝜕2 𝑓 𝑓 𝑥𝑖+1 ,𝑦𝑗 −2𝑓 𝑥𝑖 ,𝑦𝑗 +𝑓(𝑥𝑖−1 ,𝑦𝑗 )

2 𝑥=𝑥𝑖 = 2
𝜕𝑥 ℎ 𝑥 𝑖−1,𝑗 𝑖+1,𝑗
𝑦=𝑦𝑗
𝑖,𝑗

𝜕2 𝑓 𝑓 𝑥𝑖 ,𝑦𝑗+1 −2𝑓 𝑥𝑖 ,𝑦𝑗 +𝑓(𝑥𝑖 ,𝑦𝑗−1 )


ቚ = 𝑦𝑖
𝜕𝑦 2 𝑥=𝑥𝑖 ℎ2 𝑦 𝑖,𝑗−1
𝑦=𝑦𝑗
∆𝑦
𝑦2
∆𝑥
𝑦1
𝑥1 𝑥2 𝑥𝑖 𝑥𝑚
𝜕2 𝑓 𝑓 𝑥 ,𝑦 −𝑓 𝑥𝑖−1 ,𝑦𝑗+1 − 𝑓 𝑥𝑖+1 ,𝑦𝑗−1 −𝑓 𝑥𝑖−1 ,𝑦𝑗−1
ቚ 𝑥=𝑥𝑖 = 𝑖+1 𝑗+1 2ℎ2 𝑥 ℎ2 𝑦
𝜕𝑥 𝜕𝑦 y
𝑦=𝑦𝑗

i,j+1

i-1,j i,j i+1,j


i,j-1
x

11
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
Example 1
The deflection y in a simply supported beam with a uniform load q and a tensile axial load T is
given by y

d 2 y Ty qx( L  x) q
 
dx 2 EI 2 EI
T x T
Where
X = location along the beam (in). L
T = tension applied (lbs)
E = Young’s modulus of elasticity of the beam (psi). B C
I= second moment of area (in4) y ( x  0)  0 y ( x  L )  0
Q= uniform loading intensity (lb/in)
L= length of beam (in) Figure 3 Simply supported beam for Example
Given, T  7200 lb, q  5400 lbsin, E  30 Msi , and I  120 in 4
L  75 in
a) Find the deflection of the beam at x  50" Use a step size of Dx  25"
and approximate the derivatives by central divided difference approximation.
Solution
a) Substituting the given values,
d2y 7200y (5400) x(75  x )
 
dx 2 (30  106 )(120) 2(30  106 )(120)
d2y
2
 2  106 y  7.5  10 7 x(75  x) (1) 12
dx Engineering Analysis Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
𝑑2 y
Approximating the derivative at node i by the central divided difference approximation,
𝑑𝑥 2
d 2 y yi 1  2 yi  yi 1 d2y
  2  106 y  7.5  10 7 x(75  x)
dx 2 ( Dx ) 2 dx 2

We can rewrite the equation as

yi 1  2 yi  yi 1 i 1 i i 1
 2  106 yi  7.5  107 xi (75  xi ) Figure central difference method.
(Dx) 2

Since ∆ 𝑥 = 25, we have 4 nodes as given in Figure 3 𝑓 𝑥𝑖+1 − 2𝑓 𝑥𝑖 + 𝑓(𝑥𝑖−1 )


The location of the 4 nodes then is ℎ2
𝑥1 = 0 i 1 i2 i 3 i4
𝑥2 = 𝑥1 + ∆𝑥 = 0 + 25 = 25
x0 x  25 x  50 x  75
𝑥3 = 𝑥2 + ∆𝑥 = 25 + 25 = 50
𝑥4 = 𝑥3 + ∆𝑥 = 50 + 25 = 75 Figure Finite difference method from x= 0
Writing the equation at each node, we get to x=75 with ∆ 𝑥 = 25.
Node 1: From the simply supported boundary condition at x= 0 we obtain
y1  0
Node 2: Rewriting equation (1) for node 2 gives
y3  2 y 2  y1 6 7
2
 2  10 y 2  7.5  10 x 2 (75  x 2 )
(25) 7
0.0016y1  0.003202y2  0.0016y3  7.5 10 (25)(75  25)
0.0016y1  0.003202y2  0.0016y3  9.375104 Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
13
Engineering Analysis
Node 3: Rewriting equation (E1.4) for node 3 gives yi 1  2 yi  yi 1
 2  106 yi  7.5  107 xi (75  xi )
y 4  2 y3  y 2 (Dx) 2

2
 2  106 y3  7.5  107 x3 (75  x3 )
(25)
0.0016y2  0.003202y3  0.0016y4  7.5 107 (50)(75  50)
0.0016y2  0.003202y3  0.0016y4  9.375104
Node 4: From the simply supported boundary condition at x = 75, we obtain y4  0
y1  0
0.0016y1  0.003202y2  0.0016y3  9.375104
0.0016y2  0.003202y3  0.0016y4  9.375104
y4  0
Above Equations are 4 simultaneous equations with 4 unknowns and can be written in matrix
form as
 1 0 0 0   y1  0 
0.0016  0.003202 0.0016 0   y  9.375  10 4 
  2    
 0 0.0016  0.003202 0.0016  y3  9.375  10  4

    
 0 0 0 1   y 4  0 
The above equations can be solved using on of the iterative methods such as the Gauss-Siedel
method). Solving the equations we get,
 y1  0 
y   
 2    0.5852
 y3   0.5852
   
y(50)  y( x2 )  y2  0.5852"
 y 4  0  15.03.2023
14
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Engineering Analysis
𝑑2 𝑦
Example :- Solve the following differential equation 𝑥 𝑑𝑥 2 +𝑦 =0
where
Subject to boundary condition 𝑦 1 = 1, 𝑦 2 = 2
Solution-
𝑥𝑖−1 𝑥𝑖−12 𝑥𝑖 𝑥 1 𝑥𝑖+1
𝑖+
𝜕2 𝑓 𝑓 𝑥𝑖+1 −2𝑓 𝑥𝑖 +𝑓(𝑥𝑖−1 ) 2
=
𝜕𝑥 2 ℎ2
𝜕2 𝑓 𝑦𝑖+1 −2𝑦𝑖 +𝑦𝑖−1
=
𝜕𝑥 2 ℎ2

𝑤𝑒 𝑘𝑛𝑜𝑤 𝑡ℎ𝑎𝑡 0 ≤ i ≤ n, 𝑥𝑖 = 1 + 𝑖ℎ, 𝑛ℎ = 1, 𝑎𝑛𝑑 𝑙𝑒𝑡 𝑛 = 4,


by substituting into the main equation, one obtain
𝑦 −2𝑦 +𝑦
1
𝑥𝑖 𝑖+1 ℎ2𝑖 𝑖−1 + 𝑦𝑖 = 0 𝑛= 4= ,

16 𝑥𝑖 𝑦𝑖+1 + (1 − 32𝑥𝑖 )𝑦𝑖 + 16 𝑥𝑖 𝑦𝑖−1 = 0 (1)
Substituting (i= 1,2,3) into the above equation, one obtain
39 𝑦1 - 20 𝑦2 + 0 𝑦3 = 20
𝑥1 𝑥2 𝑥3
24 𝑦1 - 47 𝑦2 + 24 𝑦3 = 0
0 𝑦1 - 28 𝑦2 + 55𝑦3 = 56 𝑥0 = 1 𝑥4 =2

Using gauss elimination method , one obtain


𝑦1 = 1.3512 , 𝑦2 = 1.63495 𝑦3 = 1.85053 15
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Discretization methods (Finite Difference) using Taylor Series Expansion
• Taylor’s series expansion:
Consider a continuous function of x, namely, f(x), with all derivatives defined at x  Dx
Then, the value of f at a location can be estimated from a Taylor series expanded about point x,
that is 2
f 3
1 f n
1 f 1 f
f ( x  Dx)  f ( x)  Dx  Dx 2
 Dx 3
 ...  (Dx) n  ...
x 2! x 2
3! x 3
n! x n

In general, to obtain more accuracy, additional higher-order terms must be included.


• Higher order derivatives are unknown and can be dropped when the distance between grid
points is small.
Taylor Series
Problem: For a smooth function f(x),
y f(x)
Given: Values of f(xi) and its derivatives at xi
Find out: Value of f(x) in terms of f(xi), f(xi), f(xi), ….
xi
If the function f and its n+1 derivatives are x
continuous on an interval containing xi and x,
then the value of the function f at x is given by f(xi)
f ' ' ( xi ) f (3) ( xi )
f ( x)  f ( xi )  f ' ( xi )( x  xi )  ( x  xi ) 
2
( x  xi ) 3
2! 3!
f ( n) ( xi )
 ...  ( x  xi ) n  Rn 16
n! Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Finite Difference Approximations of the First Derivative using the Taylor Series
(forward difference)
Assume we can expand a unction f(x) into a Taylor Series about the point xi+1
f ' ' ( xi ) f (3) ( xi )
f ( xi 1 )  f ( xi )  f ' ( xi )( xi 1  xi )  ( xi 1  xi ) 
2
( xi 1  xi )3
2! 3!
f ( n ) ( xi ) y
 ...  ( xi 1  xi ) n  Rn f(x)
n! h h
xi xi+1
x
f(xi) f(x )
i+1
f " ( xi ) 2 f (3) ( xi ) 3 f ( n ) ( xi ) n
f ( xi 1 )  f ( xi )  f ' ( xi )h  h  h  h 
2! 3! n!
f ( xi 1 )  f ( xi ) f " ( xi ) f ( 3) ( xi ) 2 f ( n ) ( xi ) n 1
f ' ( xi )   h  h  h 
h 2! 3! n!
Ignore all of these terms

f ( xi 1 )  f ( xi ) + 0(h)
f ' ( xi ) 
h

17
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
Finite Difference Approximations of the First Derivative using the Taylor Series
(backward difference)
Assume we can expand a function y f(x) h
f(x) into a Taylor Series about the
point xi-1
xi-1 xi x
f(xi-1)
f(xi)
( 3)
f ' ' ( xi ) f ( xi )
f ( xi 1 )  f ( xi )  f ' ( xi )( xi 1  xi )  ( xi 1  xi ) 2  ( xi 1  xi ) 3
2! 3!
( n)
f ( xi )
 ...  ( xi 1  xi ) n  Rn
n! -h
( 3)
f " ( xi ) 2 f ( xi ) 3 f ( n ) ( xi ) n
f ( xi 1 )  f ( xi )  f ' ( xi )h  h  h  h 
2! 3! n!
f ( xi )  f ( xi 1 ) f " ( xi ) f (3) ( xi ) 2 f ( n ) ( xi ) n 1
f ' ( xi )   h  h  h 
h 2! 3! n!
f i  f ( xi )  f ( xi 1 )
f ( xi )  f ( xi 1 )
f ' ( xi )   O(h ) First backward f ' ( x ) 
f i
 O ( h)
h difference i
h

18
15.03.2023
Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Finite Difference Approximations of the Second Derivative using the Taylor
Series (forward difference)
f(x)
y
xi xi+1 xi+2 x
f(xi) h f(xi+2)
f(xi+1)
f " ( xi ) 2 f (3) ( xi ) 3 f ( n ) ( xi ) n
f ( xi 1 )  f ( xi )  f ' ( xi )h  h  h  h  (1)
2! 3! n!
f " ( xi ) 2 f (3) ( xi ) 3 f ( n ) ( xi ) n n
f ( xi  2 )  f ( xi )  f ' ( xi )2h  4h  8h    2 h 
2! 3! n! (2)

𝑓 𝑥𝑖+2 −2𝑓 𝑥𝑖+1 +𝑓(𝑥𝑖 )


𝑓′′(𝑥𝑖 )= −ℎ 𝑓 (3) (𝑥𝑖 ) (eq. 2)- 2* ( eq.1)
ℎ2

D2 f i D(Df i )
f " ( xi )  2  O(h)  2
 O ( h)
h h
Recursive formula for d2 f Dn f i
any order derivative
 2  O ( h)
dxn x  xi
h

19
15.03.2023
Numerical Analyses Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Second Derivative Centered Difference Approximation (central difference)

f " ( xi ) 2 f (3) ( xi ) 3
f ( xi 1 )  f ( xi )  f ' ( xi )h  h  h   (1)
2! 3!
( 3)
f " ( xi ) 2 f ( xi ) 3
f ( xi 1 )  f ( xi )  f ' ( xi )h  h  h   (2)
2! 3!
( 4)
f ( xi ) 4
f ( xi 1 )  f ( xi 1 )  2 f ( xi )  f ( xi )h  2
2
h  (1)+(2)
4!
f ( xi 1 )  2 f ( xi )  f ( xi 1 ) f ( 4) ( xi ) 2
f ( xi )  2
2 h 
h 4!
f ( xi 1 )  2 f ( xi )  f ( xi 1 )
f ( xi )  2
 O ( h 2
)
h

20
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Centered Difference Approximation
f " ( xi ) 2 f (3) ( xi ) 3
f ( xi 1 )  f ( xi )  f ' ( xi )h  h  h  (1)
2! 3!
f " ( xi ) 2 f (3) ( xi ) 3
f ( xi 1 )  f ( xi )  f ' ( xi )h  h  h  (2)
2! 3!
f (3) ( xi ) 3 (1)-(2)
f ( xi 1 )  f ( xi 1 )  2 f ' ( xi )h  2 h 
3!
f ( xi 1 )  f ( xi 1 ) f (3) ( xi ) 2
f ' ( xi )  2 h 
2h 3!
f ( xi 1 )  f ( xi 1 )
f ' ( xi )   O(h 2 )y
2h f(x)

xi xi+1 xi+2
h
x
f(xi)
f(xi+2)
f(xi+1)
21
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Higher Order Finite Difference Approximations
f ( xi 1 )  f ( xi ) f " ( xi ) f (3) ( xi ) 2 f ( n ) ( xi ) n 1
f ' ( xi )   h  h  h 
h 2! 3! n!

f ( xi  2 )  2 f ( xi 1 )  f ( xi 1 )
f " ( xi )  2
 hf ( 3)
( xi )  
h

 f ( xi  2 )  2 f ( xi 1 )  f ( xi ) 
 hf ( 3)
( x )  ...
f ( xi 1 )  f ( xi )  h
i 
f ' ( xi )   h
h 2!
f (3) ( xi ) 2 f ( n ) ( xi ) n 1
 h  h 
3! n!
 f ( xi  2 )  4 f ( xi 1 )  3 f ( xi ) h 2
f ' ( xi )   f ' ' ' ( x)  ...
2h 3

 f ( xi  2 )  4 f ( xi 1 )  3 f ( xi )
f ' ( xi )   O(h 2 )
2h

22
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
First Derivative

Method Formula Truncation


Error
Two-point forward difference 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖 ) 0(h)
𝑓′ 𝑥𝑖 =

Three-point forward difference 𝑓′ 𝑥 = −3 𝑓 𝑥𝑖 +4 𝑓 𝑥𝑖+1 −𝑓 𝑥𝑖+2 0(ℎ2 )
𝑖 2ℎ

Two-point central difference 𝑓 𝑥𝑖+1 − 𝑓(𝑥𝑖−1 ) 0(h)


𝑓′ 𝑥𝑖 =
2ℎ
Two-point backward difference 𝑓′ 𝑥𝑖 =
𝑓 𝑥𝑖 −𝑓(𝑥𝑖−1 ) 0(ℎ2 )

three-point central difference 𝑓 𝑥𝑖−2 − 4 𝑓 𝑥𝑖−1 + 3 𝑓 𝑥𝑖 0(ℎ2 )


𝑓′ 𝑥𝑖 =
2ℎ
Four-point central difference 𝑓′ 𝑥𝑖 =
𝑓 𝑥𝑖−2 −8 𝑓 𝑥𝑖−1 +8 𝑓 𝑥𝑖+1 −𝑓 𝑥𝑖+2 0(ℎ4 )
12ℎ

23
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Second Derivative

Method Formula Truncation


Error
Three-point forward difference 𝑓 𝑥𝑖 − 2 𝑓 𝑥𝑖+1 + 𝑓 𝑥𝑖+2 0(h)
𝑓′′ 𝑥𝑖 =
ℎ2
Four-point forward difference
𝑓′′ 𝑥𝑖 =
2 𝑓 𝑥𝑖 −5 𝑓 𝑥𝑖+1 +4𝑓 𝑥𝑖+2 −𝑓 𝑥𝑖+3 0(ℎ2 )
ℎ2

Three-point backward difference 𝑓 𝑥𝑖−2 − 2𝑓 𝑥𝑖−1 + 𝑓 𝑥𝑖 0(h)


𝑓′′ 𝑥𝑖 =
ℎ2
Four -point backward difference
𝑓′′ 𝑥𝑖 =
−3 𝑓 𝑥𝑖−3 +4 𝑓 𝑥𝑖−2 −5 𝑓 𝑥𝑖−1 +2 𝑓 𝑥𝑖 0(ℎ2 )
ℎ2

Three-point central difference


𝑓′′ 𝑥𝑖 =
𝑓 𝑥𝑖−1 −2 𝑓 𝑥𝑖 + 𝑓 𝑥𝑖+1 0(ℎ2 )
ℎ2

Five-point central difference 𝑓′′ 𝑥𝑖 = 0(ℎ4 )


− 𝑓 𝑥𝑖−2 +16 𝑓 𝑥𝑖−1 −30 𝑓 𝑥𝑖+1 −16𝑓 𝑥𝑖+1 −𝑓 𝑥𝑖+2
12ℎ2

24
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Finite Difference Methods for Solving PDE's
A partial differential equation (PDE) is an equation that involves an unknown function (the dependent
variable) and some of its partial derivatives with respect to two or more independent variables. The
classification of PDEs is important for the numerical solution you choose. 3 Parabolic
1 Elliptic 2 Hyperbolic For example, the heat or
For example the 1-D
For example, Laplace's diffusion Equation 𝜕𝑢 𝜕2𝑢
wave equation =𝐷
equation: 𝜕 2 𝑢 𝜕 2 𝑢 𝑦 𝜕𝑡 𝜕𝑥 2
𝜕2 𝑢 𝜕2 𝑢
+ 𝑐 2
= 𝑦𝑛
𝜕𝑥 2 𝜕𝑦 2 𝜕𝑥 2 𝜕𝑡 2
Using finite difference method to solve the system
1. Discretize domain into grid of evenly spaced points. 𝑢 𝑖,𝑗+1
2 2
2. For nodes where u is unknown for example :𝜕 𝑢 + 𝜕 𝑢
𝜕𝑥 2 𝜕𝑦 2 𝑦 𝑖 𝑢 𝑖−1,𝑗 𝑢 𝑖,𝑗 𝑢 𝑖+1,𝑗
discretize
𝜕2 𝑢 𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
∆𝑦
= +0 (∆𝑥 2 )
𝜕𝑥 2 (∆𝑥)2 𝑦2 𝑢 𝑖,𝑗−1
𝜕2 𝑢 𝑢𝑖,𝑗+1 −2 𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1 ∆𝑥
= +0 (∆𝑦 2 ) 𝑦1
𝜕𝑦 2 (∆𝑦)2 𝑥
When ∆𝑥 = ∆𝑦 = ℎ, substitute into main eqaution 𝑥1 𝑥2 𝑥𝑖 𝑥𝑚
𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 𝑢𝑖,𝑗+1 −2 𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1
𝑢𝑖,𝑗+1
+ + 0 (ℎ2 )
(∆𝑥)2 (∆𝑦)2
𝑢𝑖−1,𝑗 𝑢 𝑖,𝑗 𝑢𝑖+1,𝑗
3. Using Boundary Conditions, write, n*m equations for
u(xi=1:m, yj=1:n) or n*m unknowns.
4. Solve this banded system with an efficient scheme. Using
Gauss-Seidel iteratively. 𝑢𝑖,𝑗−1 25
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
1 Elliptic equation 𝑢𝑖,𝑗+1
𝜕2 𝑢 𝜕2 𝑢
The Laplace Equation + =0
𝜕𝑥 2 𝜕𝑦 2
The Laplace molecule for ∆𝑥 = ∆𝑦 = ℎ 𝑢𝑖−1,𝑗 𝑢𝑖+1,𝑗
𝑢𝑖+1,𝑗 + 𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 − 4 𝑢𝑖,𝑗 = 0 𝑢 𝑖,𝑗
1
𝑢𝑖,𝑗 = (𝑢𝑖+1,𝑗 +𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 ) 𝑢𝑖,𝑗−1
4
This shows that the value of 𝑢𝑖,𝑗 is the average of
its values at the four neighboring diagonal mesh 𝑦 𝑏2,5 𝑏 3,5 𝑏 4,5 𝑏 5,5
points. is called the diagonal five-point formula 𝑏 1,5
which is represented in Figure.
The temperature distribution can be estimated by 𝑏 1,4 𝑏 5,4
discretizing the Laplace equation at 9 points and 𝑢 2,4 𝑢 3,4 𝑢 4,4
solving the system of linear equations.
1 𝑏 1,3 𝑏 5,3
𝑢2,3 = (𝑏 +𝑢3,3 + 𝑢2,4 + 𝑢2,2 ) 𝑢 2,3 𝑢 3,3 𝑢 4,3
4 1,3
∆𝑦
1
𝑢3,4 = (𝑢2,4 +𝑢4,4 + 𝑏3,5 + 𝑢3,3 ) 𝑏 1,2 𝑏5,2
4
𝑢 2,2 𝑢 3,2 𝑢 4,2
1
𝑢4,3 = (𝑢3,3 +𝑏5,3 + 𝑢4,4 + 𝑢4,2 ) ∆𝑥 𝑥
4
𝑏 1,1
1
𝑢3,2 = (𝑢2,2 +𝑢4,2 + 𝑢3,3 + 𝑢3,1 ) 𝑏 2,1 𝑏 3,1 𝑏 4,1 𝑏 5,1
4
26
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Having found all the nine values of 𝑢𝑖,𝑗 once, their accuracy is improved by either of the
following iterative methods. In each case, the method is repeated until the difference between
two consecutive iterates becomes negligible.
(i) Jacobi’s method. Denoting the nth iterative value of 𝑢𝑖,𝑗 , by 𝑢𝑛 𝑖,𝑗 , the iterative formula to
solve is
1
𝑢𝑛+1 𝑖,𝑗 = (𝑢 𝑛
𝑖+1,𝑗
+ 𝑢 𝑛
𝑖−1,𝑗 + 𝑢𝑛 𝑖,𝑗+1 + 𝑢𝑛 𝑖,𝑗−1 )
4

It gives improved values of 𝑢𝑖,𝑗 at the interior mesh points and is called the point Jacobi’s
formula.

(ii) Gauss-Seidal method. In this method, the iteration formula is

1
𝑢𝑛+1 𝑖,𝑗 = (𝑢𝑛 𝑖+1,𝑗 + 𝑢𝑛+1 𝑖−1,𝑗 + 𝑢𝑛+1 𝑖,𝑗+1 + 𝑢𝑛 𝑖,𝑗−1 )
4

It utilizes the latest iterative value available and scans the mesh points symmetrically from left
to right along successive rows.

27
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Example: A vertical steel plate of dimensions 2.7 cm X 2.7 cm and negligible thickness is in
steady state conditions. On the top edge, the temperature is 1000 C and on the bottom the
temperature is fixed at 500 C. The temperature on the left and right edges are 500 C. Solve to
obtain heat distribution.
𝜕2 𝑇 𝜕2 𝑇
The governing equation is + =0
𝜕𝑥 2 𝜕𝑦 2
𝑇 𝑥 = 2.7, 𝑦 = 500 C ; 𝑇 𝑥 = 0, 𝑦 = 500 C ;
𝑇 𝑥, 𝑦 = 2.7 = 1000 C ; 𝑇 𝑥, 𝑦 = 0 = 500 C.
∆ 𝑥 = ∆ 𝑦 = 0.9 𝑐𝑚.
We know that the diagonal five-point formula
1
𝑢𝑖,𝑗 = 4 (𝑢𝑖+1,𝑗 +𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 )
𝑦 1000 C
The vertical plate is discretizes below:
We need to find temperatures 𝑇 1,1 , 𝑇 1,2 , 𝑇 2,1 and 𝑇 2,2
𝑇 1,2 𝑇 2,2 2.7 𝑐m
,,, (four unknowns
Apply FDE at node (1,1), 500 C 500 C
𝑇 1,1 𝑇 2,1
50 + 50 + 𝑇1 2 + 𝑇2 1 − 4𝑇1 1 = 0
or
−4𝑇1 1 + 𝑇1 2 + 𝑇2 1 = −100 (1) 𝑥
Node or grid point (1,2), 500 C
50 + 𝑇1 1 + 𝑇2 2 + 100 − 4𝑇1 2 = 0 2.7 𝑐m
or 𝑇1 1 − 4𝑇1 2 + 𝑇2 2 = −150 (2)
28
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Node or grid point (2,1),
𝑇1 1 + 50 − 4 𝑇21 + 𝑇2 2 + 50 = 0
or 𝑇1 1 − 4𝑇2 1 + 𝑇2 2 = −100 (3)
Node or grid point (2,2),
𝑇1 2 + 𝑇2 1 − 4 𝑇22 + 100 + 50 = 0
𝑇1 2 + 𝑇2 1 − 4𝑇2 2 = −150 (4)
From equations 1, 2, 3 and 4 we have
−4𝑇1 1 + 𝑇1 2 + 𝑇2 1 = −100 (1)

𝑇1 1 − 4𝑇1 2 + 𝑇2 2 = −150 (2)


𝑇1 1 − 4𝑇2 1 + 𝑇2 2 = −100 (3)
𝑇1 2 + 𝑇2 1 − 4𝑇2 2 = −150 (4)

−4 1 1 0 𝑇1 1 −100
1 −4 0 1 𝑇1 2 −150
=
1 0 −4 1 𝑇2 1 −100
0 1 1 −4 𝑇2 2 −150
solve this system of linear equations. 15.03.2023
29
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal
Numerical Analyses
Example Consider steady two-dimensional heat transfer in a long solid body whose cross section
is given in the figure. The temperatures at the selected nodes and the thermal conditions on the
boundaries are as shown. The thermal conductivity of the body is k 180 W/m · °C, and heat is
generated in the body uniformly at a rate of g = 107 10W/m3. Using the finite difference method
with a mesh size of Δx =Δy = 10 cm, determine the temperatures at nodes 1, 2, 3, and 4 and
Analysis: The nodal spacing is given to be Δx =Δx = l = 0.1
m, and the general finite difference form of an interior node
equation for steady two-dimensional heat conduction for the
case of constant heat generation is expressed as
1
𝑢𝑖,𝑗 = (𝑢𝑖+1,𝑗 +𝑢𝑖−1,𝑗 + 𝑢𝑖,𝑗+1 + 𝑢𝑖,𝑗−1 )
4
𝑔𝑛𝑜𝑑𝑒 𝑙 2
𝑇𝑙𝑒𝑓𝑡 + 𝑇𝑡𝑜𝑝 + 𝑇𝑏𝑜𝑡𝑡𝑜𝑚 + 𝑇𝑟𝑖𝑔ℎ𝑡 − 4 𝑇𝑛𝑜𝑑𝑒 + =0
𝑘
There is symmetry about a vertical line passing through
the middle of the region, and thus we need to consider
only half of the region. Then,
𝑇1 = 𝑇2 𝑎𝑛𝑑 𝑇3 = 𝑇4
𝑔𝑙 2
𝑛𝑜𝑑𝑒 1 100 + 120 + 𝑇2 + 𝑇3 − 4 𝑇1 + =0
𝑘
𝑔𝑙 2
𝑛𝑜𝑑𝑒 3 150 + 200 + 𝑇1 + 𝑇4 − 4 𝑇3 + =0
noting that 𝑇1 = 𝑇2 and 𝑇 = 𝑇 and substituting 𝑘
3 4
0.12 × 107 The solution of the above system is
200 + 𝑇3 − 3𝑇1 + =0
180
0.1 × 107
2 𝑇1 = 𝑇2 = 411.5 C and 𝑇3 = 𝑇4 = 439 C
350 + 𝑇1 − 3𝑇3 + =0 30
180 Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Engineering Analysis
Explicit and Implicit methods
Explicit and implicit methods are approaches used in numerical analysis for obtaining
numerical approximations to the solutions of time-dependent differential equations.
Explicit Method = a formulation of equation into a FD equation that expresses one unknown in
terms of the known values or express all future (t + Δt) values, T(x, t + Δt), in terms of current (t)
and previous (t - Δt) information, which is known.

Implicit methods calculate a solution by solving an equation involving both the current state of
the system and the later one or Implicit Schemes express all future (t + Δt) values, T(x, t + Δt),
in terms of other future (t + Δt), current (t), and sometimes previous (t - Δt) information.

Finite Difference Solution of Partial Differential Equations: Parabolic Equation

𝜕𝑢 𝜕2𝑢
• Solve the p.d.e. =𝐷 unknown values
𝜕𝑡 𝜕𝑥 2
The finite difference approximation to the PDE is then known values
Evaluate the p.d.e. at (i,j), (i = spatial index and j = temporal index

𝜕𝑢
Depending on how is approximated, we have three basic schemes:
𝜕𝑡

1. Explicit method 2. Implicit method 3. Crank–Nicolson method .


31
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
The explicit method

1. The explicit method - one unknown or nodal value is directly expressed in terms of known
pivotal values. • The process advancing from a known time level(s) to the unknown time level
is called “time marching”.
In this approaches using a forward difference at time t and a second order central
difference for the space derivatives. 𝜕𝑢 𝜕2𝑢
𝜕2 𝑢
=𝐷
Use a central difference approximation to evaluate at 𝑖, 𝑗 𝜕𝑡 𝜕𝑥 2
𝜕𝑥 2
𝜕2 𝑢 𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 𝑦
ቚ =
𝜕𝑥 2 𝑖,𝑗 (∆𝑥)2 𝑢 𝑖,𝑗+1
unknown values
• Let’s use a forward difference approximation
𝜕𝑢
to evaluate at 𝑖, 𝑗 𝑢 𝑖−1,𝑗 𝑢 𝑖,𝑗 𝑢 𝑖+1,𝑗
𝜕𝑡 known values 𝑢=0
𝜕𝑢 𝑢 𝑥𝑖,𝑗+1 − 𝑢(𝑥𝑖,𝑗 ) 𝑢 =0 ∆𝑡 𝑢 𝑖,𝑗−1
ቤ =
𝜕𝑡 𝑖,𝑗 ∆𝑡
∆𝑥
Substituting into the main equation, one obtain 𝑥
𝑢 = 𝑓(𝑥) 𝑥𝑚
𝑢𝑖,𝑗 +1−𝑢𝑖,𝑗 𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
=D
∆𝑡 (∆𝑥)2
𝑢𝑖+1,𝑗 −2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 𝐷∆𝑡
𝑢𝑖,𝑗+1 =𝑢𝑖,𝑗 + ∆𝑡 D Define the parameter r as 𝑟=
(∆𝑥)2 (∆𝑥)2
32
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
(𝑢𝑖,𝑗+1 − 𝑢𝑖,𝑗 ) = 𝑟 (𝑢𝑖+1,𝑗 − 2 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗 )

𝑢𝑖,𝑗+1 = 𝑟 𝑢𝑖+1,𝑗 + 1 − 2𝑟 𝑢𝑖,𝑗 + 𝑟 𝑢𝑖−1,𝑗


We can write out the matrix system of equations we will solve numerically for the temperature u.
Finite difference method PDE example (heat equation)
𝑢𝑖,𝑗+1 = 𝑟 𝑢𝑖+1,𝑗 + 1 − 2𝑟 𝑢𝑖,𝑗 + 𝑟 𝑢𝑖−1,𝑗 can be written as 𝑢 𝑗+1 = A 𝑢𝑗

33
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
2
Example :- Solve the heat conduction equation 𝜕𝑢 = 𝜕 𝑢 using the Explicit Method
𝜕𝑡 𝜕𝑥 2
where
i) 𝑢 = 0 𝑎𝑡 𝑥 = 0 𝑎𝑛𝑑 𝑥 = 1 , 𝑡 > 0 (the boundary condition) 0 < x < 1
1
ii) 𝑢 = 2𝑥 , for 0 ≤ 𝑥 ≤ 2 𝑡 = 0 (the initial condition)
1
𝑢 = 2 1 – 𝑥 , 𝑓𝑜𝑟 ≤ 𝑥 ≤ 1 𝑦
2 ∆𝑡 1 𝑢 𝑖,𝑗+1
Δ 𝑥 = ℎ = 0.1 Δ𝑡 = 0.001 𝑟 = (∆𝑥)2 = 10 𝑢=0
solution 𝑢 𝑖−1,𝑗 𝑢 𝑖+1,𝑗
𝑢 𝑖,𝑗
𝑢=0
u0,0 = 0 , u1,0 = 0.2 , u3,0 = 0.6 , u2,0 = 0.4 u4,0 = 0.8 , u5,0 = 1 , ∆𝑡
u6,0 = 0.8 , u7,0 = 0.6 u8,0 = 0.4 , u9,0 = 0.2 , u10,0 = 0
1
𝑢𝑖,𝑗+1 = 𝑟 𝑢𝑖+1,𝑗 + 1 − 2𝑟 𝑢𝑖,𝑗 + 𝑟 𝑢𝑖−1,𝑗 𝑟= ∆𝑥
10 𝑥
1 1 𝑢 = 𝑓(𝑥) 𝑥𝑚
𝑢𝑖,𝑗+1 = 𝑢𝑖+1,𝑗 + 0.8 𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
10 10

when 𝑗 = 0 1 1
1 1 𝑢4,1 = 𝑢5,0 + 0.8 𝑢4, 0 + 𝑢3,0 = 0.8
𝑢1,1 = 𝑢2,0 + 0.8 𝑢1,0 + 𝑢0,0 = 0.2 10 10
10 10 1 1
1 1 𝑢5,1 = 𝑢6,0 + 0.8 𝑢5, 0 + 𝑢4,0 = 1
𝑢2,1 = 𝑢3,0 + 0.8 𝑢2,0 + 𝑢1,0 = 0.4 10 10
10 10
1 1 1 1
𝑢3,1 = 𝑢4,0 + 0.8 𝑢3, 0 + 𝑢2,0 = 0.6 𝑢6,1 = 𝑢7,0 + 0.8 𝑢6, 0 + 𝑢5,0 = 0.8
10 10 10 10
34
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
35
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Example: Consider a steel rod that is subjected to a temperature of 100 𝐶 on the left end and 25
C on the right end. If the rod is of length 0.05 m, use the explicit method to find the temperature
distribution in the rod from 𝑡 = 0 and 𝑡 = 9 seconds. Use ∆𝑥 = 0.01 𝑎𝑛𝑑 ∆𝑡 = 3 𝑠 .
𝑊 𝑘𝑔 𝑗
Given: 𝑘 = 54 𝑚2 𝐾 𝜌 = 7800 𝑚3,𝐶 = 490 𝑘𝑔.𝐾
The initial temperature of the rod is 20 C.
i0 1 2 3 4 5
Solution
T  100  C T  25 

0.01m

Recall, Number of time steps,


t final  t initial

k 
C Dt
90
therefore, 
3
3
54
 Boundary Conditions .
7800 490
T0 j  100C 
 1.4129 10 5 m 2 / s  for all j  0,1,2,3
T5  25C 
j
Then, Dt
  All internal nodes are at
2
Dx  . t  0 sec This can be
for
3 represented as,
 1.4129 105
0.012  0.4239
Ti 0  20C, for all i  1,2,3,4
36
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Nodal temperatures when t  0 sec , j  0 :
T00 100C
T10  20C 

T20  20C 
 Interior nodes
T30  20C 
T40  20C 
T50  25C
We can now calculate the temperature at each node explicitly using the equation formulated
i i 
earlier, T j 1  T j   T j  2T j  T j
i 1 i i 1 
Nodal temperatures when t  3sec
i0 T01  100C  Boundary Condition
setting j  0
i 1 T11  T10   T20  2T10  T00  T21  T20   T30  2T20  T10 
i2
 20  0.423920  2(20)  100
 20  0.423920  2(20)  20
 20  0.423980
 20  0.42390
 20  33.912
 20  0
 53.912C
Nodal temperatures whent  3sec , j  1 :  20C

T01  100C  Boundary Condition


T11  53.912C 

T21  20C 
 Interior nodes
T3  20C
1


T 5
1
 25C  Boundary Condition 37
T4  22.120C 
1
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Nodal temperatures when t  6 sec
T02  100C  Boundary Condition
i0
setting j  1 ,
i 1 T12  T11   T21  2T11  T01  i2 T22  T21   T31  2T21  T11 
 53.912  0.423920  2(53.912)  100  20  0.423920  2(20)  53.912
 53.912  0.423912.176  20  0.423933.912
 53.912  5.1614  20  14.375
 59.073C  34.375C
Nodal temperatures when t  6 sec , j  2 :
T02  100C  Boundary Condition
T12  59.073C 

T22  34.375C 
 Interior nodes
T32  20.889C 
T4  22.442C 
2  T 5
2
 25C  Boundary Condition
Nodal temperatures when t  9 sec
i0 T03  100C  Boundary Condition
setting j  2 , i2
i 1 
T13  T12   T22  2T12  T02  
T23  T22   T32  2T22  T12 
 59.073  0.423934.375  2(59.073)  100  34.375  0.423920.899  2(34.375)  59.073
 59.073  0.423916.229  34.375  0.423911.222
 59.073  6.8795  34.375  4.7570
 65.953C  39.132C

38
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses
Nodal temperatures when t  9 sec, j  :3
T03  100C  Boundary Condition
T13  65.953C 

T23  39.132C 
 Interior nodes
T33  27.266C 
T43  22.872C 
T53  25C  Boundary Condition
To better visualize the temperature variation at different locations at different times, the
temperature distribution along the length of the rod at different times is plotted below.

39
Assistant Prof. Dr. Eng. Ibrahim Thamer Nazzal 15.03.2023
Numerical Analyses

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