Bug: Configuring sparse Jacobians with IDA assumes Jacobian has been evaluated already
维护者通常 1 天内回复
@alexander-novo 已经在做这个了。
开始于 2025年10月23日。
评估
这个 Issue 还没有评估数据。
描述
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.
- 主要语言
- C++
- 星标
- 27
- 派生
- 11
- 平均合并
- 2 天 21 小时
- 30 天内合并 PR
- 15
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ORNL/GridKit 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
ORNL/GridKit#587 · 1 个 reaction ·
维护者通常 1 天内回复
-
Companion OPF models for PD initialization constraints可能已有人在做 @lukelowry 于 3 天前认领。 未关闭IVP question
维护者通常 1 天内回复
-
Extract CommonMath functions可能已有人在做 @amandeep25100-a11y 于 6 天前认领。 未关闭cleanup
难度 4/5 3-5 天 新手友好度 54/100
维护者通常 1 天内回复
-
enhancement question
难度 5/5 一周以上 新手友好度 30/100
ORNL/GridKit#624 · 2 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
-
Add support for hierarchical modeling to the JSON format case file specifications可能已有人在做 @abirchfield 于 33 天前认领。 未关闭documentation enhancement new case question
ORNL/GridKit#619 · 8 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 2/5 1-3 小时 新手友好度 65/100
grizzlypeak3d/DJV#962 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复