Bug: Configuring sparse Jacobians with IDA assumes Jacobian has been evaluated already
Los mantenedores suelen responder en 1 día
@alexander-novo ya está trabajando en esto.
Desde el 23/10/2025.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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.
- Lenguaje dominante
- C++
- Estrellas
- 27
- Forks
- 11
- Merge medio
- 2 d 21 h
- PR fusionados (30 d)
- 15
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ORNL/GridKit
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
ORNL/GridKit#587 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Companion OPF models for PD initialization constraintsPosiblemente ocupada @lukelowry la tomó hace 3 días. AbiertoIVP question
ORNL/GridKit#656 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Extract CommonMath functionsPosiblemente ocupada @amandeep25100-a11y la tomó hace 6 días. Abiertocleanup
Dificultad 4/5 3-5 días Aptitud para principiantes 54/100
ORNL/GridKit#642 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement question
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
ORNL/GridKit#624 · 2 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
Add support for hierarchical modeling to the JSON format case file specificationsPosiblemente ocupada @abirchfield la tomó hace 33 días. Abiertodocumentation enhancement new case question
ORNL/GridKit#619 · 8 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de ORNL/GridKit
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
useless statementAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
grizzlypeak3d/DJV#962 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día