# Writings

This is a personal blog, where I post comments, errata, and code snippets. Nothing here is peer-reviewed, and should be treated as such.

## Phase retrieval in power systems

In this paper we discuss how to estimate the voltage phase angles \(\theta_i\) of a power system from measurements of the voltage magnitudes \(v_i\). This is called "phase retrieval" in the signal processing literature. We derived a circuit law that describes the power-voltage phase angle submatrices of the power flow Jacobian as a function of the voltage magnitudes, active power injections, and reactive power injections. This law is given as

\[ \frac{\partial p}{\partial \theta}(v,q) = \operatorname{diag}(v)\frac{\partial q }{\partial v} - 2 \operatorname{diag}(q), \] \[ \frac{\partial q}{\partial \theta}(v,p) = -\operatorname{diag}{v} \frac{\partial p}{\partial v} + 2 \operatorname{diag}(p). \]## Can complex power injections be estimated from voltage magnitudes?

In a recent paper we discussed when net complex power injections \(p_i + j q_i \in \mathbb{C}\) for PQ buses \(i=1,\dots,n\) can be estimated from measurements of the magnitudes of the voltage phasors \(v_i \triangleq |\overline{v}_i| \in \mathbb{R}\).

We called this idea "phaseless observability". This idea is useful because synchrophasor measurements (i.e., measurements of the voltage phase angles \(\theta_i\), \(i=1,\dots,n\)) are often unavailable, especially in distribution systems (see my recent talk for some additional exposition on this).

We came up with two conditions that use:

The bus power factors \(\alpha_i, \ i =1,\dots,n\), or ratios of active and reactive power.

The voltage magnitude-power sensitivity matrices \(\frac{\partial v}{\partial p}\) and \(\frac{\partial v}{\partial q}\),

and the implicit reactive-active power sensitivities \(\frac{\partial q}{\partial p}\), where

You can check if the network is "phaselessly observable" at its current operating point by checking if the square matrix

\[ \tilde{S} = \frac{\partial v}{\partial p} + \frac{\partial v}{\partial q} \frac{\partial q}{\partial p} \]is invertible.

Check out all of the code in the full repository available here.

## Checking if an electric power system is radial with the admittance matrix

A power system is "radial" if there are no loops in the circuit.

If we call \(L\) and \(U\) the lower and upper off-diagonal components the network admittance matrix \(Y \in \mathbb{C}^{n \times n}\), then the network is *not* radial if

or alternatively,

\[ \sum_i \sum_j U_{ij} \geq n,\\ \text{where} \ (i,j) \in \{(i,j): U_{ij} \neq 0 \}. \]This function tells you if a PowerModels.jl network model is radial or not.

```
using LinearAlgebra
"""
Given a network's admittance matrix Y, determine if that network is radial.
In other words, determine if there are no electrical loops.
Params:
Y: NxN Network admittance matrix
"""
function is_radial(Y::AbstractMatrix)
n = size(Y)[1]
#Upper and lower off-diagonal elements
U(A::AbstractMatrix) = [A[i] for i in CartesianIndices(A) if i[1]>i[2]]
L(A::AbstractMatrix) = [A[i] for i in CartesianIndices(A) if i[1]<i[2]]
#Get the nonzero upper and lower off diagonal elements
nz_upper = [1 for y_ij in U(Y) if y_ij != 0]
nz_lower = [1 for y_ij in L(Y) if y_ij != 0]
return !(sum(nz_upper)>n-1 || sum(nz_lower) >n-1)
end
#EXAMPLE: case4_dist admittance matrix
Y = [
133.333-266.667im -66.6667+133.333im 0.0+0.0im -65.0407+130.081im;
-66.6667+133.333im 133.333-266.667im -66.6667+133.333im 0.0+0.0im;
0.0+0.0im -66.6667+133.333im 66.6667-133.333im 0.0+0.0im;
-65.0407+130.081im 0.0+0.0im 0.0+0.0im 63.4543-126.909im
]
println(is_radial(Y))
```

```
true
```