Anda di halaman 1dari 83

BFlow Command

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

Tips for Boundary Conditions


In a flow model, we are solving for three fields: the pressure and the x and y components of the fluid velocity.
On each boundary, boundary conditions must be specified for these three fields. This must be done
carefully to ensure the problem is not over-determined or under-determined. Let's say we want to model flow
in a pipe, as shown below. On each of the four exterior boundaries we need to say something about three
fields. Specifically we either need to know the value of the field at that location or know the flux at that
location.

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)

inlet pressure set to 10Pa

Exit velocity specified

Created with the Personal Edition of HelpNDoc: Full-featured Kindle eBooks generator

8 / 83

Brief Description of Commands


Below is an alphabetical list of the commands, along with a brief description. This can be used to quickly
skim the available options.

Command

Comment

AdaptCellsIf(EqStr)

Refines cells based on EqStr condition

AddPt2Poly(PolyNum, x, y, bc)

Adds a point to polygon PolyNum

AddPt2Table(FuncID , xval, yval)

Adds a point to a data table

BFlowVersion()

Returns version number as long

CalcCoeffs(phinum)

Calculate the A,B coeffs of the CFD prob

CalcGrad(PhiNum, Gradx, Grady)

Calculates gradient of field PhiNum. Results stored in Gradx,


Grady

Circle2Poly(PolyNum, x0, y0,


radius, BCNum, MatNum,
SourceNum, NumSegs)

Creates a circular polygon centered at (x0,y0) with radius


Radius.

CreateBC()

Returns ID for new boundary condition

CreateBlockContourBMP (file,
EqString)

Create a blocky contour plot bit map and save to file.

CreateContourBMP (file, EqString) Create a contour plot bit map and save to file.
CreateGeoBMP(file)

Create a bit map of the problem geometry. Save to file

CreateGridBMP(file)

Create a bit map of the mesh

CreateLookupTable(TableID)

Creates a new data lookup table and returns ID

CreateMaterial()

Creates a new material and returns ID

CreatePathlinesBMP(filename, BCID, Create a pathline plot


NumPaths, time)

CreatePoly()

Creates a new polygon and returns ID

CreateQuadMesh(delx, dely)

Mesh the geometry of the prob with quads

CreateScalarField (FieldName)

Creates a new scalar field, and returns ID

CreateSource()

Creates new source term

CreateVectorBMP(file, Func1,
Func2)

Create a vector plot and save at bit map.

DefineVariable(VarName, EqString) Defines an eq string that can be used in other equations.


FixVectorLength(IsFixed)

Specifies that vector plots have fixed length arrow

GetCellCount()

Returns number of cells in domain

GetTime()

Get the current time of a transient simulation

IncrementTimeStep()

Saves Phi vals to OldPhi

InitializeBFlow()

Initializes the BFlow library.

InitializePhi(phinum,EqString)

Initializes the field phi using the equation EqString

InitializePhiN(phi,aval)

Initializes the field phi using the const aVal

InletDiffusionOn(PhiNum, bool)

Turn inlet diffusion on or off

LimitPhi(PhiNum, MinVal, MaxVal) Limit field phi to between minval and maxval

9 / 83

OverlayGeo(TrueOrFalse)

Overlays the geometry onto a plot

OverlayGrid(TrueOrFalse)

Overlays the computational grid onto a plot

RunSolver(phi,its,resid, SolverNum) Runs the solver a certain number of iterations for field phi.
Returns resid. Uses current solver
SetAxi(Axistate)

Set coor system: 0 = rect, 1 = AxiX, 2 = AxiY

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)

Sets a boundary condition for phi using constant val. BCType =


1 for value, 2 for flux.

SetBlackBackground (TrueOrFalse)

Should the background for plots be black or white?

SetCP(MatNum,EqString)

Set the Cp of a material using eqstring

SetCPN(MatNum,val)

Set the Cp of a material to a fixed value

SetDensity(MatNum,EqString)

Set the Density of a material using eqstring

SetDensityN(MatNum,val)

Set the Density of a material to a fixed value

SetDiffCoeff(MatNum, PhiNum,
xEqString,yEqString)

User can optionally have a second function for anisotropic


probs.

SetDiffCoeffN(MatNum, PhiNum,
aVal)

Set the diffustion coeff for field phi to a constant

SetMirror(Axis)

Mirrors a plot across x or y axis

SetOpPress(EqString)

Set the Operating press of problem using eqstring

SetOpPressN(val)

Set the Operating press of prob to a fixed value

SetPorousSolidCp(MatID, Eq)

Set specific heat of solid portion of porous media

SetPorousSolidDensity(MatID, Eq) Set density of solid portion of porous media


SetPorousSolidThCond(MatID, Eq) Set thermal conduction of solid portion of porous media
SetPorousVoidFraction(MatID, Eq) Set void fraction of porous media
SetRange(MinVal, MaxVal)

Set the range of contour or vector plot

SetSolid(MatNum)

Defines a polygon as solid, so flow isn't solved

SetSource
(SourceNum,PhiNum,EqString)

Set a Source terms with Eqstring

SetSource
(SourceNum,PhiNum,S0EqString,
S1EqString)

Set the linearized Source terms with Eqstrings

SetSourceN
(SourceNum,PhiNum,S0Val,
S1Val)

Set the linearized Source terms to constant vals

SetTimeStep (TimeStep)

Sets time step in seconds

SetTitle(TitleStr)

Set title string for plots

SetTol(BCID, tolerance)

Sets max difference between polygon and mesh

SetUnderRelax(phinum,val)

Sets under relaxation value for phi, from 0 to 1

SetVectorScaling(theScale)

For adjusting the length of arrows in vector plots

SetVectorSkip(skip)

Sets frequency of arrows in vector plots

SetView(X0, Y0, delx)

Used to zoom into a portion of a plot

StartPoly(PolyNum, x0, y0,

Specifies the first point in a polygon

10 / 83

MatNum, sourcenum)
ValAtPt(x,y,EqString)

Returns the value of eqstring at pt (x,y)

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

Splits all cells that meet the adaption criteria in EqStr

Syntax

Call AdaptCellsIf (EqStr As string)

Parameters

EqStr Conditional expression for cell adaption (string)

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

Split cells based on geoor temperature


CALL AdaptCellsIf (x>3 and y<7.2) 'left side
CALL AdaptCellsIf (tp>100)
Adapt based on gradient of voltage
CalcGrad(V, grad1, grad2)
CALL AdaptCellsIf (grad1 > 3.2e3)

See Also

CreateQuadMesh, SetTol

12 / 83

Created with the Personal Edition of HelpNDoc: Free iPhone documentation generator

AddPt2Poly
Purpose

Helps create a polygon by adding a point to current point list

Syntax

Call AddPt2Poly (PolyNum As Long, x As Double, y As Double, bc As Long)

Parameters

PolyNum ID number of the polygon being modified


x,y Location of the point to be added
bc ID number of the boundary condition for the segment ending at x,y.

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

Adds a single x, y data point to a data table

Syntax

Call AddPt2Table (FuncID, xval, yval)

Parameters

FuncID ID number of the Table being modified


xval x value of the data point being added
yval y value of the data point being added

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

Define Table and add some points


TempDataID = CreateLookupTable(TempDataID)
CALL AddPt2Table(TempDataID, 0, 0) 'add 1st point
CALL AddPt2Table(TempDataID, 1, 7.6) 'add 2nd point
CALL AddPt2Table(TempDataID, 2, 8.9) 'add 3rd point
CALL AddPt2Table(TempDataID, 2.5, 10.6) 'add 4th point
Call SetBC(BCNum, PhiNum, BCVal, LookupTable(TempDataID,x)) Set BC
using data

See Also

CreateLookupTable, ClearLookupTable

14 / 83

Created with the Personal Edition of HelpNDoc: Easy EBook and documentation generator

BFlowVersion
Purpose

Returns the version number of the Bflow.dll

Syntax

Result = BflowVersion()

Parameters

none

Return
Values

A long integer indicating the version number

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

Make sure version is current


If BflowVersion<100 then Msgbox Warning: you are using an old version.

See Also

15 / 83

Created with the Personal Edition of HelpNDoc: Free Web Help generator

CalcCoeffs
Purpose

Calculates the A and B or linkage coeffs

Syntax

Call CalcCoeffs(PhiID as long)

Parameters

PhiID The ID number of desired field

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

Calculates the gradient of a field

Syntax

Call CalcGrad(PhiID as long, Gradx as long, Grady as long)

Parameters

PhiID The ID number of desired field


Gradx The x component of the gradient is stored in this scalar field
Grady The x component of the gradient is stored in this scalar field

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

Create a vector plot of diffusive heat flux


dTdx = CreateScalarField(dTdx) Create two new scalar fields
dTdy = CreateScalarField(dTdy)
Call CalcGrad(Temp, dTdx, dTdy)
Call CreateVectorBMP(Vector.bmp, 0, 0, 0, -k*dTdx, -k*dTdy)

See Also

CreateScalarField, CopyDiffCoeffs

17 / 83

Created with the Personal Edition of HelpNDoc: Full-featured Documentation generator

Circle2Poly
Purpose

Creates a circular shaped polygon

Syntax

Call Circle2Poly(PolyID as long, X0 as double, Y0 as double, radius as double,


MatID as long, SourceID as long, NumSegs as long)

Parameters

PolyID The ID number of desired field


X0 The x component of the circle origin
Y0 The x component of the circle origin
Radius radius of circle
MatID ID number of the material property of the circle
SourceID ID number of the source term for circle
NumSegs Number of polygon segments in circle (max = 50)

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

Call Circle2Poly(MyPoly, 0,0, 4, Mat1, NoSource, 20)

See Also

CreatePoly, StartPoly, AddPt2Poly

18 / 83

Created with the Personal Edition of HelpNDoc: Produce Kindle eBooks easily

ClearLookupTable
Purpose

Clears data from a previously created Lookup table

Syntax

Call ClearLookupTable (TableID)

Parameters

TableID The ID number of table to be cleared

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

Copies diffusion coefficients to two scalar fields

Syntax

Call CopyDiffCoeffs (PhiID, ToPhi1, ToPhi2)

Parameters

PhiID The ID number of variable being solved for


ToPhi1 Field where x component of diffusion will be written
ToPhi2 Field where y component of diffusion will be written

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

Call CopyDiffCoeffs (temp, k1, k2)


Call CalcGrad(Temp, dTdx, dTdy)
Call CreateVectorBMP(Vector.bmp, 0, 0, 0, -k1*dTdx, k2*dTdy)

See Also

CalcGrad

20 / 83

Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor

CreateBC
Purpose

Creates a boundary condition object

Syntax

EastWall = CreateBC()

Parameters

none

Return
Values

ID number of the new BC (long integer)

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

LeftWall = CreateBC() Create the boundary condition


Call SetBC(LeftWall,Temp, BCVal, 273) Set the temperature of this BC

See Also

SetBC, SetBCLin

21 / 83

Created with the Personal Edition of HelpNDoc: Full-featured EPub generator

CreateBlockContourBMP
Purpose

To create a bitmap file of a blocky contour plot

Syntax

Call CreateBlockContourBMP (file, EqString)

Parameters

File A string containing the file name to be written to, string


EqString Equation to be plotted, string

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

Call CreateBlockContourBMP (contour.bmp,tp - 273) plot of temp in C

See Also

SetTitle, OverlayGrid, OverlayGeo, CreateVectorBMP, CreateGeoBMP, SetView,


SetRange

22 / 83

Created with the Personal Edition of HelpNDoc: Free Kindle producer

CreateContourBMP
Purpose

To create a bitmap file of a contour plot

Syntax

Call CreateContourBMP (file, EqString)

Parameters

File A string containing the file name to be written to, string


EqString Equation to be plotted, string

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

Call CreateContourBMP (contour.bmp,tp - 273) plot of temp in C

See Also

SetTitle, OverlayGrid, OverlayGeo, CreateVectorBMP, CreateGeoBMP, SetView,


SetRange, ValAtPt

23 / 83

Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source

CreateGeoBMP
Purpose

To create a bit map of the model geometry and save it to a file

Syntax

Call CreateGeoBMP(file)

Parameters

File A string containing the file name to be written to, string

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

Call CreateGeoBMP (geo.bmp)

See Also

CreateVectorBMP, CreateContourBMP, CreateGridBMP, SetView

24 / 83

Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation

CreateGridBMP
Purpose

To create a bit map of the model mesh and save it to a file

Syntax

Call CreateGridBMP(file)

Parameters

File A string containing the file name to be written to, string

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

Call CreateGridBMP (grid.bmp)

See Also

CreateVectorBMP, CreateContourBMP, CreateGeoBMP, SetView

25 / 83

Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator

CreateLookupTable
Purpose

To create a table of x, y data values

Syntax

TableID = CreateLookupTable(TableID as string)

Parameters

TableID a string that identifies the table to the equation parser

Return
Values

A long integer that is the ID number for the Table created

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

TempDataID = CreateLookupTable (TempDataID)

See Also

AddPt2Table, ClearLookupTable

26 / 83

Created with the Personal Edition of HelpNDoc: Produce electronic books easily

CreateMaterial
Purpose

To create a material property object

Syntax

theFluid = CreateMaterial()

Parameters

none

Return
Values

ID number of the new material (long integer)

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

Al3003 = CreateMaterial() Create a material


Call SetDiffCoeff(Al3003, temp, 230) set thermal conductivity

See Also

SetDiffCoeff, SetCp, SetDensity

27 / 83

Created with the Personal Edition of HelpNDoc: Free PDF documentation generator

CreatePathlinesBMP
Purpose

To create a pathline plot and save it

Syntax

Call CreatePathlinesBMP(filename as string, BCID as long, NumPaths as long,


time as double)

Parameters

Filename A string containing the file name to be written to, string


BCID ID of the boundary from which the pathlines begin
NumPaths Number of pathlines, long integer
Time Time duration for pathlines in seconds, double

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

Call CreatePathlinesBMP (path.bmp, Inlet, 20, 10)

See Also

CreateVectorBMP, CreateContourBMP, CreateGeoBMP, SetView

28 / 83

Created with the Personal Edition of HelpNDoc: Free Web Help generator

CreatePoly
Purpose

To create a polygon object

Syntax

PolyID = CreatePoly()

Parameters

none

Return
Values

ID number of the new polygon (long integer)

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

StartPoly, AddPt2Poly, Circle2Poly

29 / 83

Created with the Personal Edition of HelpNDoc: Full-featured EBook editor

CreateQuadMesh
Purpose

This subroutine creates a rectangular grid of specified size and density

Syntax

Call CreateQuadMesh(delx As Double, delY As Double)

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

SetTol, AdaptCellsIf, GetCellCount

30 / 83

Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source

CreateScalarField
Purpose

To create a new scalar field

Syntax

FieldID = CreateScalarField(FieldName as string)

Parameters

FieldName This is the name you use to refer to the field in algebraic expressions.

Return Value

ID number of the new field, as long integer

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

CreateMaterial, CreateBC, CreateSource, InitializePhi, InletDiffusionOn

31 / 83

Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source

CreateSource
Purpose

To create a new source term

