System UDF¶
Introduction¶
A system UDF operates at a global level, performing calculations that apply to the entire simulation domain or system as a whole, rather than on a per-voxel or per-particle basis. This type of UDF is evaluated once per simulation time step (or at specific intervals) and produces outputs or actions that affect the overall system behavior or global parameters.
Examples of System UDFs include:
Controlling boundary condition flow rates
Specifying moving body speeds or positions
Defining particle injection rates
System UDFs are also used for writing custom scripts, automating workflows, and controlling system outputs or data printing. Their applications extend well beyond these examples, offering robust tools to manage global simulation logic, interact with external models, or dynamically adjust system-wide parameters. System UDFs are created and modified using the System UDF Editor.
Input Variables¶
The Input Variables Panel in the System UDF Editor lists the variables available for use in each System UDF. The specific input variables depend on the context and application of the UDF. All System UDFs can utilize global variables, global constants, and lookup tables. Additionally, most System UDFs accept the current simulation time as an input variable. System UDFs can also invoke a general set of mathematical functions, as discussed below. Some System UDFs include additional input variables specific to their operation.
Output Variables¶
The Output Variables Panel in the System UDF Editor lists the variables expected to be assigned within the System UDF. The user defines the logic that determines how these pre-defined output variables are assigned values during execution. The panel specifies the variable name, data type, expected units, and usage. In almost all cases, the output variable is named value, with a data type of float. The one exception is the Stop Condition UDF, which requires a Boolean output variable named stop. In all cases, the output variable must be explicitly assigned by name within the UDF expression and cannot be renamed. In some cases, the name of the output variable is related to the dynamic name of the object within the model tree. In the index below, the dynamic output variable names are identified by curly brackets {}.
Input and Output Variable Types¶
Declaring and understanding the basic variable types in the System UDF is necessary. The fundamental variable types are float, int, and bool. A float variable represents continuous physical quantities like velocity and pressure, providing the necessary decimal precision for accurate property representations. This type defines a single precision floating point variable. The values range from \(+/- 1.18 \times 10^{-38}\) to \(+/-3.4 \times 10^{38}\) with approximately 7 decimal digits of precision. An int variable manages discrete aspects, such as mesh indices, iteration counts, and zone IDs. Values range from -2,147,483,648 to 2,147,483,647. A bool (Boolean) variable implements a conditional logic (true/false), enabling checks and control flow within the UDF; for instance, ending the simulation when a specific condition is achieved. Additionally, Boolean operations (e.g., <, >, ==, !=) are used within if statements to compare values and determine the execution path, making these comparisons essential for conditional logic. UDFs can also contain double precision floating-point variables, which store 14 decimal digits of precision. These double-precision variables should only be used when the code is operating double precision mode.
System UDF Expression Index¶
The following System UDF variables are available. The table lists the name of the UDF and the location. The location refers to the path of selections which start in the model tree and continue through the property grid to arrive at the desired UDF.
UDF Name |
Description and Location |
---|---|
Acceleration X Acceleration Y Acceleration Z |
|
Add’l Force X Add’l Force Y Add’l Force Z |
|
Average Velocity |
|
Ball Joint Unit Vector X Ball Joint Unit Vector Y Ball Joint Unit Vector Z |
|
Child Geometry Value |
|
Displacement X Displacement Y Displacement Z |
|
Dump Time |
|
Dump Value |
|
Evaporation |
|
External Torque |
|
Feed Rate |
|
Fluid Temperature |
|
Flux Rotation Speed |
|
Flux Surface Speed |
|
Global Fluid Heating |
|
Global Variable Time |
|
Headspace Pressure |
|
Initial Background Value |
|
Initial Diameter |
|
Initial Volume Fraction |
|
Injection Start Time |
|
Injection Stop Time |
|
{Inlet Outlet} Return Value |
|
{Inlet Outlet} Value |
|
Mass Flow Rate |
|
Moving Inlet Fluid Type |
|
{Moving Inlet Outlet} Specified Value |
|
Open Close |
|
Orientation Unit Vector X Orientation Unit Vector Y Orientation Unit Vector Z |
|
Position X Position Y Position Z |
|
Prescribed Rotation |
|
Pressure |
|
Recirculation Flow Ratio |
|
Recirculation Return Temperature |
|
Rotation Speed |
|
Solid Heating |
|
Speed |
|
Static Inlet Fluid Type |
|
Stop Condition |
|
Surface Temperature |
|
Surface Temperature |
|
Translation Velocity X Translation Velocity Y Translation Velocity Z |
|
Velocity Magnitude |
|
Velocity Unit X Velocity Unit Y Velocity Unit Z |
|
Volume Feed Rate |
|
Volume Flow Rate |
|
Window Length |
Built-in Functions¶
The following is a list of the built-in functions available for System Variable UDFs. These functions are based on the C++ Math library.
float cos(float) |
Calculate the cosine of the input argument |
float sin(float) |
Calculate the sine of the input argument |
float tan(float) |
Calculate the tangent of the input argument |
float acos(float) |
Calculate the arc cosine of the input argument |
float asin(float) |
Calculate the arc sine of the input argument |
float atan(float) |
Calculate the arc tangent of the input argument |
float atan2(float,float) |
Calculate the arc tangent of the ratio of first and second input arguments |
float cosh(float) |
Calculate the hyperbolic cosine of the input argument |
float exp(float) |
Calculate the base e exponential of the input argument |
float sinh(float) |
Calculate the hyperbolic sine of the input argument |
float tanh(float) |
Calculate the hyperbolic tangent of the input argument |
float log(float) |
Calculate the natural logarithm of the input argument |
float logl0(float) |
Calculate the base 10 logarithm of the input argument |
float pow(float,float) |
Calculate the value of first argument to the power of second argument |
float sqrt(float) |
Calculate the square root of the input argument |
float ceil(float) |
Calculate the ceiling of the input argument |
float abs(float) |
Calculate the absolute value of the input argument |
float floor(float) |
Calculate the floor of the input argument |
float fraction(float) |
Calculate the fractional part of the float value |
void print(string) |
Prints value to standard output |
float rand() |
Produces random number [1:0] |
double cos(double) |
Calculate the cosine of the input argument |
double sin(double) |
Calculate the sine of the input argument |
double tan(double) |
Calculate the tangent of the input argument |
double exp(double) |
Calculate the base e exponential of the input argument |
double acos(double) |
Calculate the arc cosine of the input argument |
double asin(double) |
Calculate the arc sine of the input argument |
double atan(double) |
Calculate the arc tangent of the input argument |
double atan2(double,double) |
Calculate the arc tangent of the ratio of first and second input arguments |
double cosh(double) |
Calculate the hyperbolic cosine of the input argument |
double sinh(double) |
Calculate the hyperbolic sine of the input argument |
double tanh(double) |
Calculate the hyperbolic tangent of the input argument |
double log(double) |
Calculate the natural logarithm of the input argument |
double logl0(double) |
Calculate the base 10 logarithm of the input argument |
double pow(double,double) |
Calculate the value of the first argument to the power of the second argument |
double sqrt(double) |
Calculate the square root of the input argument |
double ceil(double) |
Calculate the ceiling of the input argument |
double abs(double) |
Calculate the absolute value of the input argument |
double floor(double) |
Calculate the floor of the input argument |
double fraction(double) |
Calculate the fractional part of the float value |
bool isfinite(double) |
Determine whether the argument is finite |
bool isfinite(float) |
Determine whether the argument is finite |