Application of Fluent expression

Please note:

this article is written based on version 2024R1, details may vary in other versions.


1 Introduction

In CFD simulation, defining variables are involved, such as inlet flow rate changing with time.

In Fluent, a variable can be defined by three ways:

  • Expression. Expression, a built-in function of Fluent, can dfine boundary conditions, cell zone conditions, material properties, some physical mechanism, time step size, etc. Expression is saved in Fluent's CAS file, other files are not required.
  • UDF (User-Defined Function). UDF is C language code, more flexible than expression, and some settings can be defined by UDF but can not by expression. UDF code is saved in seperate C language code files, can be read and edited by text editor such as Notepad and VS Code.
  • Profile. Profile, defining the relationship between quantities and spatial coordinates or time in the form of discrete points, can be uesd for boundary conditions and cell zone conditions only, not for other variables like material properties, time step size and physical mechanism. Profile is saved in seperate text file, can be read and edited by Excel or text editor.


Compared with other methods, the main advantages of expression are:

  • simple and clear definition with visualizability of function
  • ability to define parameter and perform parametric analysis
  • no additional files required, means easier management
  • strong compatibility, no additional actions required if upgrade software or change system enviroment


Expression is an explicit funcition, expressing the relationship between dependent and independent variables explicitly. The basic definition is: A=f(B, C, D...), where A is the dependent variable, and B, C, D, etc. are independent variables that affect the value of A. In Fluent, independent variables can be spatial coordinates, time, flow field physical quantities, material properties, and more. Expression calculations include mathematical operations (arithmetic, exponential, trigonometric, statistical functions, etc.) and logical operations (IF, AND, OR, etc.).

For detailed syntax of expression, independent variables and functions, refer to the Fluent help in the User's Guide, Solution Mode section.

The expression syntax is almost the same as function operations in Excel, with the main difference being that units need to be marked with square brackets [ ]. All symbols in expressions must be entered in the English input state, and symbols entered in other language input state, such as Chinese square brackets 【】, cannot be recognized.


2 Applications

2.1 Using Expressions Directly

Many settings have an expression option in their drop-down menus, allowing expressions to be entered directly.

For example, the inlet velocity selection shows the expression option as illustrated in the figure.


Click the "f(x)" button to open the expression editor and enter the expression. The right side of the editor shows the currently supported types of independent variables.

Depending on the form of the expression, the result may be a numerical value or a function.



Some settings do not have expression option in their drop-down menus, meaning expressions cannot be used for definition. As shown in the figure for the cavitation mechanism settings, the vaporization pressure cannot be defined using an expression, but can be defined by UDF.


All settings based on integers (such as the number of iterations) can only be entered manually and cannot be set as variables.


2.2 Named Expressions

For frequently used expressions, they can be encapsulated as named expressions for direct invocation.

As shown in the figure, right-click on the interface and select to create a new named expression.


In the pop-up window, enter the expression and name it.


In places where the expression needs to be invoked, it can be called directly as an encapsulated function without additional writing.


Existing named expressions can also be called by other named expressions.


2.3 Obtaining Result Data

Some simulation result data is a function of physical quantities, such as lift-to-drag ratio of a wing or pressure loss across a valve. Expressions can be used in report definitions to obtain this type of data.


When creating a report, other existing reports and named expressions can be invoked. As shown in the figure for power data, the torque is an existing report, and the angular velocity is an existing named expression, both of which can be directly invoked.


2.4 Custom Physical Fields

Named expressions can be used to define custom physical fields.

As shown in the figure, the projection of velocity onto the XY plane is defined.


In post-processing, the distribution of this custom physical field based on the expression can be directly plotted.


3 Notes

3.1 Dimensions and Unit Systems

Expressions support multiple units of the same dimension, and the program automatically and forcibly converts to the international unit system in the back-end.

As shown in the figure, km/h is also a unit of velocity and can be used correctly, with the solution process automatically converting to values based on m/s.


If the expression defines a function relationship, the dimension issue must be considered.

For addition and subtraction, the terms on both sides of the operator must have the same dimension, as shown in the figure.


If the dimensions on both sides of the plus sign are different, the expression will report an error indicating that the dimensions on both sides of the operator are different, as shown in the figure.


For more complex function relationships like trigonometric or exponential functions, it is recommended to first non-dimensionalize the involved physical quantities before performing the operations, and then handle the dimensions collectively.

For example, if the relationship between inlet velocity and time is v=sin(t)+2, entering it directly will result in an error indicating that the argument of the sine function must be dimensionless or in angle units.


To modify the above, first non-dimensionalize time, and then multiply by 1 [m/s] to obtain the velocity unit.


3.2 Renaming Expressions

For named expressions, they can only be renamed if they are not being invoked. As shown in the figure, the expression is being invoked, so the name field is grayed out and cannot be renamed.


3.3 Expressions and Parameters

When defining input parameters based on named expressions, the expressions must be a constant.


If an operation relationship is used, an error message will be displayed as shown in the figure.


To define an output parameter, simply check the "create output parameter" option in the corresponding report, with no additional setup required.


要查看或添加评论,请登录

高威的更多文章

社区洞察

其他会员也浏览了