7/31/2019 BLT Report
1/57
BOUNDARY LAYER ANALYSIS TOOLKIT
An Independent Study ReportPresented to the
Faculty ofCalifornia State Polytechnic University, Pomona
In Partial FulfillmentOf the Requirements for the Degree
Master of ScienceIn
Mechanical Engineering
By
Richard Getze
December, 2003
7/31/2019 BLT Report
2/57
SIGNATURE PAGE
INDEPENDENT STUDY: Boundary Layer Analysis Toolkit
AUTHOR: Richard Getze
DATE SUBMITTED:
Dr. Kevin Anderson _____________________________________Ind. Study Committee ChairMechanical Engineering
Dr. Hassan M. Rejali _____________________________________Mechanical Engineering
Dr. Thuan K. Nguyen _____________________________________Chemical Engineering
7/31/2019 BLT Report
3/57
TABLE OF CONTENTS
Section Page
List of Tables ii
List of Figures iii
Abstract 1
Introduction 2
Definitions 2
The Boundary Layer Equations 4
Turbulence Models 8
Discretization 10
Software Operation 14
Software Validation 25
Bibliography 27
Appendix A: SIL Code 28
Appendix B: SCL Code 36
Appendix C: SIT Code 44
i
7/31/2019 BLT Report
4/57
LIST OF TABLES
Table Page
2.1 Definition of Variables 3
3.1 Boundary Layer Approximations 5
5.1 Discretized Forms of Important Differentials 10
ii
7/31/2019 BLT Report
5/57
LIST OF FIGURES
Figure Page
6.1 SIL Input Form 16
6.2 SIL Form With Output Choices 20
6.3 SIL Output Example 21
6.4 SCL Form With Output Choices 22
6.5 SIT Form With Output Choices 24
7.1 Validation of SIT Module 25
iii
7/31/2019 BLT Report
6/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
ABSTRACT
The purpose of this project was to provide an intuitive and integrated software
toolkit for boundary layer calculations. The toolkit is constrained to flow over flat
and gently curving surfaces and is able to model incompressible laminar,
compressible laminar and incompressible turbulent boundary layers. Modelling
of compressible turbulent boundary layers may be included at a later time.
Microsoft Visual Basic was used to create the software toolkit. Code for the
compressible laminar and incompressible turbulent flow modules was translated
from FORTRAN code provided in Schetz [1] and a graphical user interface (GUI)
was added for intuitive use. Code for the incompressible laminar flow module
was written from fundamental equations, discretized by the author.
1
7/31/2019 BLT Report
7/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
BOUNDARY LAYER ANALYSIS TOOLKIT
1. Introduction
For most situations faced by practicing engineers, the boundary layer equations
are too complex to be solved analytically. To address that problem, many
numerical techniques have been devised for solving the boundary layer
equations. However, computer implementation of those techniques has been
largely relegated to complex and expensive software packages. Research has
indicated that an intuitive, integrated software toolkit for solving boundary layer
equations is not available as freeware. A toolkit of the type provided by this
project is warranted, since many practicing engineers require a desktop aid,
which can be used to perform quick simulations and offer fast turn-around of
results. This is an attractive alternative when contrasted with having to build an
overly complex and computationally top heavy CFD (Computational Fluid
Dynamic) model to perform a desktop calculation.
2. Definitions
A. Definition of the Boundary Layer
When a fluid flows over a solid surface, frictional drag between the fluid and the
solid creates a layer of slower-moving fluid near the solid. That layer is termed
the boundary layer. In the boundary layer, momentum is transferred between
molecules moving with different velocities. This momentum transfer is
characterized by the viscosity, a physical property of the fluid. The fluid viscosity
plays an important part in the differential equations describing the fluids behavior
2
7/31/2019 BLT Report
8/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
in the boundary layer. Together, those equations are termed the boundary layer
equations. Outside the boundary layer, molecules are all moving with a similar
velocity (the free-stream velocity), no significant momentum transfer occurs and,
thus, the fluid viscosity does not appear in the differential equations. For that
reason, the region outside the boundary layer is termed the inviscid region.
B. Definition of Variables
Throughout this report, and in the software, certain variables are used without
explanation. The definition of those variables is provided in table 2.1.
Table 2.1 Definition of Variables
x Distance along plate
y Distance across boundary layer
u Velocity component in x-direction
v Velocity component in y-direction
T Temperature
K Turbulent kinetic energy
Velocity boundary layer thickness
T Thermal boundary layer thickness
Ue Velocity at the edge of the boundary layer
Te Temperature at the edge of the thermal boundary layer
Density
Viscosity
3
7/31/2019 BLT Report
9/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Kinematic viscosity
Second coefficient of viscosity
Shear stress
Cf 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
pe 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: 0D
UDt
+ =
i (2.1)
4
7/31/2019 BLT Report
10/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Momentum:ji
ij
j j i
uuDUg p U
Dt x x x
= + + +
i (2.2)
Energy: ( ) ji iij ijj i
uuDh Dp k T p U Dt Dt x x x
= + + + + +
i i
j
u (2.3)
Definitions of operators such as the total derivativeD
Dt
, the Kronecker delta
, and the del operator ( can be found in any Calculus text. Also, tensor
notation is used in the above equations to present them in an efficient manner.
) )
( 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
7/31/2019 BLT Report
11/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Continuity: ( ) ( )u vx y
+
0= (2.8)
x momentum:1 1
e
pu uu vx y x
+ + y (2.9)
y momentum: 0p
y
(2.10)
Energy: edph h q
u v ux 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 states2
2
Up 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:1e
e
dUu uu 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
Tq k
y
=
, resulting
in equations (2.14) through (2.21). For turbulent flow, the transport coefficients
6
7/31/2019 BLT Report
12/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
and k are modified to include additional terms so that ( )Tu
y
= +
and
( )TT
q k k y
= + . The boundary layer equations for incompressible turbulent flow
are given by equations (2.22) through (2.25). Compressible turbulent flow is not
included in the scope of this report.
Steady-state, compressible, laminar flow
Continuity: ( ) ( )u vx y
+
0= (2.14)
x momentum:1e
e
dUu u uu v U
x y dx y y
+ +
(2.15)
y momentum: 0p
y
(2.16)
Energy:
2
ep e
dUT T T uc u v uU k
x y dx y y y
+ + +
(2.17)
Steady-state, incompressible, laminar flow
Continuity: 0u v
x y
+ =
(2.18)
x momentum:2
2
ee
dUu uu v U
x y dx y
+ +
u
(2.19)
y momentum: 0p
y
(2.20)
Energy:
22
2
p p
T T k T uu v
x y c y c y
+ +
(2.21)
7
7/31/2019 BLT Report
13/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Steady-state, incompressible, turbulent flow
Continuity: 0u v
x y
+ =
(2.22)
x momentum: ( )1e
e
dUu u uu v U
x y dx y y
+ + +
T
(2.23)
y momentum: 0p
y
(2.24)
Energy: ( ) ( )2
p T
T T T uc 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 parameterT 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 eC U 0.016C=
8
7/31/2019 BLT Report
14/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
(3.2)*,T inner u y 0.41 =
where the friction velocity is * wu
= (3.3)
E. Mixing length
The mixing length parameter is l and is related to as follows.m T
2T mu
ly
(3.4)
where
*
, 1yuA
m innerl y e
(3.5)26A =
where and u*are as described in equations (3.2) and (3.3).
And (3.6), 0.09m outerl
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
32
2T T
D
k
K K K u Ku v C
x y y y y
+ + l
(3.7)
where CD is not the drag coefficient, but an empirical constant, . Also,
and is related to l by
0.09DC
1k l m
1
4DC l l
= m (3.8)
9
7/31/2019 BLT Report
15/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
and 2T mu
ly
(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 ju uu
y y
( )
2, ,
22
2i j+2 i j+1 i ju uu
y y
+
,u
( )O x (4.1)
(4.2)
10
7/31/2019 BLT Report
16/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Backward Difference, ,i j i j -1u uu
y y
( )
2
, ,22
2i j+2 i j+1 i ju uuy y
+ ,u
( )O x (4.3)
(4.4)
Central Difference, ,
2
i j+1 i j -1u uu
y y
( )
2, ,
22
2i j+1 i j i j-1u u uu
y y
+
,
2( )O x (4.5)
(4.6)
G. Continuity Equation
This equation is modelled with a forward difference approximation inu
x
and a
backward difference approximation forv
y
. However, while the simplest
application of those approximations would result in
, , , ,0
i+1 j i j i+1 j i+1 j-1u u v v
x y
+
=
, numerical accuracy would suffer because the
first term is level j, while the second term is level j - . In order to place both
terms on the same level and thereby improve accuracy, the first term is
decomposed into the average of its value at level j and its value at level j-1.
Then, the discretized equation becomes
, , , , , ,10
2
i+1 j i j i+1 j-1 i j-1 i+1 j i+1 j-1u u u u v v
x x y
+ +
=
11
7/31/2019 BLT Report
17/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
and (1, 1, 1 , , , ,2
i j i j i+1 j i j i+1 j-1 i j -1
yv v u u u u
x+ +
= +
) (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-1e i+1 e i
i j i j
u u u u u u uU Uu v
x y x y
+ + = +
where Ive used the fact that2
12
e ee 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 vu u u
y x yy y
u U U
x x
+ + +
= +
2y
(4.8)
Equation (4.8) can be expressed in matrix format like below.
2 22 2
33 3 3
44 4 4
55 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 -2N -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
7/31/2019 BLT Report
18/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard 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
, , , , , , , , ,
, , 22
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 uu vx y cy
+ + = + 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 vT T T
y x yy y
u T u ux c y
+ + +
= +
2y
(4.11)
Equation (4.11) can be expressed in matrix format like below
13
7/31/2019 BLT Report
19/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
2 22 2
33 3 3
44 4 4
55 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 -2N -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
yy
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
7/31/2019 BLT Report
20/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard 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 theflow. There are 5 frames grouping these controls by type. They are:
15
7/31/2019 BLT Report
21/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard 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
7/31/2019 BLT Report
22/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard 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
Rex
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
will produce the same solution.
Control 9. Thermal conductivity Only enabled if temperature calculations are
requested.
Control 10. Specific heat Only enabled if temperature calculations are
requested.
17
7/31/2019 BLT Report
23/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Inlet Conditions Frame
Control 11. Source of inlet conditions If user chooses Auto, inlet conditions
for u (streamwise velocity) are developed in a cubic profile. Inlet conditions for v
are taken equal to v(x=xi,y=0) and for T, if required, inlet conditions are equal to
T(x=xi,y=0).
Controls 12, 13, 14. User-specified inlet conditions These controls will accept
either constant values or functions of y.
Boundary Conditions Frame
Control 15. Freestream velocity - This control will accept a constant or a
function of x.
Control 16. Wall velocity Velocity of injected fluid. This control will accept a
constant or a function of x.
Control 17. Wall temperature Temperature of the plate surface. This control
will accept a constant or a function of x.
Control 18. Freestream temperature Temperature of the freestream fluid. This
control will accept a constant or a function of x.
Control 19. First transition position If the boundary conditions change during
the calculation, this control can be used to specify the point at which the change
occurs. In the example of figure 6.1, the freestream velocity changes at x=1.
18
7/31/2019 BLT Report
24/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Controls 20 through 23. New boundary conditions at the first transition In the
example of figure 6.1, the freestream velocity changes from 10 to a linearly
decreasing function of x at x=1.
Controls 24 through 28. Second transition position and new boundary conditions
If boundary conditions change at a second point after the first transition, the
point of transition and the new boundary conditions are specified in these
controls.
Control 29. Run button Pressing this button begins the calculation.
Output
After calculations have been completed, the SIL form expands to reveal output
choices. As shown in figure 6.2, there are two choices. One choice is an internal
two-dimensional line plot, shown in figure 6.3. The second choice is to export
data to an ASCII data file, designed for TecPlot, but readable by any program
that can import ASCII data (MS Excel and MatLab are examples). All variables
can be exported, but line plots cant be drawn for variables that are functions of
both x and y.
19
7/31/2019 BLT Report
25/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
20
Figure 6.2 SIL Form With Output Choices
7/31/2019 BLT Report
26/57
Boundary Layer Analysis ToolkitAn Independent Study Report
21
Richard Getze
Figure 6.2 SIL Output Example
7/31/2019 BLT Report
27/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
M. Steady-state, Compressible, Laminar (SCL) Module
Module SCL can be accessed at any time by pressing Ctrl-C or by pulling down
the File menu, then choosing New Form, then Steady Compressible
Laminar. Figure 6.4 shows the SCL input form with output choices. Many of the
input controls on the SCL form are the same as described above for the SIL
form. Only controls exhibiting differences will be described below.
Figure 6.4 SCL Form With Output Choices
22
7/31/2019 BLT Report
28/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Physical Properties Frame
Mach Number User enters Mach number of freestream flow.
Fluid Properties Frame
Gas pull-down This control allows user to select type of gas. This information
is used in computing viscosity as a function of temperature.
Prandtl number, Gamma (Cp/Cv), Kinematic viscosity These controls are self-
explanatory
Boundary Conditions Frame
Freestream density The density of the freestream flow. This control will accept
either a constant or a function of x.
Temperature units Required in this module only for determining values of
certain constants, intrinsic to the program.
Output
Variables available for output now include density, the Stanton number and the
ratio of specific heats (gamma).
23
7/31/2019 BLT Report
29/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
N. Steady-state, Incompressible, Turbulent (SIT) Module
Module SIT can be accessed at any time by pressing Ctrl-T or by pulling down
the File menu, then choosing New Form, then Steady Incompressible
Turbulent. Figure 6.5 shows the SIT input form with output choices. Many of
the input controls on the SIT form are the same as described above for the SIL
form. Only controls exhibiting differences will be described below.
Figure 6.5 SIT Form With Output Choices
Computational Parameters Frame
Model Here the user selects a computational model. See section 4,
Turbulence Models, for a description of the different types.
24
7/31/2019 BLT Report
30/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Boundary Conditions Frame and Inlet Conditions Frame
Controls allowing specification of v are not included because of a large number of
intrinsic computational constants whose value changes dramatically based on
the value of injection or suction velocity.
7. Software Validation
The steady, incompressible, turbulent model was validated against Spaldings log
law of the wall. The results of that validation are displayed in figure 7.1.
Figure 7.1 Validation of SIT Module
0
5
10
15
20
25
30
1 10 100 1000 10000
y+ = yu*/nu
u+
=
u/u*
SIT Module Spalding's Log Law of the Wall
25
7/31/2019 BLT Report
31/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
The log law of the wall is given by
( ) ( )2 3
1 2 6
B uu u
y u e e u
++ +
+ + +
= +
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
7/31/2019 BLT Report
32/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard 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
7/31/2019 BLT Report
33/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
APPENDIX A
CODE FOR STEADY INCOMPRESSIBLE LAMINAR FLOW (SIL) MODULE
28
7/31/2019 BLT Report
34/57
7/31/2019 BLT Report
35/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
ReDim x(m), y(n)
'*********************************************'Insert boundary conditions in matrices
'*********************************************'First, wall conditions and free-stream conditionsFor i = 1 To m
u(1, i) = 0v(1, i) = vxy0(i)u(n, i) = Ue(i)
Next i'Next, inlet conditionsIf auto Then 'If user asks for auto velocity profile use cubic
'If starting at x=0, then no profileIf xi > 0 Then
del = EST_DELTA(xi, Ue(1), nu)For j = 1 To n
yod = (j - 1) * dy / delIf yod > 1 Then
u(j, 1) = Ue(1)Else
u(j, 1) = Ue(1) * (1.5 * yod - 0.5 * yod ^ 3)End Ifv(j, 1) = 0
Next jElse
For j = 1 To nu(j, 1) = Ue(1)v(j, 1) = 0
Next jEnd If
ElseFor j = 1 To n
u(j, 1) = ux0y(j)v(j, 1) = vx0y(j)
Next jEnd If
'initialize x and y arraysx(1) = xiy(1) = 0
'*********************************************'Start moving downstream'*********************************************
30
7/31/2019 BLT Report
36/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
For i = 1 To m - 1'Update progress barfm_progress.progbar.value = i'*********************************************
'NSLx yields streamwise velocity (u) distribution.x(i + 1) = x(i) + dx'matrix elements for TDMAFor j = 2 To n - 2
'lower diagonala(j - 1) = -1 * v(j + 1, i) / (2 * dy) - nu / ((dy) ^ 2)'upper diagonalc(j - 1) = v(j, i) / (2 * dy) - nu / ((dy) ^ 2)'main diagonalb(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 diagonalb(n - 2) = u(n - 1, i) / dx + 2 * nu / ((dy) ^ 2)'modify first element and add last element to'right side vectora1 = -1 * v(2, i) / (2 * dy) - nu / dy ^ 2d(1) = d(1) - a1 * u(1, i + 1)cn = v(n - 1, i) / (2 * dy) - nu / dy ^ 2d(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 TDMAu_iter = TDMA(c, a, b, d)'*********************************************'Check for transition to turbulence REx 1000000# And Not turb Then
turb = Truemsg = "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 separationwallshear(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) * dxUnload fm_progress
31
7/31/2019 BLT Report
37/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Exit SubEnd If'*********************************************'Transfer values into u matrix and record boundary layer thickness
For z = 2 To n - 1u(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) = zdelta(i + 1) = z * dy
End IfNext 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 jNext i'*********************************************'Store the data'*********************************************'store_uv_data x, y, u, v, delta, cfglobal_x = xglobal_y = yglobal_u = u
global_v = vglobal_delta = deltaglobal_Cf = cf'*********************************************'Recover memory'*********************************************Erase u, v, deltind, delta, wallshear, cfErase a, b, c, d, u_iterErase x, y
End Sub
Public Sub SIL_T(u() As Single, v() As Single, Tx0y() As Single, Txy0() AsSingle, 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
7/31/2019 BLT Report
38/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
'Implicit scheme is implemented.'*********************************************
Dim m As Integer, n As Integer, i As Integer, j As IntegerDim T() As Single, alpha As Single, z As Integer
Dim a() As Single, b() As Single, c() As Single, d() As SingleDim a1 As Single, cn As SingleDim T_iter() As Single, T_del_flag As BooleanDim T_deltaind() As Integer, T_delta() As SingleDim x() As Single, y() As Single
'alpha is thermal diffusivityalpha = k / (rho * cp)'m is number of stations in streamwise (x) directionm = UBound(Txy0)'n is number of stations across boundary layer (y)
n = UBound(Tx0y)'Dimension arraysReDim 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 arraysx(1) = xiFor i = 2 To m
x(i) = x(i - 1) + dx
Next iy(1) = 0For j = 2 To n
y(j) = y(j - 1) + dyNext j
'*********************************************'Insert boundary conditions in matrix'*********************************************'First, wall conditions and free-stream conditionsFor i = 1 To m
T(1, i) = Txy0(i)T(n, i) = Te(i)
Next i'Next, inlet conditionsFor j = 1 To n
T(j, 1) = Tx0y(j)Next j'*********************************************
33
7/31/2019 BLT Report
39/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
'Start moving downstream'*********************************************For i = 1 To m - 1
fm_progress.progbar.value = m + i
'*********************************************'COE yields temperature distribution.'matrix elementsFor j = 2 To n - 2
'lower diagonala(j - 1) = -1 * v(j + 1, i) / (2 * dy) - alpha / dy ^ 2'upper diagonalc(j - 1) = v(j, i) / (2 * dy) - alpha / dy ^ 2'main diagonalb(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)) ^ 2Next j'add last element to main diagonalb(n - 2) = u(n - 1, i) / dx + 2 * alpha / dy ^ 2'modify first element and add last element to'right side vectora1 = -1 * v(2, i) / (2 * dy) - alpha / dy ^ 2d(1) = d(1) - a1 * T(1, i + 1)cn = v(n - 1, i) / (2 * dy) - alpha / dy ^ 2d(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 TDMAT_iter = TDMA(c, a, b, d)'Transfer values into T matrix and mark position of boundary layerT_del_flag = FalseFor 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 = TrueElseIf T_del_flag And Abs(Te(i) - T_iter(j - 1)) < 0.01 * Te(i) And
T_deltaind(i + 1) = 0 ThenT_deltaind(i + 1) = j
T_delta(i + 1) = j * dyEnd If
Next jNext i'*********************************************'Store the data'*********************************************'store_T_data x, y, T, T_delta
34
7/31/2019 BLT Report
40/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
global_T = Tglobal_T_delta = T_delta'*********************************************'Recover memory
'*********************************************Erase TErase a, b, c, d, T_iterErase T_deltaind, T_deltaErase x, y
End Sub
Public Function EST_DELTA(x As Single, u As Single, nu As Single) As SingleDim REx As Single, d As Single
'Esimate boundary layer thickness using Blasius equationREx = u * x / nud = x * 5 / Sqr(REx)EST_DELTA = d
End Function
35
7/31/2019 BLT Report
41/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
APPENDIX B
CODE FOR STEADY COMPRESSIBLE LAMINAR FLOW (SCL) MODULE
36
7/31/2019 BLT Report
42/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Option Base 1Option 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 SingleDim H() As Single, a() As Single, b() As Single, c() As SingleDim R() As Single, Cmu() As Single, rho() As SingleDim cf() As Single, St() As Single, temp() As SingleDim L As Single, Re As Single, dx As Single, ncon As SingleDim T1 As Single, nnx As Integer, deltaind() As IntegerDim deno As Single, mt As Integer, rhoua As Single, rhoub As Single, r1 As
SingleDim 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 SingleDim mest As Integer, mmm As Integer, T_deltaind() As IntegerDim u_temp() As Single, H_temp() As Single, temp_temp() As SingleDim Uinf As Single, Tinf As Single, rhoinf As SingleDim x() As Single, y() As Single, T_del_flag As Boolean
L = 1dx = (xf - xi) / (nmax - 1)Re = L * Ue(1) / cnuinf'S is Sutherland constant for viscosityT1 = S / Te(1) 'for Sutherland viscosity law
'Redim variablesReDim 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
7/31/2019 BLT Report
43/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard 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 heatsgamma(1) = gamma1xm1 = (gamma(1) - 1) * xmif ^ 2Uinf = Ue(1)Tinf = Te(1)rhoinf = rhoe(1)For i = 1 To nmax
Ue(i) = Ue(i) / UinfTw(i) = Tw(i) / TinfTe(i) = Te(i) / TinfHe(i) = Te(i) / xm1
rhoe(i) = rhoe(i) / rhoinfNext ipe(1) = 1 / (gamma(1) * xmif ^ 2)
For j = 1 To mmaxu(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) = Treftemp(j, 1) = Trefgamma(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) = 0u(1, 1) = 0
H(1, 2) = Tw(2) / xm1H(1, 1) = H(1, 2)Tref = xm1 * H(1, 1)temp(1, 2) = Treftemp(1, 1) = TrefCmu(1) = (1 + T1) * Tref ^ 1.5 / (Tref + T1)rho(1, 1) = 1 / (xm1 * H(1, 2))rho(1, 2) = rho(1, 1)
38
7/31/2019 BLT Report
44/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
'Initial profilesmest = 2mmm = mest + 3
For j = 2 To mmaxu(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.5For i = 1 To nmax
Haw(i) = He(i) * (1 + 0.195 * RR * xmif ^ 2)
Next iSt(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 nmaxfm_progress.progbar.value = innx = iu(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) = 1c(1) = 0R(1) = 0a(mmax) = 0b(mmax) = 1R(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) / denob(j) = rho(j, i - 1) * u(j, i - 1) / dx + 0.5 * (Cmu(j - 1) + Cmu(j)) * 2 / denoc(j) = 0.5 * rho(j, i - 1) * v(j, i - 1) / dy - Cmu(j) / denoR(j) = rhoe(i) * 0.5 / dx * (Ue(i) ^ 2 - Ue(i - 1) ^ 2) + rho(j, i - 1) * u(j, i - 1) ^
2 / dxNext j
u_temp = trid(mmax, a, b, c, R, u_temp)
39
7/31/2019 BLT Report
45/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
For j = 1 To mmaxu(j, i) = u_temp(j)If u_temp(j) > 0.99 * Ue(i) And deltaind(i) = 0 Then
deltaind(i) = jdelta(i) = j * dy
End IfNext j
b(1) = 1c(1) = 0R(1) = H(1, i - 1)a(mmax) = 0b(mmax) = 1R(mmax) = He(i - 1)
deno = Pr * Re * dy ^ 2
For j = 2 To mmax - 1a(j) = -0.5 * rho(j, i - 1) * v(j, i - 1) / dy - Cmu(j - 1) / denob(j) = rho(j, i - 1) * u(j, i - 1) / dx + 0.5 * (Cmu(j - 1) + Cmu(j)) * 2 / denoc(j) = 0.5 * rho(j, i - 1) * v(j, i - 1) / dy - Cmu(j) / denoR(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 mmaxH(j, i) = H_temp(j)
Next j
mt = mest - 8If mt < 1 Then mt = 1For j = mt To mmax
If u(j, i) > 0.88 * Ue(i) Thenmest = j
mmm = mest + 3Exit For
End IfNext j
For j = 1 To mmaxtemp_temp(j) = temp(j, i - 1)
Next j
40
7/31/2019 BLT Report
46/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
temp_temp = interp(nnx, mmm, gamma, temp_temp, H_temp, xmif, Tinf)
T_del_flag = False
For j = 1 To mmaxtemp(j, i) = temp_temp(j)If Abs(Te(i) - temp_temp(j)) >= 0.01 * Te(i) Then
T_del_flag = TrueElseIf T_del_flag And Abs(Te(i) - temp_temp(j)) < 0.01 * Te(i) And
T_deltaind(i) = 0 ThenT_deltaind(i) = jT_delta(i) = j * dy
End IfNext j
For j = 2 To mmax - 1Cmu(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 - 1rhoua = 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) = 0End 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) = xiFor i = 2 To nmax
x(i) = x(i - 1) + dxNext iy(1) = 0For j = 2 To mmax
y(j) = y(j - 1) + dyNext j
41
7/31/2019 BLT Report
47/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
'Reconstitute dimensional variablesFor i = 1 To nmax
For j = 1 To mmax
u(j, i) = u(j, i) * Uinfv(j, i) = v(j, i) * Uinftemp(j, i) = temp(j, i) * Tinfrho(j, i) = rho(j, i) * rhoinf
Next jNext i
'Transfer procedure-level variables into global-level variablesglobal_x = xglobal_y = yglobal_u = u
global_v = vglobal_T = tempglobal_rho = rhoglobal_Cf = cfglobal_St = Stglobal_gamma = gammaglobal_delta = deltaglobal_T_delta = T_delta
'Free up memoryErase 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 + 10j = 0temp(m) = xm1 * H(m) * Tinf
42
7/31/2019 BLT Report
48/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
80:j = j + 1xint = temp(m)If j > 160 Then GoTo 70
yout = 0For k = 1 To 8
term = ygam(k)For i = 1 To 8
If k i Thenterm = term * (xint - xt(i)) / (xt(k) - xt(i))
End IfNext iyout = yout + term
Next k
temp(m) = (1.4 / yout) * (yout - 1) * xmif ^ 2 * H(m) * TinfIf Abs(temp(m) - xint) < 0.005 Then GoTo 70GoTo 80
70:gamma(m) = youttemp(m) = temp(m) / Tinf
Next minterp = temp
End Function
43
7/31/2019 BLT Report
49/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
APPENDIX C
CODE FOR STEADY INCOMPRESSIBLE TURBULENT FLOW (SIT) MODULE
44
7/31/2019 BLT Report
50/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Option Base 1Option ExplicitDim Re As SingleDim tmu() As Single, xx() As Single
Dim tke0() As Single, ncon As IntegerDim 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 SingleDim pi As Double, red As Single, L As Single, u_vec() As SingleDim del As Single, dy As Single, dx As Single, i As Integer, j As IntegerDim usue As Single, mest As Integer, fm1 As IntegerDim mmm As Integer, nmaxp As Integer, mmaxp As IntegerDim nnx As Integer, yod As Single, Ue() As SingleDim a() As Single, b() As Single, c() As Single, R() As SingleDim deno As Single, mt As Integer, delta() As SingleDim testnum As Integer, y() As Single
pi = 4 * Atn(1)
L = 1rkap = 0.41 'coefficients for modelling law of the wallypa = 9.7 'coefficients for modelling law of the walldel = xi * 0.375 / (Uinf * xi / cnu) ^ 0.2 'boundary layer thickness, Schetz eq. 7-43dy = 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 usingcf(1) = 0.0456 * (Uinf * del / cnu) ^ (-0.25) 'Blasius law, Schetz eq. 7-13
45
7/31/2019 BLT Report
51/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
For i = 1 To nmaxxx(i) = xi + (i - 1) * dxUe(i) = Ue_full(i) / Uinf
Next i
'set up inlet conditionsFor j = 1 To mmax
u(j, 1) = Ue(1)v(j, 1) = 0tke0(j) = 0
Next j'set up no-slip conditionFor i = 1 To nmax
u(1, i) = 0Next i
'if user specifies initial velocity profile, use it; however'by default, establish initial velocity profiles using Coles wake lawusue = 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 positionfm1 = mest - 1mmm = mest + 2If auto Then
For j = 2 To mestyod = (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) = 0Next j
ElseFor j = 2 To mmax
u(j, 1) = ux0y(j)Next j
End Ifnmaxp = nmaxmmaxp = mest + 100
ncon = 1
'Start stepping downstreamFor i = 2 To nmax
fm_progress.progbar.value = innx = iu(mmax, i) = Ue(i)v(mmax, i) = 0
46
7/31/2019 BLT Report
52/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Select Case modelCase 1
mixing nnx, mmax, mest, dy, Ue, u, v, cf
Case 2eddy nnx, mmax, mest, dy, Ue, u, v, cf
Case 3testnum = tkes(nnx, mmm, mest, dy, dx, Ue, u, v, cf)If testnum = -1 Then Exit Sub
End Selectncon = 2
'prepare for tdma solutionb(1) = 1c(1) = 0
R(1) = 0a(mmax) = 0b(mmax) = 1c(mmax) = 0R(mmax) = Ue(i)deno = Re * dy ^ 2
For j = 2 To mmax - 1a(j) = -0.5 * v(j, i - 1) / dy - (1 + tmu(j - 1)) / denob(j) = u(j, i - 1) / dx + (2 + tmu(j - 1) + tmu(j)) / denoc(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) / dxNext j
'run TDMAu_vec = trid(mmax, a, b, c, R, u_vec)
'transfer u_vec into uFor j = 1 To mmax
u(j, i) = u_vec(j)Next j
'calculate vFor 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 - 10If mt < 1 Then mt = 1For j = mt To mmax
47
7/31/2019 BLT Report
53/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
'find boundary layerIf u(j, i) > 0.99 * Ue(i) Then
mest = jmmm = mest + 3
mmaxp = mest + 100Exit For
End IfNext jdelta(i) = (mest - 1) * dy
'get skin frictioncf(i) = (4 * u(2, i) - u(3, i)) / (Ue(i) ^ 2 * dy * Re)
'check for near separationIf cf(i) < 0.0001 Then
MsgBox ("Near separation")nmaxp = iExit For
End IfNext i
y(1) = 0For j = 2 To mmax
y(j) = y(j - 1) + dyNext j
global_x = xxglobal_y = yFor i = 1 To nmax
For j = 1 To mmaxu(j, i) = u(j, i) * Uinfv(j, i) = v(j, i) * Uinf
Next jNext iglobal_u = uglobal_v = vglobal_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
7/31/2019 BLT Report
54/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Ue() As Single, u() As Single, v() As Single, cf() As Single)Dim xlmo As Single, xlmm As Single, j As IntegerDim y As Single, yp As Single
'for outer region, mixing length is Lm=0.09*deltaxlmo = 0.09 * (mest - 1) * dytmu(1) = 0For j = 2 To mmax - 1
y = (j - 1) * dyyp = y * Ue(nnx) * Re * Sqr(0.5 * cf(nnx - 1))xlmm = rkap * (1 - exp(-yp / 26#)) * yIf 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 SingleDim j As Integer, arg As Single, tanh As Singledelst = 0For 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 jrmut = 0.018 * Re * Ue(nnx) * delstFor j = 1 To mmax
y = (j - 1) * dyyp = y * Ue(nnx) * Re * Sqr(0.5 * cf(nnx - 1))arg = yp / ypatanh = (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 SingleDim cdf As Single, xlmo As Single, xlmm As Single, y As Single
49
7/31/2019 BLT Report
55/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
Dim yp As Single, tlm() As Single, stkm As Single, stkm1 As Single, deno As SingleDim a() As Single, b() As Single, c() As Single, R() As SingleDim 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 Schetzfm1 = mest - 1For j = 1 To mest
yod = (j - 1) / fm1If yod < 0.001 Then
tke0(j) = 5500 * yod * ussElseIf 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 jEnd If
cdf = cd ^ 0.25xlmo = 0.09 * (mest - 1) * dy
For j = 1 To mmmy = (j - 1) * dyyp = y * Ue(nnx) * Re * Sqr(0.5 * cf(nnx - 1))xlmm = rkap * (1# - exp(-yp / 26)) * yIf xlmm > xlmo Then xlmm = xlmotlm(j) = xlmm * cdf
Next j
stkm = 0#deno = sigk * dy ^ 2b(1) = 1#c(1) = 0R(1) = 0a(mmm) = 0b(mmm) = 1R(mmm) = tke(mmm)
50
7/31/2019 BLT Report
56/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
For j = 2 To mmm - 1stkm1 = stkmIf tke0(j) >= 0 Then
stkm = Sqr(tke0(j))Else
MsgBox "Attempted square root of negative. Quitting."tkes = -1Exit Function
End If
a(j) = -0.5 * v(j, nnx - 1) / dy - stkm1 * tlm(j - 1) / denob(j) = u(j, nnx - 1) / dx + cd * stkm / tlm(j) + (stkm1 * tlm(j - 1) + stkm * tlm(j)) / denoc(j) = -stkm * tlm(j) / deno + 0.5 * v(j, nnx - 1) / dyR(j) = stkm * tlm(j) * (u(j + 1, nnx - 1) - u(j - 1, nnx - 1)) ^ 2 / (4 * dy ^ 2) + u(j, nnx - 1) * tke0(j) /
dxNext j
tke = trid(mmm, a, b, c, R, tke)
tmu(1) = 0For 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) = 0tke0(mmm) = 0
End Function
Public Function trid(mm As Integer, a() As Single, b() As Single, c() As Single, R() As Single, S() AsSingle) 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
7/31/2019 BLT Report
57/57
Boundary Layer Analysis ToolkitAn Independent Study ReportRichard Getze
rp(j) = (R(j) - a(j) * rp(j - 1)) / denoNext j
S(mm) = rp(mm)
For j = 1 To mm - 1S(mm - j) = rp(mm - j) - gam(mm - j) * S(mm - j + 1)
Next j
trid = S
End Function
Top Related