Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not simulate fmu file generated by OpenModelica #51

Closed
fa1247 opened this issue Oct 18, 2018 · 8 comments
Closed

Can not simulate fmu file generated by OpenModelica #51

fa1247 opened this issue Oct 18, 2018 · 8 comments

Comments

@fa1247
Copy link

fa1247 commented Oct 18, 2018

Hi,

I'm trying to control the simulation progress with Python, so I generated a fmu file of StableBouncingBall and import with FMPy. When I run simulate_fmu, I got an error "The current platform (win32) is not supported by the FMU". Then I read some lines of source file and added "use_source_code=True", hoping that FMPy will simulate with source-code. Then I got another error "No source files specified in the model description." But I unziped the fmu file and found .c and .h source file in the model.

The fmu file works fine in Matlab 2018 for both Co-Simulation and Model Exchange. Is there any way to solve this problem?

Best regards,
XY Fan

@hyumo
Copy link

hyumo commented Oct 18, 2018

In order to run the FMU in a certain platform, it must be exported with the corresponding platform binary or with source code (optional). Details could be found here in the FMI standard: https://fmi-standard.org/docs/2.0.1-develop/#_fmu_distribution

If you are using windows, I guess it is just because the FMU is only exported with 64 bit binary without source code, however, your python environment is in 32 bit. See a solved issue #49

Disclaimer: I am not a developer of fmpy

@chrbertsch
Copy link

(generally for such general questions on FMI, Stack overflow might be a better place to ask)
Please provide more information:

  • Which versions of tools are you using (32bit/64bit)?
  • Could you please attach the FMU?
  • Do you use a ME/CS FMU? FMI 1.0 or 2.0?

The error message looks like you are trying to import an FMU with 64bit binaries only into a 32bit Python/fmpy.

In order to support import of source Code FMUs, the tools need to define the files to be compiled, see p 67 of the FMI 2.0 specification https://svn.modelica.org/fmi/branches/public/specifications/v2.0/FMI_for_ModelExchange_and_CoSimulation_v2.0.pdf . This does not seem to be the case in the case of the FMU exported by OpenModelica. fmpy only claims to run source code FMUs exported from Dymola, but might to so also for FMUs by other tools if they provide the necessary information.

Disclaimer: I am not a developer of fmpy

@fa1247
Copy link
Author

fa1247 commented Oct 18, 2018

Thank you for your reply. The FMU is exported with source code. In the dump(fmu), it said the platform is c-code and I can see all the .c and .h file within the fmu file. If the FMU is exported with binary I think there should be a dll file but there isn't.
image
image

@t-sommer
Copy link
Contributor

The dump() function determines the supported platforms based on the contents of the FMU. If the source files are not specified in the modelDescription.xml it's not a valid C-code FMU.

See FMI 2.0 Spec, 2.3 FMU Distribution:

All C source file names that need to be defined in a compiler directive have to be defined in the xml-file under structure and

The easiest way to simulate the FMU is to install a 64-bit Python, e.g. Anaconda.

@fa1247
Copy link
Author

fa1247 commented Oct 21, 2018

Thank you for your replies.
I followed your instructions but still failed.

My test environment is as follows:
Lenevo laptop;
Windows 10 1809 64-bit;
Python 3.6.5 32-bit (Anaconda) and Python 3.6.5 64-bit(Miniconda) installed in different folders;
FMU file generated from the same model by openmodelica 32-bit and 64-bit.

As the ticket says. FMU file should be the same-bit as the software that generating it.

I have tried all four combinations (32FMU-32Python; 32-64; 64-64; 64-32 ). Every time I got the same error "Exception: The current platform (win32/64) is not supported by the FMU."

I think 64-bit FMU generated by 64-bit openmodelica should work in 64-bit Python. Maybe there is some dissonance between openmodelica and FMPy.

These are two FMU files, I don't how to share them efficiently.
FMU files google drive

@chrbertsch
Copy link

The FMUs you uploaded to not contain a "binaries" folder, so the do not contain any binaries for win32 or win64 nor any other binaries. This is a problem of creating FMUs from OpenModelica, not of importing and simulating them with fmpy.

@t-sommer
Copy link
Contributor

You claim that

The fmu file works fine in Matlab 2018

Did you actually test it with the files you provided?

@fa1247
Copy link
Author

fa1247 commented Oct 27, 2018

Sorry for the wrong report bug.

I installed too many versions of nigntly build OpenModelica during the test. In a previous version, the FMU export feature works fine. But after a point in time, this feature broke and the files generated are broken too. It's a bug in OM. I reinstall the stable 64-bit version OM and everything works.

Thank you again for your precious time.

PS: the URL in download_test_file() seems outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants