FMU export from OpenModelica to Python (FMPy)

154 Views Asked by At

I'm totally new to Function Mock-up Units (FMUs), but my objective is to export very basic FMUs from OpenModelica 1.22.1 and to open them in Python using FMPy (as a first step), I'm using FMPy's GUI.

I tried to export the simple pendulum as an FMU 2.0 in co-simulation. I'm running this on a machine with Windows x64, for this I'm using Docker. But when I try to run the FMU in python I always get this error: "Failed to load shared library"

C:\...\Temp\tmpbwoddm6i\binaries\win64\FMU_pendulum.dll. Could not find module C:\...\Temp\tmpbwoddm6i\binaries\win64\FMU_pendulum.dll (or one of its dependencies)

I've tried to change most of the given parameter for FMU exportation in OMEdit but it doesn't seem to change anything. Thanks for your answers.

2

There are 2 best solutions below

0
Léo_Schmider On

thanks for your answer. I have used docker in case I might want to use this same file for win32, but no linux is involved here. I have exported the file right click on it in OMEdit and then selected export -> FMU. Opened the file in FMPy GUI and when I push the play button the error pops up.

Modelica code OpenModelica FMU export parameters

4
AnHeuermann On

You managed to find an OpenModelica bug #12013

Basically the default value for some flag isn't the one it should be.

Workaround

Set compiler flag --fmuRuntimeDepends=modelica (Tools->Options->Simulation->Additonal Translation Flags) to add runtime dependencies like the missing pthreads.dll to your Windows FMU. If you get an error message about your CMake version being too low update OpenModelica to the latest release or the nightly version. We recently updated the CMake executable we ship with OpenModelica.