FUNDAMENTALS OF FINITE DIFFERENCE METHODS (FDM)

Transcription

FUNDAMENTALS OF FINITE DIFFERENCE METHODS (FDM)
9th Indo-German Winter Academy
FUNDAMENTALS OF FINITE
DIFFERENCE METHODS (FDM)
SHIPRA AGARWAL
Chemical Engineering
IIT Bombay
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Acknowledgement
It has been a great learning experience to prepare this lecture. I
would like to take this opportunity to thank my supervisors:
 Professor G. Biswas
 Professor V. Buwa
 Professor Ruede
Major portion of this lecture has been prepared from the lecture
notes of Professor G. Biswas.
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Outline
 Partial Differential Equations
 Discretization
 Elementary Finite Difference Quotients
 Taylor Series Expansion
 Truncation Error
 Feature of Finite Difference Equations
 Explicit and Implicit Finite Difference Method
 Error and Stability Analysis
 Fluid Flow Modeling
 Conservative Properties
 Transportive Properties
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Classification of Partial
Differential Equations
 Linear Equations: A,B,C,D,E and F are constants or f(x,y)
 Non-linear Equations: A,B,C,D,E and F contain φ or its





derivatives
Quasilinear Equations: Important subclass of nonlinear
equations. A,B,C,D,E and F may be function of φ or its first
derivatives
Homogeneous: G=0
Parabolic Equation: B2 - 4AC = 0
Elliptic Equation: B2 – 4AC < 0
Hyperbolic Equation: B2 – 4AC > 0
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: PDE Contd.
 Navier Stokes Equation is elliptic in space and parabolic
in time
 Laplace equation and Poisson Equation are elliptic
 Fluid flow problems have non-linear terms called advection
and convection terms in momentum and energy equations
respectively
 Unsteady 2-D problem represented as:
 The equation is parabolic in time and elliptic in space
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Boundary and Initial
Conditions:
 Complete specification of geometry of interest, appropriate
boundary conditions
 Conservation equations to be applied within the domain
 No. of Boundary conditions required is order of highest
derivative appearing in each independent variable
 Unsteady equations governed by a first derivative in time
require initial condition to carry out the time integration
 Three types of spatial boundary conditions:
Dirchlet Condition
Neumann Condition
Mixed Boundary Condition
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Introduction
 Basic philosophy: Replace derivatives of governing equations
with algebraic difference quotients
 Results in a system of algebraic equations solvable for
dependent variables at discrete grid points
 Analytical solutions provide closed-form expressions –
variation of dependent variables in the domain
 Numerical solutions (finite difference) - values at discrete
points in the domain
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Discrete Grid Points
 ∆x and ∆y – spacing in positive x
and y direction
 ∆x and ∆y not necessarily uniform
 In some cases, numerical
calculations performed on
transformed computational plane
having uniform spacing in
transformed variables but non
uniform spacing in physical plane
 Grid points identified by indices i
and j in positive x and y direction
respectively
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Elementary Finite Difference
Quotients
 Taylor Series Expansion:
 For small ∆x higher order terms can be neglected.
n-order accurate
Truncation error
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Elementary Finite Difference
Quotients Contd.
Forward Difference
Truncation Error 𝒪(∆x)
Backward Difference
Central Difference
Truncation Error 𝒪(∆x)
Truncation Error 𝒪(∆x)2
Central Difference for Second Derivative
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Elementary Finite Difference
Quotients Contd.
 Central difference of second derivative
difference of first derivatives
independent variables
forward
backward differences of
 Similar technique to generate mixed derivative (∂2u/∂x∂y):
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Finite Difference Equations
 Basic concept: Replace each term of PDE with its finite
difference equivalent term
 Partial difference equation:
 Using Forward time Central Space (FTCS)method of
discretization:
n: conditions at time t
i: grid point in spatial dimension
 Truncation Error (TE) = 𝒪(∆t, (∆x)2)
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Example – 1D Poisson Equation
 Boundary Value Problem:
 Central difference approximation
 System of Linear Equations
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Example – 1D Poisson Equation
contd.
 Can be represented in matrix form:
