Bug: Configuring sparse Jacobians with IDA assumes Jacobian has been evaluated already
Maintainer thường phản hồi trong vòng 1 ngày
@alexander-novo đang làm issue này rồi.
Từ ngày 23/10/2025.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Description how to reproduce the bug
Design a simulation which uses sparse Jacobians and does not evaluate the Jacobian before running the simulation (for an example of such a simulation, see this Microgrid benchmark). The Jacobian will not be calculated correctly, and the linear solver in SUNDIALS will error, complaining about being configured incorrectly.
GridKit™ version
develop
System and environment details
N/A
Additional information
The reason for the bug is simple:
This commit changed the sparse linear solver configuration code in ida.cpp to no longer assume that there were n^2 non-zero elements in the jacobian. To do that, it calls (model_->getJacobian()).nnz() but getJacobian() must be called only after calling evaluateJacobian() (un-documented, but true).
The reason that this wasn't caught is because currently, the only simulations we have being tested using sparse Jacobians coincidentally all evaluate their Jacobian before running the simulation:
But...
- This shouldn't be a necessary step.
- Evaluating Jacobians before configuring the simulation isn't even enough - some (potentially) nonzero elements are squashed during Jacobian evaluation if the
alphacoefficient is set to 0, which it often is ifupdateTime()hasn't also been called beforehand. - The number of nonzero elements should probably be allowed to change during simulations - discrete events like faults can introduce new variables into the system.
Luckily, SUNDIALS has an interface for re-allocating sparse matrices, which we can call after evaluating the system Jacobian and realising there isn't enough space.
So the correct steps should probably be something along the lines of:
- When configuring the linear solver, allocate a small (maybe 0 sized if SUNDIALS lets us) jacobian matrix, and keep track of how much space it has for nonzero elements
- After evaluating a system jacobian, compare the number of nonzero elements it has and how much space the SUNDIALS matrix has - if they differ, then re-allocate the SUNDIALS matrix to fit
- Finally, copy the entries from the system Jacobian to the SUNDIALS matrix.
Eventually, the GridKit CSR matrix interface should also be able to handle this re-allocation automatically, without having to copy between two buffers.
- Ngôn ngữ chính
- C++
- Star
- 27
- Fork
- 11
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ORNL/GridKit
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
ORNL/GridKit#587 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Companion OPF models for PD initialization constraintsCó thể đã có người làm @lukelowry đã nhận 3 ngày trước. Đang mởIVP question
ORNL/GridKit#656 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Extract CommonMath functionsCó thể đã có người làm @amandeep25100-a11y đã nhận 6 ngày trước. Đang mởcleanup
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 54/100
ORNL/GridKit#642 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement question
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
ORNL/GridKit#624 · 2 bình luận · 2 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add support for hierarchical modeling to the JSON format case file specificationsCó thể đã có người làm @abirchfield đã nhận 33 ngày trước. Đang mởdocumentation enhancement new case question
ORNL/GridKit#619 · 8 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
useless statementĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
grizzlypeak3d/DJV#962 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày