Lecture 4 Finite Difference PDF
Lecture 4 Finite Difference PDF
Lecture 5
Finite Difference
2
Lewis Fry Richardson (1881-1953)
• In 1922, Lewis Fry Richardson developed the first numerical
weather prediction system.
• Division of space into grid cells and the finite
difference approximations of Bjerknes's
"primitive differential equations.”
• His own attempt to calculate weather for a single
eight-hour period took six weeks and ended in
failure.
• His model's enormous calculation requirements led Richardson
to propose a solution he called the “forecast-factory.”
• The "factory" would have filled a vast stadium
with 64,000 people.
• Each one, armed with a mechanical calculator,
would perform part of the calculation.
• A leader in the center, using colored signal lights
and telegraph communication, would coordinate
the forecast.
3
1930s to 1950s
• Earliest numerical solution: for flow past a cylinder (1933).
• A.Thom, ‘The Flow Past Circular Cylinders at Low Speeds’, Proc. Royal Society, A141, pp.
651-666, London, 1933
• Kawaguti obtained a solution for flow around a cylinder, in 1953 by
using a mechanical desk calculator, working 20 hours per week for 18
months, citing: “a considerable amount of labour and endurance.”
• M. Kawaguti, ‘Numerical Solution of the NS Equations for the Flow Around a Circular
Cylinder at Reynolds Number 40’, Journal of Phy. Soc. Japan, vol. 8, pp. 747-757, 1953.
4
1960s and 1970s
• During the 1960s the theoretical division at Los Alamos contributed many numerical
methods that are still in use today, such as the following methods:
• Particle-In-Cell (PIC).
• Marker-and-Cell (MAC).
• Vorticity-Streamfunction Methods.
• Arbitrary Lagrangian-Eulerian (ALE).
• k- turbulence model.
• During the 1970s a group working under D. Brian Spalding, at Imperial College, London,
develop:
• Parabolic flow codes (GENMIX).
• Vorticity-Streamfunction based codes.
• The SIMPLE algorithm and the TEACH code.
• The form of the k- equations that are used today.
• Upwind differencing.
• ‘Eddy break-up’ and ‘presumed pdf’ combustion models.
• In 1980 Suhas V. Patankar publishes Numerical Heat Transfer and Fluid Flow, probably
the most influential book on CFD to date.
5
1980s and 1990s
• Previously, CFD was performed using academic, research
and in-house codes. When one wanted to perform a CFD
calculation, one had to write a program.
• This is the period during which most commercial CFD
codes originated that are available today:
• Fluent (UK and US).
• CFX (UK and Canada).
• Fidap (US).
• Polyflow (Belgium).
• Phoenix (UK).
• Star CD (UK).
• Flow 3d (US).
• ESI/CFDRC (US).
• SCRYU (Japan).
• and more, see www.cfdreview.com.
6
Navier-Stokes Equation Derivation
• Refer to
• Ch. 3 and Appendix A of
• Jiyuan Tu, Computational Fluid Dynamics -A Practical Approach, Second Edition,
2013.
• Ch. 2
• Wendt, Anderson, Computational Fluid Dynamics - An Introduction, 3rd edition 2009.
7
LAGRANGIAN AND EULERIAN DESCRIPTIONS
Kinematics: The study of motion.
Fluid kinematics: The study of how fluids flow and how to describe fluidmotion.
There are two distinct wa ys to describe motion: Lagrangian a n d Eulerian
Lagrangian description: To follow the path of individual objects.
This method requires us to track the position and velocity of each individual
fluid parcel (fluid particle) and take to be a parcel of fixedidentity.
8
• A more common method is Eulerian description of fluid motion.
• In the Eulerian description of fluid flow, a finite volume called a flow domain
or control volume is defined, through which fluid flows in and out.
• Instead of tracking individual fluid particles, we define field variables,
functions of space and time, within the control volume.
• The field variable at a particular location at a particular time is the value of
the variable for whichever fluid particle happens to occupy that location at
that time.
• For example, the p r e s s u r e field is a scalar field variable. We define the
velocity field a s a vector field variable.
Collectively, these (and other) field variables define the flow field. The
velocity field can be expanded in Cartesian coordinates a s
9
• In the Eulerian description we
don’t really care what happens to
individual fluid particles; rather we
are concerned with the pressure,
velocity, acceleration, etc., of
whichever fluid particle happens
to be at the location of interest at
the time of interest.
• While there are many occasions in
which the Lagrangian description
is useful, the Eulerian description
In the Eulerian description, one is often more convenient for fluid
defines field variables, such as mechanics applications.
the pressure field and the
velocity field, at any location • Experimental measurements are
and instant in time. generally more suited to the
Eulerian description.
1
0
10
CONSERVATION OF MASS—THE CONTINUITY
EQUATION
To derive a differential
conservation equation, we
imagine shrinking a control
volume to infinitesimal size.
1
1
11
12
13
Conservation of Mass: Alternative forms
• Use product rule on divergence term
V =u i +v j +w k
= i + j+ k
x y z
Conservation of Mass: Cylindrical coordinates
• There are many problems which are simpler to solve if the
equations are written in cylindrical-polar coordinates
• Easiest way to convert from Cartesian is to use vector
form and definition of divergence operator in cylindrical
coordinates
Conservation of Mass: Cylindrical coordinates
Conservation of Mass: Special Cases
• Steady compressible flow
( u ) ( v) ( w)
Cartesian + + =0
x y z
Cylindrical
Conservation of Mass: Special Cases
• Incompressible flow
V =u i +v j +w k
= i + j+ k
x y z
u v w
+ + =0
Cartesian x y z
Cylindrical
Conservation of Mass
• In general, continuity equation cannot be used by
itself to solve for flow field, however it can be used
to
1. Determine if a velocity field represents a flow.
2. Find missing velocity component
Example
For an incompressible flow
u = x2 + y2 + z 2
v = xy + yz + z
w=?
Determine : w , required to satisfy the continuity equation.
z2
Solution : w = −3 xz − + c( x, y )
2
Conservation of Momentum
Types of forces:
1. Surface forces: include all forces acting on the
boundaries of a medium though direct contact such
as pressure, friction,…etc.
2. Body forces are developed without physical contact
and distributed over the volume of the fluid such as
gravitational and electromagnetic.
• The force F acting on A may be resolved into two
components, one normal and the other tangential to
the area.
2
4
25
Stresses (forces per unit area) Surface of
Surface of constant x
constant -x
34
3
5
Du p 2u 2u 2u
• x- momentum = g x − + ( 2 + 2 + 2 ) (a)
Dt x x y z
Dv p 2v 2v 2v
• Y- momentum = g y − + ( 2 + 2 + 2 ) (b)
Dt y x y z
• x- momentum Du p 2u 2u 2u
= g x − + ( 2 + 2 + 2 ) (a)
Dt x x y z
• Y- momentum Dv p 2v 2v 2v
= g y − + ( 2 + 2 + 2 ) (b)
Dt y x y z
• z-momentum Dw p 2
w 2
w 2
w
= g z − + ( 2 + 2 + 2 ) (c )
Dt z x y z
• In vector form, the three equations are given by:
DV Incompressible NSE
= g − p + V
2
Incompressible NSE
written in vector form
• x- momentum u u u u p
( + u + v + w ) = g x − (a)
t x y z x
v v v v p
• Y- momentum ( + u + v + w ) = g y − (b)
t x y z y
w w w w p
• z-momentum ( + u +v + w ) = g z − (c )
t x y z z
• In vector form, the three equations are given by:
DV
= g − p Euler equations
Dt written in vector form
Differential Analysis of Fluid Flow Problems
49
3D Compressible Navier–Stokes Equations
C.E. in conservative form
50
3D Compressible Navier–Stokes Equations
C.E. in conservative form
By expanding
( u ) ( v) ( w)
+ + + =0
t x y z
51
3D Compressible Navier–Stokes Equations
Momentum Equations in conservative form
52
3D Compressible Navier–Stokes Equations
when expanded using Stokes’ hypothesis (λ= - 2/3 μ) gives
53
3D Incompressible Navier–Stokes Equations
Continuity Equation
𝜕𝑢 𝜕𝑣 𝜕𝑤
+ + =0
𝜕𝑥 𝜕𝑦 𝜕𝑧
X-Momentum
𝜕𝑢 𝜕𝑢 𝜕𝑢 𝜕𝑝 𝜕2𝑢 𝜕2𝑢
𝜌 +𝑢 +𝑣 = 𝜌𝑔𝑥 − +𝜇 2
+ 2
𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑥 𝜕𝑦
Y-Momentum
𝜕𝑣 𝜕𝑣 𝜕𝑣 𝜕𝑝 𝜕2𝑣 𝜕2𝑣
𝜌 +𝑢 +𝑣 = 𝜌𝑔𝑦 − + +𝜇 2
+ 2
𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑦 𝜕𝑥 𝜕𝑦
55
Euler Equations
Continuity Equation
𝜕𝑢 𝜕𝑣 𝜕𝑤
+ + =0
𝜕𝑥 𝜕𝑦 𝜕𝑧
𝜕𝑢 𝜕𝑢 𝜕𝑢 𝜕𝑢 𝜕𝑝
X-Momentum 𝜌 +𝑢 +𝑣 +𝑤 = 𝜌𝑔𝑥 −
𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕𝑥
𝜕𝑣 𝜕𝑣 𝜕𝑣 𝜕𝑣 𝜕𝑝
Y-Momentum 𝜌 +𝑢 +𝑣 +𝑤 = 𝜌𝑔𝑦 −
𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕𝑦
𝜕𝑤 𝜕𝑤 𝜕𝑤 𝜕𝑤 𝜕𝑝
Z-Momentum 𝜌 +𝑢 +𝑣 +𝑤 = 𝜌𝑔𝑧 −
𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑧 𝜕𝑧 56
Poisson Equation
𝜕2𝑢 𝜕2𝑢
2
+ 2 = 𝑓 𝑥, 𝑦
𝜕𝑥 𝜕𝑦
or 𝜕2𝜓 𝜕2𝜓
2
+ 2 = 𝑓 𝑥, 𝑦
𝜕𝑥 𝜕𝑦
Laplace Equation
𝜕2𝑢 𝜕2𝑢
2
+ 2=0
𝜕𝑥 𝜕𝑦
or 𝜕2𝜓 𝜕2𝜓
2
+ 2 =0
𝜕𝑥 𝜕𝑦 57
2D Viscous Burgers’ Equation (Convection)
𝜕𝑢 𝜕𝑢 𝜕𝑢 𝜕2𝑢 𝜕2𝑢
+𝑢 +𝑣 =𝜐 2
+ 2
𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦
𝜕𝑣 𝜕𝑣 𝜕𝑣 𝜕2𝑣 𝜕2𝑣
+𝑢 +𝑣 =𝜐 2
+ 2
𝜕𝑡 𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦
𝜕𝑢 𝜕2𝑢 𝜕2𝑢
=𝜐 2
+ 2
𝜕𝑡 𝜕𝑥 𝜕𝑦
58
2D Inviscid Burgers’ Equation (Convection)
𝜕𝑢 𝜕𝑢 𝜕𝑢
+𝑢 +𝑣 =0
𝜕𝑡 𝜕𝑥 𝜕𝑦
𝜕𝑣 𝜕𝑣 𝜕𝑣
+𝑢 +𝑣 =0
𝜕𝑡 𝜕𝑥 𝜕𝑦
𝜕𝑢 𝜕𝑢 𝜕𝑢
+𝑐 +𝑐 =0
𝜕𝑡 𝜕𝑥 𝜕𝑦
59
1D Viscous Burgers’ Equation
𝜕𝑢 𝜕𝑢 𝜕2𝑢
+𝑢 =𝜐 2
𝜕𝑡 𝜕𝑥 𝜕𝑥
1D Heat Equation (Diffusion)
𝜕𝑢 𝜕2𝑢
=𝜐 2
𝜕𝑡 𝜕𝑥
1D Inviscid Burgers’ Equation (Convection)
𝜕𝑢 𝜕𝑢
+𝑢 =0
𝜕𝑡 𝜕𝑥
1D Wave Equation (Linear Convection)
𝜕𝑢 𝜕𝑢
+𝑐 =0
𝜕𝑡 𝜕𝑥 60
Basics of Finite Difference Formulations
Refer to
Ch. 2
Hoffmann, A., Chiang, S., Computational Fluid Dynamics for Engineers, Vol. I, 4th ed.,
Engineering Education System, 2000.
Ch. 3, 4 and 5
Pletcher, R. H., Tannehill, J. C., Anderson, D., Computational Fluid Mechanics and Heat Tranfer,
3rd ed., CRC Press, 2011.
Ch. 5
Wendt, Anderson, Computational Fluid Dynamics - An Introduction, 3rd edition 2009.
Discretization methods (Finite Difference)
• If the PDEs are totally replaced by a system of algebraic equations which can be
solved for the values of the flow-field variables at the discrete points only, in this
sense, the original PDEs have been discretized.
• Moreover, this method of discretization is called the method of finite differences.
Taylor’s series expansion
• A partial derivative replaced with a suitable algebraic difference quotient is called
finite difference.
• Most finite-difference representations of derivatives are based on Taylor’s series
expansion.
• Taylor’s series expansion:
Consider a continuous function of x, namely, f(x), with all derivatives defined at x.
Then, the value of f at a location x+Δx can be estimated from a Taylor series
expanded about point x, that is,
f 1 2 f 1 3 f 1 n f
f ( x + x ) = f ( x ) + x + (x )2
+ (x )3
+ ... + ( x ) n
+ ...
x 2! x 2
3! x 3
n! x n
f 1 2 f 1 3 f 1 n f
f ( x i +1 ) = f ( x i ) + ( x i +1 − x i ) + ( x i +1 − x ) 2
+ ( x i +1 − x ) 3
+ ... + ( x i +1 − x ) n
+ ...
x 2! x 2 3! x 3 n! x n
i i i
f ( x i ) 2
f ( x i +1 ) f ( x i ) + f ( x i )x + x +
2!
f ( n) ( xi ) n
(x ) n n
+ x + Rn = f ( x i ) + f ( xi )
n! 1 n!
• The term, Rn, accounts for all terms from (n+1) to infinity, Truncation
error.
Taylor’s series expansion
𝑥𝑖+1 − 𝑥𝑖 = ∆𝑥 = ℎ
Truncation Error
• Need to determine f n+1(x), to do this you need f'(x).
𝜕𝑦 𝑦2 − 𝑦1
= lim
𝜕𝑥 ∆𝑥→0 𝑥2 − 𝑥1
𝜕𝑦 𝑦2 − 𝑦1
= lim
𝜕𝑥 ∆𝑥→0 ∆𝑥
Finite Differences:
Recall the Definition of a derivative:
𝜕𝑢 𝑢 𝑥𝑖 +∆𝑥 −𝑢 𝑥𝑖
= lim
𝜕𝑥 𝑥𝑖 ∆𝑥→0 ∆𝑥
𝑥
Forward, Backward and Central
Differences:
(1) Backward difference:
𝑢
𝑥
Forward, Backward and Central
Differences:
(2) Forward difference:
𝑢
𝑥
Forward, Backward and Central
Differences:
(3) Central difference:
𝑥
74
(1) Forward difference:
f
( )i =
f ( xi +1 ) − f ( xi ) ( xi +1 − xi ) f
−
2 2
( 2 )i −
( xi +1 − xi )3 3 f
( 3 )i
x ( xi +1 − xi ) 2!( xi +1 − xi ) x 3!( xi +1 − xi ) x
( xi +1 − xi ) n n f
− ... − ( n ) i − ...
n!( xi +1 − xi ) x
f f i +1 − f i x 2 f x 2 3 f x n−1 n f
( )i = − ( 2 )i − ( 3 ) i − ... − ( n ) i − ...
x x 2 x 6 x n! x
f i +1 − f i
= + O (x ) (a )
x
• This equation is known as the first forward difference
approximation of f of order (Δx).
x
• It is obvious that as the step size decreases, the error term
is reduced and therefore the accuracy of the approximation
is increased.
(2) Backward difference
Taylor series expansion:
Neglecting higher-order terms, we can get
f
f ( x i −1 ) = f ( x i ) − ( ) i ( x i − x i −1 ) +
( x i − x i −1 ) 2 2 f
( 2 )i −
( x i − x i −1 ) 3 f
3
( 3 )i
x 2! x 3! x
n ( x i − x i −1 )
n
n f
n ( x ) f
n n
+ ... + (−1) ( n ) i + ... = f ( x ) + (−1) n
n! x n =1 n! x
f
( )i =
f ( x i ) − f ( x i −1 ) ( x i − x i −1 ) 2 f
+ ( 2 )i −
( x i − x i −1 ) 3 f
( 3 )i
2
x ( x i − x i −1 ) 2 x 6 x
( x i − x i −1 ) n −1 n f f i − f i −1
+ ... + (−1) n
( n ) i + .. = + O (x ) (b )
n! x x
(2) Backward difference
• which represents the slope of the function at B using the values of
the function at points A and B, as shown in Figure 2-2.
• Equation (2-6) is the first backward difference approximation
f
of of order (Δx).
x
Figure 2-2. Illustration of grid
points used in Equation (2-6).
(3) Central difference:
f f i +1 − f i x 2 f x 2 3 f x n−1 n f
( )i = − ( 2 )i − ( 3 ) i − ... − ( n ) i − ...
x x 2 x 6 x n! x
f i +1 − f i
= + O (x ) (a )
x
n −1
f f i − f i −1 x 2 f x 2 3 f n ( x ) n f
( )i = + ( 2 )i − ( 3 ) i + ... + (−1) ( n ) i + ..
x x 2 x 6 x n! x
f i − f i −1
= + O (x ) (b )
x
• Adind (a)+(b) and neglecting higher-order terms, we
can
f get f − f + f − f x 2 3 f
2( )i = i +1 i i i −1
− + HOT
x x 3 x 3
f f − f i −1
( ) i = i +1 + O (x ) 2 (c )
x 2x
(3) Central difference:
• which represents the slope of the function f at point B using the
f A and C, as shown in Figure 2-3.
values of the function at points
x
• This representation of is known as the central difference
approximation of order (Δx)2•
Truncation error:
The higher-order term neglecting in Eqs. (a), (b), (c)
constitute the truncation error.
Forward: f f i +1 − f i
( )i = + O ( x )
x x
Backward: f f − f i −1
( )i = i + O ( x )
x x
f f − f i −1
Central: ( ) i = i +1 + O ( x ) 2
x 2x
Second derivatives:
f
f i +1 = f i + ( ) i x +
(x ) 2 2 f
( 2 )i +
(x ) 3 f
3
( 3 ) i + ... +
(x ) n n f
( n ) i + ...
x 2! x 3! x n! x
f
f i −1 = f i − ( ) i (x ) +
(x ) 2 2 f
( 2 )i −
(x ) 3 f
3
( 3 ) i + ... + (−1) n
( x ) n
n
f
( n ) i + ...
x 2! x 3! x n! x
* Central difference:
2
f
f i +1 + f i −1 = 2 f i + (x ) ( 2 ) i + O (x ) 4 + HOT
2
x
2 f f i +1 − 2 f i + f i −1
( 2 )i = + O (x ) 2
x (x ) 2
Second derivatives:
f
f i +1 = f i + ( ) i x +
(x ) f2
( 2 )i
2
+
( )
x 3 f
3
( ) + ... +
(x ) n n f
( n ) i + ...
x 2! x x 3 n! x
i
3!
f i +2 = f i + (
f
)2x +
(2x ) f2
( 2 )i
2
+
( )
2x 3 f
3
( ) + ... +
(2x ) n n f
( ) + ...
x 2! x 3! x 3 n! x n
2
f
f i + 2 − 2 f i +1 + f i = x ( 2 ) i + O (x ) 3
2
x
* Forward difference: 2 f f i + 2 − 2 f i +1 + f i
( 2 )i = + O (x )
x (x ) 2
Second derivatives:
f
f i −1 = f i − ( ) i (x ) +
(x ) 2 2 f
( 2 )i −
(x ) 3 f
3
( 3 ) i + ... + (−1) n
( x ) n
n
f
( n ) i + ...
x 2! x 3! x n! x
f i −2
f
= f i − ( )2x +
(2x ) 2 2 f
( 2 )i −
(2x ) 3 f
3
( 3 ) + ... +
(2x ) n n f
( n ) + ...
x 2! x 3! x n! x
2
f
f i − 2 − 2 f i −1 + f i = x ( 2 ) i + O (x ) 3
2
x
* Backward difference: 2 f f i − 2 f i −1 + f i − 2
( 2 )i = + O (x )
x (x ) 2
1-D Wave equation
𝜕𝑢 𝜕𝑢
+𝑐 =0
𝜕𝑡 𝜕𝑥
By applying Forward in time and central in space (FTCS)
𝑢𝑖𝑛+1 − 𝑢𝑖𝑛 𝑛
𝑢𝑖+1 − 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
+𝑐 =0
∆𝑡 ∆𝑥
By rearranging
∆𝑡
𝑢𝑖𝑛+1 = 𝑢𝑖𝑛 +𝑐 𝑛
× 𝑢𝑖+1 − 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
∆𝑥
84
1-D Wave equation
∆𝑡
𝑢𝑖𝑛+1 =𝑢𝑖𝑛 +𝑐 𝑛
× 𝑢𝑖+1 − 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
∆𝑥
Assume initial conditions of
𝑢 = 2 @ 0.5 ≤ 𝑥 ≤ 1
𝑢 = 1 @ 𝑒𝑣𝑒𝑟𝑦𝑤ℎ𝑒𝑟𝑒 𝑒𝑙𝑠𝑒
85
∆𝑡
𝑢𝑖𝑛+1 = 𝑢𝑖𝑛 + 𝑐 𝑛
× 𝑢𝑖+1 − 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
1-D Wave equation ∆𝑥
I.C.
𝑢 = 2 @ 0.5 ≤ 𝑥 ≤ 1
𝑢 = 1 @ 𝑒𝑣𝑒𝑟𝑦𝑤ℎ𝑒𝑟𝑒 𝑒𝑙𝑠𝑒
B.C.
𝑢 = 1 @ 𝑥 = 0, 2
86
1-D Inviscid Burgers’ equation
𝜕𝑢 𝜕𝑢
+𝑢 =0
𝜕𝑡 𝜕𝑥
By applying Forward in time and central in space (FTCS)
𝑢𝑖𝑛+1 − 𝑢𝑖𝑛 𝑢 𝑛
𝑖+1 − 2𝑢 𝑛
𝑖 + 𝑢 𝑛
𝑖−1
+ 𝑢𝑖𝑛 =0
∆𝑡 ∆𝑥
By rearranging
∆𝑡
𝑢𝑖𝑛+1 = 𝑢𝑖𝑛 +𝑐 × 𝑢𝑖𝑛 × 𝑢𝑖+1
𝑛
− 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
∆𝑥
87
1-D Inviscid Burgers’ equation
∆𝑡
𝑢𝑖𝑛+1 =𝑢𝑖𝑛 +𝑐 × 𝑢𝑖𝑛 × 𝑢𝑖+1
𝑛
− 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
∆𝑥
Assume initial condition of
𝑢 = 2 @ 0.5 ≤ 𝑥 ≤ 1
𝑢 = 1 @ 𝑒𝑣𝑒𝑟𝑦𝑤ℎ𝑒𝑟𝑒 𝑒𝑙𝑠𝑒
88
1-D Inviscid Burgers’ equation
∆𝑡
𝑢𝑖𝑛+1 = 𝑢𝑖𝑛 +𝑐 × 𝑢𝑖𝑛 × 𝑢𝑖+1
𝑛
− 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
∆𝑥
I.C.
𝑢 = 2 @ 0.5 ≤ 𝑥 ≤ 1
𝑢 = 1 @ 𝑒𝑣𝑒𝑟𝑦𝑤ℎ𝑒𝑟𝑒 𝑒𝑙𝑠𝑒
B.C.
𝑢 = 1 @ 𝑥 = 0, 2
89
1-D Diffusion equation
𝜕𝑢 𝜕2𝑢
=𝜐 2
𝜕𝑡 𝜕𝑦
By applying Forward in time and central in space (FTCS)
𝑢𝑖𝑛+1 − 𝑢𝑖𝑛 𝑛
𝑢𝑖+1 − 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
=𝜐
∆𝑡 ∆𝑥 2
By rearranging
∆𝑡
𝑢𝑖𝑛+1 = 𝑢𝑖𝑛 +𝜐 × 𝑢 𝑛
𝑖+1 − 2𝑢 𝑛
𝑖 + 𝑢 𝑛
𝑖−1
∆𝑥 2
90
1-D Diffusion equation
𝜕𝑢 𝜕2𝑢
=𝜐 2
𝜕𝑡 𝜕𝑦
By applying Forward in time and central in space (FTCS)
𝑢𝑖𝑛+1 − 𝑢𝑖𝑛 𝑛
𝑢𝑖+1 − 2𝑢𝑖𝑛 + 𝑢𝑖−1
𝑛
=𝜐
∆𝑡 ∆𝑥 2
By rearranging
∆𝑡
𝑢𝑖𝑛+1 = 𝑢𝑖𝑛 +𝜐 × 𝑢 𝑛
𝑖+1 − 2𝑢 𝑛
𝑖 + 𝑢 𝑛
𝑖−1
∆𝑥 2
92
Application to FTCS-Explicit scheme for the
parabolic model equation
93
Programming Assignment
Consider a fluid bounded by two parallel plates extended to
infinity such that no end effects are encountered. The walls
and the fluid are initially at rest. Now, the lower wall is
suddenly accelerated in the x-direction. The Navier-Stokes
equations for this problem may be expressed as:
𝜕𝑢 𝜕2𝑢
=𝜐 2
𝜕𝑡 𝜕𝑦
It is required to compute 𝑢 𝑡, 𝑦 .
94
Programming Assignment 1
Assume initial conditions of
𝑢 = 𝑢𝑜 @ 𝑦 = 0
𝑢 =0@ 0<𝑦 ≤ℎ
where h is the distance between the two plates and
equals 40 mm.
Assume Boundary conditions
𝑢 = 𝑢𝑜 @ 𝑦 = 0
𝑢 =0@ 𝑦 =ℎ
Take 𝜐=0.000217 m2/s, 𝑢𝑜 =40 m/s, max time of 1.08
sec. Assume 40 nodes in y direction 95
Programming Assignment 1
Apply FTCS scheme.
Calculate and plot the velocity distribution by using
Matlab by using the following time steps:
❑ dt = 0.002 sec
❑ dt = 0.00232 sec
❑ dt = 0.003 sec