Skip to content

Conversation

figueroa1395
Copy link
Member

This PR includes validation test cases that trigger a SparseMatrixError for a simple meshed grid.

Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
@figueroa1395 figueroa1395 self-assigned this Sep 8, 2025
@figueroa1395 figueroa1395 added the bug Something isn't working label Sep 8, 2025
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
@TonyXiang8787
Copy link
Member

@figueroa1395 why is this a bug? We get sparse matrix error because we do not have sufficient condition check for observability in meshed grids. So the pivot perturbation is not enabled.

@figueroa1395
Copy link
Member Author

@figueroa1395 why is this a bug? We get sparse matrix error because we do not have sufficient condition check for observability in meshed grids. So the pivot perturbation is not enabled.

Even if we hack-force the perturbation from the observability, the pivot is still not triggered and we continue to have SparseMatrixError. This happens because the matrix's (y-bus) norm is smaller than the largest pivot on the sub-block (which is an edge case as the norm excludes the diagonal elements), triggered by a link being coupled directly to the source with a simple mesh after.

In summary, the pivot is too large to be considered for perturbation, but it is too small so it triggers SparseMatrixError; even if the fully observability test for meshed grids was completed, this simple grid would still present SparseMatrixError.

Let's have an offline discussion about this.

@TonyXiang8787
Copy link
Member

Some idea to fix this issue:

Record the actual possible ill-conditioned rows in the observability check

Currently we only record if the whole matrix could be ill-conditioned if one of the rows is ill-conditioned:

if (!has_at_least_one_sensor && row != n_bus - 1) {
result.is_possibly_ill_conditioned = true;
}

We can choose to record a list of rows which can be ill-conditioned.

In LU solver, change the matrix norm to full norm including diagonal

We now exclude diagonal for calculating matrix norm. To avoid some rows are wrongly perturbed. But now we can use two step verification.

// calculate the block-wise non-diagonal infinite norm of the matrix
// that is:
// 1. calculate the infinite norm of each individual block
// 2. sum all norms of the blocks per row, except the diagonal block
// 3. take the maximum of all the sums

Two step verification of pivot perturbation

In Pivot perturbation judgment here:

perturb_pivot_if_needed(perturb_threshold, matrix(row_biggest, col_biggest), abs_pivot,
has_pivot_perturbation);

Only trigger this if the row is actually one of the rows which are determined to be possibly ill-conditioned.

Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
Copy link

@mgovers mgovers added this pull request to the merge queue Sep 22, 2025
Merged via the queue into main with commit 5be1761 Sep 22, 2025
31 checks passed
@mgovers mgovers deleted the test-sparse branch September 22, 2025 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants