Reference v0.40
1 / 83
Table of contents
Introduction .................................................................................................................................... 4
Getting Started ............................................................................................................................. 5
Creating Objects ..................................................................................................................... 5
Problem Setup ........................................................................................................................ 5
Run Model ................................................................................................................................ 6
Post Processing ...................................................................................................................... 6
Next Steps ............................................................................................................................... 6
Tips for Boundary Conditions ..................................................................................................... 7
Brief Description of Commands ................................................................................................. 9
Commands ................................................................................................................................. 12
AdaptCellsIf ........................................................................................................................... 12
AddPt2Poly ........................................................................................................................... 13
AddPt2Table ......................................................................................................................... 14
BFlowVersion ........................................................................................................................ 15
CalcCoeffs ............................................................................................................................. 16
CalcGrad ............................................................................................................................... 17
Circle2Poly ............................................................................................................................ 18
ClearLookupTable ................................................................................................................ 19
CopyDiffCoeffs ..................................................................................................................... 20
CreateBC .............................................................................................................................. 21
CreateBlockContourBMP .................................................................................................... 22
CreateContourBMP .............................................................................................................. 23
CreateGeoBMP .................................................................................................................... 24
CreateGridBMP .................................................................................................................... 25
CreateLookupTable ............................................................................................................. 26
CreateMaterial ...................................................................................................................... 27
CreatePathlinesBMP ........................................................................................................... 28
CreatePoly ............................................................................................................................. 29
CreateQuadMesh ................................................................................................................. 30
CreateScalarField ................................................................................................................ 31
CreateSource ........................................................................................................................ 32
CreateVectorBMP ................................................................................................................ 33
DefineVariable ...................................................................................................................... 34
FixVectorLength .................................................................................................................... 35
GetCellCount ......................................................................................................................... 36
GetTime ................................................................................................................................. 37
IncrementTimeStep .............................................................................................................. 38
InitializeBFlow ....................................................................................................................... 39
InitializePhi ............................................................................................................................. 40
InitializePhiN .......................................................................................................................... 41
InletDiffusionOn ..................................................................................................................... 42
LimitPhi .................................................................................................................................. 43
OverlayGeo ............................................................................................................................ 44
OverlayGrid ............................................................................................................................ 45
RunSolver .............................................................................................................................. 46
SetAxi ..................................................................................................................................... 47
SetBC .................................................................................................................................... 48
SetBCLin ............................................................................................................................... 49
SetBCn .................................................................................................................................. 51
SetBlackBackground ........................................................................................................... 52
2 / 83
SetCP .................................................................................................................................... 53
SetDensity ............................................................................................................................. 54
SetDensityN .......................................................................................................................... 55
SetDiffCoeff ........................................................................................................................... 56
SetDiffCoeffN ........................................................................................................................ 57
SetMirror ................................................................................................................................ 58
SetOpPress ........................................................................................................................... 59
SetOpPressN ........................................................................................................................ 60
SetPorousSolidCp ............................................................................................................... 61
SetPorousSolidDensity ........................................................................................................ 62
SetPorousSolidThCond ....................................................................................................... 63
SetPorousVoidFraction ....................................................................................................... 64
SetRange ............................................................................................................................... 65
SetSolid ................................................................................................................................. 66
SetSource .............................................................................................................................. 67
SetSourceLin ........................................................................................................................ 68
SetSourceN ........................................................................................................................... 69
SetTimeStep ......................................................................................................................... 70
SetTitle ................................................................................................................................... 71
SetTol ..................................................................................................................................... 72
SetUnderRelax ...................................................................................................................... 73
SetVectorScaling .................................................................................................................. 74
SetVectorSkip ....................................................................................................................... 75
SetView ................................................................................................................................. 76
StartPoly ................................................................................................................................ 77
UpdatePhi .............................................................................................................................. 78
ValAtPt ................................................................................................................................... 79
Algebraic Expressions in Bflow ............................................................................................... 80
Defining User Variables ....................................................................................................... 80
Creating and Using Data Tables ........................................................................................ 81
Using If ................................................................................................................................... 82
How Expressions are Processed ....................................................................................... 82
3 / 83
Introduction
The BFlow transport library consists of a set of commands for creating and running simple computational
fluid dynamics models. This library resides in the file bflow.dll. This document describes each command,
its syntax and examples of use. In addition, information is provided on using algebraic expressions as
inputs.
Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle
4 / 83
Getting Started
With over 60 commands in the BFlow library, the learning curve can appear steep. It's not! Many complete
models can be created with just 15 commands.
There are four steps in making a model:
- Creating the needed objects - polygons, boundary conditions, material properties, etc.
- Setting up the problem - setting geometry, BCs, etc.
- Solving the problem - getting an answer.
- Postprocessing - plotting the results.
Just a few key commands are needed for each of these steps. The first command is the one to initialize the
library. This clears out any remnants of a previous model:
InitializeBFlow
Once that is done, model creation can begin
Created with the Personal Edition of HelpNDoc: Write EPub books for the iPad
Creating Objects
A CFD model is made up of geometry (polygons), boundary conditions, material properties, source terms
and fields to be solved for. In BFlow, each of these must be created before used, with a command like:
EastWall = CreateBC()
Why is this required? Why can't BFlow simple create the objects as needed? The creation step provides
an easy way to get the ID number of an object. In the line above, CreateBC() will return a long integer which
is stored in the variable EastWall. Later, when you want to set or modify this boundary condition, you need
to be able to identify which BC you are talking about. The Create functions give you the information to do
this. They also allow BFlow to do some error checking. When you specify a BC object, where a source is
expected, the code will flag it.
The three essential creation commands are:
CreatePoly - creates a polygon object (for specifying geometry)
CreateBC - creates a boundary condition object
CreateMaterial - Creates an object for holding material information (viscosity, specific heat)
Created with the Personal Edition of HelpNDoc: Produce electronic books easily
Problem Setup
In this stage you specify all of the details that make this model unique. This is the most difficult step, but
even here, you only need seven commands. The geometry can be created with just two commands:
StartPoly - specify starting point of polygon, its material and source terms
AddPtToPoly - add another point to the polygon
With these two, shapes of arbitrary complexity can be created. In BFlow the order of the polygons is
important. The first polygon should cover the entire domain. Each subsequent one imprints its material
properties, source terms and boundary conditions onto the mesh. If two polys cover the same area, it is the
second one's properties that are retained in the final mesh. In other words each polygon overwrites the
values of any preceding polygons.
At this point, one would think we could create the mesh, since the geometry is defined. However, BFlow
5 / 83
does some checks on the boundary conditions during mesh creation, to catch user errors. So it is best to
wait on creating the mesh.
The next step is to set the boundary conditions and material properties. This is done with these
commands.
SetBC - sets a boundary condition
SetDensity - sets density of a material
SetCP
- sets specific heat of a material
SetDiffCoeff - sets diffusion coefficient (or thermal conductivity or viscosity) of a material
The mesh can now be created:
CreateQuadMesh
At this point, the model is created. The next step is running it.
Created with the Personal Edition of HelpNDoc: Free Kindle producer
Run Model
To solve the model, two steps are required. The transport equations, which are partial differential equations,
need to be converted into a set of algebraic equations. In the second step, these algebraic equations are
solved using a linear solver. The commands are:
CalcCoeffs - calculates the coefficients of the algebraic equations for a single field variable
RunSolver - Solves for a field variable using a linear solver
Normally we are solving for more than one field variable. This pair of commands is called for each variable.
And if the problem is non-linear, like the Navier-Stokes equation, we will want to create a For Next loop
where we solve for these fields repeatedly.
Created with the Personal Edition of HelpNDoc: Free help authoring tool
Post Processing
Once a solution has been found, we need to examine it. Two effective ways of doing this are to create
contour plots and probe the solution at specific points. These can be done with these commands:
CreateContourBMP - Creates a contour plot and saves it as a BMP file
ValAtPt - determines the value of any expression at a particular point.
The ValAtPt command can be called repeatedly to generate the points for a line plot.
Created with the Personal Edition of HelpNDoc: Easily create Web Help sites
Next Steps
With these 15 commands you can create a wide range of models. Once you are comfortable with them,
you will want to explore the other commands. For instance, to add a source term to your model, like a
heater, use CreateSource and SetSource. To do a transient model, use SetTimeStep and
IncrementTimeStep. To create a vector plot, use CreateVectorBMP. To zoom into a portion of a vector or
contour plot, use SetView.
Created with the Personal Edition of HelpNDoc: Full-featured EBook editor
6 / 83
For our pipe problem lets say we know the fluid enters the pipe at 1m/s at the west side and exits into the
open air, at one atmosphere, on the east side. At the inlet, we know the velocity, but not the pressure while
at the outlet we know the pressure, but not the velocity. In BFlow we would specify the inlet boundary
condition with these three lines:
SetBC(inlet, press, BCFlux, 0)
SetBC(inlet, uv, BCVal, 1) inlet velocity is 1m/s
SetBC(inlet, vv, BCVal, 0)
This says we don't know the inlet pressure, but whatever it is, its gradient is zero at the inlet. The x
component of velocity is specified to be 1 m/s. There is no y component, so it is set to zero.
For the outlet, we would write the boundary conditions this way:
SetBC(outlet, press, BCVal, 0)
SetBC(outlet, uv, BCFlux, 0)
SetBC(outlet, vv, BCVal, 0)
This sets the gauge pressure to be zero at the outlet. The x-componenet of velocity is given zero flux
meaning that while we don't know its value we know its not changing at the exit. Since the flow is purely in
the x direction, the y component of velocity can be set to zero.
For the pipe wall, we don't know the pressure, but we do know that both components of velocity are zero (no
slip boundary conditions). The following commands achieve that.
SetBC(wall, press, BCFlux, 0)
SetBC(wall, uv, BCVal, 0)
SetBC(wall, vv, BCVal, 0)
For a symmetry boundary condition, like the axis of symmetry in the figure, the gradient of pressure and uvelocity is zero. Fluid can't cross a symmetry plane so v-velocity is zero:
SetBC(axis, press, BCFlux, 0)
SetBC(axis, uv, BCFlux, 0)
SetBC(axis, vv, BCVal, 0)
7 / 83
There are other variations possible. For instance we could have a pressure inlet instead of a velocity inlet.
Or we could specify the velocity at the exit. Those boundary conditions are specified below.
SetBC(inlet2, press, BCVal, 10)
SetBC(inlet2, uv, BCFlux, 0)
SetBC(inlet2, vv, BCVal, 0)
SetBC(outlet2, press, BCFlux, 0)
SetBC(outlet2, uv, BCVal, -1)
SetBC(outlet2, vv, BCVal, 0)
Created with the Personal Edition of HelpNDoc: Full-featured Kindle eBooks generator
8 / 83
Command
Comment
AdaptCellsIf(EqStr)
AddPt2Poly(PolyNum, x, y, bc)
BFlowVersion()
CalcCoeffs(phinum)
CreateBC()
CreateBlockContourBMP (file,
EqString)
CreateContourBMP (file, EqString) Create a contour plot bit map and save to file.
CreateGeoBMP(file)
CreateGridBMP(file)
CreateLookupTable(TableID)
CreateMaterial()
CreatePoly()
CreateQuadMesh(delx, dely)
CreateScalarField (FieldName)
CreateSource()
CreateVectorBMP(file, Func1,
Func2)
GetCellCount()
GetTime()
IncrementTimeStep()
InitializeBFlow()
InitializePhi(phinum,EqString)
InitializePhiN(phi,aval)
InletDiffusionOn(PhiNum, bool)
LimitPhi(PhiNum, MinVal, MaxVal) Limit field phi to between minval and maxval
9 / 83
OverlayGeo(TrueOrFalse)
OverlayGrid(TrueOrFalse)
RunSolver(phi,its,resid, SolverNum) Runs the solver a certain number of iterations for field phi.
Returns resid. Uses current solver
SetAxi(Axistate)
SetBC
Set a boundary condition for phi using arbitrary equation.
(BCNum,phinum,BCType,EqString) BCType = 1 for value, 2 for flux.
SetBCN
(BCNum,phinum,BCType,Val)
SetBlackBackground (TrueOrFalse)
SetCP(MatNum,EqString)
SetCPN(MatNum,val)
SetDensity(MatNum,EqString)
SetDensityN(MatNum,val)
SetDiffCoeff(MatNum, PhiNum,
xEqString,yEqString)
SetDiffCoeffN(MatNum, PhiNum,
aVal)
SetMirror(Axis)
SetOpPress(EqString)
SetOpPressN(val)
SetPorousSolidCp(MatID, Eq)
SetSolid(MatNum)
SetSource
(SourceNum,PhiNum,EqString)
SetSource
(SourceNum,PhiNum,S0EqString,
S1EqString)
SetSourceN
(SourceNum,PhiNum,S0Val,
S1Val)
SetTimeStep (TimeStep)
SetTitle(TitleStr)
SetTol(BCID, tolerance)
SetUnderRelax(phinum,val)
SetVectorScaling(theScale)
SetVectorSkip(skip)
10 / 83
MatNum, sourcenum)
ValAtPt(x,y,EqString)
Created with the Personal Edition of HelpNDoc: Free help authoring environment
11 / 83
Commands
The detailed description of each command is listed below.
Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator
AdaptCellsIf
Purpose
Syntax
Parameters
Return
Values
none
Remarks
At times, the computational grid needs to be refined to improve the accuracy of the
solution. The command AdaptCellsIf can be used to provide a conditional adaption (or
refinement) of the computational cells. For instance downstream of a flow obstruction,
you may want to refine the mesh to better resolve any eddies that have formed. You can
also use this command to refine the grid based on gradients of a field, using the
CalcGrad command first.
AdaptCellsIf must be called after the mesh has been generated
Example
See Also
CreateQuadMesh, SetTol
12 / 83
Created with the Personal Edition of HelpNDoc: Free iPhone documentation generator
AddPt2Poly
Purpose
Syntax
Parameters
Return
Values
none
Remarks
This routine is used in conjunction with StartPolyto create a polygon. The initial point, as
well as the material and source term information is specified with StartPoly. Each
additional point is created and added to the polygon by calling AddPt2Poly. In addition,
the boundary condition for the segment defined by this point and the previous one is
specified. If a segment is not a boundary condition (perhaps it separates two materials),
then use the constant NoBC in place of the BC ID number.
The final point in the polygon must be the same as the starting point.
Example
See Also
Define Geometry
Poly1 = CreatePoly()
CALL StartPoly(Poly1, 0,
CALL AddPt2Poly(Poly1,
CALL AddPt2Poly(Poly1,
CALL AddPt2Poly(Poly1,
CALL AddPt2Poly(Poly1,
0, mat1, source1)
10, 0, bc1) 'bottom
10, 10, bc2) 'right side
0, 10, bc3) 'top
0, 0, bc4) 'left side
CreatePoly, StartPoly
13 / 83
Created with the Personal Edition of HelpNDoc: Free PDF documentation generator
AddPt2Table
Purpose
Syntax
Parameters
Return
Values
none
Remarks
This function allows you to add a data point to a table that can hold an arbitrary
amount of data. (A table is used to define a function that interpolates between the
data.) This can be used to define a boundary condition based on experimental
data, for instance. Prior to calling AddPt2Table, one must call CreateLookupTable
to create the table and get the table ID number. Data points are stored in
ascending order by x value, but can be entered in any order. If a call to the table
is made outside of the defined range, an extrapolation is done using the closest
two data points.
Example
See Also
CreateLookupTable, ClearLookupTable
14 / 83
Created with the Personal Edition of HelpNDoc: Easy EBook and documentation generator
BFlowVersion
Purpose
Syntax
Result = BflowVersion()
Parameters
none
Return
Values
Remarks
The result is a long integer containing the version number. The last two digits are
the minor version number. For example, a result of 121 would indicate version
1.21
Example
See Also
15 / 83
Created with the Personal Edition of HelpNDoc: Free Web Help generator
CalcCoeffs
Purpose
Syntax
Parameters
Return
Values
none
Remarks
BFlow uses the Finite Volume Method to solve the partial differential equations of
interest. The partial differential equations are converted to algebraic equations.
The coefficients of those equations are calculated here.
Example
Call CalcCoeffs(temp)
See Also
RunSolver
16 / 83
Created with the Personal Edition of HelpNDoc: Free CHM Help documentation generator
CalcGrad
Purpose
Syntax
Parameters
Return
Values
none
Remarks
This function computes the gradient of the field phi over the entire domain. To use
this function, you must create two scalar fields to store the result, using the
CreateScalarField function. Once it has been created, the gradient can be
accessed by any command that can accept an expression.
Example
See Also
CreateScalarField, CopyDiffCoeffs
17 / 83
Circle2Poly
Purpose
Syntax
Parameters
Return
Values
none
Remarks
This command makes it easy to add a circle to your model, without having to
enter all of the points.
Example
See Also
18 / 83
Created with the Personal Edition of HelpNDoc: Produce Kindle eBooks easily
ClearLookupTable
Purpose
Syntax
Parameters
Return
Values
none
Remarks
Use this command to clear the data from a lookup table prior to repopulating the
table. This can be useful if, for instance, you are updating the data in the table
after each iteration.
Example
Call ClearLookupTable(FluxDataID)
'clear old data table
del = 4 '4mm spacing betw pts in flux table
For i = 1 To 37
x = del * i * mm
Call AddPt2Table(FluxDataID, x, ValAtPt(x, 171.25 * mm,
"diff2*grad2")) 'add ith point
Next i
See Also
CreateLookupTable, AddPt2Table
19 / 83
Created with the Personal Edition of HelpNDoc: iPhone web sites made easy
CopyDiffCoeffs
Purpose
Syntax
Parameters
Return
Values
none
Remarks
This command copies the x and y diffusion coefficients to two fields you specify.
This is useful for calculating diffusive fluxes for plotting.
Example
See Also
CalcGrad
20 / 83
Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor
CreateBC
Purpose
Syntax
EastWall = CreateBC()
Parameters
none
Return
Values
Remarks
Before you can set a boundary condition, you must create it using this command.
The ID number it returns is later used to tell BFlow which boundary condition is
being set.
Example
See Also
SetBC, SetBCLin
21 / 83
CreateBlockContourBMP
Purpose
Syntax
Parameters
Return
Values
none
Remarks
This routine creates a blocky contour plot of the desired equation, using cell
centered values of the field variables. This plot is then written to a BMP file. The
region to be plotted is set with the SetView command. Contour plots are square
in shape.
Example
See Also
22 / 83
CreateContourBMP
Purpose
Syntax
Parameters
Return
Values
none
Remarks
This routine creates a contour plot of the desired equation. The field values are
interpolated to the cell nodes, giving a smooth contour plot. This plot is then
written to a BMP file. The region to be plotted is set with the SetView command.
Contour plots are square in shape.
Example
See Also
23 / 83
Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source
CreateGeoBMP
Purpose
Syntax
Call CreateGeoBMP(file)
Parameters
Return
Values
none
Remarks
This function creates a plot of the model geometry. The plot is then written to a
BMP file. The region to be plotted is set with the SetView command These plots
are square in shape.
Example
See Also
24 / 83
Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation
CreateGridBMP
Purpose
Syntax
Call CreateGridBMP(file)
Parameters
Return
Values
none
Remarks
This function creates a BMP file of the model mesh. The region to be plotted is
set with SetView. These plots are square in shape.
Example
See Also
25 / 83
Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator
CreateLookupTable
Purpose
Syntax
Parameters
Return
Values
Remarks
This function allows you to create a table that can hold an arbitrary amount of x,y
data. A table is used to define a linear interpolation function based on these data
points. This can be used to define a boundary condition derived from
experimental data, for instance. Once the CreateLookupTable command has
been called, data points are added to the table using the AddPt2Table command.
Data points are stored in ascending order by x value (but can be entered in any
order). If the interpolation function is called outside of the defined range, an
extrapolation is done using the closest two data points.
Example
See Also
AddPt2Table, ClearLookupTable
26 / 83
Created with the Personal Edition of HelpNDoc: Produce electronic books easily
CreateMaterial
Purpose
Syntax
theFluid = CreateMaterial()
Parameters
none
Return
Values
Remarks
All of the material properties for a polygon are stored in its material object. This
includes diffusion coefficients, specific heat, viscosity, etc. Once the material is
created, these can be set with the commands SetDiffCoeff and SetCP.
Example
See Also
27 / 83
Created with the Personal Edition of HelpNDoc: Free PDF documentation generator
CreatePathlinesBMP
Purpose
Syntax
Parameters
Return
Values
none
Remarks
This function creates a pathline plot and saves it as a BMP file. The length of the
pathlines is set with the Time parameter. Each path is created by integrating the
velocity over time. Longer Time values generate longer pathlines. The time step
used in the integration is based on the local cell size and velocity. The region to
be plotted is set with SetView.
Example
See Also
28 / 83
Created with the Personal Edition of HelpNDoc: Free Web Help generator
CreatePoly
Purpose
Syntax
PolyID = CreatePoly()
Parameters
none
Return
Values
Remarks
This function allows you to create a polygon object. This is the first step in
specifying the details of the polygon. Once created, the starting point, material
property and source term are set with StartPoly. Then additional points and
boundary conditions are set with AddPt2Poly.
Example
Heater = CreatePoly()
Call StartPoly(Heater, 0,0, Al3003, NoSource)
Call AddPt2Poly(Heater, 1,0, bott)
Call AddPt2Poly(Heater, 1,1, side)
Call AddPt2Poly(Heater, 0,1, top)
Call AddPt2Poly(Heater, 0,0, axis)
See Also
29 / 83
CreateQuadMesh
Purpose
Syntax
Parameters
delx the size of the grid cells in the x direction, in meters. Double precision.
dely the size of the grid cells in the y direction, in meters. Double precision.
Return Value
none
Remarks
This routine creates a mesh of rectangles that covers all of the polygons defined. It
then imprints the polygons and discards the cells that lie outside of the geometry.
The result is a stair-step mesh that may not exactly preserve the geometry defined
by the polygons in the model.
Example
''Define Geometry
CALL StartPoly(Poly1, 0, 0, mat1, source1)
CALL AddPt2Poly(Poly1, 10, 0, bc1) 'bottom
CALL AddPt2Poly(Poly1, 10, 10, bc2) 'right side
CALL AddPt2Poly(Poly1, 0, 10, bc3) 'top
CALL AddPt2Poly(Poly1, 0, 0, bc4) 'left side
Call CreateQuadMesh (0.5, 0.5)
See Also
30 / 83
Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source
CreateScalarField
Purpose
Syntax
Parameters
FieldName This is the name you use to refer to the field in algebraic expressions.
Return Value
Remarks
Bflow has four predefined fields: Pressure, u-velocity, v-velocity, and temperature.
If you want to solve additional partial differential equations, you must create the
fields for them. These scalar fields can be used to solve for species mass
fractions in reacting flows, for voltage in a conduction problem or f in an
electrostatics problem. In addition, scalars can be used to store information for
post processing, or other purposes. They are also used to store the results from
the CalcGrad calculation.
Example
''Define Geometry
VelMag = CreateScalarField(VelMag) define new field
Call InitializePhi(VelMag, sqrt(uv^2 + vv^2) ) store velocity mag in field
See Also
31 / 83
Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source
CreateSource
Purpose
Syntax
SourceID = CreateSource()
Parameters
none
Return Value
Remarks
After a source term object has been created, its specific behavior can be defined
using the command SetSource . A source term can be used to specify a heat
generation term or a gas phase reaction, for instance. It is also used to create a
momentum sink term when solving porous media models
Example
''Define Geometry
HeatSource = CreateSource() define new source
Call SetSourceLin(HeatSource, Temp, 20000, 0)
See Also
32 / 83
Created with the Personal Edition of HelpNDoc: Produce electronic books easily
CreateVectorBMP
Purpose
Syntax
Parameters
Return
Values
none.
Remarks
Typically vector plots are used to visualize the velocity through a domain. To do
that you specify the x component of velocity (field uv) and the y component (field
vv). This function can also be used to plot any vector quantity by appropriate
choice of EqStr1, and EqStr2.
Example
See Also
33 / 83
Created with the Personal Edition of HelpNDoc: iPhone web sites made easy
DefineVariable
Purpose
Syntax
Parameters
Return
Values
none
Remarks
Example
DefineVariable(FirstTerm, (uv^2)
DefineVariable (SecondTerm, (vv^2)
DefineVariable (VelMag, (sqrt(FirstTerm + SecondTerm))
CreateContourBMP(VelMag.bmp, 0,0,0,VelMag)
Create a contour plot of
velocity magnitude
See Also
34 / 83
Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator
FixVectorLength
Purpose
Syntax
Parameters
Return
Values
none
Remarks
Example
See Also
35 / 83
Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator
GetCellCount
Purpose
Syntax
TotalCells = GetCellCount()
Parameters
none
Return
Values
Remarks
This can be used after mesh generation to check the cell density of the problem.
A high cell count will result in longer computation times.
Example
See Also
CreateQuadMesh
36 / 83
Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle
GetTime
Purpose
Syntax
TheTime = GetTime()
Parameters
none
Return
Values
Remarks
Example
See Also
SetTimeStep, IncrementTimeStep
37 / 83
Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source
IncrementTimeStep
Purpose
To update the simulation time and the field values in transient models
Syntax
Call IncrementTimeStep()
Parameters
none
Return
Values
none
Remarks
This function tells BFlow the time step is over. It then increments the simulation
time by the time step. It also updates the field values for the previous time step
Example
Call SetTimeStep(delt)
For i = 1 To 120
'loop over time steps
Call CalcCoeffs(temp)
Call RunSolver (temp, 50, resid, SOR)
Call IncrementTimeStep
'Update old values
'Write out temp at several locations
Cells(25 + i, 3).Value = ValAtPt (Dia / 2, Thick/2,
tp-273)
Cells(25 + i, 4).Value = ValAtPt (Dia / 4, Thick/4,
tp-273)
Next i
See Also
GetTime, SetTimeStep
38 / 83
Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor
InitializeBFlow
Purpose
Syntax
Call InitializeBFlow()
Parameters
none
Return
Values
none
Remarks
This function should be called at the beginning of a model to initialize all arrays
and parameters to their starting values.
Example
Call InitializeBFlow()
See Also
39 / 83
InitializePhi
Purpose
Syntax
Parameters
Return
Values
none
Remarks
Example
See Also
40 / 83
Created with the Personal Edition of HelpNDoc: Easily create EPub books
InitializePhiN
Purpose
Syntax
Parameters
Return
Values
none
Remarks
Example
See Also
41 / 83
Created with the Personal Edition of HelpNDoc: Easily create Web Help sites
InletDiffusionOn
Purpose
Syntax
Parameters
Return
Values
none
Remarks
In flow problems involving species, the species are transported from the inlet by
convection and by diffusion. In some cases it is not realistic to have a diffusive
component at the inlet. In those cases, the inlet diffusion can be set to zero. By
default, inlet diffusion is on.
Example
See Also
CreateScalarField
42 / 83
Created with the Personal Edition of HelpNDoc: Easy EBook and documentation generator
LimitPhi
Purpose
Syntax
Parameters
Return
Values
none
Remarks
Example
See Also
InitializePhi, UpdatePhi
43 / 83
Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source
OverlayGeo
Purpose
Syntax
Call OverlayGeo(TrueOrFalse)
Parameters
Return
Values
none
Remarks
This function draws the polygons of the model on top of any future plots. This can
make plots clearer. It can also highlight gaps between the geometry and the
computational domain. By default OverlayGeo is set to False.
Example
Call OverlayGeo(0)
See Also
44 / 83
Created with the Personal Edition of HelpNDoc: Easy EBook and documentation generator
OverlayGrid
Purpose
Syntax
Call OverlayGrid(TrueOrFalse)
Parameters
Return
Values
none
Remarks
By default, a grid is overlaid onto plots created with BFlow. To turn this off, set
the argument to 0.
Example
See Also
45 / 83
Created with the Personal Edition of HelpNDoc: Produce Kindle eBooks easily
RunSolver
Purpose
Syntax
Parameters
Return
Values
None
Remarks
Example
Call CalcCoeffs(temp)
Call RunSolver (temp, 50, resid, SOR)
See Also
SetUnderRelax, CalcCoeffs
46 / 83
SetAxi
Purpose
Syntax
Call SetAxi(Axistate)
Parameters
Axistate long integer can be 0 (rectangular), 1 (axi along x) or 2 (axi along y).
Return
Values
none
Remarks
Example
See Also
SetMirror
47 / 83
Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor
SetBC
Purpose
Set the boundary condition for field phi using an arbitrary equation.
Syntax
Parameters
Return
Values
None
Remarks
Each surface of the domain needs a boundary condition for each variable being
solved for. CreateBC is used to create a boundary condition and give it an ID
number. Later this number is used to apply the BC to a given segment of a
polygon, using SetBC.
BCType. There are three types of boundary conditions frequently encountered in
CFD: value (where the field value is specified on the boundary), flux (where the flux
is specified) and heat transfer, where a heat transfer coefficient is specified. The
following constants are used to specify type
1 Value type BC (Dirichlet condition). Use predefined constant: BCVal
2 Flux type BC (Neumann condition). Use predefined constant: BCFlux
One can also specify the type as NoBC, for internal walls where a boundary
condition is not appropriate. For instance at a fluid-solid interface in a conjugate
heat transfer problem, the temperature should not be specified, so the
temperature BC would be set to NoBC on this surface.
For Heat transfer coefficient BC's, the boundary can be implemented with the flux
BC type, as shown in the example below.
Example
DefineVariable(T_inf, 273)
DefineVariable(h, 2.1)
Call SetBC(LeftWall, Temp, BCVal, 2.4 * x) Temp on wall
depends on x position
A Heat transfer coeff BC can be created like so
Call SetBC( RightWall, Temp, BCFlux , h*(tp - T_inf ) )
Heat transfer BC
See Also
CreateBC, SetBCLin
48 / 83
Created with the Personal Edition of HelpNDoc: Easily create Help documents
SetBCLin
Purpose
Set a linearized boundary condition for field phi using an arbitrary equation.
Syntax
Parameters
Return
Values
None
Remarks
This is a special version of the SetBC command for cases when the boundary
condition is a function of the field being solved for. For instance consider a
surface reaction, where the reaction rate depends on species concentration, C:
R = k*C (k is a constant)
When SetBC is used for this BC, the value of R is evaluated for each boundary
face by the CalcCoeffs using the value of C from the previous iteration.
In the early iterations of the model, this can lead to an oscillation between the
reaction rate and the local concentration. Before the first iteration, say C has
been initialized to a high value. R will be high; meaning a lot of species will be
removed from the domain. The solver will then calculate too low a value for C. On
the next iteration, this will lead to then rate being calculated as a small value,
removing too little C, resulting in an over estimation of C. This oscillation can be
minimized with a good initial guess, or by under relaxing C sufficiently. A good
guess is often hard to make and under relaxing can greatly slow convergence. By
linearizing the boundary condition, the local concentration and the reaction rate
stay coupled as the linear solver hones in on a solution. This greatly reduces the
tendency to oscillate.
To linearize a BC, take the expression for the boundary condition and rewrite it in
a linear form like so:
BC = A0 + A1*Phi
Where phi is the field we are solving for and A0 and A1 are constants. For the
reaction example above, this would be
BC = 0 + K*Phi
The A0 expression is the Eq0Str and A1 is the Eq1Str term. BCLim can be used
for both value type and flux type boundary conditions.
BCType. This function only applies to flux type boundary conditions. For this
special function, the BCType must be set to 4 (or use predefined constant BCLin
For Heat transfer coefficient BC's, the boundary can be linearized and
implemented with the flux BC type, as shown in the example below.
49 / 83
Example
DefineVariable(T_inf, 273)
DefineVariable(h, 2.1)
A Heat transfer coeff BC can be created like so
Call SetBCLin( RightWall, Temp, BCLin, -h*T_inf, h)
Same as h*(tp t_inf)
Surface reaction
Call DefineVariable("rate1", "k1 * C_Sp * M_Sp ")
'rate
SiH4 leaves in kg/m^2-s
Call SetBCLin(holewall, sp, BCLin, "0", "-rate1/sp")
See Also
CreateBC, SetBC
50 / 83
Created with the Personal Edition of HelpNDoc: Produce Kindle eBooks easily
SetBCn
Purpose
Syntax
Parameters
Return
Values
None
Remarks
Example
Call CreateBCn(wall, Temp, BCVal, 273) Temp on wall in kelvin
Call CreateBCn(heater, Temp, BCFlux, 12000) Heat flux from wall in W/m^2
See Also
CreateBC, SetBC
51 / 83
Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor
SetBlackBackground
Purpose
Syntax
Parameters
Return
Values
none
Remarks
By default, plots made by BFlow have a white background, with black lettering.
Sometimes it is more appealing to have a black background with white lettering.
This command lets you toggle between these states.
Example
See Also
52 / 83
Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source
SetCP
Purpose
Syntax
Parameters
Return Values
none
Remarks
Example
See Also
53 / 83
Created with the Personal Edition of HelpNDoc: Full-featured multi-format Help generator
SetDensity
Purpose
Syntax
Parameters
Return Values
none
Remarks
Example
See Also
54 / 83
Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation
SetDensityN
Purpose
Syntax
Parameters
Return Values
none
Remarks
Example
See Also
55 / 83
SetDiffCoeff
Purpose
Syntax
Parameters
Return Values
None
Remarks
All transport equations (except continuity) need a diffusion coefficient specified, but it
doesn't always go by that name. For the velocity terms, this command sets the
viscosity (diffusion of momentum) and for energy it sets the thermal conductivity
(diffusion of heat).
BFlow supports anisotropic diffusion. This is achieved by specifying different diffusion
expressions in the x and y directions. For isotropic materials, use the same equation
for both directions.
To specify a constant diffusion coefficient, it is more convenient to use SetDiffCoeffN
Example
See Also
56 / 83
Created with the Personal Edition of HelpNDoc: Free iPhone documentation generator
SetDiffCoeffN
Purpose
Syntax
Parameters
Return
Values
None
Remarks
Example
See Also
57 / 83
Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation
SetMirror
Purpose
Syntax
Call SetMirror(Axis)
Parameters
Return
Values
None
Remarks
For models with a symmetry plane, it is handy to create plots that mirror across
that symmetry plane.
Example
See Also
58 / 83
Created with the Personal Edition of HelpNDoc: Write EPub books for the iPad
SetOpPress
Purpose
Syntax
Call SetOpPress(EqString)
Parameters
Return
Values
None
Remarks
Example
See Also
SetCp, CreateMaterial
59 / 83
Created with the Personal Edition of HelpNDoc: Free help authoring tool
SetOpPressN
Purpose
Syntax
Call SetOpPressN(val)
Parameters
Return Values
None
Remarks
Example
See Also
60 / 83
SetPorousSolidCp
Purpose
Syntax
Parameters
Return
Values
None
Remarks
This function is only needed when solving models with porous materials.
Example
porous = CreateMaterial()
Call SetPorousSolidCp (porous, 1000 + 0.01*Tp) Temperature dependent
See Also
61 / 83
Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle
SetPorousSolidDensity
Purpose
Syntax
SetPorousSolidDensity(MatID, EqString)
Parameters
Return
Values
None
Remarks
This function is only needed when solving models with porous materials. The
density should be in kg/m^3
Example
porous = CreateMaterial()
Call SetPorousSolidDensity (porous, 2200) kg/m^3
See Also
62 / 83
Created with the Personal Edition of HelpNDoc: Easily create CHM Help documents
SetPorousSolidThCond
Purpose
Syntax
Parameters
Return
Values
None
Remarks
This function is only needed when solving models with porous materials. The
thermal conductivity should be in W/m-K
Example
porous = CreateMaterial()
Call SetPorousSolidDensity (porous, 15 + 0.01*Tp)
See Also
63 / 83
Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor
SetPorousVoidFraction
Purpose
Syntax
Parameters
Return
Values
None
Remarks
This function is only needed when solving models with porous materials. The void
fraction is the ratio of the fluid volume to total volume in a material. This number
must be in the range of 0 to 1. The default value for void fraction is 1 (100% fluid).
The void fraction must be set to something less than 1 in order for BFlow to
recognize the material as a porous one.
Example
porous = CreateMaterial()
Call SetPorousVoidFraction (porous, x/xmax) porosity varies with position
See Also
64 / 83
SetRange
Purpose
Syntax
Parameters
Return
Values
None
Remarks
By default, BFlow will find the entire range of values for a contour or vector plot
and use those to set the min and max range. To look at a narrower range, use
the SetRange command. To return to the default, specify 0 for the min and max.
Example
See Also
65 / 83
Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation
SetSolid
Purpose
Syntax
Call SetSolid(PolyID)
Parameters
Return
Values
None
Remarks
BFlow assumes all regions of the domain are fluid by default. If you would like to
solve for flow in only a portion of the domain, you can set the other portion to
solid. This can be handy for solving conjugate heat transfer problems
Example
Call SetSolid(HeatSink)
See Also
CreateMaterial, CreatePoly
66 / 83
Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation
SetSource
Purpose
Set the source terms for a region of the model using an arbitrary expression
Syntax
Call SetSource(SourceNum,PhiNum,EqString)
Parameters
Return
Values
None
Remarks
A source term adds or removes materials in the cells in which it is active. For
instance, a heat source term adds heat. Any expression can be used as a
source. It will be evaluated when CalcCoeffs is called, and will be a constant
when the linear solver is running. If the source depends on Phi, better
convergence can be achieved by linearizing the source term (see SetSourceLin).
This enables the source to vary linearly with Phi as the linear solver runs.
Example
See Also
CreateSource, SetSourceLin
67 / 83
Created with the Personal Edition of HelpNDoc: Produce electronic books easily
SetSourceLin
Purpose
Set the source terms for a region of the model using arbitrary expressions
Syntax
Parameters
Return
Values
None
Remarks
A source term adds or removes materials in the cells in which it is active. For
instance, a heat source term adds heat. Mathematically these sources can be of
any form, in principle. In practice, complex source terms can cause numerical
instability. For that reason BFlow requires source terms to be either a constant
or linearized. A linearized source is written in the form
S = S0 + S1*Phi.
SetSourceLin is used to assign equations for the S0 and S1 terms of this
expression.
Example
Call SetSourceLin(1,temp,12000,0)
See Also
CreateSource, SetSource
units: W/m^3
68 / 83
Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation
SetSourceN
Purpose
Set the source term for a region of the model using a simple linear relationship
Syntax
Parameters
Return
Values
None
Remarks
For numerical stability any source term must first be linearized by the user to the
form
S = S0 + S1*Phi. See Patankar for a discussion of this. SeteSourceN is used to
assign values for the S0 and S1 terms of this expression.
Example
Call SetSourceN(1,temp,12000,0)
See Also
CreateSource, SetSource
69 / 83
Created with the Personal Edition of HelpNDoc: Free PDF documentation generator
SetTimeStep
Purpose
For transient models this routine will set the size of the time step in seconds.
Syntax
Call SetTimeStep(TimeStep)
Parameters
Return
Values
none
Remarks
Default is 0. By setting a non-zero value, you tell BFlow this is a transient model.
The other function needed for transient models is IncrementTimeStep
Negative values are not permitted.
Example
Call SetTimeStep(delt)
For i = 1 To 120
'loop over time steps
Call CalcCoeffs(temp)
Call RunSolver (temp, 50, resid, SOR)
Call IncrementTimeStep
'Update old values
'Write out temp at several locations
Cells(25 + i, 3).Value = ValAtPt (Dia / 2, Thick/2,
tp-273)
Cells(25 + i, 4).Value = ValAtPt (Dia / 4, Thick/4,
tp-273)
Next i
See Also
IncrementTimeStep, GetTime
70 / 83
Created with the Personal Edition of HelpNDoc: Free help authoring environment
SetTitle
Purpose
Syntax
Call SetTitle(TitleStr)
Parameters
Return
Values
none
Remarks
To improve the clarity of output plots, a one line title can be added. Titles are
limited to about 70 characters.
Example
See Also
71 / 83
Created with the Personal Edition of HelpNDoc: Easily create EPub books
SetTol
Purpose
Syntax
Parameters
Return
Values
none
Remarks
Example
Call SetTol(LeftWall,0.0005)
See Also
AdaptCellsIf, CreateQuadMesh
72 / 83
Created with the Personal Edition of HelpNDoc: Free Web Help generator
SetUnderRelax
Purpose
Syntax
Parameters
Return
Values
none
Remarks
0.2
0.8
0.8
1.0
Call SetUnderRelax(temp, 0.5) set under relaxation to 0.5 for temperature field
See Also
RunSolver
73 / 83
Created with the Personal Edition of HelpNDoc: Free EPub and documentation generator
SetVectorScaling
Purpose
Syntax
Call SetVectorScaling(theScale)
Parameters
Return
Values
none
Remarks
This command is for improving the appearance of vector plots. The default scaling
for vector plots makes the arrows roughly the length of a cell. The command
Call SetVectorScaling(2.5)
Will make the arrows roughly 2.5 times longer than a cell. To return to the
default, specify a scale factor of 1.0
Example
See Also
74 / 83
Created with the Personal Edition of HelpNDoc: Free help authoring environment
SetVectorSkip
Purpose
Syntax
Call SetVectorSkip(skip)
Parameters
Return
Values
None
Remarks
By default, an arrow is drawn in each cell of the computational domain. For fine
meshes this can lead to a cluttered plot. To avoid that, this command can be
used to avoid drawing vectors in some cells. For instance,
Call SetVectorSkip(2)
Will skip two cells, drawing an arrow in every third cell. To reset to the default,
specify a skip value of 0.
Example
See Also
75 / 83
Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation
SetView
Purpose
Syntax
Parameters
Return
Values
none
Remarks
By default, bFlow scales an image so the entire domain fits inside the plotting
window. SetView allows you to zoom into a region
SetView is sticky. Once you set up a view, it will remain until you set it again.
In this way you can make several different plots of the same view (e.g., a vector
plot, contour plot). To return to the default view, enter zero for the parameters:
Call SetView(0,0,0) return to default view
To use the default scaling, but offset the image, set delx to 0. The length units
used in SetView are the same used to create the model. Typically meters.
Example
Call SetView(0.3, 0.5, 2.6) New draw window will go from (0.3, 0.5) to (2.9, 3.1)
See Also
76 / 83
Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation
StartPoly
Purpose
Creates the first point in a polygon, and specifies the polygon material and source
Syntax
Parameters
Return
Values
none
Remarks
Example
See Also
Define Geometry
CALL StartPoly(Poly1, 0,
CALL AddPt2Poly(Poly1,
CALL AddPt2Poly(Poly1,
CALL AddPt2Poly(Poly1,
CALL AddPt2Poly(Poly1,
0, prop1, source1)
10, 0, bc1) 'bottom
10, 10, bc2) 'right side
0, 10, bc3) 'top
0, 0, bc4) 'left side
CreatePoly, AddPt2Poly
77 / 83
Created with the Personal Edition of HelpNDoc: Free EPub and documentation generator
UpdatePhi
Purpose
Syntax
Parameters
Return
Values
none
Remarks
In addition to the fields solved for by the solver, sometimes we need additional
fields, for instance to store a gradient, or for customized output. Often the
InitializePhi command can be used for this latter application. However, you may
have a field that is computed each iteration and is used in solving for the field
variables. Perhaps a custom density function. For numerical stability, it may be
desirable to under relax this field. This can be done with UpdatePhi. If effectively
executes the following:
For I = 1 to Numcells
PhiID = (1-omega)*PhiID_old + omega*EqStr
Next I
Where omega is the under relaxation factor for field PhiID.
Example
See Also
InitializePhi, SetUnderRelax
78 / 83
ValAtPt
Purpose
Syntax
Ans = ValAtPt(PhiID,x,y)
Parameters
Return
Values
Remarks
BFlow stores field values for each variable at the cell centers. A linear
interpolation is performed between the nearest cell neighbors to determine the
field value at the desired point. These values are then used to evaluate the
equation. If x,y lies outside the domain, zero is returned.
This function can be called in a For-Next loop to generate points for an scatter
plot in Excel.
Example
See Also
CreateContourBMP
Created with the Personal Edition of HelpNDoc: Generate EPub eBooks with ease
79 / 83
Description
Standard math operations
Square root
Maximum and minimum values
Trig functions
Natural logarithm, common log and exponential
Absolute value
If x>0 return 1, else return 0
If test true return x, else y
Conditional tests. Greater than, greater than or equal, equal, etc
Logical operators, for use with IF
Uses linear interpolation on a table of x,y values to return y.
List of Variables
The table below lists the built-in variables that can be included in expressions.
x
y
r
z
t
den
p
op
uv
vv
tp
uds
x position
y position
r position (axi probs)
z position (axi probs)
time
density
pressure
operating pressure
u-velocity
v-velocity
temperature
User defined scalars
These variables are not case sensitive. DEN is the same as den.
In incompressible flow problems, the operating pressure is a value specified by the user. The actual
pressure varies only slightly from this value. The user also has access to any user defined scalars using
the name specified during creation. See CreateScalarField, above.
Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source
80 / 83
where Yi and Mi are the mass fraction and molecular weight of species i, respectively. The fourth line above
captures this relationship for our two-gas mixture of silane and hydrogen. (We are only modeling silane
mass fraction and saying the H2 mass fraction is 1 SiH4.) Once the average molecular weight is
determined, the density can be determined from the ideal gas law
Viscosity (N/m-s)
2.31E-5
2.59E-5
2.86E-5
3.12E-5
3.37E-5
3.61E-5
You could attempt to fit a polynomial to this data set, but the fit may be poor. Or it may just be easier to
use the data directly. To create this table, we first create a table object, and then enter the data, one point
at a time:
VisTable = CreateLookUpTable(VisTable)
Call AddPt2Table(VisTable, 300, 2.31E-5)
Call AddPt2Table(VisTable, 350, 2.59E-5)
Call AddPt2Table(VisTable, 400, 2.86E-5)
Call AddPt2Table(VisTable, 450, 3.12E-5)
Call AddPt2Table(VisTable, 500, 3.37E-5)
Call AddPt2Table(VisTable, 550, 3.61E-5)
Here we entered the data in ascending order, but they could be entered in any order (BFlow sorts the table
81 / 83
internally). Once the data are entered, we can use the function LookUpTable in any algebraic expression.
For instance
Call SetDiffCoeff(MyGas, uv, LookUpTable(VisTable ,tp) )
When creating the table, we must specify a TableID variable (VisTable above) in two places. The first
VisTable is a long integer used to identify the table when we are adding points to it. During table creation,
BFlow internally defines a variable (VisTable) with this same ID number. This enables the equation parser
to find the correct table when evaluating an expression as above.
What if the temperature tp is outside the range of the table? LookUpTable will use linear extrapolation of the
nearest two points to estimate the value to return. This can be a problem in the early stages of a simulation
where there can be large excursions in field values. The potential for runaway extrapolations can be limited
by adding two more points to the table:
Call AddPt2Table(VisTable, 250, 2.31E-5)
Call AddPt2Table(VisTable, 600, 3.61E-5)
Because the viscosity at 250K is the same as 300K, the extrapolation will yield a constant value of 2.31E-5.
Similarly at the upper end. This will avoid any possible runaway.
Currently BFlow allows the user to define an unlimited number of tables with up to 50 data points each.
Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation
Using If
The IF function in the expression parser is a bit different than the normal IF-THEN-ELSE statement in
programming languages. Instead, it works like the IF function in Excel. It takes three arguments, with the
first being a test. If the test evaluates to true, then the second argument is returned, otherwise the third
argument is returned. Here is an example
DefineVariable(Visc, If(tp<273, 1e-10, 2e-5) )
This example effectively defines two temperature zones for the viscosity. When the temperature is less than
273, the viscosity is set to 1e-10; at higher temperatures its set to 2e-5. You could also use IF to access
two different tables, that spanned different ranges by combining IF with LookupTable:
DefineVariable(Visc, If(tp<273, LookUpTable(LowTable, tp), LookUpTable(HiTable, tp),) )
Some very complex expressions can be developed in this way. In addition, nested IF statements are
allowed. For instance
DefineVariable(Visc, If(tp<273, If (SiH4<0.1, 1e-5, 2e-5), 5e-5) )
Created with the Personal Edition of HelpNDoc: Easy to use tool to create HTML Help files and Help web sites
82 / 83
1. Substitute in all user variables. If MyConst had been defined as 5.5 (using DefineVariable), then the
equation would be rewritten as
2.1*tp + 5.5.
This process is done recursively until all variables have been substituted. Note that if a user variable is
redefined after this command has run, BFlow is unaware of it, since all the substitutions were done with the
values in existence at the time the command was executed.
2. Convert the expression into Reverse Polish Notation. RPN is a mathematical notation familiar to users of
Hewlett Packard calculators. It is a postfix notation in which the mathematical operators appear after the
numbers to be operated on. For instance, 2 + 3 is written as 2 3 + in RPN notation. The advantage of this
notation is it is very easy for a computer to process using a stack. The computer processes the elements
one by one. If an element is a number, it pushes it onto the stack. If it's an operator, it takes numbers off
the stack and applies the operator. Our expression for conductivity then becomes
2.1 tp * 5.5 +
3. Tokenize the expression. BFlow converts the RPN expression into an internal representation that is
easier to process. This representation is stored as an array of tokens.
These steps have prepared the equation for evaluation, but they don't involve any actual evaluation. They
simply convert the expression into a form that can be quickly evaluated. By doing these steps up front, we
can save considerable amounts of time. The thermal conductivity must be evaluated at each cell in the
domain. It would be inefficient to do these preparatory steps over and over for each cell.
Later, when the CalcCoeffs(temp) command is run, the thermal conductivity will be calculated at each cell
center. Bflow does the following steps:
1. For the x,y position of interest, load in the built in variables. The position, time, density, pressure, etc are
loaded into an array.
2. Evaluate the expression. The tokenized equation is evaluated using the values of the built in variables. A
result is returned.
Created with the Personal Edition of HelpNDoc: Free EBook and documentation generator
83 / 83