OMSimulator icon indicating copy to clipboard operation
OMSimulator copied to clipboard

Improved stability of algebraic loop solutions

Open rruusu opened this issue 2 months ago • 1 comments

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 (https://github.com/OpenModelica/OMSimulator/commit/6d7a397fd7788a7abb5acd648cf3d5cba0c1ae71).

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 #1522 and can be directly merged after it.

Related Issues

  • #1333

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().

rruusu avatar Oct 21 '25 14:10 rruusu