Syntax

SourceID = CreateSource()

Parameters

none

Return Value

ID number of the new source, as long integer

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

set the source

SetSource, SetSourceLin, CreateMaterial, CreateBC, CreateScalarField

32 / 83

Created with the Personal Edition of HelpNDoc: Produce electronic books easily

CreateVectorBMP
Purpose

To create a bitmap file of a vector plot

Syntax

Result = CreateVectorBMP (file, EqStr1, EqStr2)

Parameters

File A string containing the file name to be written to


EqStr1 An equation for the x component of the vector, string
EqStr2 An equation for the y component of the vector, string

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

CreateVectorBMP (Vector.bmp, uv, vv) vector plot of velocity

See Also

CreateContourBMP, CreateGeoBMP, SetView, SetRange, SetVectorScaling,


FixVectorLength, ValAtPt

33 / 83

Created with the Personal Edition of HelpNDoc: iPhone web sites made easy

DefineVariable
Purpose

Defines an expression string that can be used in other equations

Syntax

Call DefineVariable(VarName, EqString)

Parameters

VarName the name of the variable, string


EqString The equation to be associated with the variable name, string

Return
Values

none

Remarks

DefineVariable is a simple substitution utility, like Macros in C. Macros allow


complex functions to be simplified to improve readability. For instance, a long
equation can be broken up into individual parts and a macro defined for each.
When BFlow evaluates a equation, it will see if it contains any variable definitions
and if so, substitute the equation in place of the variable name.
Warning. Variable name substitutions are made when equations are defined.
This can cause unexpected results if you redefine the variable later. Consider this
example:
Call DefineVariable(hot, 1000)
SetBC(wall, temp, BCVal, hot)

Call DefineVariable(hot, 1300)


When SetBC was called, the value of Hot at that time (1000) was written to the
boundary condition object. Later this changed, but SetBC is unaware of it, unless
you call SetBC again.

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

AddPt2Table, ClearLookupTable, CreateLookupTable

34 / 83

Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator

FixVectorLength
Purpose

Makes all arrows in a vector plot the same length

Syntax

Call FixVectorLength(IsFixed as long)

Parameters

IsFixed If 1, then used fixed length, if 0, use variable length

Return
Values

none

Remarks

By default, the length of an arrow in a vector plot is proportional to the magnitude


of the quantity being plotted. When the magnitude varies over a large range, this
can lead to some arrows being nothing more than dots. In that case, it can be
useful to fix the arrow length to a constant value for all arrows in the plot. This is
done by setting IsFixed to a non-zero value.

Example

Create a plot with fixed arrows, then one with variable


arrows.
Call FixVectorLength(1)
Call CreateVectorBMP(vect1.bmp, uv, vv)
Call FixVectorLength(0)
Call CreateVectorBMP(vect2.bmp, uv, vv))

See Also

CreateVectorBMP, CreateContourBMP, CreateGeoBMP, SetView

35 / 83

Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator

GetCellCount
Purpose

Returns the number of cells in the computational domain

Syntax

TotalCells = GetCellCount()

Parameters

none

Return
Values

Number of cells (long integer)

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

Warn of high cell counts


If GetCellCount() > 10000 then
Msgbox Cell count too high
End if

See Also

CreateQuadMesh

36 / 83

Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle

GetTime
Purpose

To find the current time of a simulation

Syntax

TheTime = GetTime()

Parameters

none

Return
Values

A double real showing the present time of simulation in seconds

Remarks
Example

After 10s, change source and double time step


If GetTime() > 10 then
SetSourceN(source1, temp, S0, S1)
Call SetTimeStep(2*delt))
End if

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

Sets up the BFlow function library before beginning a simulation

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

Created with the Personal Edition of HelpNDoc: Full-featured Documentation generator

InitializePhi
Purpose

To set the initial values of the scalar field phi

Syntax

Call InitializePhi(phinum As Long, EqString As String)

Parameters

PhiNum ID of the field of interest, long


EqString Equation describing the desired values of phi

Return
Values

none

Remarks

The expression EqString can be a function of position to provide a good guess of


the field. This function can also be used in conjuction with CreateScalarField to
create a scalar field and set its value to some function for plotting. To initialize to
a constant value, see InitializePhiN

Example

