Peric CFD Lecture4
Peric CFD Lecture4
Milovan Perić
Lecture 4
Introduction to Finite-Difference
(FD) Methods
milovan@cfd-peric.de
www.cfd-peric.de
Contents 3
• FD is the oldest numerical method for solving PDEs (Euler, 18th century)…
• Starting point – conservation equation in differential form, e.g. steady-state scalar
transport by convection and diffusion:
Black symbols:
Boundary nodes (where
boundary conditions are
applied);
Open symbols:
Internal nodes, where
equations are discretized.
Intuitive Approximations of 1st Derivative 6
Observations:
Central is closer to Exact than
Forward or Backward;
Each approximation becomes better
when grid spacing is reduced…
Taylor Series Expansion Approach – I 7
H: Higher-order terms
Blue: Approximation
• For x = xi-1, we have: Red: Truncation error
Taylor Series Expansion Approach – II 8
• By subtracting the expression for x = xi–1 from expression for x = xi+1, one obtains:
• These expressions are exact, if all terms on the r.h.s. are retained…
• Because higher-order derivatives are unknown, only the blue-framed part can be used
as an approximation of the 1st derivative at node i.
• The red-framed part is called truncation error; the leading term is usually the largest.
• The exponent of mesh spacing in the leading term represents the order of
approximation.
• By using expressions written for more grid points around x = xi , one can eliminate one
or more leading terms in the truncation error (one term per additional node)…
Taylor Series Expansion Approach – III 9
• The three approximations and their leading truncation error terms are:
• The leading truncation error term for CD becomes zero on uniform grids – the next one
is proportional to (x)2 – 2nd-order…
Polynomial Fitting - I 10
• Example: Fit a parabola to variable values at three nodes, setting a local coordinate
system origin at node i. For a constant spacing:
where
• Non-uniform grids are used to achieve a more uniform distribution of errors – by using
larger spacing where discretization errors are small.
• Many approximations loose the first term in truncation error when the grid is uniform…
• The question: Is the order of approximation really lower when the grid is non-uniform
(as it formally appears to be)?
Non-Uniform Grids – II 13
where
where
re – constant expansion factor
Non-Uniform Grids – III 14
• The ratio of leading truncation error terms from two grids at the same node i is:
4 → 2nd-order convergence!
Approximation of 2nd Derivative – I 15
• This is a second-order approximation – the leading error terms from backward and
forward approximations cancel out…
Approximation of 2nd Derivative – II 16
i −½ i+½
i−1 i i+1
Approximation of 2nd Derivative – III 17
• It is the same approximation as in the previous slide, but with the leading term in
truncation error.
• The leading term becomes zero on uniform grids, but on non-uniform grids, the ratio of
truncation errors on two systematically refined grids is the same as for the 1 st derivative:
4 → 2nd-order convergence!
See slides 13 & 14
for derivation!
Approximation of Diffusion Term – I 18
• When fluid properties are not constant, the diffusion term in the conservation equation
involves the derivation of a product of two variables, which can be performed by parts:
• This term can be approximated at grid point i using any approximation for 1st and 2nd
derivative:
• Approximations of inner derivatives are of 2nd order because the auxiliary points are
midway between grid nodes.
• The approximation of the outer derivative has a first-order leading term in the truncation
error, but it converges with 2nd order also on uniform grids, as shown in slides 13 & 14.
i −½ i+½
i−1 i i+1
Numerical Experiments to Check the Order of Approximations 20
Slope 1
Slope 2
BD and FD approach the exact value from different sides, but the errors are almost the same.
CD is much more accurate – its error is ca. 2 orders of magnitude lower than BD and FD error…
Approximations of 1st Derivative, Non-Uniform Grids 22
Slope 1
Slope 2
Slope 2
= 0 (1 + 0.1x); 0 = 1.0
Slope 2
https://community.sw.siemens.com/s/topic/0TOVb0000000GETOA2/the-peri%C4%87-lectures-on-cfd