Skip to content

Uncertainty quantification: add voltage variance for state estimation output - #1690

Draft
Plusero wants to merge 6 commits into
mainfrom
uq/01-voltage-variance
Draft

Plusero wants to merge 6 commits into
mainfrom
uq/01-voltage-variance

Conversation

@Plusero

@Plusero Plusero commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Add voltage variances for state estimation

Changes proposed in this PR

State estimation can now report the uncertainty of the voltage magnitude and voltage angle at requested buses, for Iterative-linear State Estimation (ILSE) and Newton-raphson State Estimation (NRSE), in both symmetric and asymmetric calculations.

The main changes are:

  1. Compute the blocks of the state covariance on the LU sparsity pattern, by applying the selective inverse to the LU matrix that state estimation already factorizes.
  2. Convert the covariance block of each requested bus into the variance of its voltage magnitude and voltage angle.
  3. If no voltage angle measurement is present, compute the covariance between every bus and the slack bus by one additional linear solve. Angle variances are then reported relative to the slack bus. The page docs/algorithms/state-estimation-uncertainty.md contains the detailed motivation and mathematical derivations.

The interface is internal for now: run_state_estimation in math_solver/math_solver.hpp gets an optional StateEstimationUQContext*, defined in math_solver/state_estimation_uq.hpp, that defaults to nullptr. C API and the Python API are unchanged.

There will be follow-up PRs:

  1. Branch power and current uncertainty.
  2. Nodal injection uncertainty.
  3. Observer that expose the results.

How it works

The workflow

The flow chart below describes the workflow:

flowchart TD
    start(["Call with an<br>uncertainty<br>request"])
    valid{"Requested bus<br>indices valid?"}
    reject(["Reject the<br>request"])
    estimate["Run state<br>estimation<br>as usual"]
    requested{"Request<br>non-empty?"}
    plain(["Return the<br>estimate only"])
    done(["Return the<br>estimate and<br>uncertainty"])

    start --> valid
    valid -- no --> reject
    valid -- yes --> estimate
    estimate --> requested
    requested -- no --> plain
    requested -- yes --> estimator

    subgraph uq["Uncertainty calculation"]
        estimator{"Estimator?"}
        ilse["Copy the<br>existing<br>LU factors"]
        nrse["Assemble the<br>matrix again<br>and factorize"]
        factors{"LU factors<br>without pivot<br>perturbation?"}
        angle{"Voltage angle<br>measured?"}
        slack["Extra solve:<br>covariance<br>with slack bus"]
        inverse["Selective<br>inverse on the<br>LU pattern"]
        variance["Magnitude and<br>angle variance<br>per bus"]
        invalid["Mark requested<br>values invalid"]

        estimator -- ILSE --> ilse
        estimator -- NRSE --> nrse
        ilse --> factors
        nrse --> factors
        factors -- yes --> angle
        factors -- no --> invalid
        angle -- no --> slack
        angle -- yes --> inverse
        slack --> inverse
        inverse --> variance
    end

    variance --> done
    invalid --> done
Loading

The theory

The page docs/algorithms/state-estimation-uncertainty.md contains the detailed mathematical derivations.
In short:

  • Covariance. The state covariance between buses $i$ and $j$ is $C_{x,ij} = \alpha (\bar{Z}_{ij})_{xx}$. $\bar{Z}$ is the inverse of the augmented matrix of state estimation, computed on the LU sparsity pattern by the selective inverse, and $\alpha$ is the variance normalization factor.
  • Magnitude and angle. For NRSE, both variances are diagonal entries of $C_{x,ii}$. For ILSE, the variance $V_{ii}$ of the complex voltage is split equally: $\mathrm{Var}(|U_i|) = \mathrm{Re}(V_{ii}) / 2$ and $\mathrm{Var}(\theta_i) = \mathrm{Re}(V_{ii}) / (2 |U_i|^2)$.
  • Angle reference. Without a measured voltage angle, angles are reported relative to phase $a$ of the slack bus $s$, with variance $\mathrm{Var}(\theta_i) + \mathrm{Var}(\theta_s) - 2, \mathrm{Cov}(\theta_i, \theta_s)$. One additional linear solve gives the covariance term.

Signed-off-by: jhe <JialinHe_Plusero@outlook.com>
Signed-off-by: jhe <JialinHe_Plusero@outlook.com>
@Plusero Plusero self-assigned this Nov 11, 2026
@Plusero Plusero added the feature New feature or request label Nov 11, 2026
Signed-off-by: jhe <JialinHe_Plusero@outlook.com>
Signed-off-by: jhe <JialinHe_Plusero@outlook.com>
Copilot stopped work on behalf of Plusero due to an error November 12, 2026 09:18
indirect includes and reference members

Signed-off-by: jhe <JialinHe_Plusero@outlook.com>
@Plusero
Plusero marked this pull request as ready for review November 12, 2026 13:07
@sonarqubecloud

Copy link
Copy Markdown

@Plusero
Plusero marked this pull request as draft November 16, 2026 10:58
@Plusero

Plusero commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Converted to draft. I am now reviewing it with agents on specific aspects like security, memory, etc.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant