Reuse CSR pattern in PhasorDynamics system Jacobian#342
Merged
Conversation
pelesh
approved these changes
Feb 23, 2026
Collaborator
pelesh
left a comment
There was a problem hiding this comment.
The code executes correctly. On my machine I get Hawaii case to run in 6.8s compared to 8.4s before, so we are going in the right direction.
I made a couple of nitpicking comments, but I think this is ready to be merged.
Comment on lines
+327
to
+328
| printf("%lu : %e \n", i, fres[i]); | ||
| } |
Collaborator
There was a problem hiding this comment.
Consider using iostream here:
Suggested change
| printf("%lu : %e \n", i, fres[i]); | |
| } | |
| std::cout << i << " : " << << std::scientifi << fres[i] << "\n"; | |
| } |
Comment on lines
6
to
10
| #include <GridKit/LinearAlgebra/SparseMatrix/COO_Matrix.hpp> | ||
| #include <GridKit/LinearAlgebra/SparseMatrix/CooMatrix.hpp> | ||
| #include <GridKit/LinearAlgebra/SparseMatrix/CsrMatrix.hpp> | ||
| #include <GridKit/Model/VariableMonitor.hpp> | ||
| #include <GridKit/ScalarTraits.hpp> |
Collaborator
There was a problem hiding this comment.
Do we need to include matrix header here? Could we use forward declarations instead?
Suggested change
| #include <GridKit/LinearAlgebra/SparseMatrix/COO_Matrix.hpp> | |
| #include <GridKit/LinearAlgebra/SparseMatrix/CooMatrix.hpp> | |
| #include <GridKit/LinearAlgebra/SparseMatrix/CsrMatrix.hpp> | |
| #include <GridKit/Model/VariableMonitor.hpp> | |
| #include <GridKit/ScalarTraits.hpp> | |
| #include <GridKit/LinearAlgebra/SparseMatrix/COO_Matrix.hpp> | |
| #include <GridKit/Model/VariableMonitor.hpp> | |
| #include <GridKit/ScalarTraits.hpp> | |
| namespace GridKit | |
| { | |
| namespace LinearAlgebra | |
| { | |
| template <typename RealT, typename IdxT> | |
| class CsrMatrix<RealT, IdxT>; | |
| template <typename RealT, typename IdxT> | |
| class CooMatrix<RealT, IdxT>; | |
| } | |
| } |
Collaborator
kakeueda
approved these changes
Feb 24, 2026
Collaborator
kakeueda
left a comment
There was a problem hiding this comment.
Enzyme isn't enabled on my machine yet so I haven't evaluated speedup, but it looks good to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This adapts the approach to reuse system Jacobian CSR pattern, introduced in #339 for
PowerElectronics, toPhasorDynamics.Proposed changes
PhasorDynamicssystem model to reuse the CSR Jacobian pattern.CsrJacfunction.Checklist
-Wall -Wpedantic -Wconversion -Wextra.Further comments
This only touches the system-level Jacobians. I'll follow up with a PR that changes the component-level Jacobians.