3.6.3. Expressions Workspace: Example

In this example, you will create an expression that you can use to define a new User Variable. For details, see Variables: Example.

  1. Select Insert > Expression to create a new expression.

    The Insert Expression dialog box appears.

  2. In the Insert Expression dialog box, type a name for the expression and click OK.

  3. In the Definition area of the Expression details view, enter the expression: sqrt(X^2+Y^2)

    This expression gives the distance of a point from the Z-axis.

  4. Click Apply to create the expression.

    Note that the Value field shows that the variable has units of meters. The value is variable so a single number cannot be shown, as indicated by the placeholder: <variable>.

  5. Click the Plot tab.

    Here, you can define a simple 2D plot. Because the function has two independent variables[1], you must select a constant value for one of the variables.

  6. Check the check box beside X.

    This selects X as the variable that varies. All other variables requires a fixed value (for plotting).

  7. Leave Start of Range and End of Range at their default values.

  8. For Y, set Fixed Value to 3 [m].

  9. Click Plot Expression.

    A plot shows the variation in the expression with values of X ranging from 0 to 1 [m] and the value of Y held constant at 3 [m].

  10. Click the Evaluate tab.

  11. Set X to 0.55 [m] and Y to 3 [m].

  12. Click Evaluate Expression.

    The value 3.05 [m] appears in the Value field. This is consistent with the plot and can easily be verified.

3.6.3.1. Further Expressions

After completing the variable editor example, you can try modifying this expression. You may want to try sqrt(X^2+Z^2) to define a distance from the Y-axis or sqrt(X^2+Y^2+Z^2) to define a sphere. Try moving the location of the sphere by adding values to the X, Y, or Z components; for example, sqrt(X^2+Y^2+(Z-0.5[m])^2) moves the sphere a distance of 0.5 m in the positive Z direction.



[1] CFD-Post automatically finds the variables associated with an expression, even if the expression depends on another expression.