Iteration

advertisement
Lecture Objectives
• Iterations vs. Unsteady-state calculation
• Residual
• Boundary conditions
Steady state vs. Unsteady state
Steady state
ρVx
Φ N( or N 1)  Φ N-1(or
Δx

Γ
 ΔxΔx
2Φ
Φ, eff
N)
N
 Φ N 1  Φ N-1   SΦ
a NTN-1  b NTN  c NTN1  f N
We use iterative solver to get solution
Unsteady state
Φ τNΔτ  Φ τN ρVx τ Δτ
Δτ
ρ

Φ N( or N 1)  Φ τN-1(or
Δτ
Δx

Γ
 ΔxΔx
2Φ
Φ, eff
N)
τ  Δτ
N

 Φ τN-1Δτ  Φ τNΔτ1  SΦ
a NTN-1  b NTN  c NTN1  f N
We use iterative solver to get solution and
We iterate for each time step
Make the difference between
- Calculation for different time step
- Calculation in iteration step
Advection diffusion equation
1-D, steady-state
ρVx
TP(E)  TW(P)   k/cp 2TP  TE  TW   q source
x
xx
N-1
Different notation:
x
N
x N+1
x
ρVx
TN  TN-1   k/cp 2TN  TN 1  TN 1   q source
x
xx
General equation
a NTN-1  b NTN  c NTN1  f N
 b1
a
 2








c1
b2
c2
...
ai
bi
ci
...
a N 1 bN 1
aN
  T1   f1 
 T   f 
 2   2 
  ...   ... 

 


T
f




i
i

  ...   ... 
 


cN 1  TN 1   f N 1 

 

bN   TN   f N 
General Iteration Procedure
Point Jacobi Solver
for steady state problem
Example: Advection diffusion equation, 1-D, steady-state, 4 nodes
a NTN-1  b NTN  c NTN1  f N
1) Explicit format:
1
2
3
4
TN  1/ b Nf N  a N /b NTN-1  c N /b NTN1
2) Guess initial values:
T10  ..., T20  .., T30  .., T40  ..
3) Substitute and calculate:
T11  1/ b1f1  c1/b1T0 2
T12  1/ b 2 f 2  a 2 /b 2 T11  c 2 /b 2 T 0 3
T13  1/ b3f 3  a 3 /b3T12  c3 /b3T 0 4
T11  ..., T21  .., T31  .., T41  ..
T14  1/ b 4 f 4  a 4 /b 4 T13
4) Substitute and calculate:
………………………….
T12  ..., T22  .., T32  .., T42  ..
Iterations vs. Unsteady-state
calculation
Unsteady-state

T
ρ
 ρ div( VT )  div (k / c p grad T )  q
τ



ρ   
ρVx

T
TN  T
N T N 

x
N -1
  k/cp
2T
xx
For time step  or  ?
Explicit or implicit method
N
 TN 1  T
N 1
 q
source
Unsteady state
Advection diffusion equation, 1-D
Explicit:






k/cp
ρ   
ρVx 

T
T N  T N-1 
2T N  T N 1  T N 1  q source
N T N 

x
xx
a NT  N  a N-1T N-1  a N1T N 1  f - a No T N
T  N  a N-1/a NT N-1  a N1/a NT N 1  f/aN - a No /a NT N
Rarely used due to the problem with stability of calculation
To achieve stable calculation  should be very small
Unsteady state
Advection diffusion equation, 1-D
Implicit:






ρ   
ρVx   
k/cp

  
T
T
2T   N  T   N 1  T   N 1  q source
N T N 
N T
N -1 

x
xx
a NT  N  a N-1T  N-1  a N1T  N 1  f - a No T N
Explicit format
(to solve system
of equations)
Iterative method:
T  N  a N-1/a NT  N-1  a N1/a NT  N 1  f/aN - a No /a NT N
2) Guess initial values:
T10  ..., T20  .., T30  .., T40  ..
3) Substitute and calculate:
4….) Iterate for considered time step
In iteration substitute only these values
Make the difference between iteration and calculation for next time step
Example:
Numerical Solutions
Iteration and Residual
x-exp(1/x)-2=0
Find x using iteration
Explicit form 1:
Explicit form 2:
x=exp(1/x)+2
x=1/(ln(x)-ln(2))
Solution process:
Guess x0
Not all iteration
process converge!
Iteration :
x1=exp(1/x0)+2 ,
X2=exp(1/x1)+2 ,
……..
…….
R1=x1-x0
R2=x2-x1
See the example for
the same equation
Convergence example
Explicit form 2:
x=1/(ln(x)-ln(2)
Residual calculation for CFD
• Residual for the cell
RFijk=Fkijk-Fk-1ijk
Variable: p,V,T,…
iteration
cell position
• Total residual for the simulation domain
RFtotal=S|RFijk|
For all cells
• Scaled (normalized) residual
RF=S|RFijk|/FF
Flux of variable F used for normalization
Vary for different CFD software
Relaxation
Relaxation with iterative solvers:
divergence
variable
When the equations are nonlinear
it can happen that you get divergency
in iterative procedure for solving considered
time step
solution
convergence
Solution is Under-Relaxation:
iteration
Y*=f·Y(n)+(1-f)·Y(n-1)
Y – considered parameter , n –iteration , f – relaxation factor
Value which is should be used for the next iteration
For our example Y*in iteration 101=f·Y(100)+(1-f) ·Y(99)
f = [0-1] – under-relaxation -stabilize the iteration
f = [1-2] – over-relaxation - speed-up the convergence
Under-Relaxation is often required when you have nonlinear equations!
Example of relaxation
(example from homework 3 assignment)
Example: Advection diffusion equation, 1-D, steady-state, 4 nodes
a NTN-1  b NTN  c NTN1  f N
1) Explicit format:
TN  1/ b Nf N  a N /b NTN-1  c N /b NTN1
1
2
3
4
2) Guess initial values:
T10  ..., T20  .., T30  .., T40  ..
3) Substitute and calculate:
T11  1/ b1f1  c1/b1T0 2
T12  1/ b 2 f 2  a 2 /b 2 T11  c 2 /b 2 T 0 3
T13  1/ b3f 3  a 3 /b3T12  c3 /b3T 0 4
T14  1/ b 4 f 4  a 4 /b 4 T13
4) Substitute and calculate:
Substitute and calculate:
………………………….
T11  ..., T21  .., T31  .., T41  ..
T11r  fT11  (1- f)T10 , T21r  fT21  (1- f)T20 , ....
T12  ..., T22  .., T32  .., T42  ..
T12r  fT12  (1- f)T11 , T22r  fT22  (1- f)T21 , ....
Boundary conditions
for CFD application - indoor airflow
Real geometry
Model geometry
Where are the boundary
Conditions?
CFD ACCURACY
Depends on airflow in the vicinity of
Boundary conditions
1) At air supply device
2) In the vicinity of occupant
3) At room surfaces
Detailed modeling
- limited by
computer power
Surface boundaries
thickness
0.01-20 mm
for forced
convection
Wall surface
W use wall functions to model the flow in the vicinity of surface
Using relatively large mesh (cell) size.
Airflow at air supply devices
momentum sources
Complex geometry - Δ~10-4m
We can spend all our
computing power for one small
detail
Diffuser jet properties
High Aspiration diffuser
D
L
How small cells do you need?
We need simplified models for diffusers
D
L
Simulation of airflow in In the
vicinity of occupants
How detailed should we make the geometry?
Peter V. Nielsen
AIRPAK Software
Download