Call InitializePhi(temp, x^2 + y^2 set temp field to x^2 + y^2

See Also

LimitPhi, UpdatePhi, CreateScalarField

40 / 83

Created with the Personal Edition of HelpNDoc: Easily create EPub books

InitializePhiN
Purpose

To set the initial values of the field phi to a constant

Syntax

Call InitializePhiN(phinum, value)

Parameters

PhiNum ID of the field of interest, long


Value the desired initial value for field, double

Return
Values

none

Remarks

To initialize to a general function, see InitializePhi

Example

Call InitializePhiN(temp, 273)

See Also

41 / 83

Created with the Personal Edition of HelpNDoc: Easily create Web Help sites

InletDiffusionOn
Purpose

To toggle inlet diffusion on or off

Syntax

Call InletDiffusionOn(PhiID as long, Bool as long)

Parameters

PhiID ID of the field of interest, long


Bool If > 0 then inlet diffusion is turned on. 0 = off

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

Call InletDiffusionOn(SiH4, 0) Turns off inlet diffusion for species SiH4.

See Also

CreateScalarField

42 / 83

Created with the Personal Edition of HelpNDoc: Easy EBook and documentation generator

LimitPhi
Purpose

Limits the range of possible solutions for a field variable

Syntax

Call LimitPhi(PhiID as long, MinVal as double, MaxVal as double)

Parameters

PhiID ID of the field of interest, long


MinVal minimum allowed value of phi
MaxVal maximum allowed value of phi

Return
Values

none

Remarks

In some very non-linear problems, the field values


instance, the temperature may become negative.
situation in which the model diverges. To prevent
the range can be set with this function. Typically

Example

Call LimitPhi(temp, 1, 1000)

See Also

InitializePhi, UpdatePhi

43 / 83

can become unphysical. For


This can lead to a runaway
this and improve convergence
it is not necessary.

Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source

OverlayGeo
Purpose

Enables overlaying the geometry onto a plot

Syntax

Call OverlayGeo(TrueOrFalse)

Parameters

TrueOrFalse if 0, no overlay, otherwise yes.

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

OverlayGrid, CreateVectorBMP, CreateContourBMP, CreateGeoBMP, SetView

44 / 83

Created with the Personal Edition of HelpNDoc: Easy EBook and documentation generator

OverlayGrid
Purpose

Enables overlaying the computational grid onto a plot

Syntax

Call OverlayGrid(TrueOrFalse)

Parameters

TrueOrFalse if 0, no overlay, otherwise yes.

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

Call OverlayGrid (0)

See Also

OverlayGeo, CreateVectorBMP, CreateContourBMP, CreateGeoBMP, SetView

45 / 83

Created with the Personal Edition of HelpNDoc: Produce Kindle eBooks easily

RunSolver
Purpose

This routine is called to solve the model

Syntax

Call RunSolver(phi, its, resid, Solver)

Parameters

Phi ID number of the field to be solved for, long


Its number of iterations requested of the solver, long
Resid the solver returns this measure of error, double
Solver ID number of the desired solver (SOR = 1)

Return
Values

None

Remarks

BFlow has three solvers: Successive OverRelaxation (SOR), Line Gauss-Siedel


(LGS) and Algebraic MultiGrid (AMG). These correspond to Solver numbers of 1,
2 and 3 respectively. (The solver can also be specified using constants SOR,
LGS and AMG.) The AMG solver doesn't do multiple iterations so the its
parameter is not used. The AMG solver is the most efficient of the three and is
recommended. LGS does not would with adapted meshes.

Example

Call CalcCoeffs(temp)
Call RunSolver (temp, 50, resid, SOR)

See Also

SetUnderRelax, CalcCoeffs

46 / 83

Created with the Personal Edition of HelpNDoc: Full-featured EPub generator

SetAxi
Purpose

Used to specify if a 2d model is cartesian, or axi-symmetric along the x or y


direction

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

This routine only needs to be called for axi-symmetric problems. By default


axistate = 0. If your model has an axis of symmetry and the geometry can be
describe in cylindrical coordinates, then you should call SetAxi. If your axis of
symmetry lines along the x axis, use SetAxi(1); if the axis of symmetry is along
the y axis, use SetAxi(2).

Example

Call SetAxi(1) sets problem to be axi-symmetric along x axis


Call SetAxi(2) sets problem to be axi-symmetric along y axis

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

Call SetBC(BCNum, PhiNum, BCType, EqString)

Parameters

BCNum The ID number of the boundary condition being set, long


PhiNum The ID number of the field, long
BCType For value type = 1, for flux type = 2, long
EqString The equation defining the boundary condition, string

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

Call SetBCLin(BCNum, PhiNum, BCType, Eq0Str, Eq1Str)

Parameters

BCNum The ID number of the boundary condition being set, long


PhiNum The ID number of the field, long
BCType Must be set to 4 for linearized flux
Eq0Str The equation defining the constant portion of boundary condition, string
Eq1Str The equation defining the linear portion of boundary condition, string

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

Set a constant boundary condition for field phi.

Syntax

Call SetBC(BCNum, PhiNum, BCType, Val)

Parameters

BCNum The ID number of the boundary condtion being set, long


PhiNum The ID number of the field, long
BCType For value type = 1, for flux type = 2, long
Val The value to set the BC to, double

Return
Values

None

Remarks

The advantage of SetBCn compared to SetBC is speed. The expression parser


does not need to be called at each boundary face, potentially saving considerable
time.
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 can be 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
For Heat transfer coefficient BC's, the command SetBC should be used.

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

To set the background of plots to black

Syntax

Call SetBlackBackground (TrueOrFalse)

Parameters

TrueOrFalse if 0, use white background, otherwise, black. Long integer

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

Call SetBlackBackground (1) set background to black


Call SetBlackBackground (0) set background to white

See Also

SetTitle, OverlayGrid, OverlayGeo, CreateVectorBMP, CreateContourBMP,


CreateGeoBMP, SetView

52 / 83

Created with the Personal Edition of HelpNDoc: Create HTML Help, DOC, PDF and print manuals from 1 single
source

SetCP
Purpose

To set the specific heat of a material

Syntax

Call SetCP(MatID, EqString)

Parameters

MatID ID number of material that needs Cp, long


EqString equation describing Cp, string

Return Values

none

Remarks

Cp in units of J/kg-K. EqString is an algebraic expression describing the specific heat.


If no value is set, the default is 1000 J/kg-K

Example

Call SetCP(Mat1, 2.11 * tp + 1000 )

See Also

SetDensity, SetDiffCoeff, CreateMaterial

53 / 83

Created with the Personal Edition of HelpNDoc: Full-featured multi-format Help generator

SetDensity
Purpose

To set the density of the fluid

Syntax

Call SetDensity(MatID, EqString)

Parameters

MatID ID number of material that needs density, long


EqString equation describing density, string

Return Values

none

Remarks

The density must be entered in units of kg/m^3. If no density is specified, a value of 1


kg/m 3 is used.

Example

Call SetDensity(Mat2, 10 * x ) density increases with x position

See Also

SetDiffCoeff, CreateMaterial, SetCp

54 / 83

Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation

SetDensityN
Purpose

To set the density of a material to a constant

Syntax

Call SetDensityN(MatID, theDensity)

Parameters

MatID ID number of material that needs density, long


theDensity the constant value for density, in kg/m^3, double

Return Values

none

Remarks

The density must be entered in units of kg/m^3. If no density is specified, a value of 1


is used.

Example

Call SetDensityN(mat2, 10) sets density to 10 kg/m^3

See Also

55 / 83

Created with the Personal Edition of HelpNDoc: Full-featured EBook editor

SetDiffCoeff
Purpose

Set the diffusion coefficient using an arbitrary equation

Syntax

Call SetDiffCoeff(MatID, PhiNum, xEqString, yEqString)

Parameters

MatID ID number of the material being set, long integer


PhiNum ID number of the field, long integer
xEqString equation for the diffusion coefficient in the x direction, string
yEqString - equation for the diffusion coefficient in the y direction, string

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

Call SetDiffCoeff(Mat1, temp, 5.4 * Tp + 89 , 3.7 * Tp + 94 )

See Also

CreateMaterial, SetCp, CreateScalarField

56 / 83

Created with the Personal Edition of HelpNDoc: Free iPhone documentation generator

SetDiffCoeffN
Purpose

Set the diffusion coefficient to a constant value

Syntax

Call SetDiffCoeff(MatID, PhiNum, aVal)

Parameters

MatID ID number of the material being set, long integer


PhiNum ID number of the field, long integer
aVal the value of the diffusion coefficient, double

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).
To specify the diffusion coefficient as an arbitrary function or anisotropic diffusion,
please use SetDiffCoeff

Example

Call SetDiffCoeffN(Mat1, temp, 5.2E-5)

See Also

57 / 83

Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation

SetMirror
Purpose

To mirror an image across the x or y axis in a plot

Syntax

Call SetMirror(Axis)

Parameters

axis 0 = no mirroring, 1 = mirror across x-axis, 2 = mirror across y-axis

Return
Values

None

Remarks

For models with a symmetry plane, it is handy to create plots that mirror across
that symmetry plane.

Example

Call SetMirror(1) Future plots will mirror across the x-axis.


Call SetMirror(0) Return to default (no mirroring)

See Also

SetAxi, CreateVectorBMP, CreateContourBMP, CreateGeoBMP, SetView

58 / 83

Created with the Personal Edition of HelpNDoc: Write EPub books for the iPad

SetOpPress
Purpose

To set the pressure of the model using an arbitrary equation

Syntax

Call SetOpPress(EqString)

Parameters

EqString the equation specifying the pressure, string

Return
Values

None

Remarks

The pressure must be specified in pascals. To prevent infinite recursion, the


operating pressure can not be specified as a function of density or operating
pressure. For constant density problems, BFlow doesn't require an operating
pressure. However, when the density depends on pressure, it is important to call
SetOpPress.

Example

Call SetOpPress( 101000 )

See Also

SetCp, CreateMaterial

59 / 83

Created with the Personal Edition of HelpNDoc: Free help authoring tool

SetOpPressN
Purpose

To set the pressure of the model to a constant value

Syntax

Call SetOpPressN(val)

Parameters

val the value of the pressure, double

Return Values

None

Remarks

The pressure must be specified in pascals.

Example

Call SetOpPress(133) Pressure is 133 Pa

See Also

60 / 83

Created with the Personal Edition of HelpNDoc: Free Kindle producer

SetPorousSolidCp
Purpose

To set the specific heat of a porous solid

Syntax

Call SetPorousSolidCp(MatID, EqString)

Parameters

MatID ID number of the material being set, long integer


EqString - An expression for the specific heat, string

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

SetPorousSolidThCond, SetPorousSolidDensity, SetPorousVoidFraction

61 / 83

Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle

SetPorousSolidDensity
Purpose

To set the density of the solid portion of a porous material

Syntax

SetPorousSolidDensity(MatID, EqString)

Parameters

MatID ID number of the material being set, long integer


EqString - An expression for the density, string

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

SetPorousSolidCp, SetPorousSolidThCond, SetPorousVoidFraction

62 / 83

Created with the Personal Edition of HelpNDoc: Easily create CHM Help documents

SetPorousSolidThCond
Purpose

To set the thermal conductivity of the solid portion of a porous material

Syntax

Call SetPorousSolidThCond(MatID, EqString)

Parameters

MatID ID number of the material being set, long integer


EqString - An expression for the thermal conductivity, string

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

SetPorousSolidCp, SetPorousSolidDensity, SetPorousVoidFraction

63 / 83

Created with the Personal Edition of HelpNDoc: Easy EPub and documentation editor

SetPorousVoidFraction
Purpose

To set the void fraction, or porosity of a porous material

Syntax

Call SetPorousVoidFraction(MatID, EqString)

Parameters

MatID ID number of the material being set, long integer


EqString - An expression for the void fraction, string

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

SetPorousSolidCp, SetPorousSolidDensity, SetPorousSolidThCond

64 / 83

Created with the Personal Edition of HelpNDoc: Free Kindle producer

SetRange
Purpose

To set the min and max range of a contour or vector plot

Syntax

Call SetRange(MinVal, MaxVal)

Parameters

MinVal minimum value to be plotted, double


MaxVal maximum value to be plotted, double

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

Call SetRange(0,1) Reduce range to between 0 and 1


Call SetRange(0,0) Restore default (full range)

See Also

SetTitle, OverlayGrid, OverlayGeo, CreateVectorBMP, CreateContourBMP,


CreateGeoBMP, SetView

65 / 83

Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation

SetSolid
Purpose

To designate a polygon region a solid (not a fluid)

Syntax

Call SetSolid(PolyID)

Parameters

PolyID ID number of the polygon, long integer

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

SourceNum ID number of the source being set, long integer


PhiNum ID number of the field, long integer
EqString equation for the source term, string

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

Call SetSource(1,temp,12000) units: W/m^3

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

Call SetSourceLin(SourceNum,PhiNum,S0EqString, S1EqString)

Parameters

SourceNum ID number of the source being set, long integer


PhiNum ID number of the field, long integer
S0EqString equation for the constant part, string
S1EqString - equation for the linear part, string

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

Call SetSourceN(SourceNum,PhiNum,S0, S1)

Parameters

SourceNum ID number of the source being set, long integer


PhiNum ID number of the field, long integer
S0 value for the constant part, double
S1 - value for the linear part, double

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

TimeStep The size of the time step in seconds, double

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

Set the title string displayed in plots

Syntax

Call SetTitle(TitleStr)

Parameters

TitleStr A string contain the title of the model

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

Call SetTitle(Case 1. T=400C)

See Also

CreateVectorBMP, CreateContourBMP, CreateGeoBMP, SetView

71 / 83

Created with the Personal Edition of HelpNDoc: Easily create EPub books

SetTol
Purpose

Set tolerance (or accuracy) of mesh

Syntax

Call SetTol(bcID, tol)

Parameters

bcID ID number of boundary, long integer


tol the location accuracy (meters) needed for this boundary (double)

Return
Values

none

Remarks

Mesh generation is done (with CreateQuadMesh) by imprinting the polygons that


define the geometry onto a mesh of density you specify. The resulting stair-step
mesh often deviates from the original boundary position. The SetTol command
provides a way to improve the mesh accuracy. The cells near boundary bcID will
be split until the distance from the polygon edge to the mesh representation of the
boundary is less than Tol.
This command must be called before CreateQuadMesh (but after the polygons
have been specified).
Warning: If Tol is made too small, a very high cell count can result
SetTol is optional. If the location of a particular boundary is not critical, there is
no need to set it.

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

Sets the under relaxation coefficients for field phi

Syntax

Call SetUnderRelax(PhiNum, Val)

Parameters

PhiNum ID number of field, long


Val Value of the under relaxation coefficient, from 0 to 1, double

Return
Values

none

Remarks

To improve the numerical stability of the solution process it is common to under


relax the solution. At the end of an iteration, instead of accepting the new
solution, you accept a weighted average of the new and old solutions. This
weighting is the under relaxation coefficient. If it is 1 you take the new solution in
full after each iteration. If it is 0.5, you average the old and new:
PhiNew = (1-omega)*PhiOld + omega*PhiNew
Where omega is the under relaxation parameter.
Fastest convergence is achieved with under relaxation of 1, but this isn't always
practical. The default under relaxations in BFlow are
Pressure
UV
VV
Temp

0.2
0.8
0.8
1.0

If convergence problems are encountered with these, it is recommended they be


reduced. For user created scalar fields, the default under relaxation is 1.0
Example

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

Sets the scale factor for arrow length in vector plots

Syntax

Call SetVectorScaling(theScale)

Parameters

theScale the scale factor, a double

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

Call SetVectorScaling(10) Makes vectors 10x longer than default

See Also

CreateVectorBMP, SetVectorSkip, FixVectorLength

74 / 83

Created with the Personal Edition of HelpNDoc: Free help authoring environment

SetVectorSkip
Purpose

To specify the density of arrows in a vector plot

Syntax

Call SetVectorSkip(skip)

Parameters

skip the number of skipped cells, long

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

Call SetVectorSkip(1) skip every other cell

See Also

CreateVectorBMP, SetVectorScaling, FixVectorLength

75 / 83

Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation

SetView
Purpose

Allows user to zoom into a portion of the domain for postprocessing

Syntax

Call SetView(X0, Y0, delx)

Parameters

X0, Y0 Lower left corner of view window, in meters (double)


delx width and height of desired view, in meters (double)

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

SetTitle, OverlayGrid, OverlayGeo, SetBlackBackground

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

Call StartPoly (PolyNum, x0, y0, MatID, sourcenum)

Parameters

PolyNum ID number of the polygon, long


X0, Y0 location of the point, double
MatID Material ID number for the polygon, long. Use NoMat for void region
SourceNum Source ID number for the polygon, long. Use NoSource for no
source

Return
Values

none

Remarks

This routine is used in conjunction with AddPt2Poly to create a polygon. The


initial point, as well as the material and source term information are specified with
StartPoly. Each additional point is created and added to the polygon by calling
AddPt2Poly.
To define a void region, specify NoMat as the material type. If the polygon has no
source term, specify NoSource for this argument.

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

Updates a scalar field, with under relaxation

Syntax

Call UpdatePhi (PhiID, EqStr)

Parameters

PhiID ID number of the scalar field variable, long


EqStr an expression for phi.

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

Update diffusion coefficients, using under relaxation


Call SetUnderRelax(diff1, 0.8)
Call SetUnderRelax(diff2, 0.8)
Call CopyDiffCoeffs(V, tem1, tem2) copy diffusion coeffs
to two temporary fields
Call UpdatePhi(diff1, "tem1")
Call UpdatePhi(diff2, "tem2")

See Also

InitializePhi, SetUnderRelax

78 / 83

Created with the Personal Edition of HelpNDoc: Full-featured EPub generator

ValAtPt
Purpose

Return the value of an arbitrary function at a specific point in the domain

Syntax

Ans = ValAtPt(PhiID,x,y)

Parameters

x x value of the coordinate, double


y y value of the coordinate, double
EqSstring Equation to be evaluated at the point (x,y), string

Return
Values

The value of the equation at the requested point, double

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

Ans = ValAtPt(5.2, 3.7, Tp - 273 )


Temp in C is
returned
Generate points for Excel plot
for i=1 to 10
cells(i+10,1).value = (i-1)*delx
x position
cells(i+10,1).value = ValAtPt((i-1)*delx,3.2, tp-273)
temp in C
next i

See Also

CreateContourBMP

Created with the Personal Edition of HelpNDoc: Generate EPub eBooks with ease

79 / 83

Algebraic Expressions in Bflow


Many Bflow commands can accept algebraic expressions as input. Here we explain how to use this
capability and describe the built-in functions and variables.
List of Functions
Function
+, -, *, /, ^
Sqrt(x)
Min(x,y), Max(x,y)
Sin(x), cos(x), tan(x)
Ln(x), log(x), exp(x)
Abs(x)
Ustep(x)
If(test, x, y)
>, >=, =, <, <=
AND, OR, NOT
LookUpTable(TableID, x)

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

Defining User Variables


User defined variables can greatly improve readability of expressions by simplifying them. The
DefineVariable command is used to create these. Consider this example for determining gas density.
CALL DefineVariable("M_SiH4", "32")
CALL DefineVariable("M_H2", "2")
CALL DefineVariable("R_gas", "8315") 'Rg = 8315 kmol-Pa/K

80 / 83

CALL DefineVariable("MolWt", " 1/((SiH4)/M_SiH4 + (1-SiH4)/M_H2) " )


CALL DefineVariable("Dens", "OP * MolWt /( R_gas *(Tp + 1e-15) )" )
The first three definitions improve overall readability. With these, we can then write the density in a clear
way. The density depends on the molecule weight of the gas. However, in mixing problems or reacting flow
problems, the average molecular weight varies with position, since the composition varies. Mathematically
this is given by

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

This is captured in the last DefineVariable statement.


As these definitions are created, they are stored in a list. Any mathematical expressions can then make
use of these variables (assuming the variables have been defined before the expression). When the
expression is preprocessed, all the variable substitutions are made, reducing the expression to one
consisting of numbers of the predefined variables.
Like the built-in variables, user defined variables are not case sensitive. MolWt is the same as molwt.
Created with the Personal Edition of HelpNDoc: Free HTML Help documentation generator

Creating and Using Data Tables


Data tables can be used in those cases where a material property or boundary condition doesn't readily lend
itself to mathematical expression. For instance, you may have a table containing viscosity data for the gas
you are modeling:
Temperature (K)
300
350
400
450
500
550

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

How Expressions are Processed


BFlow does some pre-processing of expressions when they are entered. This is done to reduce the
performance penalty for processing an equation over and over. Consider this statement
Call SetDiffCoeff(metal, temp, 2.1*tp + myconst, 2.1*tp + myconst)
This sets the thermal conductivity of the material Metal to
k= 2.1*T + MyConst
in both the x and y directions. When this command is executed, the following steps occur

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

Anda mungkin juga menyukai