# Simcenter STAR-CCM+ How to handle 2D tabular interpolation in STAR-CCM+

2022-08-08T20:11:09.000-0400
Simcenter STAR-CCM+ Simcenter STAR-CCM+ Virtual Reality Teamcenter Share Simcenter Cloud HPC Simcenter STAR-CCM+ Viewer Simcenter STAR-CCM+ Application Specific Solutions

## Summary

Simcenter STAR-CCM+ provides a built-in capability to interpolate tabular data as field function. This functionality is meant to interpolate a dependent variable against a single independent variable. This article shows a method and provides an automation script that can be used to handle interpolation of a dependent variable from a table against two independent variables.

## Details

 Attachments:

Simcenter STAR-CCM+ provides a built-in capability to interpolate tabular data as field function. This functionality is meant to interpolate a dependent variable against a single independent variable. This article shows a method and provides an automation script that can be used to handle interpolation of a dependent variable from a table against two independent variables. A simple example is chosen for demonstration purposes.

## 1D interpolation:

One-dimensional interpolation can be handled within STAR-CCM+ using the interpolate field function. Consider that we have a table of variable A and D as shown below. We are interested in linearly interpolating the value of "D" against the values of "A", using a field function value of "\$A".

1D Table
12
24
36
48

This can be handled using the following field function syntax:

`interpolateTable(@Table("<tablename>"), "<x-column>", {LINEAR | STEP | SPLINE}, "<phi-column>", <scalar_expression>)`

For our example this becomes:

```interpolateTable(@Table("table-1"), "A", LINEAR, "D", \$A)
```

## 2D interpolation:

Now lets consider that our dependent variable "D" depends on two independent variables. 1st independent variable "A" and 2nd independent variable "B" as shown in the table and plot below. We are interested in interpolating the value of D from a table against two field functions called "\$A" and "\$B".

2D Table
A\B300320340360
12468
246810
3681012
48101214

To handle this 2D interpolation, we will convert this 2D table into a series of 1D tables as shown below.

1D Table - at B=300
12
24
36
48

1D Table - at B=320
14
26
38
410

We import a 1D table corresponding to each value of the 2nd independent variable "B". We write a 1D interpolation field function (FF) that interpolates the value of dependent variable D against each 1st independent variable A, using the field function \$A as shown below.

```FF name = A_at_B_300
FF definition = interpolateTable(@Table("1D Table - at B=300"), "A", LINEAR, "D", \$A)

FF name = A_at_B_320
FF definition = interpolateTable(@Table("1D Table - at B=320"), "A", LINEAR, "D", \$A)

FF name = A_at_B_340
FF definition = interpolateTable(@Table("1D Table - at B=340"), "A", LINEAR, "D", \$A)

FF name = A_at_B_360
FF definition = interpolateTable(@Table("1D Table - at B=360"), "A", LINEAR, "D", \$A)

```

Now we can use these interpolations with the 1st independent variable A to write another field function that interpolates linearly with the 2nd independent variable B as shown below.

```FF name = final_interp_FF
FF definition =
\$B<=300 ? \$A_at_B_300 :
\$B>300 && \$B<=320 ? ((\$A_at_B_320-\$A_at_B_300)/(320-300))*(\$B-300) + \$A_at_B_300  :
\$B>320 && \$B<=340 ? ((\$A_at_B_340-\$A_at_B_320)/(340-320))*(\$B-320) + \$A_at_B_320  :
\$B>340 && \$B<=360 ? ((\$A_at_B_360-\$A_at_B_340)/(360-340))*(\$B-340) + \$A_at_B_340  :
\$B>=360 ? \$A_at_B_360 : 0
```

An example simulation file is attached with the demonstrated implementation of the field function. A user input for field functions \$A = 3.5, \$B=350; results in a 2D interpolated value of 12.0.

## Automation:

Writing these field functions can be a daunting task. A macro has been provided to write all the interpolation field functions. The macro provides detailed description of the user inputs and has been commented well for understanding.

The attached compressed file contains two example sim files with the sample data shown in this article. The "Example_final.sim" contains the field functions already implemented, the "Example_start.sim" can be used to run the macro to generated the field functions automatically.

SummaryDetails

### Associated Components

Design Manager Electronics Cooling In-Cylinder (STAR-ICE) Job Manager Simcenter STAR-CCM+