19.14.5. User Defined Result Expressions

The term "expression" has more than one use when defining user defined results. An expression is:

  • Primarily, the combination of mathematical values, based on syntax rules and the available math operations.

  • A column displayed on the Solution Worksheet that indicates the result type.

  • An entry field in the Details view of a user defined result where you enter mathematical values, such as UX+UY+UZ.

The example of the Solution Worksheet shown below highlights the Expression column.

When a User Defined Result is applied, the content of the above column populates the Expression field of the user defined result's Detail View. In this example, UX.


Note:  You can manually enter an expression using the Expression property. An expression must include a variable and not only a combination of constants. For example, the expressions "3" or "3+5"are not supported. However, "3 + UX" or "6 + VOLUME" are accepted expressions. This expression result is evaluated for each node or element, depending upon the variable you use.


The content of the Expression field can be modified using mathematical operators to further define the expression. As shown below, you can combine the X, Y, and Z components and then retrieve a new customized result.

Expression Syntax

Expressions support the following syntax:

  • Operands: ( ‘+’, ‘-‘,’*’, ‘/’, ‘^’, ‘**’)

  • Functions: (sqrt(), min()…) - always use lower case

  • Numbers: (scalar quantities such as 1.0, 25, -314.23, or 2.5e12)

  • Identifiers: unique user defined names

Supported Mathematical Operations

The following is a list of the mathematical operations currently supported for user defined results. The shorthand notation "s" defines a single-valued quantity (constant values such as 1.34) and "a" defines an array. An array is distinguished by its dimension which includes the length, based on the number of rows (that is, number of nodes or elements), and the width, consisting of 1, 3, or 6 columns depending on the type of result stored.

  • Addition (+): s1+s2, a1+a2, a+s (s+a is not supported)

  • Subtraction (-): s1-s2, a1-a2, a-s

  • Multiplication (*): s1*s2, a1*a2, a*s, s*a

  • Division (/): s1/s2, a1/a2, a/s

  • Power of (^ or **): s1^s2, a1^a2, a^s, s^a, (undefined if s1 = 0 and s2 < 0 or if s1<0 and s2 is a non-integer). The characters "**" perform the same action as the caret symbol (^) and you can use them interchangeably.

  • Log base ten (log10): log10(s), log10(a), (s and a > 0.0)

  • Square root (sqrt): sqrt(s), sqrt(a), (s and a should be >= 0.0)

  • Dot product (dot): dot(a1,a2) (results in a single-column array consisting of the inner products, one for each row of a1 and a2; therefore, a1, a2 should have the same dimensions)

  • Cross product (cross): cross(a1,a2) (a1, a2 must have 3 columns)

  • Add Comp (addcomp): If the argument, such as "uvectors," has 3 columns, they are added to produce a single-column array. If the argument is a single-column array, the result will be a scalar summing all the array entries. This operation returns a variable with a different dimension than its argument , such as addcomp (UVECTORS). This particular expression is evaluated as a scalar (one value) on a per node/element contour result. However, as another example, such as addcomp (VOLUME) evaluates to a singular number and this is not a valid value to be displayed as a contour result. To make this case valid, you can convert to an expression containing valid variables instead, for example: addcomp(VOLUME) + VOLUME - VOLUME.

    This expression evaluates to a constant result value for all of the elements of the body to which it is scoped.

  • Maximum (max): s = max(s1,s2), a = max(a1,a2)

  • Minimum (min): s = min(s1,s2), a = min(a1,a2)

  • Absolute Value (abs): s = abs(s1), a=abs(a1)

  • Trigonometric Functions (sin, cos, tan): sin(s), cos(s), tan(s), sin(a), cos(a), tan(a) (s and a are both in radians)

  • Inverse Trigonometric Functions (asin, acos, atan): asin(s), acos(s), atan(s), asin(a), acos(a), atan(a) (return values are in radians; where -1 <= s <= 1 and -1 <= a <=1 for asin and acos)

  • atan2: atan2(s1,s2), atan2(a1,a2) (return values are in radians; calculates the arctangent of s1/s2 or a1/a2 and uses the sign of the arguments to determine the quadrant of the returned angle)


Note:
  • A comma "," is used as the separator, if a period "." is used the decimal sign.

    and...

    A semi-colon ";" is used as the separator, if a comma "," is used the decimal sign.

  • The current expression list does not allow input parameters from the Parameter Workspace. Only output parameters are allowed for Min and Max values of a user defined result.

  • All operations involving two vector arrays must have the same dimensionality.

  • Any result whose expression contains the addcomp function must be scoped to exactly one body.