Closed GiuseppeR96 closed 1 year ago
Ciao @GiuseppeR96 ,
While I cannot talk for the Spawn development team, I can tell you how we compile our models. If I cannot help you solve this issue, then I suggest you reach our to the Spawn team.
We do not compile the FMU directly from the Modelica IDE, instead we use Michael Wetter's Docker image with pyModelica installed to compile and export the FMU.
If you are familiar with Docker, I suggest you create a container based on michaelwetter/ubuntu-1804_jmodelica_trunk
. If you want to see an example of a Dockerfile used for creating such a container, see this file, found in the testing folder.
Within the docker container, you can run a Python script with the following:
from pymodelica import compile_fmu
fmu_path = compile_fmu(model_path, file_name)
This should save a compiled FMU in the Docker container. There are simple functions for copying from/to docker containers, you can find this information online pretty easily. So in summary, you would need to:
michaelwetter/ubuntu-1804_jmodelica_trunk
Having Docker in the way seems cumbersome, but it is quite easy to be honest. The reason we use this Docker container is because it is one of the last available sources for JModelica, and Spawn usually compiles well with JModelica.
In our case, since we need some extra steps during compilation, we are doing things a little differently. I write it here in case you find something useful for your application:
parsing/parser.py
parsing/parser.py
calls, in turn, the compile_fmu function from pyModelica that I described in the code snippet above. This is the only thing you would need in your particular application.Last note: we were using the Modelica Buildings Library v8.0.0 to build our Spawn models, but now v9.0.0 is out. You should consider updating if you have a chance. Spawn is being actively developed, and I believe it now runs on Windows systems too.
Let me know if you have other questions on compiling Spawn FMUs, or on setting the Docker image up. Cordiali saluti Thibault
I will reopen this issue if there is activity on this thread
Hi, I'd like to run a Spawn example from my own master Python code using pyFMI. I ask OpenModelica to extract an FMU from a Buildings Library model (e.g.
Buildings.ThermalZones.EnergyPlus.Examples.SingleFamilyHouse.AirHeating
), then I try to load the model on Python:model = load_fmu("AirHeating.fmu")
such FMU will not work on Python, yielding this error message:I also tried with FMpy:
This code yields this error message:
Exception: Failed to load shared library C:\ ...\AppData\Local\Temp\tmpmysxzg5z\binaries\win64\FMU_model.dll. Could not find module 'C:\Users\...\AppData\Local\Temp\tmpmysxzg5z\binaries\win64\FMU_model.dll' (or one of its dependencies). Try using the full path with constructor syntax.
I tried inspecting an FMU from the MODRLC-actb project that uses spawn:https://github.com/henze-research-group/MODRLC/tree/actb/testcases/spawnrefsmalloffice/models
and I noticed that the modelDescription file includes explicit references to the spawn exe, namely:which are absent in the FMU that I extracted with OpenModelica. Besides, there are differences in the binaries and resouces folders between the forementioned example and my own, OpenModelica generated FMU. May this be relevant?
It is worth noticing that:
Details on software and setup: • OS: Windows 10 • OpenModelica v1.19.0-dev.beta1 (64-bit) and OpenModelica v1.20.0-dev-327-g42e1d1bbb6 (64-bit) (attempted with both version) • FMI version: 2.0 • Python 3.8