Skip to content

Add new FMU node-type - #1017

Open
riteshk001 wants to merge 4 commits into
masterfrom
node-fmu
Open

Add new FMU node-type#1017
riteshk001 wants to merge 4 commits into
masterfrom
node-fmu

Conversation

@riteshk001

Copy link
Copy Markdown
Collaborator

@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.

@stv0g stv0g changed the title Add new node type FMU. Add new node-type FMU Jul 9, 2026

@stv0g stv0g left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. Its great to see FMI support landing in VILLAS

Comment thread etc/examples/nodes/fmu.conf Outdated
Comment thread cmake/FindFMI.cmake Outdated
Comment thread doc/openapi/components/schemas/config/nodes/_fmu.yaml Outdated
Comment thread etc/examples/nodes/fmu.conf Outdated
Comment thread etc/examples/nodes/fmu.conf Outdated
Comment thread etc/examples/nodes/fmu.conf Outdated
Comment thread lib/nodes/fmu.cpp Outdated
Comment thread lib/nodes/fmu.cpp Outdated
Comment thread lib/nodes/fmu.cpp Outdated
Comment thread lib/nodes/fmu.cpp Outdated
while (hasInputs && (writingTurn || currentTime >= stopTime)) {
pthread_cond_wait(&cv, &mutex);
}
double targetTime = currentTime + stepSize;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, it needs periodic input data. My plan would be to include real-time later

@stv0g stv0g added the node::fmi label Jul 9, 2026
@al3xa23
al3xa23 requested a review from pjungkamp July 29, 2026 07:16

@pjungkamp pjungkamp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread doc/openapi/components/schemas/config/nodes/fmu.yaml Outdated
Comment thread doc/openapi/components/schemas/config/nodes/fmu.yaml Outdated
Comment thread doc/openapi/components/schemas/config/nodes/fmu.yaml Outdated
Comment thread doc/openapi/components/schemas/config/nodes/fmu.yaml Outdated
Comment thread etc/examples/nodes/fmu.conf Outdated
Comment thread include/villas/nodes/fmu.hpp Outdated
Comment thread lib/nodes/fmu.cpp Outdated
Comment thread lib/nodes/fmu.cpp Outdated
Comment thread lib/nodes/fmu.cpp Outdated
Comment thread lib/nodes/fmu.cpp Outdated
@stv0g stv0g changed the title Add new node-type FMU Add new FMU node-type Jul 29, 2026
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
@stv0g

stv0g commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

As per the new Contribution guidelines, could you please briefly state if LLMs have been used for this contribution?

@riteshk001

riteshk001 commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

The main logic was written by Jitpanu before. I modified some parts of the code myself and but I also used an LLM mainly to clean and format the code.

Edit: Sorry, I just saw the new Contribution guidelines regarding the use of LLMs,

  • Cursor's LLM was used for formatting and cleaning the code in fmu.cpp.
  • The same tool was also used to reformat the file to ensure variable naming adhered to the coding standards mentioned in the documentation.

@riteshk001

riteshk001 commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

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 pjungkamp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some more smaller nitpicks here.

Comment thread lib/nodes/fmu.cpp Outdated
Comment thread packaging/deps.sh Outdated
Comment thread packaging/deps.sh Outdated
Comment thread lib/nodes/fmu.cpp Outdated
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants