The CFX Expression Language is declarative. You declare the name and definition of the expression using expression language statements. The statements must conform to a predefined syntax that is similar to Fortran mathematical statements and to C statements for logical expressions.
The statement must consist of the following:
a number, optionally with associated units. This defines a constant. Constants without units are termed dimensionless.
for mathematical expressions, one or more references to mathematical constants, system variables, or existing user variables, separated by
+
(addition),-
(subtraction),*
(multiplication),/
(division) and^
(exponentiation), with optional grouping of these by parentheses. The syntax rules for these expressions are the same as those for conventional arithmetic.for logical expressions involving relational operators, one or more references to mathematical constants or results from mathematical expressions, separated by
<=
(is less than or equal to),<
(is less than),==
(is equal to),!=
(is not equal to),>
(is greater than) and>=
(is greater than or equal to) with optional grouping of these by parentheses.for logical expressions involving logical operators, one or more references to logical constants or results from relational operations separated by
!
(negation),&&
(logical AND) and||
(logical OR), with optional grouping by parentheses.
Constants do not need to be defined prior to being used in an
expression. For example, you could choose to evaluate the expression x + 5 [m]
. Or, you could define a constant, b = 5 [m]
and then create an expression x + b
.
The logical constants are false
and true
. Results of logical expressions are either false
or true, which are evaluated as 0
and 1
(corresponding to false
and true
, respectively) when a numerical representation is
required.
The use of constants may be of benefit in generating complicated expressions or if you have several expressions that use the same constants.
All numbers are treated as real numbers.
The precedence of mathematical operators is as follows (from highest to lowest):
The power operator
^
as inx^y
.The unary minus or negation operator
-
as in-x
.Multiplication and division as in
x*y/z
.Addition and subtraction as in
x+y-z
.
The precedence of logical and relational operators is as follows (from highest to lowest):
The negation operator
!
as in!x
.The relational operators involving less than or greater than (
<=
,<
,>
and>=
) as inx >= y
.The relational operator is equal to and is not equal to (
==
and!=
) as inx != y
.The logical AND operator (
&&
) as inx && y
.The logical OR operator (
||
) as inx || y
.
It is often useful, particularly with complex expressions, to use more than one line when creating your expression. CFX allows you to use multiple lines to generate an expression, provided each line is separated by an appropriate operator.
For example, you may have an equation, A + B/C, that consists of three complex terms, A, B, and C. In this case, you could use three lines to simplify creating the expression:
A + B / C
Note that the operator may be used at the end of a line (A +) or at the beginning of a line (/ C). You do not need to enter the operator twice.
Once the expression has been created, it will appear in the Existing Definitions list box as if it were generated on a single line (A + B/C).