Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

OM FMUs don't run in Simulilnk

OM FMUs don't run in Simulilnk

Hello,

I have created a FMU with OpenModelica and exported it into Simulink. To import the model into Simulink I used FMIKit for Simulink, which was able to load it, howhever when the project is executed, I get the following message:

Error in 'test/filename' while executing C MEX S-function 'sfun_fmurun', (mdlStart), at time 0.0.

Unexpected Standard exception from MEX file.
What() is:Could not load shared library


I imported the model back into OM and it runs, so I'm hesitating the problem is I lack to include another library or dll in order to run the model in Simulink.

Any hint of what I'm missing?

Thanks in advice,
Jorge

Re: OM FMUs don't run in Simulilnk

What Simulink do you have, the 32 bit or 64 bit?
What version of OpenModelica do you have?
Note that the 64 bit makes a 64 bit FMU the 32 bit makes a 32 bit FMU.

Re: OM FMUs don't run in Simulilnk

Sorry for the missing information.
I have used OM version 1.11.0 and the nightly build 1.12.0 for 64bits to create the FMU and Simulink version 8.7 for MATLAB R2016a also with 64 bits.

Thanks,
Jorge

Re: OM FMUs don't run in Simulilnk

Hm, it should work but it might be that Simulink does not load the FMU main dll in such a way that the extra dlls that we have in the FMU are found (see below).
You could try to add to PATH these paths (at the end): %OPENMODELICAHOME%/bin/;%OPENMODELICAHOME%/tools/msys/mingw64/bin; before starting Simulink.

The OM FMUs dll needs to be loaded with altered search path:
https://msdn.microsoft.com/en-us/librar … s.85).aspx
Alternate Search Order for Windows Store apps
If a module changes the standard search order by calling the LoadLibraryEx function with LOAD_WITH_ALTERED_SEARCH_PATH, the system searches the directory the specified module was loaded from instead of the directory of the calling process.

Re: OM FMUs don't run in Simulilnk

Thanks for your answer, the problem is solved now.

Cheers,
Jorge

Re: OM FMUs don't run in Simulilnk

I'm glad it worked.

I wouldn't say the problem is solved because if you need to change the PATH and you need OM to be able to run the FMUs you cannot send the FMUs to other people that do not have OM installed (and your path settings).

Maybe you can report this to Simulink to tell them to load the dll with the flag given above as the FMU should not need anything from the running process directory but is arguable that more needed dlls are where the FMU is unpacked.

Re: OM FMUs don't run in Simulilnk

In my opinion this is neither a problem of Simulink nor of the FMI-Kit, but of the exported FMU from OpenModelica.
I have an example of an FMU with a dependency on an additicional dll that can be simulated with FMIkit in Simulink and many other tools. On request I can provide it to the OpenModelica developers with source code as an example how to implement this.

