Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
Related Issues
Purpose
This set of changes improves the behavior of CVODE in strongly coupled systems that include algebraic loops.
It also includes a change that allows the KINSol solver to maintain its own Jacobian estimate between successive solutions, which reduces the number of necessary iterations for algebraic loop solutions. This can result in a significant drop in simulation time.
Approach
It calculates a dynamic tolerance value that attempts to take into account the size of the difference quotient steps taken by CVODE, which can be extremely small. If the algebraic loops are not solved to sufficient accuracy, the Jacobian estimates achieved by CVODE will be bad, which directly affects both the simulation time and the accuracy of the achieved results.
This approach is still somewhat heuristic. It is difficult to estimate what level of algebraic loop tolerance would be sufficient for a stable Jacobian estimate by CVODE, even if the difference quotient step sizes were known exactly.
It might be better to just always use a near zero tolerance for the algebraic loops. The performance hit from this is not as great, when KINSol is allowed to keep its earlier Jacobian estimates.
The usefulness of these changes are improved by changes included in: