Interpolating and Differentiating Table Values

Using expressions, you can interpolate and differentiate imported table values to construct scalar or vector fields.

To access table data from expressions, import the relevant tables under the Tools > Tables node. For information, see Tables.
NoteWhen you access table data from expressions, do not include any units specification in the column names.

Interpolating and Differentiating Column Values as Function of Another Column

Tables often contain column values that are functions of another column of values. Using the interpolateTable expression, you can interpolate the dependent values as functions of the independent values, to construct a continuous field. The expression returns the interpolated field at a value that you define using an additional expression.

The differentiateTable expression interpolates the dependent values of a table as functions of the independent values and then returns the derivative of the interpolated field at a value that you define using an additional expression.

For tables containing a column of values for each component of a vector, you can interpolate and differentiate all component columns at the same time to construct a vector field.

The general syntax is:

  • For an output scalar field:
    interpolateTable(@Table("<tablename>"), "<x-column>", {LINEAR | STEP | SPLINE | CUBIC_AKIMA}, "<phi-column>", <scalar_expression>)
    differentiateTable(@Table("<tablename>"), "<x-column>", {LINEAR | SPLINE | CUBIC_AKIMA}, "<phi-column>", <scalar_expression>)

    The interpolateTable expression generates a scalar field by interpolating the values in <phi-column> as functions of the values in <x-column>, and calculates the scalar field at the value specified by <scalar_expression>.

    The differentiateTable expression generates a scalar field by differentiating the interpolated scalar field. The return value is the slope of the segment at the value specified by <scalar_expression>. If this value corresponds exactly to one of the table values, the average of the slopes of the adjacent segments is returned.

  • Similarly, for an output vector field:
    interpolateTable(@Table("<tablename>"), "<x-column>", {LINEAR | STEP}, "<phi_0-column>", "<phi_1-column>", "<phi_2-column>", <scalar_expression>)
    differentiateTable(@Table("<tablename>"), "<x-column>", "<phi_0-column>", "<phi_1-column>", "<phi_2-column>", <scalar_expression>)

    The expressions return a vector.

where:

  • <tablename> is the name of the table under the Tools > Tables node.
  • <x-column> is the name of the table column that is used as the independent variable for the interpolation. In the example above, <x-column> is Time.
  • <scalar_expression> is the expression that gives the x variable. In the examples above, the <scalar_expression> would give the time field function, ${Time}.
  • For scalars:
    • <phi-column> is the column of scalar y-values to be interpolated as a function of x.
  • For vector values:
    • <phi_0-column> is the table column of component [0] values to be interpolated as a function of x.
    • <phi_1-column> is the table column of component [1] values to be interpolated as a function of x.
    • <phi_2-column> is the table column of component [2] values to be interpolated as a function of x.
  • The following interpolation methods are supported:
    • LINEAR -- uses piecewise-linear interpolation between y table values.
    • STEP -- uses y table values at the largest x table value that is less than the value of $scalar_expression.

      This method is not supported for the differentiateTable expression.

    • SPLINE -- uses B-spline interpolation between y table values (scalar expressions only).

    • CUBIC_AKIMA -- uses the Akima cubic method. See Cubic and Spline Interpolation Methods.

Example: Consider a table named "RotationData", with columns "Time" and "RotationAngle". The following expression:

interpolateTable(@Table("RotationData"), "Time", LINEAR, "RotationAngle", $Time)

linearly interpolates "RotationAngle" as a function of "Time" and returns the interpolated value at the time given by the Time field function ($Time).

Periodically Interpolating and Differentiating Column Values as Function of Another Column

For tables containing a column of values that are a function of another column of values, you can create an output scalar or vector field that periodically repeats a certain period of the interpolated dependent values. Similarly, you can create an output scalar or vector field that periodically repeats the derivative of a certain period.

The general syntax is:

  • For a scalar field with a period length that is longer than the tabular input profile:
    interpolateTablePeriodic(@Table("<tablename>"), "<x-column>", {LINEAR | STEP | SPLINE | CUBIC_AKIMA}, "<phi-column>", <scalar_expression_1>,<scalar_expression_2>)
    differentiateTablePeriodic(@Table("<tablename>"), "<x-column>", {LINEAR | SPLINE | CUBIC_AKIMA}, "<phi-column>", <scalar_expression_1>,<scalar_expression_2>)
  • For a scalar field with a period length that is shorter than the tabular input profile:
    interpolateTablePeriodic(@Table("<tablename>"), "<x-column>", {LINEAR | STEP | SPLINE | CUBIC_AKIMA}, "<phi-column>", <scalar_expression_1>,<scalar_expression_2>,<scalar_expression_3>)
    differentiateTablePeriodic(@Table("<tablename>"), "<x-column>", {LINEAR | SPLINE | CUBIC_AKIMA}, "<phi-column>", <scalar_expression_1>,<scalar_expression_2>,<scalar_expression_3>)

where:

  • <scalar_expression_1> is the expression that gives the x variable, such as ${Time}.
  • <scalar_expression_2> is the period length, such as the length of a certain interval in time.
  • <scalar_expression_3> is the start of the period, such as a point in time.

You can also interpolate a vector periodically from a table. In general, you would write:

interpolateTablePeriodic(@Table("TableName"), "Independent Variable Column", VECTOR_INTERPOLATION_METHOD, "X Component Column", "Y Component Column", "Z Component Column", independentVariableValue, period, periodStart)

VECTOR_INTERPOLATION_METHOD can be either STEP for a step interpolant, or LINEAR for a linear interpolant; these methods work exactly the same as for scalars.

To differentiate a periodically-interpolated vector, you would write:

differentiateTablePeriodic(@Table("TableName"), "Independent Variable Column", "X Component Column", "Y Component Column", "Z Component Column", independentVariableValue, period, periodStart)

The interpolation method is not required because Simcenter STAR-CCM+ always differentiates a linear interpolant for vector interpolation from tables.

Example: Consider a table named "MassFlowData", with columns "Time" and "MassFlowRate", that provides the following mass flow rate for every second of a minute:



Further, consider the following field function:

interpolateTablePeriodic(@Table("MassFlowData"), "Time", LINEAR, "MassFlowRate", $Time, 15, 10)

This expression linearly interpolates "MassFlowRate" as a function of "Time" and returns the interpolated values between 10s and 25s periodically, at the time given by the Time field function as follows:



Interpolating Position Values

You can use expressions to interpolate position table data, generating a position-dependent field. The function for generating a scalar field is:

interpolatePositionTable(@Table("<tablename>"), "<phi-column>")

or, with a coordinate system:

interpolatePositionTable(@Table("<tablename>"), @CoordinateSystem("<coordinatesystem>"), "<phi-column>")

or, with a nested coordinate system:

interpolatePositionTable(@Table("<tablename>"), @CoordinateSystem("<coordinatesystem>.<coordinatesystem>.<coordinatesystem>"), "<phi-column>")

The function for generating a position-dependent vector field is:

interpolatePositionTable(@Table("<tablename>"), "<phi_0-column>","<phi_1-column>","<phi_2-column>")

or, with a coordinate system:

interpolatePositionTable(@Table("<tablename>"), @CoordinateSystem("<coordinatesystem>"), "<phi_0-column>","<phi_1-column>","<phi_2-column>")

or, with a nested coordinate system:

interpolatePositionTable(@Table("<tablename>"), @CoordinateSystem("<coordinatesystem>.<coordinatesystem>.<coordinatesystem>"), "<phi_0-column>","<phi_1-column>","<phi_2-column>")

where:

  • <coordinatesystem> is the name of a coordinate system in the Tools > Coordinate Systems node. Multiple instances of this name, which dots separate, represent layers of nesting. When a coordinate system is not specified, the laboratory system is used and assumed to be Cartesian.
  • <tablename> is a table in the Tools > Tables node. The table columns contain coordinate values in the specified <coordinatesystem>. Column names must be those that the coordinate system dictates, that is, Cartesian ("X", "Y", "Z"), cylindrical ("r", "theta", "z") or spherical ("r", "theta", "phi").
  • For scalar functions:
    • <phi-column> is the table column for spatial interpolation using the nearest neighbor, corresponding to the position coordinate columns.
  • For vector functions:
    • <phi_0-column>, <phi_1-column>, and <phi_2-column> represent the column names of the three values of the components of the position vector in <coordinatesystem>.

Nearest-neighbor (closest point) interpolation is used, based on the coordinate values in each row of the table. Data points in the table do not need to follow an particular spatial ordering (the point data is considered to be scattered).