UDF Library¶
The UDF Library is where users define new reusable functions that behave like built-in functions. These functions accept input arguments, perform arbitrary calculations, and return a single output value. Once defined, a custom function can be invoked anywhere an expression is permitted—inside local or global UDFs, runtime scripts, or other calculated fields. This makes the UDF library the preferred way to package bespoke correlations, transformations, or proprietary models that need to be reused in multiple places across a simulation.
The UDF library is commonly used to (i) encode empirical or semi-empirical correlations that are not available among built-in functions or (ii) capture domain-specific models (for example, a reaction-rate expression, a transport-property correction, or a vendor-specific energy-efficiency factor).
By consolidating these reusable relationships into named functions, the UDF library keeps models cleaner, more maintainable, and easier to audit, especially when the same correlation appears in many places across a model. See also UDF Library Editor.
Property Grid¶
- UDF Library Code
The UDF Library Code Editor is launched by pressing the
icon. Within the UDF Library Editor, a notional function is defined as:
where the input variables are defined in the function signature and the return variable is the function output. Intermediate variables and calls to built-in math functions are also permitted. Once saved,
myFunction(x,y)
can be called just like a native built-in function anywhere in the model. Multiple functions can be defined within a single UDF Library.In the example below, we pre-define a custom UDF Library function that adds random forces to particles to mimic the effects of stochastic Brownian motion. The forcing subroutine defined within the UDF Library is applied across multiple particle sets. The single location for this model reduces duplication errors if modifications to the kernel are made. The purpose of this simulation is to assess the effects of Brownian motion on particle diffusion, as compared to scalar fields and particles with no additional Brownian motion.
Download Sample File: UDF Library
UDF Library Toolbar¶
Context-Specific Toolbar Options |
Description |
---|---|
|
The Help command launches the M-Star reference documentation in your web browser. |
See also Child Geometry Context Specific Toolbar.
For a full description of each selection on the Context-Specific Toolbar, see Toolbar Selections.