Expressions, Quantities, and Units

The ANSYS Workbench expression parser supports standard math functions and operators, as well as units for quantities. Dimensional quantities are defined in units that are a combination of one or more separate units.


Note:
  • Negative dimension values can invert the direction vector of SpaceClaim operations with which they are associated. This change is applied to the current and subsequent design point updates. As a result, when a Workbench input parameter is used as a driving dimension for a SpaceClaim geometry, negative dimension values can result in unexpected geometric changes.

  • When dimensional geometry parameters are imported into Workbench from SpaceClaim or a bi-directional CAD interface, design point updates may fail when dependencies exist between the parameters or when the parametric update in the CAD-system or SpaceClaim cannot be realized with the parameter values specified in Workbench.


ANSYS Workbench expression and mathematical function evaluation is based on the Python 2.6 programming language (www.python.org) and inherits some behavior as described here. All Python numeric and function capabilities can be used. For example, Python provides support for hexadecimal (base 16) numbers. Appending a zero and an x to the front of a number tells Python to treat the number as a hexadecimal numeric literal.

When entering expressions, you must use the list and decimal separators defined in your locale settings. For example, if a comma is defined as a decimal separator and a semicolon defined as a list separator, use these when you type in an expression.

Do not start expression definitions with an = operator. Given existing parameters P1, P2, and P3 to define a derived parameter P4 such that P4=P1*P2*P3, type the expression P1*P2*P3 in the Value field.

When you click away from the field, the expression is solved.

Expressions that involve quantities must be dimensionally consistent. The + and − operators require that the two operands have compatible units. For example, you cannot add an Area parameter to a Length parameter. Both units must be Length or both units must be Area. The * and / operators do not have this limitation. They allow one operand to be a quantity with a unit and the other operand to be a dimensionless factor. Or, they allow both operands to be quantities with units where the result is a different quantity type. For example, Length/Time results in a quantity with a Velocity unit.

Expressions support the following intrinsic functions, which support both standard numeric values and quantities as arguments. For functions preceded by an asterisk (*), be sure to read the information that follows this list.

abs(arg) cosh(arg) log10(arg) sin(arg)
acos(arg) exp(arg) max(arg list) sinh(arg)
asin(arg)fabs(arg) min(arg list) sqrt(arg)
atan(arg) floor(arg)nint(arg) tan(arg)
*atan2(arg1,arg2) int(arg) pow(value, exponent) tanh(arg)
ceil(arg) log(arg) round(arg) PI, pi − constant
cos(arg) loge(arg)sign(arg) E, e − constant

The arguments for trigonometric functions are evaluated as follows:

You can include units, assuming that the unit makes sense in context of the expression. For example, P2+3[mm]*P3 is valid if mm is a valid unit expression for P2 and P3. For example, mm is a valid unit expression if P2 is torque and P3 is force, or if P2 is area and P3 is length.

The project unit system is used to evaluate the expressions. For temperatures, absolute temperature values are used in expression evaluation. All quantity values in an expression are converted to the project unit system.

The general units syntax in ANSYS Workbench is defined as multiplier|unit|^power, where:

For examples of multipliers and commonly used units, see Table 3: Unit Multipliers and Table 4: Example Quantities and Units.

When typing units in an expression, you must enclose the units in square braces [...]. You generally do not see the braces when selecting units from a list of commonly used units. In general, units declarations must obey the following rules:


Caution:  When the specified project unit system uses the relative temperature units (C or F), the evaluation of expressions involving temperature, temperature differences, or temperature variances is a special case.

For the unit conversion of a specific temperature value, 1 degC = 274.15 K. However, the unit conversion for a temperature interval (delta T) is 1 degC = 1 K. The expression evaluator takes any temperature value and treats it as a specific temperature (not a temperature interval) by converting it to the absolute unit of the project unit system (either K or R). If the intent is to perform the evaluation in terms of temperature intervals, you need to start with temperatures in absolute units.

Similarly, any expressions to be evaluated in terms of temperatures or temperature differences are converted to absolute units for calculation. In an expression with a temperature unit raised to a power other than 1 or a unit involving both temperatures and other units (for example a temperature gradient [C/m]), the temperature is assumed to be a temperature difference.


Table 2:  Scenarios in which temperature-related units are converted before and during expression evaluation

ScenarioExample
Temperature unit conversion10[C] * 2 = 566.3[K] = 293.15[C]
Temperatures appearing as part of a mixed unit are converted as temperature intervals 10[C/m] * 50 [m] = 500[K]
Temperatures raised to a power other than 1 are converted as temperature intervals 10[C^3] * 10[C] = 2831.5[K^4]

Once the value quantity name (such as Area) is determined from the unit of the value, it can only be subsequently changed by changing the Quantity Name property for the parameter. You cannot change the expression (for example, from area to volume) without changing the Quantity Name property. Automatic unit conversion is only done when the quantity name is known. If you want to express a temperature difference, start with temperature in absolute units.


Note:  "Sound Pressure Level" and "A Weighted Sound Pressure Level" are dimensionless quantities with units dB and dBA, respectively.

  • Math operations between these two units or either of these and a numerical value will result in a value with no unit. For example, 10 db x 10 = 100. (no unit)

  • Math operations between either of these units and a dimensional unit will result in a value with the dimensional unit. For example, 10 db x 10 m = 100 m.


Table 3:  Unit Multipliers

Multiplier NameMultiplier ValueMultiplier Abbreviation
exa1018 E
peta 1015 P
tera 1012 T
giga 109 G
mega 106 M
kilo 103 k
hecto102 h
deca 101 da
deci 10-1d
centi 10-2 c
milli 10-3 m
micro 10-6 u
nano 10-9 n
pico 10-12 p
femto 10-15 f
atto10-18a

Table 4:  Example Quantities and Units

QuantityDimensionalityExample Units
Acceleration Length Time^-2
m s^-2
ft s^-2
in s^-2
um ms^-2
Current Current
A
mA
pA
Density Mass Length^-3
kg m^-3
g cm^-3
lb ft^-3
slug in^-3
slinch in^-3
Electric Charge Current Time
A s
coulomb
pA s
Energy Mass Length^2 Time^-2
J
BTU
erg
lbf ft
slug in^2 s^-2
Force Mass Length Time^-2
dyne
N
pdl
lbf
slug in s^-2
Length Length
m
cm
foot
in
mm
micron
ft
um
yard
Pressure Mass Length^-1 Time^-2
Pa
MPa
N m^-2
bar
torr
mm Hg
psi
psf
atm
dyne cm^-2
Power Mass Length^2 Time^-3
W
BTU s^-1
HP
erg s^-1
lbf ft s^-1
TemperatureTemperature
K
C
R
F
Temperature DifferenceTemperature
K
C
R
F
Temperature VarianceTemperature^2
K^2
C^2
R^2
F^2


Release 18.2 - © ANSYS, Inc. All rights reserved.