Computational Techniques in Civil Engineering: 5. Finite Difference Method (FDM)
Computational Techniques in Civil Engineering: 5. Finite Difference Method (FDM)
5.1 Introduction
FDM is a technique of solving PDES by replacing them with difference equations over a small step.
f(x)
Real
derivative
f(x1)
Approximate
f(x2) derivative
x
x1 x2
Real derivative is represented by tangent to a point on a curve. For example, the approximate derivative
can be represented as
( ) ( )
Finite difference equations (FDE) are obtained by using Taylor’s series approximation to PDE.
( )
f(x)
( )
x
x
Forward difference approximation of derivative
Taylor’s series expansion of f(x) at is
( ) ( ) (a)
Neglecting second and higher order terms
( ) ( )
Steps in FDM
I. Discretization of domain: Replacing the continuous spatial and temporal domain by grid points
or cells and time levels
II. Discretization of PDE: Replacing PDE by a set of algebraic equations known as Finite difference
equations
III. Specification of solution algorithm: Step by step procedure for solving FDE at each point/grid.
If continuous PDES (real) are obtained from FDEs as and approaches to zero, then the resulting
solution is said to be consistent. (Consistency related to equations). Taylor’s series expansion is
applicable for consistency analysis.
If solution of FDM approaches the true solution as and approaches to zero, then the resulting
solution is said to be convergent. (Convergence related to solution of equations).
If the round-off and truncation errors do not accumulate to cause the solution to diverge, then the
solution is said to be stable. Fourier analysis is performed for stability analysis.
5.2 Explicit and implicit schemes
If the solution at t = n+1 is obtained from the conditions at t = n, the scheme is known as explicit
scheme. In such scheme, the equations are solved sequentially. The explicit scheme is simpler to
implement, but it can be unstable. It is also convenient because results are given at grid points and it can
treat slightly varying channel geometry from section to section. It is less efficient than implicit method
and hence not suitable for simulation over long time period.
If the solution at t = n+1 is obtained from the conditions at t = n and n+1, the scheme is known as
implicit scheme. In such scheme, the equations are solved simultaneously. Implicit scheme is
mathematically more complicated. The method is stable for large computation steps and hence works
much faster than explicit scheme. The method can handle channel geometry varying significantly from
one section to the next.
Discretization
finding . /
dx
n+1
dt
n
i-1 i i+1
Explicit FDEs
Forward difference:
Backward difference:
Central difference:
Implicit FDEs
Forward difference:
Backward difference:
Central difference:
( ) 6( ) ( ) 7 6 7
( )
5.3 Stability and order of accuracy
A necessary condition for explicit scheme to be stable is the Courant condition.
Courant no.
| |
Courant no. =
V = velocity, c = celerity of wave
For computational purposes in an explicit scheme, is specified and kept fixed throughout the
computations, while is determined at each time step. at each point on a time line is computed
satisfying Courant condition and the smallest one is used.
Order of accuracy of represents how well the solution of finite difference method approximates the resl
solution of differential equations. It is an extension of consistency concept.
The equation of unsteady non-uniform flow in 1D is known as Saint Venant Equations. These equations
are based on continuity and momentum principle.
Assumptions
The channel is prismatic.
The flow is 1D, i.e. the velocity is uniform in a cross-section.
Hydrostatic pressure prevails and vertical accelerations are negligible.
Bottom slope of the channel is small.
Manning’s equation is used to describe resistance effects (to evaluate friction slope).
The fluid is incompressible.
Full equations
( )
. /
Simplified equations
The most common form of equation (taking Neglecting eddy loss, wind shear and lateral flow)
Continuity:
( )
Momentum: ( )
In the Saint Venant equations, all the flow variables are functions of both time and distance along the
channel. The unknowns are Q and y in conservative forms of equations, and V and y in non-conservation
form. The other flow variables, such as the area, A, and the friction slope, Sf, can be expressed in terms
of Q and y. The independent variables are time, t, and distance along the channel, x. An initial condition
and two boundary conditions are needed to solve the Saint Venant equations. The initial condition is
described by the variation of the unknowns, Q and y (or V and y), along the channel at time zero.
. /
√
Comparing to
. /
√
5.5 Numerical scheme for kinematic wave model
dx
n+1
dt
n
i i+1 x
: known points
Discretization
: backward difference
: backward difference
Non-derivative terms
: average along diagonal for linearity
. /
4 . / 5 . / . /
4 5 4 5
(a)
( 4 5 )
Solution technique for linear kinematic wave model for channel routing
Error in timing of peak in the numerical solution is called dispersion. It is related to phase error, in which
timing of the peak computed by numerical scheme is shifted from the real solution.
f(x) f(x)
x
Diffusion Dispersion
dx
n+1
dt
n
i i+1 x
: known points
: backward
: backward
Non-derivative terms
: average on i+1 distance line
Substituting in continuity equation
With
( ) and ( )
Substituting
( ) ( )
Solving for
( ) ( ) . / (a)
It is non-linear in . The above equation can be solved by iteration technique, such as Newton-
Raphson method.
Let RHS = C which is known.
Residual error is ( ) ( ) (b)
( ) ( ) (c)
The objective is to find that forces ( ) to become zero.
Newton-Raphson formula
( )
( ) ( ) ( )
(d)
Solution technique for linear kinematic wave model for channel routing
1. Supply initial condition at time t = 0 on time line n=1.
2. Advance to next time step, t= and n=n+1.
2.1 Apply upstream boundary conditions (flow hydrograph) to obtain at i=1.
2.2 Move to next point on time line n+1 by (x= ).
2.3 Solve for initial estimate of at k=1 using linear scheme. Find ( ) using eq. (b).
2.4 Find ( ) from eq. (c).
2.5 Find ( ) using eq. (b).
2.6 If ( ) , move to next grid point. Else repeat steps 2.4-2.5 until the condition is
satisfied.
2.7 Repeat steps 2.2-2.6 until the last grid point is reached.
3. Repeat steps 2.1-2.7 for the remaining time periods.
dx
n+1
dt
n
n-1
i-1 i i+1
Central difference for space and time derivatives
Non-derivative term
or or
Continuity equation
(I)
Momentum equation
( )
( )
,( ) ( ) - ( )
0 *( ) ( ) + ( ) 1 (II)
Example of implicit scheme
(Implicit dynamic wave model)
In Preissmann scheme, four points are used to evaluate the derivatives. The scheme is forward
difference scheme with weight.
θ
n+1
dt
0.5 0.5
n
i 1-θ
i+1
dx
( ) ( )
Space derivative: ( )
Time derivative: . /
( )
Non-derivative term: ( ) ( )
= 0.5: box scheme
= 0: fully explicit
= 1: fully implicit
For implicit scheme, should be between 0.5 to 1.
For in between 0.5 to 1, the scheme is unconditionally stable.
Continuity equation
( ) ( )
. / ( ) (I)
Momentum equation
( )
( )
{( ) ( ) } *( ) ( ) +
4 5 ( )
( ) ( ) ( )
8 ( ) ( )9 8 ( ) 9
( ) ( )
2 ( ) ( )3 2 .( ) ( ) / .( )
( ) /3 (II)
The unknown quantities in implicit finite difference equations are and . (The terms and
should also be computed simultaneously). The area and the friction slope ( ) can be
expressed in terms of are and .All the other terms are known either from the initial conditions
or from the previous time step computations.
For i = 1, 2,…….,N, there are N-1 reaches. For each reach, 2 equations (continuity and momentum) can
be written. So, there are 2N-2 equations. Additional 2 equations are provided from boundary conditions.
f(x)=0
Solution technique of resulting equations: Newton-Raphson iteration technique (forcing the residuals to
become zero)
Start with values of unknowns from initial condition, previous time step or from extrapolation.
Compute residuals (0-value of f(x)).
Find the corrections. (Matrix inversion)
Apply the correction to previous value. Repeat the procedure until two values of corrections do not
change significantly.
Value at next time step = value at previous time step+correction