13
NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL SOLUTION OF PDE’s 7.1. Introduction Recall, that fluid flow problems are governed by the Navier-Stokes equations, which (in 3D) comprise of a system of 7 Partial Differential Equations (PDE) with 7 unknowns. Such system of PDE’s cannot be solved analytically (i.e. by hand), however, we can attempt to solve it numerically. A numerical solution means that we use some form of iterative method to find the solution to the mathematical problem. In this Chapter, we will show that how to select the appropriate governing equations, what form should we attempt to solve them (integral or differential, conservative or non-conservative) and that what types of discretizations (or numerical methods) are available to solve them via a computer (Finite Difference, Finite Volume, Finite Element, Spectral Method). We will demonstrate the various discretization methods on a model equation. 7.2. The principle of discretization Discretization means the process of transferring continuous functions, models, and equations into discrete counterparts. This process is usually carried out as a first step toward making them suitable for numerical evaluation and implementation on digital computers. The basic idea behind discretization in CFD is to replace the exact derivatives appearing in the governing equations (which are PDE”s, and as such, contain numerous derivatives) with approximate finite differences. This is done by describing an unknown function (our solution we look for) by Taylor series expansion. This can be done in two steps: 1) If we don’t know the analytical form of a function (which is the solution to the PDE), but we know its value at a certain point x, as well as its first, second and higher derivatives at this point, then we can use Taylor expansion to express the functions value at x+x location as:

7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

  • Upload
    others

  • View
    5

  • Download
    1

Embed Size (px)

Citation preview

Page 1: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

1

7. NUMERICAL SOLUTION OF PDE’s

7.1. Introduction

Recall, that fluid flow problems are governed by the Navier-Stokes equations,

which (in 3D) comprise of a system of 7 Partial Differential Equations (PDE)

with 7 unknowns. Such system of PDE’s cannot be solved analytically (i.e. by

hand), however, we can attempt to solve it numerically. A numerical solution

means that we use some form of iterative method to find the solution to the

mathematical problem.

In this Chapter, we will show that how to select the appropriate governing

equations, what form should we attempt to solve them (integral or differential,

conservative or non-conservative) and that what types of discretizations (or

numerical methods) are available to solve them via a computer (Finite

Difference, Finite Volume, Finite Element, Spectral Method).

We will demonstrate the various discretization methods on a model equation.

7.2. The principle of discretization

Discretization means the process of transferring continuous functions, models,

and equations into discrete counterparts. This process is usually carried out as a

first step toward making them suitable for numerical evaluation and

implementation on digital computers.

The basic idea behind discretization in CFD is to replace the exact derivatives

appearing in the governing equations (which are PDE”s, and as such, contain

numerous derivatives) with approximate finite differences. This is done by

describing an unknown function (our solution we look for) by Taylor series

expansion.

This can be done in two steps:

1) If we don’t know the analytical form of a function (which is the solution to

the PDE), but we know its value at a certain point x, as well as its first,

second and higher derivatives at this point, then we can use Taylor

expansion to express the functions value at x+x location as:

Page 2: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

2

In the above expression, the meaning of the individual terms is:

Point 3 Point 4 Point 5 ….. in Fig. 7.1.

This process can be illustrated in the figure below:

Fig. 7.1. Taylor series expansion for a function. Source: Anderson.

Then, one can express the first derivative from the above expression to obtain an

approximate representation of (df/dx).

For a concrete case of velocity, this would look like:

Page 3: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

3

Approximations for second and higher order terms can be expressed from the

above formulae in a similar fashion.

7.3. Order of discretization

In the above expression, we usually neglect the higher order terms, i.e. the

“Truncation error”. In other words, in CFD, we approximate the first derivative

of u the following term:

This approximation obviously introduces an error (of approximation), which we

called above the “Truncation error”. The lowest order of x in the “Truncation

error” term represents the “order of discretization”. For the above example:

and this means that the above discrete approximation of du/dx is of first-order

accuracy.

It is very important in presenting CFD results, to always report the accuracy of

the discretization used. The higher the order of accuracy, the less terms we

neglect from the Taylor series approximation, i.e, the more accurate the

approximation is. On the other hand, the higher the order of accuracy, the more

computationally expensive a calculation is.

We typically use second order accuracy for industry problems. However, certain

terms are often discretized with first order or higher order accuracy (up to 5th

order).

Page 4: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

4

7.4. Forward, backward and central differences

As was shown above, for the Taylor series expansion we need to know the value

and the derivatives of the function at a neighbouring point. However, we can

select this neighbouring point to be forward (as we did above), backward or from

both sides of x in Fig. 7.1. These would lead to the so-called forward, backward

or central differences. The expression shown above (for x) was a first order

accurate forward difference. Expressing the same for the y direction would lead

to:

7.5. Selection of mathematical model

The very first step in solving a fluid flow problem via CFD is the selection of the

suitable governing equations.

The general rule is to use the simplest possible model equation for a particular problem, e.g. there is no need to solve the full N-S equations when an inviscid

simulation is sufficient to capture all necessary phenomena, or to run a

turbulent simulation when the Reynolds number is below the critical

(transitional) Reynolds number, where the flow is laminar.

In other words, select model equations capable of capturing the essential flow physics, but nothing more!

Once the model equation has been identified (for example, the Euler or the

Navier-Stokes equations with suitable closing equations for fluid flow problems),

it should be expressed in the correct form for the particular problem, e.g.

- conservative integral form for compressible flows

- non-conservative, differential form for incompressible flows, etc.

Page 5: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

5

7.6. Selection of discretisation method

Once the appropriate model equation has been identified, the type of the

discretisation method shall be selected. There are 4 major discretisation methods:

- Finite Difference (FD)

- Finite Volume (FV)

- Finite Element (FE)

- Spectral Method (SM)

The basic idea behind the 4 discretisation methods will be demonstrated on the

unsteady 1D heat diffusion equation:

2

2

x

T

t

T

7.6.1. Finite Difference Method (FD)

Idea: Replace derivatives in the PDE’s with finite differences based on truncated Taylor series.

For the model equation shown above, replace the:

Time-derivative Forward Difference: [n47]

Page 6: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

6

Spatial-derivative Central Difference: [n48]

So, the finite difference equation (or just “difference equation”) will become: [n49]

This equation then must be solved on a structured grid with either an explicit or

implicit method.

ADV: - easy to code, simple to understand

- can be both explicit or implicit (meaning to be explained later)

DIS: - not very good at handling discontinuities (shock smeared through

several nodes)

- grid orthogonality is required (good for simple geometries only)

- need coordinate transformation for non-uniform grids

7.6.2. Finite Volume Method (FV)

Idea: Employ integration over a cell representing a Control Volume, just like in Fluids Mechanics.

For the model equation above, integrate the equation over time step t and

through the cell (CV) as:

2

Page 7: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

7

[n50]

Then, select a 1D Control Volume (CV) as:

[n51]

Then, the integral equation above can be rewritten as: [n52]

For the Left Hand Side (LHS), employ first order backward difference in time:

[n53]

(W)West (E)East

cross-section of face A

Page 8: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

8

For the Right Hand Side (RHS), employ central differencing again: [n54]

Now we need to evaluate the time evolution of TE, TP and TW. Since we don’t

know this exactly, let us assume that TE, TP and TW are all evaluated at time “t”

and that dt = t. Then the RHS becomes:

[n55]

and the FV (Finite Volume) discretised equation will take the form:

[n56]

Note that while the LHS is identical, the RHS is different for the Finite Volume

(FV) than it was for the FD (Finite Difference) form.

ADV: - can be used for both structured and unstructured meshes,

- no need for coordinate transformation (to be explained later) i.e.

- good for handling complex geometries

Page 9: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

9

- can handle discontinuities inside CV (since we are not concerned

about the processes inside the cell – we only relate the inflow and

outflow), i.e.

- excellent for shock waves, shear layers, i.e. compressible flows!!

DIS: - ??? (I can’t think of any…)

Most commercial CFD codes (CFX-Fluent, CFX-Ansys, Vectis, etc.) use Finite

Volume Method for the discretization.

7.6.3. Finite Element Method (FE)

Idea: Develop local “element equations” for the solution of the PDE’s for each element and using an optimization technique, minimize the error of this solution on each element.

(Main difference from Finite Difference: while FD approximates the

PDE’s, FE approximates the solution to the PDE’s)

The optimization techniques used for FE can be categorized into 2 major groups:

- weighted residual methods:

- collocation method

- subdomain method

- least-squares method

- Galerkin method

- variational (or energy) method

In the explanation below, the easiest optimization method – the Galerkin

method – will be demonstrated.

Take again the model equation for the 1D unsteady heat diffusion shown earlier

and multiply it by a “test function” (or “weighting function”) , and integrate

over the volume of the element:

2

2

x

T

t

T

[n57]

Page 10: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

10

Next, assume that the solution of T can be constructed by some “trial function”

i(x). Note that the “test function ” and the “trial function “ are two different

things. Then, the assumed shape of the solution of T over the element can be

expressed as:

mj

j

jjTxT1

)(

where (m) is the number of faces of the element (3 for a 2D triangle, 2 for a 1D

element, etc).

How is j defined? It is simply a function of the element geometry, i.e. of the

coordinates of the element vertices and of its area, A. For a 1D element,

),( Axf jj

Furthermore, the “test function ” and the “trial function “ are also related to

each other as:

mi

i

ii

1

Using

t

TT

t

T nn

1

and back-substituting all these into the governing equation (eq. shown at [n57])

leads to

[n58]

mi

i

ii

imi

i

ii gdxx

Tf11

)(),,,(

LHS RHS

i.e. LHS = RHS

Page 11: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

11

which can be reduced to:

[n59]

e

i

mi

i

e

ji

n

j RHSKT

1

,

1

which in its full form is

2

1

2

1

2,21,2

2,11,1

RHS

RHS

T

T

KK

KKee

ee

for a 1D problem

where

dx

xxdx

tK

jijiji

,

mj

j

i

m

i

mj

j d

ji

e

i dxTdSRHS

KK

11

2,21,1

(See Hoffmann pp. 424 for full derivation.) The above equation for the RHS is for

one particular element. When we apply the same methodology to all other

elements, we get a “global matrix” in the form:

[n60]

nene RHS

RHS

T

T 1

.

.

.

.

.

.

.

. 1

Symmetric

matrix

Page 12: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

12

This system can then be solved for the solution vector [T1, ….., Tne], where (ne) is

the number of elements in the computational domain.

The advantages and disadvantages of the FE method are:

ADV: - no need for grid transformation

- naturally suited for unstructured meshes, i.e. good for complex

geometries

- effective: large elements can be applied since the assumed solution

via the element need not to be constant, it can be represented by

polynomials too.

- accurate: because of the above, the quality of approximation

between the grid points is much-much better than in FD.

DIS: - difficult to implement

- method is inherently implicit, i.e. no explicit formulation is

available for FE.

7.6.4. Spectral Methods (SM)

Idea: (For this description, note the similarities and differences in the formulation in comparison to FE):

To develop such “local element equations” so that their linear combination over the entire domain is an approximation to the solution of PDE’s over the entire domain. In other words, the main difference from FE is that while the FE minimizes the error of the assumed solution OVER AN ELEMENT only, the SM minimizes the error of the solution OVER THE ENTIRE DOMAIN. Yet in other words: FE: local approach SM: global approach

Fundamental principle: express the solution of the PDE’s via Fourier series. Idea

comes from observing that many PDE’s exhibit wave-like behaviour in their

solutions, which can be described very efficiently via Fourier series.

Main advantage: back-substitution of the Fourier series to the PDE’s leads to

ODE’s (ODE = Ordinary Differential Equation, i.e. a differential equation

Page 13: 7. NUMERICAL SOLUTION OF PDE’s...NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering 1 7. NUMERICAL

NGM_JF006_1: Computational Fluid Dynamics Széchenyi University Instructor: D. Feszty, T. Jakubík Audi Department of Vehicle Engineering

13

containing a function or functions of only one independent variable and its

derivatives), which solution is very fast. This leads to fast-fast convergence,

resembling exponential behaviour.

The underlying mathematical details are too lengthy for the purposes of this

course, in which we will focus on the Finite Volume Method. It is left for the

reader to conduct further research on Spectral Methods, if more information is

required.

ADV: - super-fast exponential convergence

DIS: - since the method is global, it works best for SMOOTH solutions,

i.e. not the best method for compressible flows with shock waves!!!