Skip to content

Conversation

@rruusu
Copy link

@rruusu rruusu commented Oct 21, 2025

These changes are cherry picked from the branch "work", which includes changes originally made to the master branch in October 2024. I hadn't had the time earlier to rebase my code on the major refactoring done to SystemSC.cpp on 19.11.2024 (6d7a397).

Note:

  • This request is based on the maintenance/v2.1 branch, on which I have been working on.
  • This request includes the changes introduced by Output all CVODE steps #1522 and can be directly merged after it.

Related Issues

Purpose

This request introduces a mechanism that prevents solutions to algebraic loops from intermediate model evaluations by CVODE to lead into the results. It starts the solution of each algebraic loop from values that the input variables had at the start of the solver time step and/or event iteration.

This prevents noise from difference quotient evaluations leaking as a strange form of noise through the inexact algebraic loop solutions. This happens, when the algebraic loop solution for a step change inside CVODE during a difference quotient-based Jacobian matrix estimation ends up being accepted as the solution for an algebraic loop at the end of the step. This results in non-zero, seemingly random changes in system states, even if the inputs variable values for the entire system would indicate a stationary state with zero derivatives.

Approach

At the beginning of each solver step, the values of algebraic loop inputs are stored into a member named initial_guess. They are restored from there before each call to updateInputs().

@CLAassistant
Copy link

CLAassistant commented Oct 21, 2025

CLA assistant check
All committers have signed the CLA.

@rruusu rruusu mentioned this pull request Oct 21, 2025
- Some errors made in commit 4c3fe79.
- All discrete inputs should be updated before going back to continous time mode in any FMU.

refs OpenModelica#1326
Even though the inputs values shouldn't change in continuous time mode, calling setters for such inputs is against the FMI standard and may result in error responses from FMUs.

refs OpenModelica#1326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants