Documente Academic
Documente Profesional
Documente Cultură
T
Thermal boundary layer thickness
U
e
Velocity at the edge of the boundary layer
T
e
Temperature at the edge of the thermal boundary layer
Density
Viscosity
3
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Kinematic viscosity
Second coefficient of viscosity
Shear stress
C
f
Skin friction [dimensionless shear stress at the wall (y=0)]
St Stanton number (dimensionless heat transfer coefficient at the wall)
Re Reynolds number (ratio of inertial forces to viscous forces)
Gamma, the ratio of specific heats
P
V
C
C
| |
|
\ .
h Enthalpy
p
e
Pressure at the edge of the velocity boundary layer
k Thermal conductivity
q Heat flux
3. The Boundary Layer Equations
A. Fundamental Equations
The fundamental equations of viscous flow are consituted by three conservation
laws conservation of mass (continuity), conservation of momentum (Navier-
Stokes), and conservation of energy. Those equations are presented without
derivation below. For the purposes of this project, buoyancy terms have been
neglected. An excellent derivation of these equations is presented in White [2].
Continuity: 0
D
U
Dt
+ =
i (2.1)
4
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Momentum:
j
i
ij
j j i
u
u DU
g p U
Dt x x x
( | |
= + + + |
|
(
\ .
i ( (2.2)
Energy:
( )
j
i i
ij ij
j i
u
u Dh Dp
k T p U
Dt Dt x x x
( | |
= + + + + + ( |
|
(
\ .
i i
j
u
(2.3)
Definitions of operators such as the total derivative
D
Dt
\ .
|
(
ij
B. Boundary Layer Approximations
The assumption of steady-state and the application of certain approximations
consistent with boundary layers yield the boundary layer equations. These
approximations are valid for Re >> 1 and are listed in table 3.1.
Table 3.1 Boundary Layer Approximations
(2.4) x
(2.5) v u
u
x y
u
(2.6)
v
x y
v
(2.7)
C. Boundary Layer Equations
The two-dimensional boundary layer equations for steady-state, compressible
flow are:
5
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Continuity: ( ) ( ) u v
x y
+
0 = (2.8)
x momentum:
1 1
e
p u u
u v
x y x
+ +
y
(2.9)
y momentum: 0
p
y
(2.10)
Energy:
e
dp h h q
u v u
x y dx y
| |
+ +
|
\ .
u
y
(2.11)
Equations (2.9) and (2.11) can be simplified using Bernoulis equation along the
streamline that forms the boundary between the viscid and inviscid regions.
Ignoring gravity, that equation states
2
2
U
p Constant
+ = along a streamline of
the flow. Then, taking a derivative and inserting subscripts to indicate edge
conditions, that equation becomes
e
e
dp dU
U
dx dx
=
e
(2.12)
Thus, equation (2.9) becomes
x momentum:
1
e
e
dU u u
u v U
x y dx y
+ +
(2.13)
Equations (2.8) through (2.11) are equally valid for laminar and turbulent flow. In
application, the difference arises from the way in which the shear stress, , and
the heat flux, q, are modeled. For laminar flow,
u
y
and
T
q k
y
, resulting
in equations (2.14) through (2.21). For turbulent flow, the transport coefficients
6
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
and k are modified to include additional terms so that ( )
T
u
y
= +
and
( )
T
T
q k k
y
= +
|
+ +
\ .
|
|
(2.15)
y momentum: 0
p
y
(2.16)
Energy:
2
e
p e
dU T T T u
c u v uU k
x y dx y y y
| | | | |
+ + +
| |
\ . \ . \
|
|
.
(2.17)
Steady-state, incompressible, laminar flow
Continuity: 0
u v
x y
+ =
(2.18)
x momentum:
2
2
e
e
dU u u
u v U
x y dx y
+ +
u
(2.19)
y momentum: 0
p
y
(2.20)
Energy:
2
2
2
p p
T T k T u
u v
x y c y c y
| |
+ +
|
\ .
(2.21)
7
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Steady-state, incompressible, turbulent flow
Continuity: 0
u v
x y
+ =
(2.22)
x momentum: ( )
1
e
e
dU u u u
u v U
x y dx y y
+ + +
T
(
(
(2.23)
y momentum: 0
p
y
(2.24)
Energy: ( ) ( )
2
p T
T T T u
c u v k k
x y y y y
| | ( |
+ + + +
| (
\ . \
T
|
|
.
(2.25)
4. Turbulence Models
Though it is listed above, the energy equation was not included in the scope of
this projects turbulence module. Three turbulence models were implemented in
the software the eddy viscosity model, the mixing length model and the
turbulent kinetic energy (TKE) model.
Turbulent boundary layers are typically decomposed into an inner layer, in which
viscous shear dominates, and an outer layer, in which turbulent (eddy) shear
dominates. The turbulence models use different parameters for the different
layers.
D. Eddy viscosity
The parameter
T
is defined as the eddy viscosity. For convenience and ease of
comparison, it can be used with the other models also.
(3.1)
*
, T outer e
C U 0.016 C =
8
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
(3.2)
*
, T inner
u y 0.41 =
where the friction velocity is
* w
u
= (3.3)
E. Mixing length
The mixing length parameter is l and is related to as follows.
m T
2
T m
u
l
y
(3.4)
where
*
,
1
yu
A
m inner
l y e
(
(
(
(3.5) 26 A =
where and u* are as described in equations (3.2) and (3.3).
And (3.6)
,
0.09
m outer
l
F. Turbulent Kinetic Energy
This model introduces a new variable, the turbulent kinetic energy K, and a new
equation that is coupled with the continuity and momentum equations [(2.22) and
(2.23)]. The equation for K is
3
2
2
T T
D
k
K K K u K
u v C
x y y y y
| | | |
+ +
| |
\ . \ .
l
(3.7)
where C
D
is not the drag coefficient, but an empirical constant, . Also,
and is related to l by
0.09
D
C
1
k
l
m
1
4
D
C l l
=
m
(3.8)
9
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
and
2
T m
u
l
y
(3.9)
so that equations (3.5) and (3.6) can be used to estimate and .
T
l
5. Discretization
All flow types treated in the software were discretized using the finite difference
method. Implicit solutions were implemented in all cases to avoid instability. The
incompressible turbulent flow and compressible laminar flow modules were
translated from FORTRAN code in Schetz [1]. However, the incompressible
laminar equations were discretized by the author. The method of discretization is
presented below. Throughout the development, subscript i represents a nodes
position in the x-direction, and subscript j represents a nodes position in the y-
direction. Table 5.1 lists the discretized forms of important differentials.
Table 5.1 Discretized Forms of Important Differentials (Adapted from Chung [3])
Method Approximations Error Equation
Forward Difference
, , i j+1 i j
u u
u
y y
( )
2
, ,
2 2
2
i j+2 i j+1 i j
u u
u
y
y
+
,
u
( ) O x (4.1)
(4.2)
10
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Backward Difference
, , i j i j -1
u u
u
y y
( )
2
, ,
2 2
2
i j+2 i j+1 i j
u u
u
y
y
+
,
u
( ) O x (4.3)
(4.4)
Central Difference
, ,
2
i j+1 i j -1
u u
u
y y
( )
2
, ,
2 2
2
i j+1 i j i j -1
u u u
u
y
y
+
,
2
( ) O x
(4.5)
(4.6)
G. Continuity Equation
This equation is modelled with a forward difference approximation in
u
x
and a
backward difference approximation for
v
y
)
(4.7)
H. Momentum Equation
Using forward difference in the x-derivatives and central difference in the y-
derivatives, momentum equation (2.19) becomes
( )
2 2
, , , , , , , , ,
, , 2
2
2 2
i+1 j i j i+1 j+1 i+1 j-1 i+1 j+1 i+1 j i+1 j -1 e i+1 e i
i j i j
u u u u u u u U U
u v
x y x
y
| |
| | + | | | |
+ = + |
|
| |
|
|
\ . \ .
\ .
\ .
where Ive used the fact that
2
1
2
e e
e
dU dU
dx dx
= U .
Then, gathering like terms,
( ) ( ) ( )
, , ,
, , , 2 2
2 2 2
, , ,
2
2 2
2
i j i j i j
i+1 j+1 i+1 j i+1 j 1
i j e i+1 e i
v u v
u u u
y x y
y y
u U U
x x
| | | | |
+ + + | |
| |
\ . \ . \
= +
2
y
|
|
|
.
(
(
(4.8)
Equation (4.8) can be expressed in matrix format like below.
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
0 0
0 0
0 0 0
0 0
. . . . . . . . .
0 0
0 0
i+1,2 i+1,1
i+1,3
i+1,4
i+1,5
i+1,N-2 N-2 N-2 N-2 N-2
i+1,N-1 N-1 N-1 i+1,N N-1 N-1
u u
u
u
u
u
u u
( (
( (
( (
( (
( (
=
( (
( (
( (
( (
( (
(
(
(
(
(
(
(
(
(4.9)
Where
12
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
( )
( )
( )
,
2
,
2
,
2
2 2 2
, , ,
2
2
2
2
i j
j
i j
j
i j
j
i j e i+1 e i
j
v
y
y
u
x
y
v
y
y
u U U
x x
= +
= +
(4.10)
Equation (4.9) can then be solved using the Thomas algorithm for tri-diagonal
matrices.
I. Energy Equation
The energy equation is much like the momentum equation in form. Using
forward difference in the x-derivatives and central difference in the y-derivatives,
equation (2.21) becomes
( )
2
, , , , , , , , ,
, , 2
2
2 2
i+1 j i j i+1 j+1 i+1 j -1 i+1 j+1 i+1 j i+1 j -1 i j+1 i j-1
i j i j
p
T T T T T T T u u
u v
x y c
y
| |
+ | | | | |
+ = + |
| |
|
\ . \ . \
\ .
y
|
|
.
where Ive used the thermal diffusivity,
p
k
c
= . Gathering like terms,
( ) ( ) ( )
, , ,
, , , 2 2
2
, , , ,
2
2 2
2
i j i j i j
i+1 j+1 i+1 j i+1 j 1
i j i j i j+1 i j -1
p
v u v
T T T
y x y
y y
u T u u
x c y
| | | | |
+ + + | |
| |
\ . \ . \
| |
= +
|
\ .
2
y
|
|
|
.
(4.11)
Equation (4.11) can be expressed in matrix format like below
13
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
(
(
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
0 0
0 0
0 0 0
0 0
. . . . . . . . .
0 0
0 0
i+1,2 i+1,1
i+1,3
i+1,4
i+1,5
i+1,N-2 N-2 N-2 N-2 N-2
i+1,N-1 N-1 N-1 i+1,N N-1 N-1
T T
T
T
T
T
T T
( (
( (
( (
( (
( (
=
( (
( (
( (
( (
( (
(
(
(
(
(
(
(
(
(4.12)
With
( )
( )
( )
,
2
,
2
,
2
2
, , , ,
2
2
2
2
i j
j
i j
j
i j
j
i j i j i j+1 i i-1
j
p
v
y
y
u
x
y
v
y
y
u T u u
x c y
= +
| |
= +
|
\ .
(4.13)
6. Software Operation
J. Overview
The Boundary Layer Analysis Toolkit (BLT) is a desktop tool allowing engineers
to solve the boundary layer equations for many different flow parameters
including velocity components, temperature, thermal and velocity boundary layer
thickness and skin friction.
14
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
K. Constraints
Flow must be over a flat or gently curving plate. Flow must be in the laminar
regime or, if turbulent, flow must be incompressible. For turbulent flows, solving
for temperature is not included.
L. Steady-state, Incompressible, Laminar (SIL) Module
Module SIL can be accessed at any time by pressing Ctrl-L or by pulling down
the File menu, then choosing New Form, then Steady Incompressible
Laminar. Figure 6.1 shows the SIL input form.
The SIL input form contains check boxes and text boxes in which to specify the
flow. There are 5 frames grouping these controls by type. They are:
15
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Figure 6.1 SIL Input Form
Computational Parameters Frame
Control 1. Include temperature in calculations? Because the energy equation
is decoupled from the other equations for incompressible flow, the user has the
option to ignore temperature considerations. Checking the No box will disable
all controls specific to the energy equation, such as thermal conductivity and
temperature boundary conditions.
16
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Control 2. Extent to carry calculation in y-direction If Auto is checked, the
program estimates the extent of the boundary layer using the Blasius solution
5.0
Re
x
x
= .
Controls 3 and 4. Number of nodes Use these controls to specify how many
points in the flow field are to be calculated. Generally speaking, larger numbers
mean greater accuracy but longer calculation time.
Physical Properties Frame
Controls 5 and 6. Limits of calculation in x-direction.
Fluid Properties Frame
Control 7. Viscosity Fluid viscosity, normally indicated by the symbol .
Control 8. Density Fluid density. If temperature is not considered, only the
kinematic viscosity is used in the calculations. Any combination of viscosity and
density with the same ratio
+
+ +
+ + +
(
(
= +
(
where and are defined in figure 7.1 and and B are empirical constants
with values 0.4 and 5.5, respectively.
y
+
u
+
26
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
BIBLIOGRAPHY
1. Schetz, J.A., Boundary Layer Analysis, Prentice Hall, 1993
2. White, F.M. Viscous Fluid Flow, 2nd Ed., McGraw-Hill, 1991
3. Chung, T.J., Computational Fluid Dynamics, Cambridge University Press,
2002
4. Wilcox, David C., Turbulence Modeling for CFD, 2nd Ed., DCW Industries,
1998
5. Potter, Merle C. and Wiggert, David C., Mechanics of Fluids, 2nd Ed.,
Prentice Hall, 1997
27
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
APPENDIX A
CODE FOR STEADY INCOMPRESSIBLE LAMINAR FLOW (SIL) MODULE
28
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Option Explicit
Option Base 1
Public oplist As Variant
Public global_x() As Single
Public global_y() As Single
Public global_u() As Single
Public global_v() As Single
Public global_Cf() As Single
Public global_St() As Single
Public global_gamma() As Single
Public global_T() As Single
Public global_rho() As Single
Public global_delta() As Single
Public global_T_delta() As Single
Public Sub SIL_UV(ux0y() As Single, vx0y() As Single, vxy0() As Single, Ue() As
Single, mu As Single, _
rho As Single, xi As Single, dx As Single, dy As Single, auto As Boolean)
'*********************************************
'Solution for Steady, Incompressible, Laminar boundary layer flow
'Velocity solution only.
'Solution for temperature distribution is implemented separately.
'Implicit scheme is implemented.
'*********************************************
'Declare variables
'*********************************************
Dim m As Integer, n As Integer, i As Integer, j As Integer
Dim z As Integer, u() As Single, v() As Single, nu As Single
Dim a() As Single, b() As Single, c() As Single, d() As Single
Dim u_iter() As Single, deltind() As Single, delta() As Single, wallshear() As
Single
Dim a1 As Single, cn As Single, cf() As Single, REx As Single, check As
Integer
Dim turb As Boolean, x() As Single, y() As Single, msg As String
Dim del As Single, yod As Single
'Calculate kinematic viscosity
nu = mu / rho
'm is number of stations in streamwise (x) direction
m = UBound(vxy0)
'n is number of stations across boundary layer (y)
n = UBound(ux0y)
'Allocate space for arrays
ReDim u(n, m), v(n, m), deltind(m), delta(m), wallshear(m), cf(m)
ReDim a(n - 3), b(n - 2), c(n - 3), d(n - 2), u_iter(n - 2)
29
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
ReDim x(m), y(n)
'*********************************************
'Insert boundary conditions in matrices
'*********************************************
'First, wall conditions and free-stream conditions
For i = 1 To m
u(1, i) = 0
v(1, i) = vxy0(i)
u(n, i) = Ue(i)
Next i
'Next, inlet conditions
If auto Then 'If user asks for auto velocity profile use cubic
'If starting at x=0, then no profile
If xi > 0 Then
del = EST_DELTA(xi, Ue(1), nu)
For j = 1 To n
yod = (j - 1) * dy / del
If yod > 1 Then
u(j, 1) = Ue(1)
Else
u(j, 1) = Ue(1) * (1.5 * yod - 0.5 * yod ^ 3)
End If
v(j, 1) = 0
Next j
Else
For j = 1 To n
u(j, 1) = Ue(1)
v(j, 1) = 0
Next j
End If
Else
For j = 1 To n
u(j, 1) = ux0y(j)
v(j, 1) = vx0y(j)
Next j
End If
'initialize x and y arrays
x(1) = xi
y(1) = 0
'*********************************************
'Start moving downstream
'*********************************************
30
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
For i = 1 To m - 1
'Update progress bar
fm_progress.progbar.value = i
'*********************************************
'NSLx yields streamwise velocity (u) distribution.
x(i + 1) = x(i) + dx
'matrix elements for TDMA
For j = 2 To n - 2
'lower diagonal
a(j - 1) = -1 * v(j + 1, i) / (2 * dy) - nu / ((dy) ^ 2)
'upper diagonal
c(j - 1) = v(j, i) / (2 * dy) - nu / ((dy) ^ 2)
'main diagonal
b(j - 1) = u(j, i) / dx + 2 * nu / ((dy) ^ 2)
'right side vector
d(j - 1) = (u(j, i) ^ 2) / dx + (Ue(i + 1) ^ 2 - Ue(i) ^ 2) / (2 * dx)
Next j
'add last element to main diagonal
b(n - 2) = u(n - 1, i) / dx + 2 * nu / ((dy) ^ 2)
'modify first element and add last element to
'right side vector
a1 = -1 * v(2, i) / (2 * dy) - nu / dy ^ 2
d(1) = d(1) - a1 * u(1, i + 1)
cn = v(n - 1, i) / (2 * dy) - nu / dy ^ 2
d(n - 2) = (u(n - 1, i) ^ 2) / dx + (Ue(i + 1) ^ 2 - Ue(i) ^ 2) / (2 * dx) - cn * u(n, i
+ 1)
'Solve for u(i+1) using TDMA
u_iter = TDMA(c, a, b, d)
'*********************************************
'Check for transition to turbulence REx<10^6
REx = Ue(i) * x(i) / nu
If REx > 1000000# And Not turb Then
turb = True
msg = "Warning! Transition to turbulence at x = " & x(i) _
& ". Results beyond that point may not be valid."
check = MsgBox(msg, vbOKCancel)
If check = 2 Then Exit Sub
End If
'*********************************************
'Record wall shear, skin friction and check for separation
wallshear(i) = mu / (2 * dy) * (4 * u(2, i) - u(3, i))
cf(i) = wallshear(i) / (0.5 * rho * Ue(i) ^ 2)
If wallshear(i) < 0.0001 Then
MsgBox "Separation occurs at x=" & (i - 1) * dx
Unload fm_progress
31
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Exit Sub
End If
'*********************************************
'Transfer values into u matrix and record boundary layer thickness
For z = 2 To n - 1
u(z, i + 1) = u_iter(z - 1)
If u_iter(z - 1) > 0.99 * Ue(i) And deltind(i + 1) = 0 Then
deltind(i + 1) = z
delta(i + 1) = z * dy
End If
Next z
'*********************************************
'COM yields transverse velocity (v) distribution.
For j = 2 To n
v(j, i + 1) = v(j - 1, i + 1) - dy / (2 * dx) * _
(u(j, i + 1) - u(j, i) + u(j - 1, i + 1) - u(j - 1, i))
y(j) = y(j - 1) + dy
Next j
Next i
'*********************************************
'Store the data
'*********************************************
'store_uv_data x, y, u, v, delta, cf
global_x = x
global_y = y
global_u = u
global_v = v
global_delta = delta
global_Cf = cf
'*********************************************
'Recover memory
'*********************************************
Erase u, v, deltind, delta, wallshear, cf
Erase a, b, c, d, u_iter
Erase x, y
End Sub
Public Sub SIL_T(u() As Single, v() As Single, Tx0y() As Single, Txy0() As
Single, Te() As Single, nu As Single, k As Single, rho As Single, cp As Single, _
xi As Single, dx As Single, dy As Single)
'*********************************************
'Solution for Steady, Incompressible, Laminar boundary layer flow.
'Temperature solution only. Requires velocity solution as input.
'Solution for velocity distribution is implemented separately.
32
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
'Implicit scheme is implemented.
'*********************************************
Dim m As Integer, n As Integer, i As Integer, j As Integer
Dim T() As Single, alpha As Single, z As Integer
Dim a() As Single, b() As Single, c() As Single, d() As Single
Dim a1 As Single, cn As Single
Dim T_iter() As Single, T_del_flag As Boolean
Dim T_deltaind() As Integer, T_delta() As Single
Dim x() As Single, y() As Single
'alpha is thermal diffusivity
alpha = k / (rho * cp)
'm is number of stations in streamwise (x) direction
m = UBound(Txy0)
'n is number of stations across boundary layer (y)
n = UBound(Tx0y)
'Dimension arrays
ReDim T(n, m)
ReDim a(n - 3), b(n - 2), c(n - 3), d(n - 2), T_iter(n - 2)
ReDim T_deltaind(m), T_delta(m)
ReDim x(m), y(n)
'Construct x and y arrays
x(1) = xi
For i = 2 To m
x(i) = x(i - 1) + dx
Next i
y(1) = 0
For j = 2 To n
y(j) = y(j - 1) + dy
Next j
'*********************************************
'Insert boundary conditions in matrix
'*********************************************
'First, wall conditions and free-stream conditions
For i = 1 To m
T(1, i) = Txy0(i)
T(n, i) = Te(i)
Next i
'Next, inlet conditions
For j = 1 To n
T(j, 1) = Tx0y(j)
Next j
'*********************************************
33
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
'Start moving downstream
'*********************************************
For i = 1 To m - 1
fm_progress.progbar.value = m + i
'*********************************************
'COE yields temperature distribution.
'matrix elements
For j = 2 To n - 2
'lower diagonal
a(j - 1) = -1 * v(j + 1, i) / (2 * dy) - alpha / dy ^ 2
'upper diagonal
c(j - 1) = v(j, i) / (2 * dy) - alpha / dy ^ 2
'main diagonal
b(j - 1) = u(j, i) / dx + 2 * alpha / dy ^ 2
'right side vector
d(j - 1) = u(j, i) * T(j, i) / dx + nu / cp * ((u(j + 1, i) - u(j - 1, i)) / (2 * dy)) ^ 2
Next j
'add last element to main diagonal
b(n - 2) = u(n - 1, i) / dx + 2 * alpha / dy ^ 2
'modify first element and add last element to
'right side vector
a1 = -1 * v(2, i) / (2 * dy) - alpha / dy ^ 2
d(1) = d(1) - a1 * T(1, i + 1)
cn = v(n - 1, i) / (2 * dy) - alpha / dy ^ 2
d(n - 2) = u(n - 1, i) * T(n - 1, i) / dx + nu / cp * ((u(n, i) - u(n - 2, i)) / (2 * dy))
^ 2 - cn * T(n, i + 1)
'Solve for T(i+1) using TDMA
T_iter = TDMA(c, a, b, d)
'Transfer values into T matrix and mark position of boundary layer
T_del_flag = False
For j = 2 To n - 1
T(j, i + 1) = T_iter(j - 1)
If Abs(Te(i) - T_iter(j - 1)) >= 0.01 * Te(i) Then
T_del_flag = True
ElseIf T_del_flag And Abs(Te(i) - T_iter(j - 1)) < 0.01 * Te(i) And
T_deltaind(i + 1) = 0 Then
T_deltaind(i + 1) = j
T_delta(i + 1) = j * dy
End If
Next j
Next i
'*********************************************
'Store the data
'*********************************************
'store_T_data x, y, T, T_delta
34
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
global_T = T
global_T_delta = T_delta
'*********************************************
'Recover memory
'*********************************************
Erase T
Erase a, b, c, d, T_iter
Erase T_deltaind, T_delta
Erase x, y
End Sub
Public Function EST_DELTA(x As Single, u As Single, nu As Single) As Single
Dim REx As Single, d As Single
'Esimate boundary layer thickness using Blasius equation
REx = u * x / nu
d = x * 5 / Sqr(REx)
EST_DELTA = d
End Function
35
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
APPENDIX B
CODE FOR STEADY COMPRESSIBLE LAMINAR FLOW (SCL) MODULE
36
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Option Base 1
Option Explicit
Dim xm1 As Single, gamma() As Single
'Dim xmif As Single, Tinf As Single
Public Sub CLBL6(xi As Single, xf As Single, Tw() As Single, Te() As Single, _
Ue() As Single, xmif As Single, ux0y() As Single, vx0y() As Single, vxy0() As
Single, _
cnuinf As Single, nmax As Integer, mmax As Integer, dy As Single, Pr As
Single, _
gamma1 As Single, rhoe() As Single, S As Single)
'2D compressible boundary layer computation from Schetz.
'1st order implicit, lagged coefficient.
'Laminar with Sutherland viscosity law
'Equations are dimensionless, fluid is assumed ideal gas
Dim u() As Single, v() As Single, delta() As Single
Dim H() As Single, a() As Single, b() As Single, c() As Single
Dim R() As Single, Cmu() As Single, rho() As Single
Dim cf() As Single, St() As Single, temp() As Single
Dim L As Single, Re As Single, dx As Single, ncon As Single
Dim T1 As Single, nnx As Integer, deltaind() As Integer
Dim deno As Single, mt As Integer, rhoua As Single, rhoub As Single, r1 As
Single
Dim He() As Single, pe() As Single, T_delta() As Single
Dim i As Integer, j As Integer, Tref As Single, RR As Single, Haw() As Single
Dim mest As Integer, mmm As Integer, T_deltaind() As Integer
Dim u_temp() As Single, H_temp() As Single, temp_temp() As Single
Dim Uinf As Single, Tinf As Single, rhoinf As Single
Dim x() As Single, y() As Single, T_del_flag As Boolean
L = 1
dx = (xf - xi) / (nmax - 1)
Re = L * Ue(1) / cnuinf
'S is Sutherland constant for viscosity
T1 = S / Te(1) 'for Sutherland viscosity law
'Redim variables
ReDim u(mmax, nmax), v(mmax, nmax), H(mmax, nmax), u_temp(mmax),
H_temp(mmax)
ReDim a(mmax), b(mmax), c(mmax), R(mmax), Cmu(mmax), rho(mmax,
nmax)
ReDim cf(nmax), St(nmax), gamma(mmax), temp(mmax, nmax),
temp_temp(mmax)
37
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
ReDim He(nmax), Haw(nmax), pe(nmax), delta(nmax), deltaind(nmax)
ReDim T_delta(nmax), T_deltaind(nmax), x(nmax), y(mmax)
'Gamma is a function of temperature and equals the free stream ratio of
'specific heats
gamma(1) = gamma1
xm1 = (gamma(1) - 1) * xmif ^ 2
Uinf = Ue(1)
Tinf = Te(1)
rhoinf = rhoe(1)
For i = 1 To nmax
Ue(i) = Ue(i) / Uinf
Tw(i) = Tw(i) / Tinf
Te(i) = Te(i) / Tinf
He(i) = Te(i) / xm1
rhoe(i) = rhoe(i) / rhoinf
Next i
pe(1) = 1 / (gamma(1) * xmif ^ 2)
For j = 1 To mmax
u(j, 2) = ux0y(j)
u(j, 1) = Ue(1)
v(j, 2) = vx0y(j)
v(j, 1) = vx0y(j)
H(j, 2) = He(2)
H(j, 1) = He(1)
Tref = xm1 * H(j, 1)
temp(j, 2) = Tref
temp(j, 1) = Tref
gamma(j) = gamma(1)
Cmu(j) = (1 + T1) * Tref ^ 1.5 / (Tref + T1)
rho(j, 1) = 1 / (xm1 * H(j, 2))
rho(j, 2) = rho(j, 1)
Next j
u(1, 2) = 0
u(1, 1) = 0
H(1, 2) = Tw(2) / xm1
H(1, 1) = H(1, 2)
Tref = xm1 * H(1, 1)
temp(1, 2) = Tref
temp(1, 1) = Tref
Cmu(1) = (1 + T1) * Tref ^ 1.5 / (Tref + T1)
rho(1, 1) = 1 / (xm1 * H(1, 2))
rho(1, 2) = rho(1, 1)
38
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
'Initial profiles
mest = 2
mmm = mest + 3
For j = 2 To mmax
u(j, 1) = ux0y(j)
v(j, 1) = vx0y(j)
H(j, 1) = He(1)
rho(j, 1) = 1 / (xm1 * H(j, 1))
Next j
cf(1) = (4 * u(2, 1) - u(3, 1)) * Cmu(1) / (Ue(1) ^ 2 * dy * Re * rhoe(1))
RR = Pr ^ 0.5
For i = 1 To nmax
Haw(i) = He(i) * (1 + 0.195 * RR * xmif ^ 2)
Next i
St(1) = (3 * H(1, 1) - 4 * H(2, 1) + H(3, 1)) * Cmu(1) / (2 * Pr * Ue(1) * dy * Re *
rhoe(1) * (H(1, 2) - Haw(1)))
For i = 2 To nmax
fm_progress.progbar.value = i
nnx = i
u(mmax, i - 1) = Ue(i - 1)
H(mmax, i - 1) = He(i - 1)
rho(mmax, i - 1) = 1 / (xm1 * H(mmax, i - 1))
pe(i) = 1 / (gamma(1) * xmif ^ 2)
v(1, i - 1) = vxy0(i - 1)
b(1) = 1
c(1) = 0
R(1) = 0
a(mmax) = 0
b(mmax) = 1
R(mmax) = Ue(1)
deno = Re * dy ^ 2
For j = 2 To mmax - 1
a(j) = -0.5 * rho(j, i - 1) * v(j, i - 1) / dy - Cmu(j - 1) / deno
b(j) = rho(j, i - 1) * u(j, i - 1) / dx + 0.5 * (Cmu(j - 1) + Cmu(j)) * 2 / deno
c(j) = 0.5 * rho(j, i - 1) * v(j, i - 1) / dy - Cmu(j) / deno
R(j) = rhoe(i) * 0.5 / dx * (Ue(i) ^ 2 - Ue(i - 1) ^ 2) + rho(j, i - 1) * u(j, i - 1) ^
2 / dx
Next j
u_temp = trid(mmax, a, b, c, R, u_temp)
39
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
For j = 1 To mmax
u(j, i) = u_temp(j)
If u_temp(j) > 0.99 * Ue(i) And deltaind(i) = 0 Then
deltaind(i) = j
delta(i) = j * dy
End If
Next j
b(1) = 1
c(1) = 0
R(1) = H(1, i - 1)
a(mmax) = 0
b(mmax) = 1
R(mmax) = He(i - 1)
deno = Pr * Re * dy ^ 2
For j = 2 To mmax - 1
a(j) = -0.5 * rho(j, i - 1) * v(j, i - 1) / dy - Cmu(j - 1) / deno
b(j) = rho(j, i - 1) * u(j, i - 1) / dx + 0.5 * (Cmu(j - 1) + Cmu(j)) * 2 / deno
c(j) = 0.5 * rho(j, i - 1) * v(j, i - 1) / dy - Cmu(j) / deno
R(j) = -rhoe(i) * 0.5 / dx * (Ue(i) ^ 2 - Ue(i - 1) ^ 2) * u(j, i - 1) + rho(j, i - 1) *
u(j, i - 1) * H(j, i - 1) / dx + _
Cmu(j) * (u(j + 1, i) - u(j - 1, i)) ^ 2 / (4 * Re * dy ^ 2)
Next j
H_temp = trid(mmax, a, b, c, R, H_temp)
For j = 1 To mmax
H(j, i) = H_temp(j)
Next j
mt = mest - 8
If mt < 1 Then mt = 1
For j = mt To mmax
If u(j, i) > 0.88 * Ue(i) Then
mest = j
mmm = mest + 3
Exit For
End If
Next j
For j = 1 To mmax
temp_temp(j) = temp(j, i - 1)
Next j
40
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
temp_temp = interp(nnx, mmm, gamma, temp_temp, H_temp, xmif, Tinf)
T_del_flag = False
For j = 1 To mmax
temp(j, i) = temp_temp(j)
If Abs(Te(i) - temp_temp(j)) >= 0.01 * Te(i) Then
T_del_flag = True
ElseIf T_del_flag And Abs(Te(i) - temp_temp(j)) < 0.01 * Te(i) And
T_deltaind(i) = 0 Then
T_deltaind(i) = j
T_delta(i) = j * dy
End If
Next j
For j = 2 To mmax - 1
Cmu(j) = (1 + T1) * (0.5 * (temp(j, i) + temp(j - 1, i))) ^ 1.5 / _
(0.5 * (temp(j, i) + temp(j - 1, i)) + T1)
rho(j, i) = pe(i) * gamma(j) / (0.5 * (H(j - 1, i) + H(j, i)) * (gamma(j) - 1))
Next j
For j = 2 To mmax - 1
rhoua = rho(j, i - 1) * u(j, i - 1)
rhoub = rho(j - 1, i - 1) * u(j - 1, i - 1)
r1 = rho(j - 1, i) / rho(j, i)
v(j, i) = r1 * v(j - 1, i) - (0.5 * dy / dx) * (u(j, i) + r1 * u(j - 1, i) - (rhoua +
rhoub) / rho(j, i))
If u(j, i) = u(j - 1, i) And u(j, i - 1) = u(j - 1, i - 1) And v(j, i) = v(j - 1, i) Then
v(j, i) = 0
End If
Next j
cf(i) = (4 * u(2, i) - u(3, i)) * Cmu(1) / (Ue(i) ^ 2 * dy * Re * rhoe(i))
St(i) = (3 * H(1, i) - 4 * H(2, i) + H(3, i)) * Cmu(1) / (2 * Pr * Ue(i) * dy * Re *
rhoe(i) * (H(1, i) - Haw(i)))
Next i
x(1) = xi
For i = 2 To nmax
x(i) = x(i - 1) + dx
Next i
y(1) = 0
For j = 2 To mmax
y(j) = y(j - 1) + dy
Next j
41
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
'Reconstitute dimensional variables
For i = 1 To nmax
For j = 1 To mmax
u(j, i) = u(j, i) * Uinf
v(j, i) = v(j, i) * Uinf
temp(j, i) = temp(j, i) * Tinf
rho(j, i) = rho(j, i) * rhoinf
Next j
Next i
'Transfer procedure-level variables into global-level variables
global_x = x
global_y = y
global_u = u
global_v = v
global_T = temp
global_rho = rho
global_Cf = cf
global_St = St
global_gamma = gamma
global_delta = delta
global_T_delta = T_delta
'Free up memory
Erase u(), v(), H(), u_temp(), H_temp(), a(), b(), c(), R(), Cmu()
Erase rho(), cf(), St(), gamma(), temp(), temp_temp(), x(), y()
Erase He(), Haw(), pe(), delta(), deltaind(), T_delta(), T_deltaind()
End Sub
Private Function interp(nnx As Integer, mm As Integer, gamma() As Single,
temp() As Single, _
H() As Single, xmif As Single, Tinf As Single) As Single()
Dim xt(), ygam()
Dim i As Integer, k As Integer, j As Integer, m As Integer
Dim xint As Single, yout As Single, term As Single
xt = Array(273, 373, 474, 573, 673, 773, 873, 973)
ygam = Array(1.401, 1.397, 1.39, 1.378, 1.368, 1.357, 1.346, 1.338)
For m = 2 To mm + 10
j = 0
temp(m) = xm1 * H(m) * Tinf
42
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
80:
j = j + 1
xint = temp(m)
If j > 160 Then GoTo 70
yout = 0
For k = 1 To 8
term = ygam(k)
For i = 1 To 8
If k <> i Then
term = term * (xint - xt(i)) / (xt(k) - xt(i))
End If
Next i
yout = yout + term
Next k
temp(m) = (1.4 / yout) * (yout - 1) * xmif ^ 2 * H(m) * Tinf
If Abs(temp(m) - xint) < 0.005 Then GoTo 70
GoTo 80
70:
gamma(m) = yout
temp(m) = temp(m) / Tinf
Next m
interp = temp
End Function
43
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
APPENDIX C
CODE FOR STEADY INCOMPRESSIBLE TURBULENT FLOW (SIT) MODULE
44
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Option Base 1
Option Explicit
Dim Re As Single
Dim tmu() As Single, xx() As Single
Dim tke0() As Single, ncon As Integer
Dim rkap As Single, ypa As Single
'Dim u0() As Single, v0() As Single
Public Sub ITBL2(xi As Single, xf As Single, cnu As Single, Uinf As Single, _
mmax As Integer, nmax As Integer, Ue_full() As Single, model As Integer, _
auto As Boolean, ux0y() As Single)
'****************************************
'Incompressible, Turbulent Boundary Layers
'From Schetz, "Boundary Layer Analysis"
'****************************************
Dim u() As Single, v() As Single, cf() As Single
Dim pi As Double, red As Single, L As Single, u_vec() As Single
Dim del As Single, dy As Single, dx As Single, i As Integer, j As Integer
Dim usue As Single, mest As Integer, fm1 As Integer
Dim mmm As Integer, nmaxp As Integer, mmaxp As Integer
Dim nnx As Integer, yod As Single, Ue() As Single
Dim a() As Single, b() As Single, c() As Single, R() As Single
Dim deno As Single, mt As Integer, delta() As Single
Dim testnum As Integer, y() As Single
pi = 4 * Atn(1)
L = 1
rkap = 0.41 'coefficients for modelling law of the wall
ypa = 9.7 'coefficients for modelling law of the wall
del = xi * 0.375 / (Uinf * xi / cnu) ^ 0.2 'boundary layer thickness, Schetz eq. 7-43
dy = del / (400 / 550 * mmax - 1) '(using (400/550)*mmax points across boundary layer.)
dx = (xf - xi) / (nmax - 1)
Re = Uinf * L / cnu
'*****************************************
'Redim some arrays
'*****************************************
ReDim tmu(mmax), u(mmax, nmax), v(mmax, nmax), y(mmax)
ReDim a(mmax), b(mmax), c(mmax), R(mmax), delta(nmax)
ReDim tke0(mmax), cf(nmax), xx(nmax), Ue(nmax), u_vec(mmax)
'Put this one down here because it must be dimensioned before using
cf(1) = 0.0456 * (Uinf * del / cnu) ^ (-0.25) 'Blasius law, Schetz eq. 7-13
45
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
For i = 1 To nmax
xx(i) = xi + (i - 1) * dx
Ue(i) = Ue_full(i) / Uinf
Next i
'set up inlet conditions
For j = 1 To mmax
u(j, 1) = Ue(1)
v(j, 1) = 0
tke0(j) = 0
Next j
'set up no-slip condition
For i = 1 To nmax
u(1, i) = 0
Next i
'if user specifies initial velocity profile, use it; however
'by default, establish initial velocity profiles using Coles wake law
usue = Sqr(cf(1) / 2) '=u*/Ue, u*=sqrt(wallshear/rho)
red = Re * del * usue * Ue(1) 'Red=Ue*delta/nu?
mest = CInt(400 / 550 * mmax) 'm index of initial boundary layer position
fm1 = mest - 1
mmm = mest + 2
If auto Then
For j = 2 To mest
yod = (j - 1) / fm1 'y over delta
u(j, 1) = usue * Ue(1) * (1 / rkap * Log(Uinf * yod * del * usue * Ue(1) _
/ cnu) + 4.9 + 0.51 / rkap * 2 * Sin(pi / 2 * yod) ^ 2)
v(j, 1) = 0
Next j
Else
For j = 2 To mmax
u(j, 1) = ux0y(j)
Next j
End If
nmaxp = nmax
mmaxp = mest + 100
ncon = 1
'Start stepping downstream
For i = 2 To nmax
fm_progress.progbar.value = i
nnx = i
u(mmax, i) = Ue(i)
v(mmax, i) = 0
46
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Select Case model
Case 1
mixing nnx, mmax, mest, dy, Ue, u, v, cf
Case 2
eddy nnx, mmax, mest, dy, Ue, u, v, cf
Case 3
testnum = tkes(nnx, mmm, mest, dy, dx, Ue, u, v, cf)
If testnum = -1 Then Exit Sub
End Select
ncon = 2
'prepare for tdma solution
b(1) = 1
c(1) = 0
R(1) = 0
a(mmax) = 0
b(mmax) = 1
c(mmax) = 0
R(mmax) = Ue(i)
deno = Re * dy ^ 2
For j = 2 To mmax - 1
a(j) = -0.5 * v(j, i - 1) / dy - (1 + tmu(j - 1)) / deno
b(j) = u(j, i - 1) / dx + (2 + tmu(j - 1) + tmu(j)) / deno
c(j) = 0.5 * v(j, i - 1) / dy - (1 + tmu(j)) / deno
R(j) = 0.5 / dx * (Ue(i) ^ 2 - Ue(i - 1) ^ 2) + (u(j, i - 1) ^ 2) / dx
Next j
'run TDMA
u_vec = trid(mmax, a, b, c, R, u_vec)
'transfer u_vec into u
For j = 1 To mmax
u(j, i) = u_vec(j)
Next j
'calculate v
For j = 2 To mmax - 1
v(j, i) = v(j - 1, i) - (0.5 * dy / dx) * (u(j, i) - u(j, i - 1) + u(j - 1, i) - u(j - 1, i - 1))
Next j
mt = mest - 10
If mt < 1 Then mt = 1
For j = mt To mmax
47
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
'find boundary layer
If u(j, i) > 0.99 * Ue(i) Then
mest = j
mmm = mest + 3
mmaxp = mest + 100
Exit For
End If
Next j
delta(i) = (mest - 1) * dy
'get skin friction
cf(i) = (4 * u(2, i) - u(3, i)) / (Ue(i) ^ 2 * dy * Re)
'check for near separation
If cf(i) < 0.0001 Then
MsgBox ("Near separation")
nmaxp = i
Exit For
End If
Next i
y(1) = 0
For j = 2 To mmax
y(j) = y(j - 1) + dy
Next j
global_x = xx
global_y = y
For i = 1 To nmax
For j = 1 To mmax
u(j, i) = u(j, i) * Uinf
v(j, i) = v(j, i) * Uinf
Next j
Next i
global_u = u
global_v = v
global_delta = delta
global_Cf = cf
Erase tmu(), u(), v(), y(), a(), b(), c(), R(), delta()
Erase tke0(), cf(), xx(), Ue(), u_vec()
End Sub
Private Sub mixing(nnx As Integer, mmax As Integer, mest As Integer, dy As Single, _
48
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Ue() As Single, u() As Single, v() As Single, cf() As Single)
Dim xlmo As Single, xlmm As Single, j As Integer
Dim y As Single, yp As Single
'for outer region, mixing length is Lm=0.09*delta
xlmo = 0.09 * (mest - 1) * dy
tmu(1) = 0
For j = 2 To mmax - 1
y = (j - 1) * dy
yp = y * Ue(nnx) * Re * Sqr(0.5 * cf(nnx - 1))
xlmm = rkap * (1 - exp(-yp / 26#)) * y
If xlmm > xlmo Then xlmm = xlmo
' tmu(j) = Re * xlmm ^ 2 * Abs(u0(j + 1) - u0(j - 1)) / (2 * dy)
tmu(j) = Re * xlmm ^ 2 * Abs(u(j + 1, nnx - 1) - u(j - 1, nnx - 1)) / (2 * dy)
Next j
tmu(mmax) = tmu(mmax - 1)
End Sub
Private Sub eddy(nnx As Integer, mmax As Integer, mest As Integer, dy As Single, _
Ue() As Single, u() As Single, v() As Single, cf() As Single)
Dim delst As Single, rmut As Single, yp As Single, y As Single
Dim j As Integer, arg As Single, tanh As Single
delst = 0
For j = 2 To mest
' delst = delst + dy * (1 - 0.5 * (u0(j - 1) + u0(j)) / Ue(nnx))
delst = delst + dy * (1 - 0.5 * (u(j - 1, nnx - 1) + u(j, nnx - 1)) / Ue(nnx))
Next j
rmut = 0.018 * Re * Ue(nnx) * delst
For j = 1 To mmax
y = (j - 1) * dy
yp = y * Ue(nnx) * Re * Sqr(0.5 * cf(nnx - 1))
arg = yp / ypa
tanh = (exp(arg) - exp(-1 * arg)) / (exp(arg) + exp(-1 * arg))
tmu(j) = rkap * (yp - ypa * tanh)
If tmu(j) > rmut Then tmu(j) = rmut
Next j
End Sub
Private Function tkes(nnx As Integer, mmm As Integer, mest As Integer, dy As Single, dx As Single, _
Ue() As Single, u() As Single, v() As Single, cf() As Single) As Integer
Dim uss As Single, fm1 As Integer, j As Integer, yod As Single
Dim cdf As Single, xlmo As Single, xlmm As Single, y As Single
49
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
Dim yp As Single, tlm() As Single, stkm As Single, stkm1 As Single, deno As Single
Dim a() As Single, b() As Single, c() As Single, R() As Single
Dim tke() As Single
Const sigk = 1#
Const cd = 0.09
ReDim tke(mmm), tlm(mmm), a(mmm), b(mmm), c(mmm), R(mmm)
tke(mmm) = 0#
If ncon < 2 Then
uss = 0.5 * Ue(nnx) ^ 2 * cf(nnx - 1)
'Assume initial profile of K from fig. 7-20 in Schetz
fm1 = mest - 1
For j = 1 To mest
yod = (j - 1) / fm1
If yod < 0.001 Then
tke0(j) = 5500 * yod * uss
ElseIf yod < 0.12 Then
tke0(j) = 0.5 * uss * (7# - 3# / 0.099 * (yod - 0.11))
Else
tke0(j) = 0.5 * uss * (-7 / 0.9 * (yod - 1))
End If
Next j
End If
cdf = cd ^ 0.25
xlmo = 0.09 * (mest - 1) * dy
For j = 1 To mmm
y = (j - 1) * dy
yp = y * Ue(nnx) * Re * Sqr(0.5 * cf(nnx - 1))
xlmm = rkap * (1# - exp(-yp / 26)) * y
If xlmm > xlmo Then xlmm = xlmo
tlm(j) = xlmm * cdf
Next j
stkm = 0#
deno = sigk * dy ^ 2
b(1) = 1#
c(1) = 0
R(1) = 0
a(mmm) = 0
b(mmm) = 1
R(mmm) = tke(mmm)
50
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
For j = 2 To mmm - 1
stkm1 = stkm
If tke0(j) >= 0 Then
stkm = Sqr(tke0(j))
Else
MsgBox "Attempted square root of negative. Quitting."
tkes = -1
Exit Function
End If
a(j) = -0.5 * v(j, nnx - 1) / dy - stkm1 * tlm(j - 1) / deno
b(j) = u(j, nnx - 1) / dx + cd * stkm / tlm(j) + (stkm1 * tlm(j - 1) + stkm * tlm(j)) / deno
c(j) = -stkm * tlm(j) / deno + 0.5 * v(j, nnx - 1) / dy
R(j) = stkm * tlm(j) * (u(j + 1, nnx - 1) - u(j - 1, nnx - 1)) ^ 2 / (4 * dy ^ 2) + u(j, nnx - 1) * tke0(j) /
dx
Next j
tke = trid(mmm, a, b, c, R, tke)
tmu(1) = 0
For j = 2 To mmm
tmu(j) = Re * tlm(j) * Sqr(tke0(j))
Next j
For j = 1 To mmm
tke0(j) = tke(j)
Next j
tke0(1) = 0
tke0(mmm) = 0
End Function
Public Function trid(mm As Integer, a() As Single, b() As Single, c() As Single, R() As Single, S() As
Single) As Single()
'TDMA
Dim j As Integer, gam() As Single, rp() As Single, deno As Single
ReDim gam(UBound(S)), rp(UBound(S))
gam(1) = c(1) / b(1)
rp(1) = R(1) / b(1)
For j = 2 To mm
deno = b(j) - a(j) * gam(j - 1)
gam(j) = c(j) / deno
51
Boundary Layer Analysis Toolkit
An Independent Study Report
Richard Getze
52
rp(j) = (R(j) - a(j) * rp(j - 1)) / deno
Next j
S(mm) = rp(mm)
For j = 1 To mm - 1
S(mm - j) = rp(mm - j) - gam(mm - j) * S(mm - j + 1)
Next j
trid = S
End Function