The Fluent Expression Language is an interpreted, declarative language based on Python, that enables you to:
Specify complex boundary conditions and source terms with respect to time, iteration number, position, and solution variables.
Specify various model and solver settings in terms of time or iteration.
Important: Expression values are updated at the same frequency as the Profile Update Interval (specified in the Run Calculation task page).
An expression is a string representing a combination of values, variables, operators, and function calls that returns a value when evaluated with appropriate values for the variables.
For example: Vmax*(5.0*exp(-t-0.3 [s]/2.8 [s]))
The following sections cover the basic elements of proper expression syntax:
The evaluated result of an expression can be a real number, a boolean, a real field or
a boolean field. For example, 2*StaticPressure
evaluates to a
real field when computed on a zone. Whereas, average(2*StaticPressure,
["inlet"])
evaluates to a single real values.
Note: Cell registers evaluate as boolean.
Values can be real numbers (for example, 1.0e-3
), integers
(for example, -10, 5, 37), booleans (true or false), or quantities. Quantities are real
numbers with units associated. The syntax supported for quantities is
<number> [ <unit> ]
, for example,
2324.0 [Pa kg^-3 s]
. The unit specification is based on CFX
(Units Syntax in the CFX-Pre User's Guide).
All of the following mathematical functions take inputs in the form of an expression that evaluates to a real number or a real field and return a real number or real field:
Table 5.1: Operations and Functions
Description |
Function |
---|---|
Operators |
|
Conditional |
|
Flux |
|
Hyperbolic |
|
Mathematical |
* *
* ** |
Reduction |
*
*
|
Trigonometric |
|
Vector |
|
*For mass-weighted reduction operations (Sum
and
Average
), weight. MassFlowRate
is
equivalent to a mass-weighted surface integral (Sum
) or surface
average (Average
), AbsMassFlowRate
is
equivalent to the absolute value mass-weighted surface integral
(Sum
) or surface average (Average
) ,
and Mass
is equal to a mass-weighted volume integral.
Operations
Components of vectors can be accessed with the .x
,
.y
, and the .z
suffixes; magnitude can
be accessed with the .mag
suffix.
Important: Do not use multiple comparison operators within a single expression, as the
operation will not work as intended. For example, 300[K]<
StaticTemperature < 400[K]
will not work. To accomplish this expression,
use AND(StaticTemperature>300[K],
StaticTemperature<400[K])
.
IF Statements
The IF(<cond>, <true_value>, <false_value>)
function returns the <true_value>
if
<cond>
is true, else it returns the
<false_value>
. Any of the arguments can be fields. The
type and unit dimension of <true_value>
and
<false_value>
must be the same.
OR Statements
OR(<cond1>, <cond2>)
returns true if any of the
conditions (any of which can be a boolean field) returns true.
AND Statements
AND(<cond1>, <cond2>)
returns true if all of the
conditions (any of which can be a boolean field) returns true.
Flux Operations
The following flux operations are explained in greater detail:
FilmHeatTransferRate([<location>, …],phase = <phase>)—compute the heat transfer rate of the film at the specified location for the specified phase. Note that you do not need to provide a phase for single-phase flow.
FilmMassFlowRate([<location>, …],phase = <phase>)—compute the mass flow rate of the film at the specified location for the specified phase. Note that you do not need to provide a phase for single-phase flow.
HeatTransferRate([<location>, …],phase = <phase>)—compute the heat transfer rate at the specified location for the specified phase. Note that you do not need to provide a phase for single-phase flow.
MassFlow([<location>, …],phase = <phase>)—compute the mass flow rate at the specified location for the specified phase. Note that you do not need to provide a phase for single-phase flow.
RadiationHeatTransferRate([<location>, …],phase = <phase>)—compute the radiation heat transfer rate at the specified location for the specified phase. Note that you do not need to provide a phase for single-phase flow.
SensibleHeatTransferRate([<location>, …],phase = <phase>)—compute the sensible heat transfer rate at the specified location for the specified phase. Note that you do not need to provide a phase for single-phase flow.
Important: Fluxes are evaluated on boundaries and face zones, but not on user-defined postprocessing surfaces (such as planes and iso-surfaces). This input requirement is similar to flux reports.
Mathematical Operations
The following mathematical operations are explained in greater detail:
gradient(<expr>)—compute the spatial gradient of an expression. For example:
Average(gradient(StaticPressure).mag,['wall-top','wall-bottom'])
.The gradient() function computes the gradient of the expression using the currently selected gradient method (see Choosing the Spatial Discretization Scheme for additional information). In some cases, the values obtained may not match the solver gradients for the same variable, as special techniques are employed when computing solver gradients to improve solver robustness. These techniques are not applied when computing the gradients of expressions.
normalize(<expr>, [<location>,…])—normalize the value of an expression by scaling according to the maximum value of the expression at the specified location(s), which is equivalent to:
(<expr> - Minimum(<expr>, [<location>]))/(Maximum(<expr>, [<locations>]) - Minimum(<expr>, [<location>]))
.Step (<expr>)
Step functions work as follows (
x
must be a non-dimensional expression of type real):If
step(x)
<0.0
return0.0
If
step(x)
==0.0
return0.5
If
step(x)
>0.0
return1.0
Reduction Operations
The following reduction operations provide simpler access to more complex operations:
AreaAve(Field, ['location'])—calculates the area averaged value for the specified field variable and location. This reduction operation is equivalent to
Average(Field, ['location'], Weight='Area')
.AreaInt(Field, ['location'])—calculates the area integrated averaged value for the specified field variable and location. This reduction operation is equivalent to
Average(Field, ['location', Weight], Weight='Area')
.Centroid(['location'])—calculates the geometric centroid of the specified location(s) as a vector.
Count(['location'])—calculates the number of solve cells included in the specified location. This reduction operation is equivalent to
Sum(1, ['location'])
.CountIf(Boolean_Expr, ['location'])—calculates the number of solve cells in the specified location according to the provided boolean expression. This reduction operation is equivalent to Sum(IF(Boolean_Expr, 1, 0),['location']).
Force(['location'])—calculates the force on the location(s) specified (should be walls) as a vector. The expression may include porous walls.
MassAve(Field,['location'])—calculates the mass-weighted average value for the specified field variable and location. This reduction operation is equivalent to
Average(Field, ['location'], Weight='Mass')
.MassFlowAve(Field, ['location'])—calculates the mass-flow-weighted average value for the specified field variable and location. This reduction operation is equivalent to
Average(Field, ['location'], Weight='MassFlowRate')
.MassFlowAveAbs(Field, ['location'])—calculates the absolute value of the mass-flow-weighted average for the specified field variable and location. This reduction operation is equivalent to
Average(Field, ['location'], Weight='AbsMassFlowRate')
.MassFlowInt(Field, ['inelt1'], ['inlet2'])—calculates the total mass flow across the specified inlets. This reduction operation is equivalent to
Sum(Field, ['inlet1', 'inlet2'], Weight='MassFlowRate')
.MassInt(Field, ['location'])—computes the total mass-weighted value for the specified field and location. This reduction operation is equivalent to
Sum(Field, ['location'], Weight='Mass')
.Maximum(Field, ['location'])—computes maximum value for the specified field and location.
Minimum(Field, ['location'])—computes minimum value for the specified field and location.
Moment([[<PointExpression>], 'location'])—calculates the moment vector about the specified point (which can be single-valued expression) for the given location(s).
PressureForce(['location'])—calculates the pressure force on the location(s) specified (should be walls) as a vector.
Sum( Field, ['location'], Weight=[Weight])—computes the sum of the specified field variable at the specified location.
SumIf( Field, Boolean_Expr, ['location'], Weight=[Weight])—computes the sum of the specified field variable at the specified location according to the provided boolean operation. This reduction operation is equivalent to
Sum(IF(Boolean_Expr, Field, 0), ['location'], Weight=[Weight])
.ViscousForce(['location'])—calculates the viscous force on the location(s) specified (should be walls) as a vector.
VolumeAve(Field, ['location'])—calculates the volume-weighted average value for the specified field variable and location. This reduction operation is equivalent to
Average(Field, ['location'], Weight='Volume')
.VolumeInt(Field, ['location'])—calculates the volume-weighted total for the specified value and location. This reduction operation is equivalent to
Sum(Field, ['location'], Weight='Volume')
.
Vector Operations
cross(<expr>, location)—compute the cross product of an expression and a location. For example:
cross(Force(['wall-top', 'wall-bottom']),Centroid(['wall-top', 'wall-bottom'])).mag
.dot(<v1>, <v2>)—calculates the dot product of vectors.
<v>.dir—calculates a unit vector along the direction of <v>, which is equivalent to <v>/<v>.mag.
vector (<Xexpression>, <Yexpression>, <Zexpression>)—calculates a vector from scalar component expressions. The components should evaluate to the same units, but they can be a mix of field and single-valued vector expressions. For example,
vector(-y, x, 0[m])
.vector (<X>, <Y>, <Z>, <unit>)—calculates a vector in the specified units from constant values. For example,
vector(0.4, 0.5, 0.2,'cm')
.unitVector (<X>, <Y>, <Z>)—calculates a unit vector from constant values.
Expressions are validated to ensure they have consistent unit types. For example,
Fluent flags 1 [cm] + TotalPressure
because centimeters are not
units of pressure. Note that units can still be provided in different unit systems, for
example, 1 [atm] + 200 [Pa]
.
Important:
Even though radians is a dimensionless unit for measuring angles, it is still considered in expression units validation. For example, is not allowed. You must either divide the first term by or multiply the second term by to make the units consistent.
Consider using absolute units when specifying temperature (either Kelvin or Rankine). If an expression contains multiple instances of a temperature expressed in Celsius or Fahrenheit, Fluent will convert each value separately into absolute units, which could lead to unexpected results.