I would recomment that OpenModelica participates at the FMI Cross Check (https://www.fmi-standard.org/tools) by submitting FMUs, then such porblems would be detected. What I see there currenty: only OpenModelica reports successful simulation of FMUs exported by OpenModelica (FMI 1.0)

Re: OM FMUs don't run in Simulilnk

cbertsch wrote:


In my opinion this is neither a problem of Simulink nor of the FMI-Kit, but of the exported FMU from OpenModelica.
I have an example of an FMU with a dependency on an additicional dll that can be simulated with FMIkit in Simulink and many other tools. On request I can provide it to the OpenModelica developers with source code as an example how to implement this.

I would recomment that OpenModelica participates at the FMI Cross Check (https://www.fmi-standard.org/tools) by submitting FMUs, then such porblems would be detected. What I see there currenty: only OpenModelica reports successful simulation of FMUs exported by OpenModelica (FMI 1.0)

We are in the process of fixing this in several ways:
1. produce just one DLL
2. make the main dll load the dependencies
You can also send us your code, if you want (Adrian Pop: http://www.ida.liu.se/~adrpo33/ or to OpenModelica@ida.liu.se)
to see if we are on the right track.

We are also working on providing more FMUs for FMI Cross Check and we will check them with other tools as well.
By default we are checking them with the fmuChecker but that works fine.

Re: OM FMUs don't run in Simulilnk

adrpo wrote:

We are in the process of fixing this in several ways:
1. produce just one DLL
2. make the main dll load the dependencies
You can also send us your code, if you want (Adrian Pop: http://www.ida.liu.se/~adrpo33/ or to OpenModelica@ida.liu.se)
to see if we are on the right track.

We are also working on providing more FMUs for FMI Cross Check and we will check them with other tools as well.
By default we are checking them with the fmuChecker but that works fine.

This sounds good! I have sent you the example FMU calling an external DLL.
When you run the compliance checker on your FMUs: Do you do this on a PC without OpenModelica being installed?

Re: OM FMUs don't run in Simulilnk

cbertsch wrote:


adrpo wrote:

We are in the process of fixing this in several ways:
1. produce just one DLL
2. make the main dll load the dependencies
You can also send us your code, if you want (Adrian Pop: http://www.ida.liu.se/~adrpo33/ or to OpenModelica@ida.liu.se)
to see if we are on the right track.

We are also working on providing more FMUs for FMI Cross Check and we will check them with other tools as well.
By default we are checking them with the fmuChecker but that works fine.

This sounds good! I have sent you the example FMU calling an external DLL.
When you run the compliance checker on your FMUs: Do you do this on a PC without OpenModelica being installed?

Yes. No OM installed, and even if is installed we do not put anything in the path.
I think that the FMIL library loads the DLL with altered search path, that's why it works fine.

Re: OM FMUs don't run in Simulilnk

I would recomment that OpenModelica participates at the FMI Cross Check (https://www.fmi-standard.org/tools) by submitting FMUs, then such porblems would be detected. What I see there currenty: only OpenModelica reports successful simulation of FMUs exported by OpenModelica (FMI 1.0)

It's not only OpenModelica able to import the OM 1.9.1 win32 FMUs, but 14 different tools...

We have test FMUs for: win32, win64, linux32, linux64, arm-linux-gnueabi, darwin64 and C-code for FMI 2.0 ME and CS using OpenModelica 1.11. As far as I know, no other vendor tested any of them (and we didn't upload new FMUs for FMI 1.0 since FMI 1.0 doesn't really work for numerical integration).

You don't get entries in the main page unless people actually test things, and why would a commercial vendor test a free software and thus give advertisement to it if they only need to test against 3 tools to get their "import" stamp? (We mainly do linux64 export and no import in OpenModelica itself; only 3 tools tested linux64 import and none of them on a recent OM FMU..).

When the OM FMI simulator is available, it will be a separate tool in the list and we'll setup scripts to try it against many tools.

Re: OM FMUs don't run in Simulilnk

sjoelund.se wrote:

It's not only OpenModelica able to import the OM 1.9.1 win32 FMUs, but 14 different tools...

You are right; sorry I confused columns and rows of the cross-check table. But that means that there have been submitted no test results of importing FMUs in OpenModelica except for FMUs exported from OpenModelica, correct?


I have tested importing FMUs in OpenModelica (on a Windows platform; I know that you mainly develop on Linux) for every new release in the last years, and faced many problems: almost everything failed. I think, that participating in the Cross Check also for the import of FMUs in OpenModelica would be very beneficial; otherwise you should not offer FMI import on Windows platforms.

sjoelund.se wrote:

As far as I know, no other vendor tested any of them

sjoelund.se wrote:

and why would a commercial vendor test a free software and thus give advertisement to it if they only need to test against 3 tools to get their "import" stamp?

I agree that it would be much better if more tools would include FMUs from OpenModelica in their cross check, and report results more often.
However, I do not see  signs of systematic "discrimination" of FMUs from OpenModelica:
e.g. on  https://www.fmi-standard.org/results_FM … ange_win64 two out of three tools that have submitted test results after the submission of OM exported FMUs have tested those. (When a third tool has tested your FMUs for this platform, you will get the green button for the export.)
On https://www.fmi-standard.org/results_FM … ge_linux64 it is one out of one as well as for https://www.fmi-standard.org/results_FM … n_linux64; for https://www.fmi-standard.org/results_FM … tion_win64 it is two out of two.


There are 0 guests and 0 other users also viewing this topic
You are here: