modelExchange

Test model for exchange function

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

This example calls various functions in the Python module testFunctions.py. It tests whether arguments and return values are passed correctly. The functions in testFunctions.py are very simple in order to test whether they compute correctly, and whether the data conversion between Modelica and Python is implemented correctly. Each call to Python is followed by an assert statement which terminates the simulation if the return value is different from the expected value.

Parameters

TypeNameDefaultDescription
BooleanpassPythonObjectfalseSet to true if the Python function returns and receives an object, see User's Guide
Real[1]yR1Real function value
Integer[1]yI1Integer function value
Real[2]yR2Real function value
Integer[2]yI2Integer function value

Contents

NameDescription
MprotectedClass that contains the Python object

Revisions

  • September 19, 2025, by Michael Wetter:
    Updated to Python 3.12.
  • January 10, 2022, by Michael Wetter:
    Updated to Python 3.8.
  • December 11, 2021, by Michael Wetter:
    Changed implementation to assigning parameters as opposed to variables because the assignment is made through impure function calls. This is for MSL 4.0.0.
  • December 10, 2021, by Michael Wetter:
    Removed call to impure function removeFile. This removal is required for MSL 4.0.0.
  • April 10, 2020, by Jianjun Hu and Michael Wetter:
    Updated to Python 3.6.
  • February 2, 2016, by Michael Wetter:
    Changed constant arguments of exchange function from int to double. This is required for OpenModelica.
  • January 31, 2013, by Michael Wetter:
    First implementation.