[A]u = F
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Consistency
 A finite difference representation of a PDE is said to be
consistent if:
 For equations where truncation error is 𝒪(∆x) or 𝒪(∆t) or
higher orders, TE vanishes as the mesh is refined
 However, for schemes where TE is 𝒪(∆t/∆x), the scheme is
not consistent unless mesh is refined in a manner such that
∆t/∆x→0
 For the Dufort-Frankel differencing scheme (1953), if ∆t/∆x
does not tend to zero, a parabolic PDE may end up as a
hyperbolic equation
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Convergence
 A solution of the algebraic equations that approximate a PDE
is convergent if the approximate solution approaches the
exact solution of the PDE for each value of the independent
variable as the grid spacing tends to zero
 RHS is the solution of algebraic equation
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Explicit Finite Difference
Method
 Explicit method uses the fact that we know the dependent
variable, u at all x at time t from initial conditions
 Since the equation contains only one unknown,
(i.e. u at
time t+∆t), it can be obtained directly from known values of
u at t
 The solution takes the form of a “marching” procedure in
steps of time
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Crank-Nicolson Implicit
method
 The unknown value u at time level (n+1) is expressed both in
terms of known quantities at n and unknown quantities at (n+1)
 The spatial differences on RHS are expressed in terms of averages
between time level n and (n+1)
 The above equation cannot result in a solution of
at grid point
i
 The eq. is written at all grid points resulting in a system of
algebraic equations which can be solved simultaneously for
u at all i at time level (n+1)
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Crank-Nicolson Implicit
method contd.
 The equation can be rearranged as
where r = α∆t/(∆x)2
 On application of eq. at all grid points from i=1 to i=k+1 , the
system of eqs. with boundary conditions u=A at x=0 and u=D at x=L
can be expressed in the form of Ax = C
 A is the tridiagonal coefficient matrix and x is the solution vector. The
eq. can be solved using Thomas Algorithm
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM:2-D Heat Conduction Equation
 u(temperature) = f(x,y,t)
Explicit Method
Crank-Nicolson Method
where
 The resulting system of linear equations is a function of five
unknowns
 For a (6x6) computational grid, a system of 16 linear equations
have to be solved at (n+1) time level. The method is very time
consuming. Instead we use Alternating Direction Implicit
(ADI) methods
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Alternating Direction Implicit
method (ADI)
 ADI – Two step Scheme
Step I
For each j, a tridiagonal matrix can be formed for varying i index
and values from i=2 to (imax-1) at (n+1/2) can be obtained.
Step II
Now, for each i, another tridiagonal matrix can be formed for
varying j index and values from j=2 to (jmax-1) at nth level can be
obtained.
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Explicit and Implicit Methods
Explicit Method
Implicit Method
 Advantage: Simple solution
 Advantage: Stability maintained
algorithm
 Disadvantage: For a given ∆x,
stability constraints impose a
maximum limit on ∆t, many
time steps required
over larger ∆t, fewer time steps
required
 Disadvantage:
 More involved procedure
 More time consuming due to
matrix manipulations
involved in the algorithm
 Due to larger ∆t, truncation
error is also larger
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Errors and Stability Analysis
 A = Analytical solution of PDE
 D = Exact solution of finite difference equation
 N = Numerical solution from a real computer with finite
accuracy
 Discretization Error = A – D = Truncation error + error
introduced due to the treatment of boundary condition
 Round-off Error = ε = N – D
N=ε+D
ε will be referred to as “error” henceforth
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Errors and Stability Analysis
contd.
 Consider the 1-D unsteady state heat conduction equation and its FDE
 N must satisfy the finite difference equation.
 Also, D being the exact solution also satisfies FDE
 Subtracting above 2 equations, we see that error ε also satisfies FDE.
 If errors εi’s shrink or remain same from step n to n+1, solution is
stable. Condition for stability is
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Von Neumann Stability
Analysis
 Assume distribution of errors along x-axis is given by Fourier series
and time wise distribution is exponential in t. Since the difference is
linear, behavior of one term of series is same as the series
I: unit complex number
k: wave number
 Substituting the expression for ε in FDE and simplifying, we have for
stability
 The stability requirement for which the solution of the difference
will be stable is
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: First Order Wave Equation
 Second order wave equation:
u: amplitude
c: wave speed
Eigen values λ of [A] are λ1 = +c and λ2 = -c representing two
travelling waves with speeds given by
 Euler’s equation may be treated as a system of first order
wave equations
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Stability of Hyperbolic and
Elliptic Equations
 Consider First order wave equation:
 Representing spatial derivative by central difference and time
derivative by first order difference:
 Time derivative employed is called Lax Method of Discretization (u(t)
is represented by average value between grid points i-1 and i+1
 Using Von Neumann Stability Analysis,
we get
Amplification factor , G as
 For stability requirement |G|≤ 1,
C: Courant number
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Fluid Flow Modeling
 Fluid mechanics: More complex, governing PDE’s form a
nonlinear system
 Burger’s Equation:
Includes time dependent,
convective and diffusive term
 Here u: velocity
γ: coefficient of viscosity
ζ: any property which can be transported or diffused
 Neglecting viscous term, remaining equation is a simple
analog of Euler’s equation
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Conservative Property
 FDE possesses conservative property if it preserves integral
conservation relations of the continuum
 Consider Vorticity Transport Equation:
where is nabla, V is fluid velocity and ω is vorticity.
 Integrating over a fixed region we get,
which can be written as
i.e. rate of accumulation of ω in is equal to net advective flux rate plus
net diffusive flux rate of ω across Ao into
 The concept of conservative property is to maintain this integral relation
in finite difference representation.
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Conservative Property contd.
 Consider inviscid Burger’s equation:
FDE analog
 Evaluating the integral
i=I2 ,
over a region running from i=I1 to
Thus, the FDE analogous to inviscid part of the integral has preserved
the conservative property
 For the non-conservative form of inviscid Burger’s equation:
i.e. FDE analog has failed to preserve the conservative property
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: The Upwind Scheme
 The inviscid Burger’s equation in the following forms are
unconditionally unstable:
 The equations can be made stable by using backward space
difference scheme if u > 0 and forward space difference scheme if
u<0
 Upwind method of discretization is necessary in convection
dominated flows
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Transportive Property
 FDE formulation of a flow is said to possess the transportive property if
the effect of perturbation is convected only in the direction of velocity
 Consider model Burger’s equation in conservative form and a
perturbation εm = δ in ζ for u>0, all other ε=0
 Using FTCS, we find the transportive property to be violated
 On the contrary when an upwind scheme is used,
Downstream Location (m+1)
Point m of disturbance
Upstream Location (m-1)
 Upwind method maintains unidirectional flow of information.
_____________________________________________________________________________
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Upwind Differencing and
Artificial Viscosity
Substituting Taylor series expansion in the upwind scheme of model
Burger’s equation
we get,
where
γe is known as the numerical or artificial viscosity
Considering u>0 and C<1 (due to CFL condition), γe is always a nonzero positive quantity (so that the algorithm can work)
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Upwind Differencing and
Artificial Viscosity contd.
 For a steady state analysis:
 Substituting Taylor series expansion in the upwind scheme of a two-
dimensional convective-diffusive equation
where
with
 Some amount of upwind effect is necessary to maintain transportive
property of flow equations.
______________________________________________________________________________
_____________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Second Upwind Differencing or
Hybrid Scheme
u: velocity in x direction
and
For uR > 0 and uL > 0
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: References
 Prof. G. Biswas’s Lecture Notes
 Wikipedia
 http://www.mathematik.uni-dortmund.de
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
Finite Difference Methods
THANK YOU
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
Finite Difference Methods
APPENDIX
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Thomas Algorithm
 Modified Gaussian matrix-solver applied to tridiagonal
system.
 Idea is to transform coefficient matrix into upper triangular
form
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay
FDM: Thomas Algorithm contd.
Back Substitution:
______________________________________________________________________________
Finite Difference Methods
Shipra Agarwal, IIT Bombay