Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transfer variables after initialisation #766

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

kyllingstad
Copy link
Member

@kyllingstad kyllingstad commented Jun 24, 2024

fixed_step_algorithm::initialize() ends by calling simulator::start_simulation(), which, for an FMI 2.0 FMU ends up calling fmi2ExitInitializationMode(). This function is not prohibited from modifying variable values, which means that we must assume that it does. Previously we did not, and this has led to issue #609, which to me looks like a pretty severe correctness issue. Here, I've added get_variables() and set_variables() calls at additional points in the call sequence of a slave_simulator() where variable values may have changed, and I've added a variable transfer at the end of fixed_step_algorithm::initialize().

I've run the quarter-truck case to verify that these changes actually do fix #609:

issue-609-before-after

The PR also fixes #762 (in the same way that PR #765 does – they have a common change in slave_simulator.cpp).

`fixed_step_algorithm::initialize()` ends by calling
`simulator::start_simulation()`, which, for an FMI 2.0 FMU ends up
calling `fmi2ExitInitializationMode()`. This function is not prohibited from
modifying variable values, which means that we must assume that it does.
Previously we did not, which led to issue #609, which to me looks like a
pretty severe correctness issue. Here, I've added `get_variables()` and
`set_variables()` calls at additional points in the call sequence of a
`slave_simulator()` where variable values may be needed/changed, and
I've added a variable transfer at the end of
`fixed_step_algorithm::initialize()`.

Closes #609.
@kyllingstad kyllingstad added the bug Something isn't working label Jun 24, 2024
@kyllingstad kyllingstad self-assigned this Jun 24, 2024
@kyllingstad kyllingstad changed the title Transfer variables after setup and initialisation Transfer variables after initialisation Jun 24, 2024
@kyllingstad kyllingstad merged commit 02ca778 into master Jun 24, 2024
20 checks passed
@kyllingstad kyllingstad deleted the bugfix/609-transfer-vars-during-init branch June 24, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants