GridPACK’s state estimation module provides a parallel weighted least squares (WLS) solver for computing the most likely operating state of a power network from a sparse, noisy set of measurements. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/GridOPTICS/GridPACK/llms.txt
Use this file to discover all available pages before exploring further.
SEAppModule class in the gridpack::state_estimation namespace accepts measurements of bus voltage magnitude, voltage angle, real and reactive power injection, real and reactive branch power flow, and branch current magnitude. After solving the Newton-Raphson normal equations, the module runs an automatic bad data detection loop based on the chi-square distribution of weighted residuals. Results can be saved to DataCollection objects and used to initialize a dynamic simulation, making state estimation a natural first stage in a hybrid estimation-simulation workflow.
Setting up and running state estimation
Open the configuration file
Parse the XML input deck and obtain a configuration pointer. The
State_estimation block must be accessible from the cursor when readNetwork() is called.Read and partition the network
Create an empty If the network already exists (cloned from a power flow or previous calculation), use
SENetwork and pass it to readNetwork(). The method reads the PSS/E RAW file named in the networkConfiguration field and partitions the network across MPI ranks.setNetwork() instead to avoid re-reading and re-partitioning:Load measurements
Read measurements from the XML file named in the Alternatively, supply measurements programmatically using
measurementList field:setMeasurements(). This is useful when measurements come from another module or a non-XML data source:Solve the WLS problem
Run the Newton-Raphson WLS solver with automatic bad data detection:The method returns after convergence or after exhausting the iteration limit. Query
hasConverged() to check the outcome.Measurement types
The measurement file (orsetMeasurements() vector) supports the following types:
| Type | Description | Element |
|---|---|---|
VM | Voltage magnitude (pu) | Bus |
VA | Voltage angle (radians) | Bus |
PI | Real power injection (pu) | Bus |
QI | Reactive power injection (pu) | Bus |
PIJ | Real power flow, from-bus direction (pu) | Branch |
QIJ | Reactive power flow, from-bus direction (pu) | Branch |
IIJ | Current magnitude, from-bus direction (pu) | Branch |
IJI | Current magnitude, to-bus direction (pu) | Branch |
Deviation field (standard deviation in the same units) that sets the WLS weight as 1 / σ².
Measurement file format
The measurement file is a standalone XML document referenced by themeasurementList field:
XML configuration reference
Weighted least squares algorithm
The WLS estimator minimizes the objective functionJ(x) = (z − h(x))ᵀ W (z − h(x)), where z is the measurement vector, h(x) is the vector of measurement functions evaluated at the state x, and W = diag(1/σᵢ²) is the diagonal weight matrix. The normal equations are solved iteratively using Newton-Raphson:
H = ∂h/∂x is the Jacobian. GridPACK assembles H in parallel using the mapped bus-vector framework and solves the normal equations using PETSc. Sparse matrix storage is enabled internally when beneficial for large systems, controlled by the p_use_sparse_matrices flag in the implementation.
The dampingFactor parameter scales each Newton-Raphson update step before it is applied to the state vector. A value of 1.0 (default) gives full Newton-Raphson steps. Values below 1.0 can improve convergence stability for poorly conditioned measurement sets.
Bad data detection
After each Newton-Raphson convergence, the solver computes the chi-square statistic for the weighted measurement residuals. If the statistic exceeds the threshold for the system’s degrees of freedom, the measurement with the largest normalized residual is identified and removed from the estimator. The solver then re-converges with the reduced measurement set. This process repeats up tomaxBadDataIterations (default 5) times.
A measurement is flagged as bad data when its normalized residual exceeds badDataThreshold (default 3.0 standard deviations). The chi-square threshold is computed from the degrees of freedom (number of measurements minus number of state variables) at the configured confidence level.
The
write() output includes a side-by-side comparison of each measurement’s estimated value and its original measured value, making it straightforward to identify which measurements were flagged or have large residuals.Diagnostic output levels
ThediagnosticOutputLevel parameter controls solver verbosity:
| Level | Output |
|---|---|
basic | Convergence status only |
standard | Per-iteration mismatch, bad data summary, measurement residuals |
detailed | Full Jacobian performance statistics, per-measurement normalized residuals, chi-square value and threshold, degrees of freedom |
Python API
The Python binding exposessetMeasurements() for supplying measurements at runtime, which is useful in co-simulation and scripting workflows:
Voltage constraint measurements
WhenuseVoltageConstraints is true, the solver adds virtual voltage magnitude measurements at every bus with very tight standard deviations (deviation=0.001) that constrain voltages to the [minVoltage, maxVoltage] interval. PV bus voltages are handled separately via handlePVBusVoltages(), which ensures that generator terminal voltages are treated as equality constraints rather than soft measurements.
Chaining state estimation with dynamic simulation
BecausesaveData() writes results into the network’s DataCollection objects, a state estimation solution can serve directly as the initial operating point for dynamic simulation initialization, bypassing the need for a separate power flow run:
BUS_SE_VMAG and BUS_SE_VANG are used by the dynamic simulation factory to set the initial bus voltages instead of the default power flow values.
Test cases
GridPACK ships updated IEEE 14-bus and IEEE 118-bus test inputs for state estimation in thesrc/applications/modules/state_estimation/test/ directory. These include measurement files for all supported types and input XML files demonstrating bad data injection and detection.
Power flow
Run a conventional power flow as an alternative base-case initialization method.
Dynamic simulation
Chain state estimation results into a transient stability simulation.