Simcenter STAR-CCM+ User Coding for 2-dimensional T,p-Table interpolation - Windows OS

2023-11-06T20:37:05.000-0500
Simcenter STAR-CCM+ Simcenter STAR-CCM+ Virtual Reality Teamcenter Share Simcenter STAR-CCM+ Viewer Simcenter STAR-CCM+ Application Specific Solutions

Summary

This article tries to show a way how 2-dimensional interpolation of a temperature and pressure table can be done, via user coding on a Windows machine. This is very useful in cases where you cannot directly provide a Table (T,p) for a property item of the STAR-CCM+ simulation tree.


Details

This article tries to show a way how 2-dimensional interpolation of a temperature and pressure table Table (T,p) can be done. This is very useful in cases, where you cannot directly provide a Table (T,p) for a property item of the STAR-CCM+ simulation tree.

A separate article was provided already, which explains this method for clients who use Linux operating system. Since in case of Windows operating system, few adjustments were needed during the compilation process, I decided to create a separate article for Windows, which in the end will explain the differences. 

For example, when you are trying to provide a temperature and pressure dependent net emission coefficient as volumetric heat source, you will see that here you can only specify the following options:



User-added image


We can see that here the option Table (T,p) is not available. Hence we need to use a workaround and pick in this case the option Field Function. In case the option Table (T,p) is there, the solver of  STAR-CCM+ would automatically do this table interpolation.

Then you need to compile the provided user code on your WINDOWS machine by using following command lines, which will create the user library libuser.dll:

1.  cl -MD -D_WINDOWS -DDOUBLE_PRECISION -c d2InterpolationTable_Windows.c

2.  link -dll -out:libuser.dll d2InterpolationTable_Windows.obj "C:\Program Files\Siemens\17.04.007-R8\STAR-CCM+17.04.007-R8\star\lib\win64\clang11.1vc14.2-r8\lib\UserFunctions.lib"

3.  dumpbin/exports libuser.dll

For compiler x64 Native Tools Command Prompt VS 2017 the above command line led to a successful creation of libuser.dll. 

Please pay attention to specify the correct path on your machine, to the data file VolHeatSource_TP.txt in the file d2InterpolationTable_Windows.c:
  /*  Points to the table file */
  char *filename =  "C:\\PATH_to_FILE\\VolHeatSource_TP.txt";

d2InterpolationTable_Linux.c will interpolate the table data of VolHeatSource_TP.txt and will give them back as result to STAR-CCM+.

In the user code d2InterpolationTable_Windows.c few adjustments compared to the Linux version of the user code (d2InterpolationTable_Linux.c) had to be done:
1.  "ssize_t" should be replaced with "signed" for Windows
2.  getline was re-written for Windows since getline did not work for the compiler mentioned above (x64 Native Tools Command Prompt VS 2017)

After you complied the code please load the library into STAR-CCM+ under Tools > User Code:



User-added image


and apply the User heatSource function to the Volumetric Heat Source of the Region:


User-added image


The Volumetric Heat Source or net emission coefficient provided in this table is per Steradian ([W/m3/sr]), hence the user code will multiply the interpolated table value of net emission coefficient with 4pi to satisfy the unit [W/m3] of Volumetric Heat Source option. In case this is not needed in your case, please remove this multiplication from the user code.

For further informations on user code, compilation to create user library, loading of library and other user coding examples, please see following link:
See User Code chapter of User Guide

KB Article ID# KB000054067_EN_US

Contents

SummaryDetails

Associated Components

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