Hello again,
The time has come and I can’t go any further inside the ongoing GSoC Final Term Evaluation period. Therefore, I shall “lay down the pencil” and submit the work done so far.
Fortunately, I have some new positive results to share.
Successes
At the time of my last post, segfaults in FMI2 calls during simulation were preventing us to have a usable OpenModelica based solution. Gladly, I was able to track down the problem to its root, a fmi2Terminate call, that turned out to be unneeded. That way, now we can run a complete Modelica diagram simulation without crashing Scilab.
Also, I discovered that some OpenModelica forum searches lead me to outdated information, and the default options for model library compilation on which I was relying have been changed. Now, for building a pure Model Exchange library with no dependencies, as originally intended, the generation call inside .mos scripts must receive a few extra arguments, like in:
Finally, comparison between the old modelicac compiler and OpenModelica one shows that the new implementation is able to yield similar results, which is a must, in most of the cases:
(modelicac "Chaos" model simulation)
(omc "Chaos" model simulation)
(modelicac RLC circuit simulation)
(omc RLC circuit simulation)
(modelicac 2nd order model simulation)
(omc 2nd order model model simulation)
(modelicac bouncing ball simulation)
(omc bouncing ball simulation)
Persisting Issues
As seen in the last comparison, I still couldn’t find a way to make the FMI2 wrapper properly handle events such as mechanical collisions, even if they are at least correctly detected.
Another issue that prevented me from testing more Xcos Modelica examples was a bug in generation of flattened (all code combined into a single file) .mo files, where mathematical signs end up duplicated, causing errors in the following compilation, like in the one from “Ball in a platform” demo:
As the error is caused by a third-party tool, OMCompiler, I’ve submitted a bug report for it to be fixed upstream.
Build System Integration
One task that I ended up leaving to the end and didn’t take the time to blog about before is the replacement of modelicac and OCaml sources by OMCompiler ones in Scilab’s repository and build process. For my work I could simply use a minimal system-wide version of OpenModelica, but providing it as a bundled tool is useful for systems where is not easy to get a clean OMCompiler install.
Fortunately, Scilab uses the same autotools build system as the compiler, so integration is facilitated (but still cumbersome enough to make me hope for a CMake solution, which is less powerful but easier to get).
After some modifications to OMCompiler build scripts (which were still looking for unneeded dependencies for minimal omc-no-sim target), I’ve removed modelicac and OCaml entries from Scilab’s ones and added conditional support for our new tool.
- In scilab/configure.ac:
- In scilab/Makefile.in:
Missing Work
Apart from necessary fixes, remaining work for offering a full modelicac replacement involves improving Windows (mainly 64 bits) compatibility (the FMI2 library imports are formed erratically, most probably an upstream problem as well) and better testing the integration of OMCompiler into Scilab’s build process.
Final Thoughts
In the end, some aspects of this project ended up being more troublesome than expected, even if I knew since the beginning that it was a difficult task, and I couldn’t make as much progress as I wanted. Nevertheless, I also admit lack of organization with my time and academic/real life affairs that held me back quite a lot. Shame on me, right ?!
On the other hand, I’m happy with all the learning experience and the fact that I was able to get the OpenModelica integration to work, to some extent. The FMI2 specification, particularly, was a great finding that I surely intend to use for some of my future projects.
From now on it’s all about cleaning up/submitting the code (hosted in a public GitHub repository) and waiting for my mentors evaluation. I’m thankful for all the help they provided me and I’ll respect any decision regarding this final phase.
That’s it for this 2017 GSoC. Thanks one more time for sticking with me over the course of this (northern) summer.
I hope to come back soon with new things to show.