Sie sind auf Seite 1von 35

SEM

300 Thermo-Fluid System Design

Numerical Methods
in Heat Transfer

Movie: Cerfacs, France

Dr. Jrg Schlter


SEM 300 Thermo-Fluid System Design

Numerical Methods in
Heat Transfer: Objectives

Understand the need for numerical methods.


Understand at the example of Finite Difference
Method, how PDEs are solved numerically.
Identify the role of discretization, boundary
conditions and initial conditions.
Understand the role of validation in identifying
inaccuracies in numerical methods.
SEM 300 Thermo-Fluid System Design

Why Numerical Methods


In Module 2, we solved various heat
conduction problems in various geometries
in a systematic but highly mathematical
manner by
(1) deriving the governing differential
equation by performing an energy balance
on a differential volume element,
(2) expressing the boundary conditions in
the proper mathematical form, and
(3) solving the differential equation and
applying the boundary conditions to
determine the integration constants.
SEM 300 Thermo-Fluid System Design

Heat Conduction Simulation

source: Siemens NX

source: Solidworks

source: adapco
SEM 300 Thermo-Fluid System Design

How to put PDEs into a


Computer Code?
You probably know how to compute a simple equation, e.g:
y = x2 +1

y=x*x+1

But a PDE?..e.g. 1-D Heat Transfer Equation

T 2T
= 2
t dx
Example: Finite-Difference Method
SEM 300 Thermo-Fluid System Design

PDE Discretization
T 2T
L = 2
t dx

Beam heated up
in the centre

T x
L
Uneven Temperature
distribution along the beam
SEM 300 Thermo-Fluid System Design

PDE Discretisation
PDEs are discretized on a mesh
Example: temperature distribution on a one-dimensional beam

Beam:
T T=T(x) T 2T
= 2
t dx
x
Mesh:
i= 1 2 3 n
Array: T1 T2 T3 Tn

Function
Given that the temperature distribution Ti is given on represented by
the mesh, how to compute the derivatives?
discrete values.
SEM 300 Thermo-Fluid System Design

PDE Discretisation
PDE Terms: Using Taylor Theorem
1 2 1 3
f (x + x) = f (x) + x f (x) + x f (x) + x f (x) + O(x 3 )
2 6

Initial guess Correction with Correction with Error estimate


gradient higher order
derivatives
f(x) f(x+x)
f(x)

x x
SEM 300 Thermo-Fluid System Design

PDE Discretisation
Example of the temperature distribution:
1 2 1 3
T(x + x) = T(x) + x T (x) + x T (x) + x T (x) + O(x 3 )

2 6
On a 1-D mesh:
1 2 1 3
Ti+1 = Ti + x Ti+ x Ti+ x Ti+ O(x 3 )
2 6
T

i= 1 2 3 n
T1 T2 T3 Tn
SEM 300 Thermo-Fluid System Design

First Derivative
(forward)
Taylor Theorem:

f i+1 = f i + x f i(x) + O(x)

Resolve for f Stencil on 1-D mesh:

fi fi+1
f i+1 f i
f i = + O(x)
x

Forward difference, first order accurate


SEM 300 Thermo-Fluid System Design

First Derivative
(backward)
Taylor theorem (backward)
1 1
f (x x) = f (x) x f (x) + x 2 f (x) x 3 f (x) + O(x 3 )
2 6
On a mesh
1 2 1 3
f i1 = f i x f i+ x f i x f i + O(x 3 )
2 6
First order:
f i1 = f i x f i+ O(x) fi-1 fi
f i f i1
f i = + O(x)
x
Backward difference, first order accurate
SEM 300 Thermo-Fluid System Design

First derivative (central)


In most cases first order (O(x)) not accurate enough
Use 2nd order aproximation:
Forward 1
(1) f (x + x) = f (x) + x f (x) + x 2 f (x) + O(x
1
2
)
2
Backward
1 2
(2) f (x x) = f (x) x f (x) + x f (x) + O(x
2
2
)
2

(1-2) f (x + x) f (x x) = 2 x f (x) + O(x 2 )

f i+1 f i1 = 2 x f i+ O(x 2 )
fi-1 fi+1
f i+1 f i1
f i = + O(x 2 )
2 x
Central difference, second order accurate
SEM 300 Thermo-Fluid System Design

Second Derivative
Second Derivative
1 2
Forward (1) f (x + x) = f (x) + x f (x) + x f (x) + O(x 2
)
2
1
Backward (2) f (x x) = f (x) x f (x) + x 2 f (x) + O(x 2 )
2

(1+2) f (x + x) + f (x x) = 2 f (x) + x 2 f (x) + O(x 2 )

f i+1 + f i1 = 2 f i + x 2 f i+ O(x 2 )
fi-1 fi fi+1
f i+1 2 f i + f i1
f i= + O(x 2
)
x 2

Second derivative, second order accurate


SEM 300 Thermo-Fluid System Design

Discretization of Heat
Conduction Equation
Discretisation:
Discretize:
T 2T t in time
= 2 Ti
t dx in space
Mesh:

t3
t2
t1
t
time t0
i= 1 2 3 n x
SEM 300 Thermo-Fluid System Design

Discretization of Heat
Conduction Equation
T Tit +1 Tit
Discretization in time:
1. order
T T t
2 t
= 2 2
t
Discretization in space: dx T T t
2T t
+ T t
i+1 i i1
2. order
2
dx 2
x
Ti t+1 Ti t t
Ti+1 2Ti t + Ti1
t
=
t x 2
Resolving for Tit+1:
T t
2T t
+ Ti1
t
Ti = t
t+1 i+1 i
+ T t

x
2 i

Explicit discretization
SEM 300 Thermo-Fluid System Design

Discretization of 1-D Heat


Conduction Equation
Converting into code:

t t
2 ( i+1 i1 )
Ti t+1
= T 2T t
+ T t
+ T t

x
i i

T t
2T t
+ Ti1
t
T_new[i]= t+1
= t
delta_t*alpha/(delta_x**2)*
i+1 i
T(T_old[i+1]-2*T_old[i]+T_old[i-1])+
+ T t

x
i 2 i
T_old[i]
SEM 300 Thermo-Fluid System Design

Solving the Heat


Conduction Equation
Next time step can be computed from preceding one:
T t
2T t
+ Ti1
t
Ti = t
t+1 i+1 i
+ T t

x 2
i

t3
t2
t1
t time t0
i= 1 2 3 n x

Since the new solution is always based on previous


time step an initial solution is required
SEM 300 Thermo-Fluid System Design

Boundary Conditions
Boundary Conditions

t3
! !
t2
t1
t
time t0
i= 1 2 3 n x

Boundary points require special treatment (additional


conditions)
SEM 300 Thermo-Fluid System Design

Boundary Conditions
Dirichlet boundary conditions:
Value at boundary is prescribed
E.g.: Cooling at the sides of the beam to constant T

T0 = const; Tn = const

Neumann boundary conditions:


Derivatives at boundary are prescribed
E.g.: Constant heat flux over the sides
dT dT
= const; = const
dx 0 dx n
SEM 300 Thermo-Fluid System Design

1-D Heat Equation


Algorithm
1. Set mesh size x
2. Set time step t
3. Create initial solution
4. Solve for all i=1, n-2 (all points except boundary points):

T t
2T t
+ Ti1
t
Ti = t
t+1 i+1 i
+ Ti ; i = 0,...,n 1
t

x 2

5. Set boundary conditions (T for i=0 and i=n)
6. Repeat 4. And 5. until desired time span is computed
SEM 300 Thermo-Fluid System Design

1-D Heat Conduction


Equation Outcomes
A PDE needs to be discretized on a mesh
Gradients are approximated with a Taylor series
The discretization introduces an error
An initial solution is required
Boundary conditions need to be defined
SEM 300 Thermo-Fluid System Design

Discretisation of 2-D
PDE
Additional dimension
Mesh: t2

m
y t
t1

3
2
Multiple variables can
j=1 t0
be stored on the mesh,
i= 1 2 3 n e.g. T, u, v, p,
x
SEM 300 Thermo-Fluid System Design

Discretize 2-D
Continuity Equation
Continuity:
u v t
ui+1, u t
v t
v t
+ =0 j i1, j
+ i, j +1 i, j1 = 0
dx dy 2x 2y

u v
+ + =0
t dx dy

i,t +1j i,t j i,t j ui+1,


t
t
u t
t
v t
t
v t

+ j i, j i1, j
+ i, j i, j +1 i, j i, j1
=0
t 2x 2y
SEM 300 Thermo-Fluid System Design

Discretisation Error and


Stability
Errors in the discretization may add up
Instable solutions possible
Error is proportional to discretization:

f i+1 2 f i + f i1 f i+1 f i
f i= + O(x 2
) f i = + O(x)
x 2
x

Large x and t may result in diverging solutions


Code blows up
SEM 300 Thermo-Fluid System Design

Non-Linear Equations
Fluid Mechanics is full of non-linear PDEs
Example: Euler equation: u u u p
+u +v =
t x y x
v v v p
+u +v =
t x y y
Matrix components dependent on solution
uit +1 t +1 1 t +1 uit +1 t +1 1 t
ui+1 + ui ui1 = ui
2x t 2x t
!
Iterative Solution Methods required!
SEM 300 Thermo-Fluid System Design

Iterative Solutions
PDEs are solved iteratively!
Each iteration improves solution
Residuals (e.g. from continuity) provide measure of
accuracy and consistency of solution
u v w
+ + + =0
t x y z

Residuals to be
monitored during
computation.
SEM 300 Thermo-Fluid System Design

Meshes
1) Create geometry
2) Create mesh
- solution will be computed for each cell

Geometry

Mesh Source:cfd-online.com
SEM 300 Thermo-Fluid System Design

Meshes II
Computational Meshes

Source:wright.edu

Quality of mesh can


influence results
Source:www.asr.ucar.edu
SEM 300 Thermo-Fluid System Design

Mesh Generation
Imports geometry from CAD software:

1) Geometry
import

Source: fluent.com
SEM 300 Thermo-Fluid System Design

Mesh Generation

3) Surface meshing

2) Volume extraction &


clean up

4) Volume meshing
Source: fluent.com
SEM 300 Thermo-Fluid System Design

Mesh Generation
What is a good mesh?
Not the first mesh provided by software (!)
Engineers discretion:
Refine mesh in location where it much is happening
Coarsen, where nothing is going on
Mesh refinement study

Image: Travis Mikjaniec


SEM 300 Thermo-Fluid System Design

Verification and
Validation
All numerical simulations are inaccurate (!) due to:
Numerical error
Model error
Bugs
User error

It is up to the user/engineer to show that his


simulations are correct, through verification and
validation!
SEM 300 Thermo-Fluid System Design

Verification and
Validation
Verification: Am I solving the equations right?
Validation: Am I solving the right equations?

Verification to ensure that there are no errors in the code,


usually tested with analytical solutions and manufactured
solutions.

Validation to ensure that the results delivered by the code


are physical meaningful, usually tested by comparison
with experiments.
SEM 300 Thermo-Fluid System Design

Validation
Flow over an airfoil
3rd Mesh
0.2
2nd Mesh
1st Mesh
0.4
Experimental

P/Ho
0.6

0.8

1
0 0.2 0.4x/c 0.6 0.8 1
SEM 300 Thermo-Fluid System Design

Numerical Methods

Numerical methods powerful tools for complex


engineering problems
Discretization with e.g. Finite Difference Method
(other important method: Finite Volume Method)
Numerical methods introduce errors
Errors need to be assessed
by validation

Das könnte Ihnen auch gefallen