Skip to content

Add option for IDA consistent initial conditions mode - #542

Open
Steven-Roberts wants to merge 7 commits into
developfrom
steven/ida-init
Open

Add option for IDA consistent initial conditions mode#542
Steven-Roberts wants to merge 7 commits into
developfrom
steven/ida-init

Conversation

@Steven-Roberts

@Steven-Roberts Steven-Roberts commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Description

As discussed Monday, this adds the option to pick between IDA's two modes for computing consistent initial conditions.

Proposed changes

This add Ida::setConsistentICType(IdaConsistentICType consistent_ic_type) and a corresponding consistent_ic_type JSON property to set the mode. It keeps the bool findConsistent argument to Ida::initializeSimulation, so it is still possible to skip the solve.

Checklist

  • All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • The CHANGELOG.md has been updated to reflect the changes. If this is a minor PR that is part of a larger fix already included in the file, state so.

@Steven-Roberts
Steven-Roberts requested a review from pelesh August 18, 2026 20:59
@nkoukpaizan nkoukpaizan added the enhancement New feature or request label Aug 18, 2026

@nkoukpaizan nkoukpaizan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me in terms of providing the option to set the initialization type. I am not sure that if addresses the underlying question about steady-state initialization.

Comment thread tests/UnitTests/Solver/Dynamic/IdaTests.hpp Outdated
Model::ConsistentICTypeEvaluator<ScalarT, IdxT> model;

Ida<ScalarT, IdxT> ida(&model);
ida.setConsistentICType(AnalysisManager::Sundials::IdaConsistentICType::YA_YDP);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works well to make yp consistent with the equations. If I understood @pelesh's plan correctly, the question is whether we can use IdaConsistentICType::Y to solve for inconsistent y while fixing yp=0 (for a system with differential equations that admits a steady state solution).

I tried to use IdaConsistentICType::Y for the Texas test case, unsuccessfully. @Steven-Roberts My understanding was that this would not work, but is it expected to?

[IDAICFailFlag] The linesearch algorithm failed: step too small or too many backtracks.
29: terminate called after throwing an instance of 'AnalysisManager::Sundials::SundialsException'
29:   what():  Method in Ida class failed!

I could be misunderstanding the plans...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm seeing the same issue for the Texas case. Can you explain why you don't expect it to work?

It seems a necessary condition for this working is $f_y(y_0, 0)$ is invertible where $f(y, y')$ is the DAE residual function. Perhaps this is not the case.

I'll need to look closer at the logs to understand why it's failing to converge.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From debugging the solver, it's seemingly getting stuck in a local minimum rather than a true root. I think a better initial guess is needed to get it to converge.

…#543)

* std::abs--> isEqual

* Make all checks explicity in IDATest::consistentICType, including unchanged states.

* Add test for IDATest::consistentICType with initially consistent derivative.

* Change IDATest::consistentICType model to something that admits a steady-state solution.

* Increasing consistentICType tolerances.

* Update tolerance comment.

---------

Co-authored-by: nkoukpaizan <nkoukpaizan@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants