Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#6002 closed defect (fixed)

Undefined variable units when using FMUs

Reported by: marwa.maghnie@… Owned by: Lennart Ochel
Priority: critical Milestone: 1.16.0
Component: FMI Version:
Keywords: fmpy Cc:

Description

Dear OM team,

When using FMUs (exported with OpenModelica only) within python code and the FMPy library, an error blocks the code run, similar to the one shown here: https://github.com/CATIA-Systems/FMPy/issues/113 .

Any help is appreciated.

Best,
Marwa

Attachments (6)

OM_FMI.PNG (57.3 KB ) - added by anonymous 4 years ago.
FMI settings used when exporting FMUs from OMC
AixLib.Fluid.FMI.ExportContainers.Examples.FMUs.ThermalZone.fmu (10.8 MB ) - added by anonymous 4 years ago.
OMC FMU
AixLib_Fluid_FMI_ExportContainers_Examples_FMUs_ThermalZone.fmu (1.1 MB ) - added by anonymous 4 years ago.
Dymola FMU
FMU_test.py (360 bytes ) - added by anonymous 4 years ago.
Test that triggers error message with OMC-exported FMU
OMC_FMU_log.txt (2.2 KB ) - added by anonymous 4 years ago.
Output after running "FMU_test.py" with OMC FMU
Dymola_FMU_log.txt (3.6 KB ) - added by anonymous 4 years ago.
Output after running "FMU_test.py" with Dymola FMU

Change History (20)

comment:1 by Francesco Casella, 4 years ago

Milestone: Future1.16.0

@marwa, in general it would be really helpful if you could attach one or more minimal working examples to this ticket, that allow us to reproduce the problem. Without a concrete example it is often hard to figure out what's wrong and fix it.

That said, #5845 or #5920 may have fixed that already. Which version of OMC are you using? Could you try the latest nightly build?

Thanks!

by anonymous, 4 years ago

Attachment: OM_FMI.PNG added

FMI settings used when exporting FMUs from OMC

by anonymous, 4 years ago

Attachment: FMU_test.py added

Test that triggers error message with OMC-exported FMU

by anonymous, 4 years ago

Attachment: OMC_FMU_log.txt added

Output after running "FMU_test.py" with OMC FMU

by anonymous, 4 years ago

Attachment: Dymola_FMU_log.txt added

Output after running "FMU_test.py" with Dymola FMU

comment:2 by marwa, 4 years ago

Thanks for the lightening fast reply, casella!

I was using OMC 1.14 and switched to 1.16 as recommended in your links, but the error message still showed up. However, now a different unit is shown as undefined.

Having said that, for a MWE, we can export this AixLib model as an FMU (attached), then run "FMU_test.py" to get the error message shown in "OMC_FMU_log.txt". To give the whole picture, "OMC_FMI.PNG" shows the FMI settings used. (It could be that I missed something there?)

A Dymola FMU exported from the same AixLib model and the output from running the Python script with it are also attached to show how an ideal run could look like.

Thanks for your time :-)

comment:3 by Francesco Casella, 4 years ago

Priority: highcritical

@lochel, what do you think of this?

comment:4 by Lennart Ochel, 4 years ago

Status: newaccepted

I will take care of the issue. There are two problems (in OpenModelica):

  1. Unknown units, in this case bar, shouldn't be exported at all.
  2. The unit bar shouldn't be unknown.

comment:5 by Lennart Ochel, 4 years ago

comment:6 by Francesco Casella, 4 years ago

Thanks!

comment:7 by Francesco Casella, 4 years ago

Is this related to #4608, perhaps?

comment:8 by Lennart Ochel, 4 years ago

No, this one was FMI specific. #4608 seems to fail much earlier in the compiler.

in reply to:  4 comment:9 by Lennart Ochel, 4 years ago

Replying to lochel:

I will take care of the issue. There are two problems (in OpenModelica):

  1. Unknown units, in this case bar, shouldn't be exported at all.
  2. The unit bar shouldn't be unknown.

I've been wrong with (1). Unknown units should be exported in the UnitDefinitions but obviously without a BaseUnit representation.

comment:10 by Lennart Ochel, 4 years ago

Resolution: fixed
Status: acceptedclosed

I pushed the changes to the master and it will be available in the next nightly build. Please reopen this ticket if the problem isn't solved for you.

comment:11 by marwa, 4 years ago

Again, thank you very much for the quick reponse and fix!

I can't test it yet because the models I'm using still operate with Modelica 3.2.3. However, hope that in the meantime other users could benefit from this OMC update. :-)

comment:12 by Martin Sjölund, 4 years ago

You can load Modelica 3.2.3 in any number of OpenModelica versions, including the nightly builds. If you have multiple versions of Modelica available, you can change from "default" to "3.2.3" in OMEdit to have it loaded automatically on startup.

comment:13 by Francesco Casella, 4 years ago

Even better, just install 1.16.0-dev.03, which does not include MSL 4.0.0, which we still don't fully support. In fact, it's not even been formally approved by the Modelica Association yet.

comment:14 by marwa, 4 years ago

Thanks so much for the helpful suggestions! :-)
I can confirm that it works with both Windows and Linux OMCs. 👍

Note: See TracTickets for help on using tickets.