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
  • Index
  • » Users
  • » schteppe
  • » Profile

Posts

Posts

Feb-19-13 17:01:47
Cannot import FMUs generated from OM, Dymola or FMU-SDK

Hi,
I'm using the nightly builds of OpenModelica on Ubuntu Linux 12.10 and I got an error message while importing a co-simulation FMU. The automatically generated .mo file has a syntax error:

Syntax    14:29:37    /tmp/OpenModelica/OMEdit/spring_cs_st_FMU.mo    86:11-185:19    Parse error: The identifier at start and end are different

Looking into this .mo-file, it seems like a package declaration begins with "package fmiFunctions" and ends with "end fmi1Functions;". Removing the character "1" from the latter fixes it.

I'll be working some more with co-simulation FMUs in the near future, I'll get back to you if I find more bugs.

Stefan

Nov-23-12 11:54:25
Category: Developer

Hi there,
I was playing around with PyFMI and wanted to see if I could use an FMU from OpenModelica in there. There was already an example FMU with a Bouncing Ball provided by PyFMI so I thought, why not just try doing the equivalent in OpenModelica and then run it in my PyFMI simulation master code.

Here is the code for the PyFMI bouncing ball master. Works fine with the PyFMI bouncing ball example FMU.
http://www.jmodelica.org/assimulo_home/ … ative.html

To get the PyFMI bouncing ball FMU, I guess you'll have to download the PyFMI trunk from here:
http://pypi.python.org/pypi/PyFMI
The FMU can be found in PyFMI-1.1/src/pyfmi/examples/files/FMUs/bouncingBall.fmu

I made the OpenModelica version of the bouncing ball example using the code at the following url (works as it should in OpenModelica)
http://proactive.activeeon.com/trunk/Sc … elica.html

Looking at the PyFMI master code (first link) you can see that when a state event occurs (ball hits ground), it calls model.event_update() as indicated by the FMI specification (page 20 of https://svn.modelica.org/fmi/branches/p … v1.0.pdf). It expects the FMU to do something; hopefully the FMU will change the value of eventInfo.iterationConverged so it can continue integration. In the specific Bouncing Ball example, I guess what should happen is that the velocity should change direction and eventInfo.iterationConverged should be set to TRUE.

The problem is that nothing happens when I call model.event_update() from PyFMI on the OpenModelica FMU. After investigating, I found that the eventUpdate() function in the exported FMU doesn't contain any code:

// Used to set the next time event, if any.
void eventUpdate(ModelInstance* comp, fmiEventInfo* eventInfo) {
}

I tried to export several examples from OpenModelica and none of them adds code to this function. Is this really how it should be?
I looked through the rest of the automatically generated c code in the OM FMU and it looks like it contains logic for changing the states at discrete events, however it looks like this logic is never used.

I guess this is how it should be:
https://github.com/mtiller/fmusdk/blob/ … Ball.c#L88

Surprisingly, the code works when importing the OpenModelica FMU into the OpenModelica environment again... I guess I missed something.

I'm using OpenModelica 1.8.1+ (r11859) on Linux 64 bit. I heard that the FMU export is kinda broken in 1.9, that's why I'm still on that one.

Another thing, a bit related... The menus say "Export FMI", "Import FMI" etc. Shouldn't it be FMU instead of FMI? As I understood it, the menu is used to import/export a unit (zip file), not the interface (c header files + xml schema)...

  • Index
  • » Users
  • » schteppe
  • » Profile
You are here: