• No results found

Kalman filtering

Mathematical basis for protective relaying algorithms

3.9 Kalman filtering

The Kalman filter provides a solution to the estimation problem in the context of an evolution of the parameters to be estimated according to a state equation. It has been used extensively in estimation problems for dynamic systems.8 – 10 Its use in relaying is motivated by the filter’s ability to handle measurements that change in time. To model the problem so that a Kalman filter may be used it is necessary to write a state equation for the parameters to be estimated in the form

xk+1= φkxk+ kwk (3.73)

zk= Hkxk+ εk (3.74)

where Equation (3.73) (the state equation) represents the evolution of the parameters in time and Equation (3.74) represents the measurements. The terms wk andεk are discrete time random processes representing state noise, i.e. random inputs in the evolution of the parameters, and measurement errors, respectively. Typically wk

andεk are assumed to be independent of each other and uncorrelated from sample to sample. If wk andεk have zero means then it is common to assume that

E {wkwTj} = Qk; k = j (3.75)

= 0; k = j

E {εkεTj} = Rk; k = j (3.76)

= 0; k = j

The matrices Qk and Rk are the covariance matrices of the random processes and are allowed to change as k changes.

The matrix ϕk in Equation (3.73) is the state transition matrix. If we imagine sampling a pure sinusoid of the form

y(t) = Yc cos(ωt) + Ys sin(ωt)

at equal intervals corresponding toωt = ψ then we could take the state to be xk=

Yc Ys



and since the state does not change in time ϕ =

1 0 0 1



In this case Hk the measurement matrix would be Hk = [cos(kψ) sin(kψ)]

A second possibility is to define the state as xk=

 cos kψ sin kψ

− sin kψ cos kψ

 Yc

Ys



so that

ϕk =

 cosψ sin ψ

− sin ψ cos ψ



and

Hk = [1 0]

The Kalman filter assumes an initial (before the measurements are made) statistical description of the state x, and recursively (as each measurement becomes available) updates the estimate of state. The initial assumption about the state is that it is a random vector independent of the processes wkandεk and with a known mean and covariance matrix, P0. The recursive calculation involves computing a gain matrix Kk. The estimate ˆx is given by

ˆxk+1= ϕkxk+ Kk+1[zk+1− Hk+1ϕkˆxk] (3.77) The first term in Equation (3.77) is an update of the old estimate by the state transition matrix while the second is the gain matrix multiplying the observation residual. The bracketed term in Equation (3.77) is the difference between the actual measurement, zk, and the predicted value of the measurement, i.e. the residual in predicting the measurement. That is, φkˆxk is the predicted state and Hk+1φkˆxk

is the predicted measurement. The computation of the gain matrix Kk involves the computation of two covariance matrices. The first is the covariance of the one-step prediction denoted P(k+1|k). The second is the covariance of the error in the estimate at time k, P(k|k). The first step in computing the gain matrix is to update the covariance for the one-step prediction

P(k+1|k) = φkP(k|k)φTk + kQkTk (3.78)

The gain matrix can be computed as

Kk+1= P(k+1|k)HTk+1[Hk+1P(k+1|k)HTk+1+ Rk+1]−1 (3.79) The matrix that must be inverted in Equation (3.79) is of the dimension of the measurements which typically is smaller than the number of states. In the line relaying application, the state dimension is 2 while there is only one measurement.

In order to maintain the recursion an additional calculation is involved. The matrix P(k+1|k+1) must be formed to be used in the next version of Equation (3.78).

P(k+1|k+1) = [I − Kk+1Hk+1]P(k+1|k) (3.80) Alternate gain expressions are frequently useful. Many forms of Equations (3.78), (3.79) and (3.80) can be obtained using the matrix inversion lemma given in Equation (3.81)

(A−1+ BTC−1B)−1 = A − ABT(BABT+ C)−1BA (3.81) If we write Equation (3.79) in a more compact notation as K = PHT(HPHT+R)−1 and apply the lemma as in Equation (3.82)

K =(P−1+ HTR−1H)−1(P−1+ HTR−1H)PHT(R + HPHT)−1 (3.82) K =(P−1+ HTR−1H)−1(HT+ HTR−1HPHT)(R + HPHT)−1

K =(P−1+ HTR−1H)−1HTR−1(HPHT+ R)(R + HPHT)−1 K =(P−1+ HTR−1H)−1HTR−1

Or

Kk+1= [HTk+1Rk+1Hk+1+ P−1(k+1|k)]−1Hk +1T Rk+1 (3.83) Substituting Equation (3.79) into Equation (3.80) with the same notation and employing the lemma again

P = P − PHT(HPHT+ R)−1HP =(P + HTR−1+ R)−1 (3.84)

Example 3.22

It seems appropriate to give a comparison of the Kalman estimates and the estimates formed using the DFT algorithms. To do so, however, it is necessary to put the algorithms on a common basis. The Kalman estimate assumes an initial estimate and an initial covariance for that estimate, while the DFT algorithm does not.

Equations 3.78–3.80 are not convenient if there is no initial estimate. A form of

the equations which is convenient for this case involves the inverse of the covariance matrix P(k|k). If we define the inverse of the covariance matrix as

Fk= P(k|k)−1

and assume that there is no random input to the system, i.e. Qk= 0, then Equations (3.78) and (3.79) can be rewritten in terms of an update of Fk as

Fk+1= ϕ−Tk Fkϕ−1k + HTk+1R−1k+1Hk+1 (3.85) The advantage of Equation (3.82) is that F0 can be taken as zero. The matrix Fk is referred to as the information matrix and can also be used to compute the gain from

Fk+1Kk+1 = HTk+1R−1k+1 (3.86) Equation (3.85) makes it clear that, if the initial F0is zero, we must make enough measurements so that Fk is invertible before the gain matrix can be computed. In the relaying problem, this is a manifestation of the fact that one measurement is not sufficient to form an estimate of a phasor. If we take the form of the state equation for the phasor given by ϕk= I and Hk = [cos(kψ)sin(kψ)], and assume that Rk = I, the recursion for the information matrix becomes

Fk+1= Fk+

 cos2(k + 1)ψ cos(k + 1)ψ sin(k + 1)ψ cos(k + 1)ψ sin(k + 1)ψ sin2(k + 1)ψ



or

FN=

N k=1

 cos2kψ cos kψ sin kψ cos kψ sin kψ sin2



Under the assumption that ϕk= I, Qk= 0, Rk= I, the recursions are

Kk= F−1k HTk (3.87)

Fk= Fk−1+ HTk Hk (3.88)

And using Equation (3.87) in Equation (3.77)

ˆxk=Xk−1+ F−1k HTk[zk− Hk ˆxk−1] ˆxk= F−1k [Fk− HTkHk]ˆxk−1+ HTkzk] and using Equation (3.85)

ˆxk = F−1k [Fk−1ˆxk−1+ HTkzk] (3.89)

Equation (3.89) can be repeated to yield

ˆxk= F−1k [Foxo+ HT1z1+ HT2z2+ · · · + HTkzk] (3.90) Equation (3.90) shows that if the initial information matrix is zero then the esti-mate is formed as the weighted sum of the measurements (if F0 is zero then the first term in the brackets is zero). The bracketed quantity in Equation (3.87) is

 cos(kψ)zk

sin(kψ)zk



In other words, if there is no initial information and the measurement error has a constant covariance then the Kalman filter estimate is a combination of DFT terms.

The particular combination depends on the matrix F−1k .

If there are an even number of samples per half cycle, at multiples of a half cycle, ψ = π/2n, N = 2nm, i.e. m = 1 is a half cycle, m = 2 is a full cycle, m = 3 is 3 sum of cos(π/n) or sin(π/n) over a full period. Since

2n

In fact, the Kalman filter estimate exactly corresponds to the Fourier estimates in these situations.11 The estimates given by Equation (3.90) were first derived in a

digital relaying context without reference to Kalman filtering. There are seen to be two possible reasons to use the Kalman filter. They are: the existence of an initial estimate, or non-constant measurement noise.

3.10 Summary

In this chapter we have presented the background material needed to understand relaying algorithms. We have examined the Fourier series and Fourier transform as means of determining the frequency content of signals. In a digital relaying context the discrete Fourier transform which takes samples of a signal and computes the various harmonics is of particular importance. The Fourier transform sheds light on the sampling process and explains the need for anti-aliasing filters.

Ideas of probability and random processes are required in order to appreciate how various algorithms estimate the parameters of interest in the relaying application.

The view that the solution of an over-defined set of equations is an estimation problem will be used extensively in Chapter 4. The Kalman filter has also been applied in distance relaying. Our presentation of the Kalman filter makes it clear that the primary use of the filter in relaying should be in situations where the mea-surement noise does not have a constant covariance. When the meamea-surement noise has a constant covariance and when no prior knowledge of the state is assumed, then the Kalman filter solution is equivalent to solutions obtained with other tech-niques.

Problems

3.1 Determine whether each of the following signals is periodic. If so, give the