Skip to content

Add interface to partitioned DAE integrator - #614

Open
Steven-Roberts wants to merge 4 commits into
developfrom
steven/partitioned-dae-integrator
Open

Steven-Roberts wants to merge 4 commits into
developfrom
steven/partitioned-dae-integrator

Conversation

@Steven-Roberts

@Steven-Roberts Steven-Roberts commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This is a draft of a partitioned DAE integrator interface. It currently uses masking of the residual and Jacobian, with many TODO statement indicating where things will need to be updated when GridKit partitioning functionality is in place.

It requires this branch of SUNDIALS: https://github.com/llnl/sundials/tree/feature/partitioned-dae-stepper

Proposed changes

Adds a new DynamicSolver and a unit test on a simple 5 variable DAE.

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.

* Add gridkit@v0.2 and sundials@partitioned-dae

* Add CMake guards for PARTITIONED_DAE.

* Add ^sundials@partitioned-dae CI jobs.

* Patch out missing partitioned-dae example in SUNDIALS spack package.
@nkoukpaizan
nkoukpaizan marked this pull request as ready for review October 22, 2026 19:17
@pelesh

pelesh commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

The PartitionedTest test segfaults in my case.

1/1 Test #52: PartitionedTest ..................***Exception: SegFault  0.03 sec

Here is the backtrace:

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
  * frame #0: 0x00000001001b2870 libsundials_idas.6.dylib`IDASetLinearSolver(ida_mem=0x000000012b008e00, LS=<unavailable>, A=0x0000000000000000) at idas_ls.c:130:28 [opt]
    frame #1: 0x000000010007797c libgridkit_solvers_dyn.0.dylib`AnalysisManager::Sundials::Partitioned<double, unsigned long>::configurePartitionSolvers(this=0x000000016fdfe240) at Partitioned.cpp:366:21 [opt]
    frame #2: 0x00000001000757fc libgridkit_solvers_dyn.0.dylib`AnalysisManager::Sundials::Partitioned<double, unsigned long>::createSolver(this=0x000000016fdfe240, t0=<unavailable>) at Partitioned.cpp:336:7 [opt]
    frame #3: 0x00000001000755b8 libgridkit_solvers_dyn.0.dylib`AnalysisManager::Sundials::Partitioned<double, unsigned long>::initializeSimulation(this=0x000000016fdfe240, t0=0) at Partitioned.cpp:92:7 [opt]
    frame #4: 0x0000000100006fd8 test_partitioned`GridKit::Testing::PartitionedTests<double, unsigned long>::integration(this=0x000000016fdfe78b) at PartitionedTests.hpp:362:16 [opt]
    frame #5: 0x0000000100006e78 test_partitioned`main at runPartitionedTests.cpp:7:18 [opt]
    frame #6: 0x000000019155ab98 dyld`start + 6076
(lldb) 

@pelesh pelesh 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.

This looks very good and the test passes.

I suggest to start separating interface to partitioned solver from the solver implementation as suggested below. That will help make it more clear what should API for partitioned solvers look like.

Comment on lines +371 to +377
success *= std::abs(y[0] - 0.8181325137273604) < tol;
success *= std::abs(y[1] - 1.2467607076859357) < tol;
success *= std::abs(y[2] - 0.2350113335864333) < tol;
success *= std::abs(y[3] - 1.4725904879949860) < tol;
success *= std::abs(y[4] - 1.6662073483671279) < tol;
success *= callbacks == 4;
success *= solver.getStats().num_steps_ == 1000;

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.

I would use GridKit's isEqual helper function.

Comment on lines +25 to +26
struct PartitionedStats
{

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.

I suggest Implementing helper classes and structs in separate files. Files Partitioned*pp should contain interface to the solver. The solver itself should be implemented in files located in Partitioned subdirectory.

@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.

I recommend adding some minimal documentation of the methods. We'll likely iterate on the function signatures, so just a high-level description of that they do.

Good to merge after the minor comments have been addressed.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants