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

Chapter 01 - Introduction To Finite Difference

This document discusses finite difference methods for solving partial differential equations (PDEs). [1] Finite difference methods approximate derivatives using Taylor series expansions, converting continuous PDEs into discrete algebraic equations. Common schemes include finite difference, finite volume, and finite element, with finite difference being the simplest. [2] Finite difference approximates derivatives at grid points using forward, backward, or central differences. Central differences are second-order accurate while forward and backward are first-order. [3] The method is applied to PDEs by discretizing independent variables like space and time into a grid. Partial derivatives are then approximated using finite differences on the grid.
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)
17 views

Chapter 01 - Introduction To Finite Difference

This document discusses finite difference methods for solving partial differential equations (PDEs). [1] Finite difference methods approximate derivatives using Taylor series expansions, converting continuous PDEs into discrete algebraic equations. Common schemes include finite difference, finite volume, and finite element, with finite difference being the simplest. [2] Finite difference approximates derivatives at grid points using forward, backward, or central differences. Central differences are second-order accurate while forward and backward are first-order. [3] The method is applied to PDEs by discretizing independent variables like space and time into a grid. Partial derivatives are then approximated using finite differences on the grid.
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

MEP 3060

Computational Fluid Dynamics (CFD)


In
Thermal Sciences

Part I: Finite Difference (FD)

By: Dr. Ahmed Hafez


Part I - Topics

• Introduction

• Parabolic Differential Equations

• Elliptic Differential Equations


Grading System

• Course work = 30 (midterm + reports + assignments)

• Final = 45 (2 hours)

• Total = 75
Chapter 01

Introduction to Finite Difference


Introduction

Navier-Stokes Equations
Introduction

Heat Equation
Introduction
• Partial Differential Equations (PDEs) are the dominant form of governing equations in modeling.
• Many PDEs cannot be solve analytically.
• To solve them, we use a lot of assumptions.

Heat Equation

Navier-Stokes Equations
Introduction

• We use a lot of assumptions or use numerical methods


• Numerical methods: convert PDEs to algebraic equations.
• Discretization → “Converting a continuous function into a discrete one”.

• The most common schemes are: Finite Difference, Finite Volume and Finite Element.
• Here, we will study Finite Difference as it is easy and simple.
What is Finite Difference?

• Finite Difference is approximation to derivatives using Taylor series

• Taylor series can applied if the function 𝑢(𝑥) and its derivatives are:
• Single valued
• Finite
• Continuous

1 1
𝑢 𝑥 + Δ𝑥 = 𝑢 𝑥 + 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 + 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑎)
2 6
1 1
𝑢 𝑥 − Δ𝑥 = 𝑢 𝑥 − 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 − 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑏)
2 6
First Derivative - Forward Difference
1 1
𝑢 𝑥 + Δ𝑥 = 𝑢 𝑥 + 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 + 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑎)
2 6
1 1
𝑢 𝑥 − Δ𝑥 = 𝑢 𝑥 − 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 − 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑏)
2 6

First Derivative - Forward Difference => Evaluating Eq. 𝑎 − 𝑢(𝑥)

1 1
𝑢 𝑥 + Δ𝑥 − 𝑢 𝑥 = 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 + 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯
2 6

𝑢 𝑥 + Δ𝑥 − 𝑢 𝑥
𝑢′ 𝑥 = + 𝑂(Δ𝑥)
Δ𝑥
Error Order

First Order accurate


approximation
First Derivative - Backward Difference
1 1
𝑢 𝑥 + Δ𝑥 = 𝑢 𝑥 + 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 + 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑎)
2 6
1 1
𝑢 𝑥 − Δ𝑥 = 𝑢 𝑥 − 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 − 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑏)
2 6

First Derivative - Backward Difference => Evaluating 𝑢(𝑥) – Eq. (b)

1 1
𝑢 𝑥 − 𝑢 𝑥 − Δ𝑥 = 𝑢′ 𝑥 Δ𝑥 − 𝑢′′ 𝑥 Δ𝑥 2 + 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯
2 6

𝑢 𝑥 − 𝑢 𝑥 − Δ𝑥
𝑢′ 𝑥 = + 𝑂(Δ𝑥)
Δ𝑥
Error Order

First Order accurate


approximation
First Derivative - Central Difference
1 1
𝑢 𝑥 + Δ𝑥 = 𝑢 𝑥 + 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 + 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑎)
2 6
1 1
𝑢 𝑥 − Δ𝑥 = 𝑢 𝑥 − 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 − 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑏)
2 6

First Derivative - Central Difference => Evaluating Eq. 𝑎 − 𝐸𝑞. (𝑏)

1 ′′′
𝑢 𝑥 + Δ𝑥 − 𝑢 𝑥 − Δ𝑥 = 2𝑢′ 𝑥 Δ𝑥 + 𝑢 𝑥 Δ𝑥 3 + ⋯
3

𝑢 𝑥 + Δ𝑥 − 𝑢 𝑥 − Δ𝑥
𝑢′ 𝑥 = + 𝑂(Δ𝑥 2 )
2Δ𝑥
Error Order

Second Order accurate


approximation
Accuracy and false (Numerical) diffusion
Second Derivative - Central Difference
1 1
𝑢 𝑥 + Δ𝑥 = 𝑢 𝑥 + 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 + 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑎)
2 6
1 1
𝑢 𝑥 − Δ𝑥 = 𝑢 𝑥 − 𝑢′ 𝑥 Δ𝑥 + 𝑢′′ 𝑥 Δ𝑥 2 − 𝑢′′′ 𝑥 Δ𝑥 3 + ⋯ (𝑏)
2 6

Second Derivative - Central Difference => Evaluating Eq. 𝑎 + 𝐸𝑞. (𝑏)

𝑢 𝑥 + Δ𝑥 + 𝑢 𝑥 − Δ𝑥 = 2𝑢 𝑥 + Δ𝑥 2 𝑢′′ 𝑥 + 𝑂(Δ𝑥 4 )

𝑢 𝑥 + Δ𝑥 − 2𝑢 𝑥 + 𝑢 𝑥 − Δ𝑥
𝑢′′ 𝑥 = + 𝑂(Δ𝑥 2 )
Δ𝑥 2
Error Order

Second Order accurate


approximation
Summary

First Derivative Second Derivative

Forward Difference - First Order accurate 𝑂(Δ𝑥)

𝑢 𝑥 + Δ𝑥 − 𝑢 𝑥
𝑢′ 𝑥 =
Δ𝑥

Backward Difference - First Order accurate 𝑂(Δ𝑥)

𝑢 𝑥 − 𝑢 𝑥 − Δ𝑥
𝑢′ 𝑥 =
Δ𝑥

Central Difference – Second Order accurate 𝑂(Δ𝑥2) Central Difference – Second Order accurate 𝑂(Δ𝑥2)

𝑢 𝑥 + Δ𝑥 − 𝑢 𝑥 − Δ𝑥 𝑢 𝑥 + Δ𝑥 − 2𝑢 𝑥 + 𝑢 𝑥 − Δ𝑥
𝑢′ 𝑥 = 𝑢′′ 𝑥 =
2Δ𝑥 Δ𝑥 2
Partial derivatives

To apply the finite-difference concept to PDE’s, t or 𝒚


Grid and Notation system are required.

𝑖, 𝑗 + 1
𝑢 𝑥, 𝑡 𝑜𝑟 𝑢 𝑥, 𝑡 … 𝑒𝑡𝑐.
𝑖 − 1, 𝑗 𝑖, 𝑗 𝑖 + 1, 𝑗
𝑥 , 𝑦 , 𝑡 𝑎𝑟𝑒 𝑖𝑛𝑑𝑒𝑝𝑒𝑛𝑑𝑒𝑛𝑡 𝑣𝑎𝑟𝑖𝑎𝑏𝑙𝑒𝑠 𝑢𝑖,𝑗

𝑡 = 𝑗Δt or y = 𝑗Δ𝑦
And i , j are integers 𝑖, 𝑗 − 1

Δt orΔy
Δ𝑥 𝒙
𝑥 = 𝑖Δ𝑥
Notation System

t or 𝒚

𝑖, 𝑗 + 1

𝑖 − 1, 𝑗 𝑖, 𝑗 𝑖 + 1, 𝑗
𝑢𝑖,𝑗
𝑡 = 𝑗Δt or y = 𝑗Δ𝑦

𝑖, 𝑗 − 1
Δt orΔy

Δ𝑥 𝒙
𝑥 = 𝑖. Δ𝑥
Partial derivatives

First Derivative for x, y, t


t or 𝒚

𝑑𝑢 𝑢𝑖+1,𝑗 − 𝑢𝑖−1,𝑗 𝑖, 𝑗 + 1
= , 𝑒𝑟𝑟𝑜𝑟 𝑂(Δ𝑥 2 )
𝑑𝑥 𝑖,𝑗
2Δ𝑥
𝑖 − 1, 𝑗 𝑖, 𝑗 𝑖 + 1, 𝑗
𝑢𝑖,𝑗

𝑑𝑢 𝑢𝑖,𝑗+1 − 𝑢𝑖,𝑗−1

𝑡 = 𝑗Δt or y = 𝑗Δ𝑦
𝑖, 𝑗 − 1
= , 𝑒𝑟𝑟𝑜𝑟 𝑂(Δ𝑦 2 )
𝑑𝑦 𝑖,𝑗
2Δ𝑦

Δt orΔy
𝑑𝑢 𝑢𝑖,𝑗+1 − 𝑢𝑖,𝑗
= , 𝑒𝑟𝑟𝑜𝑟 𝑂(Δ𝑡)
𝑑𝑡 𝑖,𝑗
Δ𝑡
Δ𝑥 𝒙
𝑥 = 𝑖. Δ𝑥
Partial derivatives

Second Derivative for x, y


t or 𝒚

𝑖, 𝑗 + 1
𝑑2𝑢 𝑢𝑖+1,𝑗 − 2𝑢𝑖,𝑗 + 𝑢𝑖−1,𝑗
= , 𝑒𝑟𝑟𝑜𝑟 𝑂(Δ𝑥 2 )
𝑑𝑥 2 𝑖,𝑗
Δ𝑥 2
𝑖 − 1, 𝑗 𝑖, 𝑗 𝑖 + 1, 𝑗
𝑢𝑖,𝑗

𝑡 = 𝑗Δt or y = 𝑗Δ𝑦
𝑖, 𝑗 − 1

𝑑2𝑢 𝑢𝑖,𝑗+1 − 2𝑢𝑖,𝑗 + 𝑢𝑖,𝑗−1


= , 𝑒𝑟𝑟𝑜𝑟 𝑂(Δ𝑦 2 )
𝑑𝑦 2 𝑖,𝑗
Δ𝑦 2

Δt orΔy
Δ𝑥 𝒙
𝑥 = 𝑖. Δ𝑥
Second Order PDE’s
The General Transport Equation

𝜕𝜙
𝜌 + 𝜌𝑉 ∙ 𝛻𝜙 = 𝛻 ∙ Γ𝜙 𝛻𝜙 + 𝑆𝜙
𝜕𝑡
Where:

𝑉 = 𝑢𝑖 + 𝑣𝑗 + 𝑤𝑘

𝜕 𝜕 𝜕
𝛻≡ 𝑖+ 𝑗+ 𝑘
𝜕𝑥 𝜕𝑦 𝜕𝑧
Second Order PDE’s
The General Transport Equation Terms

𝜕𝜙
𝜌 + 𝜌𝑉 ∙ 𝛻𝜙 = 𝛻 ∙ Γ𝜙 𝛻𝜙 + 𝑆ด
𝜙
ถ 𝜕𝑡
Transient or Convective Term Diffusion term Source term
Unsteady term

Change with time motion of fluid Mass diffusion, Heat Generation,


particles Conduction Pressure

steady state → 0 when media


at rest → 0
The General Second Order PDE

𝜕2𝜙 𝜕2𝜙 𝜕2𝜙 𝜕𝜙 𝜕𝜙


𝑎 2 +𝑏 +𝑐 2 +𝑑 +𝑒 + 𝑓𝜙 + 𝑔 = 0
𝜕𝑥 𝜕𝑥𝜕𝑦 𝜕𝑦 𝜕𝑥 𝜕𝑦

Where 𝑎, 𝑏, 𝑐, 𝑑, 𝑒, 𝑓 𝑎𝑛𝑑 𝑔 are arbitrary coefficients


which are generally functions of 𝑥, 𝑦, 𝜙 .
Types of the Second Order PDE

𝜕2𝜙 𝜕2𝜙 𝜕2𝜙 𝜕𝜙 𝜕𝜙


𝑎 2 +𝑏 +𝑐 2 +𝑑 +𝑒 + 𝑓𝜙 + 𝑔 = 0
𝜕𝑥 𝜕𝑥𝜕𝑦 𝜕𝑦 𝜕𝑥 𝜕𝑦

Elliptic when 𝑏2 − 4𝑎𝑐 < 0

Parabolic when 𝑏2 − 4𝑎𝑐 = 0

Hyperbolic when 𝑏2 − 4𝑎𝑐 > 0

The specification of boundary conditions and method of solution


depends on the type of the equation.
Examples of Second Order PDE

Elliptic when 𝑏2 − 4𝑎𝑐 < 0

𝜕2𝑇 𝜕2𝑇
+ =0 Laplace’s equation
𝜕𝑥 2 𝜕𝑦 2

𝜕2𝑇 𝜕2𝑇
+ + 𝑞𝑔𝑒𝑛 = 0 Poisson’s equation
𝜕𝑥 2 𝜕𝑦 2

Steady State Conduction and Potential Flows


Examples of Second Order PDE

Parabolic when 𝑏2 − 4𝑎𝑐 = 0

𝜕𝑇 𝜕2𝑇
=𝛼 2 Transient or unsteady 1-D conduction
𝜕𝑡 𝜕𝑥
Examples of Second Order PDE

Hyperbolic when 𝑏2 − 4𝑎𝑐 > 0

𝜕2𝑢 𝜕 2𝑢

2
= 𝛼2 2
𝜕𝑡 𝜕𝑥

𝑏2 − 4𝑎𝑐 > 0

Problems that are discontinuous in time


Wave equation as Shockwave; vibrating string

You might also like