33
1 Lecture 20 Power Engineering - Egill Benedikt Hreinsson Sparse Matrices in Power Flow Calculations

RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

Embed Size (px)

Citation preview

Page 1: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

1Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Sparse Matrices in Power Flow Calculations

Page 2: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

2Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Any matrix that has a high proportion of its elements equal to zero is a sparse matrix.

•Most large matrices that arise in engineering applications are sparse.

Sparse Matrices?

Page 3: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

3Lecture 20 Power Engineering - Egill Benedikt Hreinsson

The Sparsity of a Matrix - A definition

The sparsity of a matrix

Number of elements Total number of elements

=⋅0 100 %

A sparse matrix: A matrix, where most of the elements are zero, but a few are different from zero

A full matrix: A matrix, where all the elements are non-zero

=

Page 4: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

4Lecture 20 Power Engineering - Egill Benedikt HreinssonWhy and What Are Sparse Matrices in Power Systems?

• Matrices in power systems are often very large and very sparse!• A large matrix: is for instance of dimension 100x100,

1000x1000 or 10000x10000!• A sparse matrix: A matrix where, for instance, 99% of the

elements are zero, but 1% are different from zero.• Examples of these matrices are the Ybus matrix and the Jacobi-

matrix, which both are used in power flow calculations.

Page 5: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

5Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Ybus Matrix Composition• The diagonal elements of the Ybus

matrix consist of the sum of the (series and shunt) admittances connected to the bus in question

• These elements are always present!

• The off-diagonal elements of the Ybusmatrix consist of the negative value of the series admittances connecting the 2 buses in question. These elements will be zero when no direct connection is between buses. (The Ybus matrix is very sparse!)

• These elements are present only when there is a link (a line or transformer)

11 12 1

21 22 1

1 2

n

n

n n nn

y y yy y y

y y y

⎡ ⎤⎢ ⎥⎢ ⎥=⎢ ⎥⎢ ⎥⎣ ⎦

busY

ikik iky y eγ=

We review the rule for building the Ybus matrix:

Page 6: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

6Lecture 20 Power Engineering - Egill Benedikt Hreinsson

The Sparsity of a Matrix: Example 1:

An example: Assume, in an electrical power system, each bus is on the average connected to 1.5 other buses. Further assume that we have a 100 bus system. We get a 100 by 100 matrix with 100 · 100 elements.

With the above assumption in the Ybus matrix there are 100 diagonal elements ≠ 0 and 150 elements above the diagonal and 150 elements below the diagonal ≠ 0. The sparsity of this matrix will therefore be:

Sparsity = 100 100 150 150 100

100 100

960

⋅ − − −⋅

= , %

We can say that the matrix is 4% full.

Sparsity

Page 7: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

7Lecture 20 Power Engineering - Egill Benedikt Hreinsson

The Sparsity of a Matrix: Example 2:

Similarly for a 1000 bus system we get a matrix with 1000 · 1000 elements. We have for the same assumption of how each bus is interconnected for the Ybus matrix 1000 diagonal elements ≠ 0 and 1500 elements above the diagonal and 1500 elements below the diagonal ≠ 0. The sparsity of this matrix will be:

Sparsity = 1000 1000 1500 1500 1000

1000 1000

996

⋅ − − −⋅

= , %

We can perhaps say that the matrix is 0,4% full.

Sparsity

Page 8: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

8Lecture 20 Power Engineering - Egill Benedikt Hreinsson

The Sparsity of the Jacobi-Matrix The J1 sub-matrix :

The J2 sub-matrix :

The J3 sub-matrix

The J4 sub-matrix :

Conclusion: If Ybus is a sparse matrix, the Jacobi matrix is also sparseThe elements of Ybus are also in the Jacobi matrices

( )1,

sinn

ii k ik i k ik

k k ii

PV V y δ δ γ

δ = ≠

∂= − ⋅ − −

∂ ∑

( )sinii k ik i k ik

k

PV V y δ δ γ

δ∂

= ⋅ − −∂

i k≠

( ) ( )1,

2 cos cosn

ii ii ii j ij i j ij

j j ii

PV y V y

Vγ δ δ γ

= ≠

∂= ⋅ − + ⋅ − −

∂ ∑

( )cosii ik i k ik

k

PV y

Vδ δ γ

∂= ⋅ − −

∂k i≠

( )1,

cosn

ii j ij i j ij

j j ii

QV V y δ δ γ

δ = ≠

∂= ⋅ − −

∂ ∑

( )cosii k ik i k ik

k

QV V y δ δ γ

δ∂

= − ⋅ − −∂

k i≠

( ) ( )1,

2 sin sinn

ii ii ii j ij i j ij

j j ii

QV y V y

Vγ δ δ γ

= ≠

∂= ⋅ − + ⋅ − −

∂ ∑

( )sinii ik i k ik

k

QV y

Vδ δ γ

∂= ⋅ − −

∂ k i≠

Page 9: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

9Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Random Sparse MatricesA Random Sparse Matrix

Sparse matrices can be of different nature

Page 10: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

10Lecture 20 Power Engineering - Egill Benedikt Hreinsson

IEEE TEST systems• IEEE test systems are standardized power systems to test

research theories in power system analysis• We will look at different sparse Ybus matrices for different

IEEE test systems along with their one-line diagram:– 14 bus– 30 bus– 57 bus– 118 bus– 300 bus

• These test systems can be found at:– http://www.ee.washington.edu/research/pstca/– (http://www.pserc.cornell.edu/matpower/)

Page 11: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

11Lecture 20 Power Engineering - Egill Benedikt Hreinsson

IEEE 14 BUS TEST CASE

0 5 10 15

0

5

10

15nz = 54

Use the SPY function in Matlab

Page 12: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

12Lecture 20 Power Engineering - Egill Benedikt Hreinsson

IEEE 30 BUS TEST CASE

Use the “SPY” function in Matlab to obtain the graphical representation of the sparse matrix

0 5 10 15 20 25 30

0

5

10

15

20

25

30

nz = 112

Page 13: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

13Lecture 20 Power Engineering - Egill Benedikt Hreinsson

IEEE 57 BUS TEST CASE

Sparsity 93%

0 10 20 30 40 50

0

10

20

30

40

50

nz = 213

Use the SPY function in Matlab

Page 14: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

14Lecture 20 Power Engineering - Egill Benedikt Hreinsson

IEEE 118 bus test system

(Ybus)

0 20 40 60 80 100

0

20

40

60

80

100

nz = 476

Page 15: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

15Lecture 20 Power Engineering - Egill Benedikt Hreinsson

IEEE 300 bus test system(Ybus)

0 50 100 150 200 250 300

0

50

100

150

200

250

300

nz = 1118

See details for the one-line diagrams for the 300 bus system on the following slides

Page 16: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

16Lecture 20 Power Engineering - Egill Benedikt Hreinsson

300 bus IEEE test system (1) one line diagram

Page 17: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

17Lecture 20 Power Engineering - Egill Benedikt Hreinsson

300 bus IEEE test system (2)

one line diagram

Page 18: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

18Lecture 20 Power Engineering - Egill Benedikt Hreinsson

300 bus IEEE test system (3) one line diagram

Page 19: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

19Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Sparsity structure of a 108 bus Icelandic system Ybus matrix

0 10 20 30 40 50 60 70 80 90 100

0

10

20

30

40

50

60

70

80

90

100

nz = 346

Page 20: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

20Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Solutions to the power system problem with sparse matrices

• For large systems (and power systems are large) we need to exploit the sparsity of the system matrices

• Therefore solutions to power flow problem with Newton’s method involves solution to a set of linear equations rather than direct inversion of matrices

• We use Gauss elimination as a standard set of solving large linear systems of equations where we exploit simultaneously the sparsity structure of the system matrix (Jacobi)

Page 21: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

21Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Sparse Matrices and Solutions to Sets of Linear Equations in Power Systems

1,1 1,2 1, 1 1

2,1 2,2 2, 2 2

,1 ,2 ,

n

n

n n n n n n

a a a x ba a a x b

a a a x b

⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⋅ =⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥

⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎣ ⎦ ⎣ ⎦⎣ ⎦

To solve: Find a vector of unknown x-es. Other quantities are known or the a-s and b-s are known

Page 22: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

22Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Matrix Notation in Linear Equations

1,1 1,2 1, 1 1

2,1 2,2 2, 2 2

,1 ,2 ,

n

n

n n n n n n

a a a x ba a a x b

a a a x b

⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥= = =⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎣ ⎦ ⎣ ⎦⎣ ⎦

A x b

A is a known matrixx is a vector with unknown variables. b is a known vector.

⋅ =A x b

Page 23: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

23Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Direct methods

Gaussian eliminationGauss-Jordan eliminationLU factorizationCholesky factorization

Iterative methods

Jacobi iterationsGauss-Seidel iteration

Solution methods for linear equations based on numerical analysis

Page 24: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

24Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Solutions to a Set of Linear Equations

• If we can transform the matrix to a triangular form, it is possible to solve the equations

• “Elementary Operations” can be carried out without changing the solution

• Examples of “Elementary Operation”:– Multiply rows (equations) with a constant– Add rows (equations) to each other

• This is the Gauss elimination method

Page 25: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

25Lecture 20 Power Engineering - Egill Benedikt Hreinsson

⎥⎥⎥⎥

⎢⎢⎢⎢

=

⎥⎥⎥⎥

⎢⎢⎢⎢

⎥⎥⎥⎥

⎢⎢⎢⎢

nnnn

n

n

b

bb

x

xx

a

aaaaa

2

1

2

1

,

,22,2

,12,11,1

00

0

Solutions to Linear Equations in Power Systems. A Special Case (triangular form)

Assume for a moment that a matrix has the special triangular form case -- The matrix, A is triangular with all zeros below the diagonal:

Solution method: Back substitution

Page 26: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

26Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Back Substitution

1,111,1 −−−−− =+ nnnnnnn bxaxa

,

nn

n n

bxa

=

1,1

,111

−−

−−−

−=

nn

nnnnn a

xabx

1,1

,133,122,111

,

1,

2,2

11,2,222

axaxaxab

x

a

xabx

axaxab

x

nn

kk

n

kjjjkk

k

nn

nnnnnnnn

−−−−=

−=

−−=

∑+=

−−

−−−−−−

1,1 1,2 1, 1 1

2,2 2, 2 2

,

0

0 0

n

n

n n n n

a a a x ba a x b

a x b

⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⋅ =⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥

⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎣ ⎦ ⎣ ⎦⎣ ⎦

nnnn bxa =,

2,211,222,2 −−−−−−−− =++ nnnnnnnnnn bxaxaxa

The last line

The second last line

The 3rd line from the end

Page 27: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

27Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Solution method

• How do we get any matrix to a triangular form?• Transform the matrix by Gauss elimination to a lower

triangular form matrix• Solve such a matrix by back substitution

• We have already checked out back substitution. Let us look at Gauss elimination!!

Page 28: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

28Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Gaussian Elimination (1st step)

1,1 1,2 1,3 1,

2,1 2,2 2,3 2,

3,1 3,2 3,3

,1 ,2 ,3 ,

n

n

n n n n n

a a a aa a a aa a a

a a a a

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

The original matrix:

1,1 1,2 1,3 1,

2,1 2,1 2,12,2 1,2 2,3 1,3 2, 1,

1,1 1,1 1,1

3,1 3,1 3,13,2 1,2 3,3 1,3 3, 1,

1,1 1,1 1,1

,1 ,1 ,1,2 1,2 ,3 1,3 , 1,

1,1 1,1 1,1

0

0

0

n

n n

n n

n n nn n n n n

a a a aa a a

a a a a a aa a aa a a

a a a a a aa a a

a a aa a a a a a

a a a

⎡⎢⎢ − ⋅ − ⋅ − ⋅⎢⎢⎢ − ⋅ − ⋅ − ⋅⎢⎢⎢⎢⎢ − ⋅ − ⋅ − ⋅⎢⎣

⎤⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥

⎢ ⎥⎦

Multiply the 1st rowwith a2,1/a1,1 and subtract from the 2nd row

Multiply the 1st rowwith a3,1/a1,1 and subtract from the 3rd row

Multiply the 1st row with an,1/a1,1 and subtract from the last row

2,1

1,1

aa

Page 29: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

29Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Gaussian Elimination (2nd step)

1,1 1,2 1,3 1,(1) (1) (1)2,2 2,3 2,

(1) (1) (1)1,2 1,3 1,

(1) (1) (1),2 ,3 ,

0

00

n

n

n n n n

n n n n

a a a aa a a

a a aa a a− − −

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

The matrix after the 1st step:

The 1st column is with zerosexcept at the top row

Page 30: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

30Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Gaussian Elimination (2nd step)The matrix after the 1st step:

1,1 1,2 1,3 1,(1) (1) (1)2,2 2,3 2,

(1) (1)3,2 3,2(1) (1) (1) (1)

3,3 2,3 3, 2,(1) (1)2,2 2,2

(1) (1),2 ,2(1) (1) (1) (1)

,3 2,3 , 2,(1) (1)2,2 2,2

0

0 0

0 0

n

n

n n

n nn n n n

a a a aa a a

a aa a a a

a a

a aa a a a

a a

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟− ⋅ − ⋅⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟− ⋅ − ⋅⎜ ⎟⎜ ⎟⎝ ⎠

Multiply the 2nd row with

and subtract from the 3rd row

Multiply the 2nd row with

and subtract from the last row

1,2 1,2 1,3 1,(1) (1) (1)2,2 2,3 2,

(1) (1) (1)1,2 1,3 1,

(1) (1) (1),2 ,3 ,

0

00

n

n

n n n n

n n n n

a a a aa a a

a a aa a a− − −

⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦

)1(2,2

)1(2,3

aa

)1(2,2

)1(2,

aan

Now the 2nd row plays the same role as the 1st row before:

Page 31: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

31Lecture 20 Power Engineering - Egill Benedikt Hreinsson

1,2 1,2 1,3 1,(1) (1) (1)2,2 2,3 2,

(2) (2)1,3 1,

(2) (2),3 ,

0

0 00 0

n

n

n n n

n n n

a a a aa a a

a aa a− −

⎛ ⎞⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎜ ⎟⎝ ⎠

Gaussian Elimination (3rd step)

The matrix after the 2nd step:

The 1st column with zeros except at the top

The 2nd column with zeros, except in the 2 top rows

Page 32: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

32Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Gauss-Elimination Transforms the Matrix to the Following Form :

This matrix is U or an “upper” or “unit upper”triangular matrix. The elements are calculated with iteration, where each step is an “elementary operation”. It is possible to solve the equation with a simple “back substitution”. It is found by dividing each row with the diagonal element

1 112 1

2 22

10 1

0 0 1

n

n

n n

x ba ax ba

x b

′′ ′ ⎡ ⎤ ⎡ ⎤⎛ ⎞⎜ ⎟ ⎢ ⎥ ⎢ ⎥′′⎜ ⎟ ⎢ ⎥ ⎢ ⎥=⎜ ⎟ ⎢ ⎥ ⎢ ⎥⎜ ⎟ ⎢ ⎥ ⎢ ⎥⎜ ⎟ ′⎢ ⎥ ⎢ ⎥⎝ ⎠ ⎣ ⎦ ⎣ ⎦

⋅ =U x G

Page 33: RK20 power flow sparse - University of Iceland · Lecture 20 Power Engineering - Egill Benedikt Hreinsson 1 Sparse Matrices in Power Flow Calculations

33Lecture 20 Power Engineering - Egill Benedikt Hreinsson

Gaussian Elimination

• After n-1 steps the matrix has become triangular!

• Computer time grows fast with the matrix size (increasing n)

• Computer time grows in proportion to n3, if the matrix is not sparse

• We can obtain a “1” on the diagonal by dividing by the diagonal element in each step