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

FMU eventUpdate() does nothing

FMU eventUpdate() does nothing

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)...

Edited by: schteppe - Nov-23-12 12:39:47

Re: FMU eventUpdate() does nothing

I also experienced the same problem in OpenModelica release 1.8.1 (r13816)

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