Setting Values Using an Expression

In addition to constants, you can enter expressions that use field function syntax, such as 10 * sin(3.14 * $Time), directly. This is an easy alternative to creating a macro for calculations of non-constant physical values.

Examples of applications include:

  • Valve openings or closings
  • Tank sloshing
  • A vehicle starting at rest and accelerating to full speed
  • Prescribed rigid body motion
  • A varying gravity vector
  • A solar radiation vector
Simply type the function definition into the property value as you would a constant. The example in the following screenshot specifies oscillation with a period of 2 seconds.

This technique can also be used for vector entries.

Alternatively, you can create a field function that uses the expression, and then copy the name of the field function into the property.

The name comes from the FunctionName property of the field function. When you enter it into a constant value property, prefix it with $. In the preceding example, the function name of the field function is SolarFlux.

At the same time, other objects in the simulation can reference these field functions.

The field functions that can be used to define the expressions cannot be a function of space; they have to evaluate to a single number as the expressions are constants in space. Variables such as $Time, $TimeStep and $Iteration, as well as the field functions associated with reports, are valid. Variables such as $Temperature or $Pressure have different values at every different point in space and cannot be used in expressions.

Using Units

You can include units in these expressions, for example:

  • $Time - <1 min>
  • <180 deg>
  • <65 mph>