Skip to content

Add new node-type FMU#1017

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

Add new node-type FMU#1017
riteshk001 wants to merge 8 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.

riteshk001 and others added 7 commits June 29, 2026 15:19
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
Signed-off-by: Alexandra <alexandra.bach@eonerc.rwth-aachen.de>
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
@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

@@ -0,0 +1,61 @@
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University

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.

Fix copyright years

Comment thread cmake/FindFMI.cmake
@@ -0,0 +1,26 @@
# CMakeLists.txt.
#
# Author: Ritesh Karki

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.

Please add a contact mail address

@@ -0,0 +1,7 @@
# yaml-language-server: $schema=http://json-schema.org/draft-07/schema
# SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University

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.

Fix copyright years

},
fmu_node = {
type = "fmu"
# Path to fmu file

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.

Suggested change
# Path to fmu file
# Path to the FMU file (.fmu)

# Path to fmu file
fmu_path = "/workspaces/node/fmu_temp/asine.fmu"
fmu_unpack_path = "/workspaces/node/fmu_temp/fmu_asine"
fmu_writefirst = true

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.

Suggested change
fmu_writefirst = true
fmu_write_first = true

type = "file"
# format = "csv"
uri = "/workspaces/node/fmu_temp/output.dat"
out = {

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.

Is this empty section required?

Comment thread lib/nodes/fmu.cpp
callbacks.log_level = jm_log_level_info;
callbacks.context = nullptr;
context = fmi_import_allocate_context(&callbacks);

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 believe at least the callbacks can be initialized in the constructor?

Comment thread lib/nodes/fmu.cpp

struct stat sb;
if (stat(unpack_path, &sb) != 0)
std::cerr << "The unpack path is invalid" << std::endl;

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.

Dont log via iostreams. Use the existing logging infrastructure.

Comment thread lib/nodes/fmu.cpp
return Node::prepare();
}

int FmuNode::check() { return Node::check(); }

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.

Code formatting?

Comment thread lib/nodes/fmu.cpp
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.

@stv0g stv0g added the node::fmi label Jul 9, 2026
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.

3 participants