Skip to content

Commit 6a09c99

Browse files
authored
Merge pull request #962 from PowerGridModel/feature/current-sensor-docs
add current sensor + power sensor variance diff to ILSE docs
2 parents edc1018 + 18c2037 commit 6a09c99

File tree

2 files changed

+227
-16
lines changed

2 files changed

+227
-16
lines changed

docs/user_manual/calculations.md

Lines changed: 116 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ Output:
5757
- Power flow through branches
5858
- Deviation between measurement values and estimated state
5959

60-
In order to perform a state estimation, the system should be observable. If the system is not observable, the calculation will raise either a `NotObservableError` or
61-
a `SparseMatrixError`.
62-
In short, meeting the requirement of observability indicates that the system is either an overdetermined system (when the number of measurements is larger than the number of unknowns.
63-
For each node, there are two unknowns, `u` and `u_angle`. Due to the relative nature of `u_angle` (relevant only in systems with at least two nodes), in total the following conditions should be met:
60+
In order to perform a state estimation, the system should be observable. If the system is not observable,
61+
the calculation will raise either a `NotObservableError` or a `SparseMatrixError`.
62+
In short, meeting the requirement of observability indicates that the system is either an overdetermined
63+
system (when the number of independent measurements is larger than the number of unknowns) or an exactly
64+
determined system (the number of independent measurements equals the number of unknowns).
65+
For each node, there are two unknowns, `u` and `u_angle`. Due to the relative nature of `u_angle`
66+
(relevant only in systems with at least two nodes), in total the following conditions should be met:
6467

6568
$$
6669
\begin{eqnarray}
@@ -82,11 +85,15 @@ The number of measurements can be found by taking the sum of the following:
8285
- two times the number of nodes with a voltage sensor with magnitude and angle
8386
- two times the number of nodes without appliances connected
8487
- two times the number of nodes where all connected appliances are measured by a power sensor
85-
- two times the number of branches with a power sensor
88+
- two times the number of branches with a power sensor and/or a current sensor
8689

8790
```{note}
8891
Having enough measurements does not necessarily mean that the system is observable. The location of the measurements is
89-
also of importance. Additionally, there should be at least one voltage measurement.
92+
also of importance, i.e., the measurements should be topologically independent. Additionally, there should be at least one voltage measurement.
93+
```
94+
95+
```{note}
96+
Global angle current measurements require at least one voltage angle measurement to make sense. See also the [current sensor component documentation](./components.md#global-angle-current-sensors).
9097
```
9198

9299
```{warning}
@@ -99,9 +106,13 @@ In observable systems this helps better outputting correct results. On the other
99106
Based on the requirements of observability mentioned above, users need to satisfy at least the following conditions for state estimation calculation in `power-grid-model`.
100107

101108
- `n_voltage_sensor >= 1`
102-
- If no voltage phasor sensors are available, then the following conditions should be satisfied: `n_unique_power_sensor >= n_bus - 1`. Otherwise: `n_unique_power_sensor + n_voltage_sensor_with_phasor >= n_bus`
109+
- If no voltage phasor sensors are available, then both the following conditions shall be satisfied:
110+
- There are no global angle current sensors.
111+
- `n_unique_power_or_current_sensor >= n_bus - 1`.
112+
- Otherwise (if there are voltage phasor sensors available), the following condition shall be satisfied:
113+
- `n_unique_power_or_current_sensor + n_voltage_sensor_with_phasor >= n_bus`
103114

104-
`n_unique_power_sensor` can be calculated as sum of following:
115+
`n_unique_power_or_current_sensor` can be calculated as sum of following:
105116

106117
- Zero injection or zero power flow constraint if present for all nodes.
107118
- Complete injections for all nodes: All appliances in a node are measured or a node injection sensor is present. Either of them counts as one.
@@ -424,6 +435,8 @@ At the moment, the following state estimation algorithms are implemented.
424435
By default, the [iterative linear](#iterative-linear-state-estimation) method is used.
425436
```
426437

438+
#### State estimation measurement aggregation
439+
427440
There can be multiple sensors measuring the same physical quantity. For example, there can be multiple
428441
voltage sensors on the same bus. The measurement data can be merged into one virtual measurement using a Kalman filter:
429442

@@ -449,14 +462,51 @@ $$
449462

450463
Where $S_k$ and $\sigma_{P,k}$ and $\sigma_{Q,k}$ are the measured value and the standard deviation of the individual appliances.
451464

465+
#### State estimate sensor transformations
466+
467+
Sometimes, measurements need to be transformed between coordinate spaces. For example, current measurements are in polar coordinates (magnitude and angle), but it is beneficial to transform them to separate real and imaginary components per phase, with each their own variances.
468+
Variances of the results of such transformations are estimated using the common linearization approximation.
469+
E.g., for a real random variable $X$, the random variable $Y = F\left(X\right)$, with $F$ sufficiently well-behaved, exists.
470+
The variances of $Y$ can then be estimated from the variance of $X$ using
471+
$\text{Var}\left(Y\right) \approx \text{Var}\left(X\right) \left\|\frac{\delta f}{\delta X}\right\|^2$
472+
473+
This approach generalizes to extension fields and to more dimensions. Both generalizations are required for current sensors.
474+
The current phasor is described by a complex random variable, which can be decomposed into a real and an imaginary component, or into a magnitude and a phasor.
475+
Asymmetric sensors and asymmetric calculations, on the other hand, require multidimensional approaches.
476+
The generalization is done as follows.
477+
478+
Let $A$ and $B$ be fields (or rings) that may be multidimensional and that may be extension fields.
479+
Let $\boldsymbol{X}$ be a random variable with codomain $A$ with components $X_i$.
480+
Let $\boldsymbol{Y} = \boldsymbol{F}\left(\boldsymbol{X}\right)$ be a random variable with codomain $B$, with $\boldsymbol{F}$ sufficiently well-behaved,
481+
so that its components $Y_j = F_j\left(\boldsymbol{X}\right)$ are well-behaved.
482+
Then the variances $\text{Var}\left(Y_i\right)$ of the components of $\boldsymbol{Y}$ can be estimated
483+
in terms of the variances $\text{Var}\left(X_j\right)$ of the components of $\boldsymbol{X}$ using the following function.
484+
485+
$$
486+
\text{Var}\left(Y_j\right) = \text{Var}\left(F_j\left(\boldsymbol{X}\right)\right) \approx \sum_i \text{Var}\left(X_i\right) \left\|\frac{\delta F_j}{\delta x_i}\left(\boldsymbol{X}\right)\right\|^2
487+
$$
488+
489+
The following illustrates how this works for `sym_current_sensor`s in symmetric calculations.
490+
See also [the full mathematical workout](https://github.com/PowerGridModel/power-grid-model/issues/547).
491+
492+
$$
493+
\begin{eqnarray}
494+
& \mathrm{Re}\left\{I\right\} = I \cos\theta \\
495+
& \mathrm{Im}\left\{I\right\} = I \sin\theta \\
496+
& \text{Var}\left(\mathrm{Re}\left\{I\right\}\right) = \sigma_i^2 \cos^2\theta + I^2 \sigma_{\theta}^2\sin^2\theta \\
497+
& \text{Var}\left(\mathrm{Im}\left\{I\right\}\right) = \sigma_i^2 \sin^2\theta + I^2 \sigma_{\theta}^2\cos^2\theta
498+
\end{eqnarray}
499+
$$
500+
452501
#### Iterative linear state estimation
453502

454503
Algorithm call: {py:class}`CalculationMethod.iterative_linear <power_grid_model.enum.CalculationMethod.iterative_linear>`
455504

456-
Linear WLS requires all measurements to be linear. This is only possible when all measurements are phasor unit measurements,
457-
which is not realistic in distribution grids. Therefore, traditional measurements are linearized prior to running the algorithm:
505+
Linear WLS requires all measurements to be linear and only handles voltage phasor measurements including a phase angle,
506+
as well as complex current phasor measurements. This is only possible when all measurements are phasor unit measurements,
507+
which is not realistic in distribution grids. Therefore, traditional measurements are linearized prior to running the algorithm.
458508

459-
- Bus voltage: Linear WLS requires a voltage phasor including a phase angle. Given that the phase shift in the distribution grid is very small,
509+
- Bus voltage: Given that the phase shift in the distribution grid is very small,
460510
it is assumed that the angle shift is zero plus the intrinsic phase shift of transformers. For a certain bus `i`, the voltage
461511
magnitude measured at that bus is translated into a voltage phasor, where $\theta_i$ is the intrinsic transformer phase shift:
462512

@@ -466,8 +516,38 @@ $$
466516
\end{eqnarray}
467517
$$
468518

469-
- Branch/shunt power flow: Linear WLS requires a complex current phasor. To make this translation, the voltage at the terminal should
470-
also be measured, otherwise the nominal voltage with zero angle is used as an estimation. With the measured (linearized) voltage
519+
- Branch current with global angle: The global angle current measurement captures
520+
the phase offset relative to the same predetermined reference phase against which the voltage angle is measured. It is not
521+
sufficient to use the default zero-phase reference offset, because the reference point is not uniquely determined when there
522+
are no voltage angle measurements, resulting in ambiguities. As a result, using any global angle current sensor in the grid
523+
requires at least one voltage phasor measurement (with angle).
524+
525+
$$
526+
\begin{eqnarray}
527+
\underline{I} = I_i \cdot e^{j \theta_i}
528+
\end{eqnarray}
529+
$$
530+
531+
- Branch current with local angle: Sometimes, (accurate) voltage measurements are not available for a branch,
532+
which means no power measurement is possible. While it is not straightforward to use magnitude-only measurements of currents in
533+
calculations, current phasor measurements can in fact be used in cases where it is possible to obtain a reasonably accurate
534+
measurement of the current amplitude and the relative phase angle to the voltage. In this way, we still have enough information
535+
for the state estimation. The resulting local current phasor $\underline{I}_{\text{local}}$ can be translated to the global
536+
current phasor (see above) for iterative linear state estimation. Given the measured (linearized) voltage phasor,
537+
the current phasor is calculated as follows:
538+
539+
$$
540+
\begin{equation}
541+
\underline{I} = \underline{I}_{\text{local}}^{*} \frac{\underline{U}}{|\underline{U}|}
542+
= \underline{I}_{\text{local}}^{*} \cdot e^{j \theta}
543+
\end{equation}
544+
$$
545+
546+
where $\underline{U}$ is either measured voltage magnitude at the bus or assumed unity magnitude, with the intrinsic phase shift.
547+
$\theta$ is the phase angle of the voltage.
548+
549+
- Branch/shunt power flow: To translate the power flow to a complex current phasor, the voltage at the terminal should
550+
also be measured, otherwise the nominal voltage with zero angle is used as an estimation. Given the measured (linearized) voltage
471551
phasor, the current phasor is calculated as follows:
472552

473553
$$
@@ -476,7 +556,7 @@ $$
476556
\end{eqnarray}
477557
$$
478558

479-
- Bus power injection: Linear WLS requires a complex current phasor. Similar as above, if the bus voltage is not measured,
559+
- Bus power injection: Similar as above, to translate the power flow to a complex current phasor, if the bus voltage is not measured,
480560
the nominal voltage with zero angle will be used as an estimation. The current phasor is calculated as follows:
481561

482562
$$
@@ -506,12 +586,28 @@ be the slack bus, which is connected to the external network (source). $\underli
506586
- Normalize the voltage phasor angle by setting the angle of the slack bus to zero:
507587
- If the maximum deviation between $\underline{U}^{(k)}$ and $\underline{U}^{(k-1)}$ is smaller than the error tolerance $\epsilon$,
508588
stop the iteration. Otherwise, continue until the maximum number of iterations is reached.
509-
589+
510590
In the iteration process, the phase angle of voltages at each bus is updated using the last iteration;
511591
the system error of the phase shift converges to zero. Because the matrix is pre-built and
512592
pre-factorized, the computation cost of each iteration is much smaller than for the [Newton-Raphson](#newton-raphson-state-estimation)
513593
method, where the Jacobian matrix needs to be constructed and factorized each time.
514594

595+
Because the matrix depends on the variances of the linearized current measurements, pre-factorization
596+
requires assuming that the magnitudes of the voltages remain constant throughout the iteration process.
597+
This assumption is, of course, an approximation, and potentially results an inaccurate relative weighing
598+
of the power measurements. However, the difference between the solution and the actual grid state is
599+
usually small, because the error introduced by this is typically dominated by the following contributing
600+
factors (see also [this thread](https://github.com/PowerGridModel/power-grid-model/pull/951#issuecomment-2805154436)).
601+
602+
- voltages in the distribution grid are usually close to 1 p.u..
603+
- power sensor errors are usually best-effort estimates.
604+
- the interpretation of power measurements as current measurements is an approximation.
605+
606+
```{warning}
607+
In short, the pre-factorization may produce results that may deviate from the actual grid state.
608+
If higher precision is desired, please consider using [Newton-Raphson state estimation](#newton-raphson-state-estimation) instead.
609+
```
610+
515611
```{warning}
516612
The algorithm will assume angles to be zero by default (see the details about voltage sensors). This produces more correct outputs when the system is observable, but will prevent the calculation from raising an exception, even if it is unobservable, therefore giving faulty results.
517613
```
@@ -527,7 +623,7 @@ However, the Jacobian matrix needs to be calculated every iteration and cannot b
527623

528624
The Newton-Raphson method considers all measurements to be independent real measurements.
529625
I.e., $\sigma_P$, $\sigma_Q$ and $\sigma_U$ are all independent values.
530-
The rationale behind to calculation is similar to that of the [Newton-Raphson for power flow](#newton-raphson-power-flow).
626+
The rationale behind to calculation is similar to that of the [Newton-Raphson method for power flow](#newton-raphson-power-flow).
531627
Consequently, the iteration process differs slightly from that of [iterative linear state estimation](#iterative-linear-state-estimation), as shown below.
532628

533629
- Initialization: let $\boldsymbol{U}^{(k)}$ be the column vector of the estimated voltage magnitude and $\boldsymbol{\theta}^{(k)}$ the column vector of the
@@ -550,6 +646,10 @@ We initialize $\boldsymbol{U}^{(0)}$ and $\boldsymbol{\theta}^{(k)}$ as follows:
550646
As for the [iterative linear](#iterative-linear-state-estimation) approach, during iterations, phase angles of voltage at each bus are updated using ones from the previous iteration.
551647
The system error of the phase shift converges to zero.
552648

649+
```{note}
650+
Newton-Raphson state estimation does not support current measurements at this moment. See also [this issue](https://github.com/PowerGridModel/power-grid-model/issues/765).
651+
```
652+
553653
```{warning}
554654
The algorithm will assume angles to be zero by default (see the details about voltage sensors). In observable systems this helps better outputting correct results. On the other hand with unobservable systems, exceptions raised from calculations due to faulty results will be prevented.
555655
```

0 commit comments

Comments
 (0)