Add new FMU node-type - #1017
Conversation
stv0g
left a comment
There was a problem hiding this comment.
Nice work. Its great to see FMI support landing in VILLAS
| while (hasInputs && (writingTurn || currentTime >= stopTime)) { | ||
| pthread_cond_wait(&cv, &mutex); | ||
| } | ||
| double targetTime = currentTime + stepSize; |
There was a problem hiding this comment.
I think this not executing the FMU using a real-time scale?
Can you elaborate a bit how this node-type is indentend to be used?
E.g. does it expect periodic input data to proceed its internal time?
How does the internal time related to the real time?
Do we already have a PR for the node-type? I think this deserves some explanation.
There was a problem hiding this comment.
Right now, it needs periodic input data. My plan would be to include real-time later
pjungkamp
left a comment
There was a problem hiding this comment.
I really like the general coding style, it's clean and very readable. Could you please fix the commit such that you have one commit that introduces the FMU node type. You have two unrelated changes changing the capitalization of writing_turn in opendss.{hpp,cpp} which should not be part of that commit. You can either move those changes into their commit or drop them.
|
As per the new Contribution guidelines, could you please briefly state if LLMs have been used for this contribution? |
|
The main logic was written by Jitpanu before. Edit: Sorry, I just saw the new Contribution guidelines regarding the use of LLMs,
|
|
Also, clang-format seems to format functions which have just a single line of body by rewriting it into a single line. I think that is why every time I ran clang-format, it would reformat the function body. I think that's why the code formatting looked different to what you expected. For the integration test, I did not know where to place the fmu file in the repository, otherwise the intergration test itself is working. But once I add the fmu file, I can remove the "Test not ready" comment from the integration test. |
pjungkamp
left a comment
There was a problem hiding this comment.
Just some more smaller nitpicks here.
|
I'm happy with with the code. Run integration testOn the topic of including an FMU in this repository for integration testing:
I see an on the topic of binary blobsWe're linking our Nix builds against OpalRT's binary OpalOrchestra blobs, so I think that a binary FMU blob might be fine here, even if I don't like it. Binary blobs for testing are the way that the infamous I'd still like to see a way to build the FMU in a binary-reproducible fashion from source, but that tends to be rather hard. @stv0g We've recently discussed some better modelica/FMU tooling, do you have any good ideas here? out of curiosityI've taken a little more time to look into what the FMU actually does and have a few more questions. I don't want these to block the merge, you also don't have to change anything. Just some questions to satisfy my curiosity on some of your choices in the implementation.
|
|
The asine.fmu file is a simple fmu model that I exported from a Simulink model of arcsine. I wanted to have a simple model to test the implementation and later include it in the integration test for the node. But there are also reference models that are given by Modelica (Reference FMUs) and licensed under BSD-2. To answer your questions regarding the implementation:
|
|
I am a little confused with regards to variable naming conventions, the guidelines say that camel case is required for naming variables, functions and types. But across many cpp/hpp files, snake case is used instead. Which one should I stick to? :) |
I know that pain. The old C code is pretty much entirely snake_case, so we've got a ton of free functions that are snake_case. We're also using encouraging use of the C++ standard library which also is entirely snake_case. Other libraries like I think that the current compromise is something like:
Don't use nested classes or type aliases unless it's really necessary. Note that we can't enforce any of this statically. Take e.g. a And of course every dependency adds another naming convention into the mix... |
The main limitations of a Hook compared to a loopback-style node like you have implemented here are:
Using a node instead of a hook lifts these restrictions but forces the user to use 2 paths in VILLASnode, one for the input, one for the output side. Each path is a separate thread and thus adds extra synchronization overhead. The current capabilities of the FMU node could well have been implemented as a Hook (as far as I can tell) but I don't know whether the expected advancements for e.g. model exchange and proper simulation time support would clash with the restrictions that a Hook imposes. |
Can you check the MathWorks/Simulink documentation about the licensing for FMUs exported from Simulink? I've never looked those that before. A Modelica BSD-2 Clause FMU should be compatible with our Apache-2.0 license. |
|
I believe we should go with one of the Modelica Reference FMUs. The Statespace one could be a good pick: https://github.com/modelica/Reference-FMUs/tree/main/StateSpace They are distributed as C Code which we could easily compile into an FMU without depending on external tools like Simulink or OpenModelica. At the same time we have a good guarantee that they are Standard Compliant. We could just built them from source or integrate them as a binary blob which we download. I would be open to both approaches. But I agree with Philipp, that an integration test should be there. |
|
I wanted to add the Statespace model too, but the outputs happen to be 3 element arrays which as of now are not supported by VILLAS if I am not wrong. |
|
Well, an FMU is just a ZIP file and thus can't be annotated using comments. If we assume a file named You can check the reuse.software website for the specification of how you should annotate uncommentable files. |
pjungkamp
left a comment
There was a problem hiding this comment.
You're close! You'll have to run clang-format once more and fix your commit messages. They have a space between the type and the scope of the commit. Use type(scope): description instead of type (scope): description.
There was a problem hiding this comment.
You don't need C style comments here. Just put the SPDX headers there. Nothing else.
On a related note: Are you the author? I thought the FMU was a reference from Modelica sources.
There was a problem hiding this comment.
Oh no, I did not make any modifications to the FMU, I was testing the license locally and forgot to remove it in the end. I have fixed it now. :)
Signed-off-by: Ritesh.K <riteshkarki@tutamail.com>
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Signed-off-by: Ritesh.K <riteshkarki@tutamail.com>
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
Co-authored-by: Philipp Jungkamp <philipp.jungkamp@rwth-aachen.de> Signed-off-by: al3xa23 <140614263+al3xa23@users.noreply.github.com>
@al3xa23
New node type implementation based on Functional Mock-up Interface (FMI 3.0). Currently supports Co-Simulation. Functionality can be further extended to include Model Exchange simulation too.