How to use the code opening feature in Simcenter Amesim

Siemens Experimenter Siemens Experimenter
Siemens Experimenter


Modeling complex phenomenon such as heat transfer or pressure drop sometimes requires using specific correlations representing companies’ know-how in the domain.

The code opening feature allows you replacing Simcenter Amesim standard correlations for heat transfer and pressure drop with your own ones (empirical or from literature) and share them with third parties while ensuring IP protection.

This feature is currently available for some generic heat transfer/pressure drop components and a generic tool was designed to help the user: the dynamic library compiler tool.

Dynamic library compiler tool

The dynamic library compiler tool guides you through the different steps of the external function creation:

  1. Get a source code template,
  2. Edit the code,
  3. Compile the external function,
  4. Get your model ready to use it.



Launching the tool

When available, an “external user-defined function” option appears for heat exchange or pressure drop definition.



Selecting this option leads to a dedicated parameter group display.



This editable parameter group is composed of:

  • a link to launch the dynamic library compiler tool,
  • the user-function path.

Source code loading and saving

The "New" button allows loading and saving the source code skeleton.




A preview of the code is displayed in the tool (read-only).


Source code opening

The "Open" button allows browsing and opening a previously modified external function file.




Source code edition

The “Edit” button allows opening the source code into the preferred '.c' file editor for modification.





Find bellow an example reproducing the standard heat transfer correlation for circular pipe:





Note that the reserved zone for private code allows you focusing on the correlation definition. Inputs/outputs management is already handled by the skeleton.

A large number of available Simcenter Amesim documented public utilities can be directly used. Math expressions are recognized too.


Compilation process

Once modified, the external function has to be compiled to be well interpreted by the component at run time.

The compilation follows three steps:




  • Compiler selection

Select an available compiler on your current installation.

Tips: Prefer using the same compiler as the one set for the sketch compilation.


  • Compilation launch

Use the "Compile" button to launch the complete compilation process.


  • Compilation status

The compilation process appends the log window with every available information.

Tips: Those displayed information are important for compilation failure understanding and code correction.


Apply the created external function

Once created, the dynamic library embedding the external function is to be applied to the component.

Using the "Apply and close" button allows applying the file path to the dynamic library related text parameter.







As illustrated in this article, to create an external user-defined function in Simcenter Amesim, these steps must be followed:

  • Select the “external user-defined function” option
  • Launch the tool
  • Get a “New” template
  • “Edit” the source code
  • Launch the compilation process
  • Apply the created file path to component parameters

This external function definition allows validating the implemented correlation at once and then sharing it. This file can be used into several components on a same sketch.



I had a problem while i use the AMESet to make a component , I want to use the function "tpf_thermo_2" to get the "h, fluid specific enthalpy in the fluid ",but i don't konw what's meaning of "com,comunication index of capacitive element",is it means the "com index at port~"?

in the function "tpf_thermo_2" the "com" is "int ".but in the component the "com index at port~" is "double"?


function1.pngcom index at port 1.pngcom index at port is double.pngfunction need int.png

Siemens Experimenter Siemens Experimenter
Siemens Experimenter

Hi wangxiaobo,


LMS Ameset only enables to declare doubles as port input/output.
This TPF communication index allows to identify every capacity with a unique identifier and accessing properly its properties.


To use those indexes as "int" inputs, we usually cast those variables:
   int comIdx1 = (int)(*com1);

Then use it:

   tpf_thermo_2_(&comIdx1, ...);


PS: sorry for the late answer, no alert/notification was active on this article. I will keep an open eye on it plus force notifications on this article.