You are on page 1of 25

AC Power Flows, Generalized OPF Costs and their

Derivatives using Complex Matrix Notation


Ray D. Zimmerman
March 14, 2011∗

Matpower Technical Note 2


c 2008, 2010, 2011 Power Systems Engineering Research Center (Pserc)
All Rights Reserved


Third revision. First draft was February 29, 2008, second February 24, 2010.
CONTENTS CONTENTS

Contents
1 Notation 4

2 Introduction 5

3 Voltages 6
3.1 Bus Voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Branch Voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 Bus Injections 7
4.1 Complex Current Injections . . . . . . . . . . . . . . . . . . . . . . . 7
4.1.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.2 Complex Power Injections . . . . . . . . . . . . . . . . . . . . . . . . 8
4.2.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.2.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 8

5 Branch Flows 11
5.1 Complex Currents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.1.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.1.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2 Complex Power Flows . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.2.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.2.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 13
5.3 Squared Current Magnitudes . . . . . . . . . . . . . . . . . . . . . . . 15
5.3.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.3.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 16
5.4 Squared Apparent Power Magnitudes . . . . . . . . . . . . . . . . . . 17
5.4.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.4.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 17
5.5 Squared Real Power Magnitudes . . . . . . . . . . . . . . . . . . . . . 18
5.5.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.5.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 18

2
CONTENTS CONTENTS

6 Generalized AC OPF Costs 19


6.1 Polynomial Generator Costs . . . . . . . . . . . . . . . . . . . . . . . 19
6.1.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 20
6.1.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 20
6.2 Piecewise Linear Generator Costs . . . . . . . . . . . . . . . . . . . . 20
6.2.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.2.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 21
6.3 General Cost Term . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6.3.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 22
6.3.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 23
6.4 Full Cost Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.4.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 23
6.4.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 23

7 Lagrangian of the AC OPF 24


7.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
7.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3
1 NOTATION

1 Notation
nb , ng , nl number of buses, generators, branches, respectively
|vi |, θi bus voltage magnitude and angle at bus i
vi complex bus voltage at bus i, that is |vi |ejθi
V, Θ nb × 1 vectors of bus voltage magnitudes and angles
V nb × 1 vector of complex bus voltages vi
Ibus nb × 1 vector of complex bus current injections
If , It nl × 1 vectors of complex branch current injections, from and to ends
Sbus nb × 1 vector of complex bus power injections
Sf , St nl × 1 vectors of complex branch power flows, from and to ends
Sg ng × 1 vector of generator complex power injections
P, Q real and reactive power flows/injections, S = P + jQ
M, N real and imaginary parts of current flows/injections, I = M + jN
Ybus nb × nb system bus admittance matrix
Yf nl × nb system branch admittance matrix, from end
Yt nl × nb system branch admittance matrix, to end
Cg nb × ng generator connection matrix
(i, j)th element is 1 if generator j is located at bus i, 0 otherwise
Cf , Ct nl × nb branch connection matrices, from and to ends,
(i, j)th element is 1 if from end, or to end, respectively, of branch i is
connected to bus j, 0 otherwise
[A] diagonal matrix with vector A on the diagonal
AT (non-conjugate) transpose of matrix A
A∗ complex conjugate of A
1n n × 1 vector of all ones

4
2 INTRODUCTION

2 Introduction
The purpose of this document is to show how the AC power balance and flow equa-
tions used in power flow and optimal power flow computations can be expressed in
terms of complex matrices, and how their first and second derivatives can be com-
puted efficiently using complex sparse matrix manipulations. Similarly, the deriva-
tives of the generalized AC OPF cost function used by Matpower and the corre-
sponding OPF Lagrangian function are developed.
We will be looking at complex functions of the real valued vector
 
Θ
 V 
X=  Pg 
 (1)
Qg
 T
For a complex scalar function f : Rn → C of a real vector X = x1 x2 · · · xn ,
we use the following notation for the first derivatives (transpose of the gradient)

∂f h
∂f ∂f ∂f
i
fX = = ∂x1 ∂x2
··· ∂xn (2)
∂X
The matrix of second partial derivatives, the Hessian of f , is
 
∂2f 2f

T ∂x21
· · · ∂x∂1 ∂x n
2
 
∂ f ∂ ∂f  . . . 
fXX = = =  .
. . . .
.  (3)
∂X 2 ∂X ∂X ∂2f ∂2f

∂xn ∂x1
··· ∂x2 n

For a complex vector function F : Rn → Cm of a vector X, where


 T
F (X) = f1 (X) f2 (X) · · · fm (X) (4)

the first derivatives form the Jacobian matrix, where row i is the transpose of the
gradient of fi  ∂f1 ∂f1

∂x1
· · · ∂x n
∂F
FX = =  ... .. ..  (5)

. . 
∂X ∂fm
∂x1
· · · ∂f
∂xn
m

In these derivations, the full 3-dimensional set of second partial derivatives of F will
not be computed. Instead a matrix of partial derivatives will be formed by computing

5
3 VOLTAGES

the Jacobian of the vector function obtained by multiplying the transpose of the
Jacobian of F by a vector λ, using the following notation

FX T λ

FXX (λ) = (6)
∂X
Just to clarify the notation, if Y and Z are subvectors of X, then

FY T λ

FY Z (λ) = (7)
∂Z
One common operation encountered in these derivations is the element-wise mul-
tiplication of a vector A by a vector B to form a new vector C of the same dimension,
which can be expressed in either of the following forms

C = [A] B = [B] A (8)


It is useful to note that the derivative of such a vector can be calculated by the chain
rule as
∂C ∂B ∂A
CX = = [A] + [B] = [A] BX + [B] AX (9)
∂X ∂X ∂X

3 Voltages
3.1 Bus Voltages
V is the nb × 1 vector of complex bus voltages. The element for bus i is vi = |vi |ejθi .
V and Θ are the vectors of bus voltage magnitudes and angles. Let

E = [V]−1 V (10)

3.1.1 First Derivatives


∂V
VΘ = = j [V ] (11)
∂Θ
∂V
VV = = [V ] [V]−1 = [E] (12)
∂V
∂E
EΘ = = j [E] (13)
∂Θ
∂E
EV = = 0 (14)
∂V

6
3.2 Branch Voltages 4 BUS INJECTIONS

3.1.2 Second Derivatives


It may be useful in later derivations to note that

∂V T
 

VVV (λ) = λ = [λ] EV = 0 (15)
∂V ∂V

3.2 Branch Voltages


The nl × 1 vectors of complex voltages at the from and to ends of all branches are,
respectively

Vf = Cf V (16)
V t = Ct V (17)

3.2.1 First Derivatives

∂Vf ∂V
= Cf = jCf [V ] (18)
∂Θ ∂Θ
∂Vf ∂V
= Cf = Cf [V ] [V]−1 = Cf [E] (19)
∂V ∂V

4 Bus Injections
4.1 Complex Current Injections
Ibus = Ybus V (20)

4.1.1 First Derivatives

∂Ibus  ∂Ibus ∂Ibus



= ∂Θ ∂V
0 0 (21)
∂X
∂Ibus ∂V
= Ybus = jYbus [V ] (22)
∂Θ ∂Θ
∂Ibus ∂V
= Ybus = Ybus [V ] [V]−1 = Ybus [E] (23)
∂V ∂V

7
4.2 Complex Power Injections 4 BUS INJECTIONS

4.2 Complex Power Injections


Consider the complex power balance equation, Gs (X) = 0, where

Gs (X) = Sbus + Sd − Cg Sg (24)

and

Sbus = [V ] Ibus ∗ (25)

4.2.1 First Derivatives

∂Gs
GsX =
 s
GΘ GsV GsPg GsQg

= (26)
∂X
∂Sbus ∂V ∂Ibus ∗
GsΘ = = [Ibus ∗ ] + [V ] (27)
∂Θ ∂Θ ∂Θ
= [Ibus ∗ ] j [V ] + [V ] (jYbus [V ])∗ (28)
= j [V ] ([Ibus ∗ ] − Ybus ∗ [V ∗ ]) (29)

∂Sbus ∂V ∂Ibus ∗
GsV = = [Ibus ∗ ] + [V ] (30)
∂V ∂V ∂V
= [Ibus ∗ ] [E] + [V ] Ybus ∗ [E ∗ ] (31)
= [V ] ([Ibus ∗ ] + Ybus ∗ [V ∗ ]) [V]−1 (32)

GsPg = −Cg (33)

GsQg = −jCg (34)

4.2.2 Second Derivatives


GsXX (λ) = GsX T λ

(35)
∂X
 
GsΘΘ (λ) GsΘV (λ) 0 0
 GsVΘ (λ) GsVV (λ) 0 0 
=   (36)
 0 0 0 0 
0 0 0 0

8
4.2 Complex Power Injections 4 BUS INJECTIONS


GsΘΘ (λ) = GsΘ T λ

(37)
∂Θ
∂    
= j [Ibus ∗ ] − [V ∗ ] Ybus ∗ T [V ] λ (38)
∂Θ
∂  
= j [Ibus ∗ ] [V ] λ − [V ∗ ] Ybus ∗ T [V ] λ (39)
∂Θ


[V ∗ ]) + [Ibus ∗ ] [λ] (j [V ])

= j
[V ] [λ] |(−jYbus
{z } | {z }
∂Ibus ∗ ∂V
∂Θ ∂Θ

h i
− [V ∗ ] Ybus ∗ T [λ] (j [V ]) − Ybus ∗ T [V ] λ (−j [V ∗ ]) (40)

| {z } | {z }
∂V ∂V ∗
∂Θ ∂Θ
 h i
= [V ∗ ] Ybus ∗ T [V ] [λ] − Ybus ∗ T [V ] λ
+ [λ] [V ] (Ybus ∗ [V ∗ ] − [Ibus ∗ ]) (41)
= E +F (42)


GsVΘ (λ) = GsV T λ

(43)
∂Θ
∂  
= [E] [Ibus ∗ ] λ + [E ∗ ] Ybus ∗ T [V ] λ (44)
∂Θ
= [E] [λ] (−jYbus ∗ [V ∗ ]) + [Ibus ∗ ] [λ] j [E]
| {z } |{z}
∂Ibus ∗ ∂E
∂Θ ∂Θ
h i
∗ ∗T ∗T
+ [E ] Ybus [λ] j [V ] + Ybus [V ] λ (−j [E ∗ ]) (45)
|{z} | {z }
∂V ∂E ∗
∂Θ ∂Θ
  h i
= j [E ∗ ] Ybus ∗ T [V ] [λ] − Ybus ∗ T [V ] λ

∗ ∗ ∗
− [λ] [E] (Ybus [V ] − [Ibus ]) (46)
  h i
= j [V]−1 [V ∗ ] Ybus ∗ T [V ] [λ] − Ybus ∗ T [V ] λ

− [λ] [V ] (Ybus ∗ [V ∗ ] − [Ibus ∗ ]) (47)
= jG(E − F) (48)

9
4.2 Complex Power Injections 4 BUS INJECTIONS


GsΘV (λ) = GsΘ T λ

(49)
∂V
 h i
= j [λ] [V ] Ybus ∗ − Ybus ∗ T [V ] λ [V ∗ ]
  
− [V ∗ ] Ybus ∗ T − Ibus ∗ [V ] [λ] [V]−1 (50)
= GsVΘ T (λ) (51)


GsVV (λ) = GsV T λ

(52)
∂V
∂  
= [E] [Ibus ∗ ] λ + [E ∗ ] Ybus ∗ T [V ] λ (53)
∂V
= [E] [λ] Ybus ∗ [E ∗ ] + [Ibus ∗ ] [λ] |{z}
0
| {z }
∂E
∂Ibus ∗
∂V
∂V
h i
+ [E ∗ ] Ybus ∗ T [λ] [E] + Ybus ∗ T [V ] λ |{z}
0 (54)
|{z} ∗
∂V ∂E
∂V ∂V
 
−1
= [V] ∗ ∗ ∗
[λ] [V ] Ybus [V ] + [V ] Ybus ∗T
[V ] [λ] [V]−1 (55)
= G(C + C T )G (56)

Computational savings can be achieved by storing and reusing certain interme-


diate terms during the computation of these second derivatives, as follows:

A = [λ] [V ] (57)
B = Ybus [V ] (58)
C = AB ∗ (59)
D = Ybus ∗ T [V ] (60)
E = [V ∗ ] (D [λ] − [Dλ]) (61)
F = C − A [Ibus ∗ ] = j [λ] GsΘ (62)
G = [V]−1 (63)
s
GΘΘ (λ) = E +F (64)
GsVΘ (λ) = jG(E − F) (65)
GsΘV (λ) = GsVΘ T (λ) (66)
GsVV (λ) = G(C + C T )G (67)

10
5 BRANCH FLOWS

5 Branch Flows
Consider the line flow constraints of the form H(X) < 0. This section examines 3
variations based on the square of the magnitude of the current, apparent power and
real power, respectively. The relationships are derived first for the complex flows at
the from ends of the branches. Derivations for the to end are identical (i.e. just
replace all f sub/super-scripts with t).

5.1 Complex Currents

I f = Yf V (68)
I t = Yt V (69)

5.1.1 First Derivatives


f ∂I f h
f f f f
i
IX = = IΘ IV IPg IQg (70)
∂X

 
∂V
IΘf = Yf = jYf [V ] (71)
∂Θ
 
∂V
IVf = Yf = Yf [V ] [V]−1 = Yf [E] (72)
∂V
IPf g = 0 (73)
IQf g = 0 (74)

5.1.2 Second Derivatives

f ∂  fT 
IXX (µ) = IX µ (75)
∂X
 f f 
IΘΘ (µ) IΘV (µ) 0 0
 I f (µ) I f (µ) 0 0 
=  VΘ VV  (76)
 0 0 0 0 
0 0 0 0

f ∂  fT 
IΘΘ (µ) = I µ (77)
∂Θ Θ
11
5.2 Complex Power Flows 5 BRANCH FLOWS


j [V ] Yf T µ

= (78)
∂Θ
= − Yf T µ [V ]

(79)

f ∂  fT 
IVΘ (µ) = I µ (80)
∂Θ V

[E] Yf T µ

= (81)
∂Θ
= j Yf T µ [E]
 
(82)
= f
−jIΘΘ (µ) [V]−1 (83)

f ∂  fT 
IΘV (µ) = I µ (84)
∂V Θ

j [V ] Yf T µ

= (85)
∂V
= j Yf T µ [E]
 
(86)
f
= IVΘ (µ) (87)

f ∂  fT 
IVV (µ) = I µ (88)
∂V V

[E] Yf T µ

= (89)
∂V
= 0 (90)

5.2 Complex Power Flows



S f = [Vf ] I f (91)

S t = [Vt ] I t (92)

5.2.1 First Derivatives

∂S f h i
f
SX = = SΘf SVf SPf g SQf g (93)
∂X

h ∗ i ∂V
f ∂I f
= If + [Vf ] (94)
∂X ∂X

12
5.2 Complex Power Flows 5 BRANCH FLOWS


h ∗ i ∂V
f ∂I f
SΘf = I f
+ [Vf ] (95)
h ∗ i ∂Θ ∂Θ
= I f
jCf [V ] + [Cf V ] (jYf [V ])∗ (96)
h ∗i
= j( I f Cf [V ] − [Cf V ] Yf ∗ [V ∗ ]) (97)


h ∗ i ∂V
f ∂I f
SVf = If + [Vf ] (98)
h ∗ i ∂V ∂V
= I f Cf [E] + [Cf V ] Yf ∗ [E ∗ ] (99)

SPf g = 0 (100)

SQf g = 0 (101)

5.2.2 Second Derivatives

f ∂  fT 
SXX (µ) = SX µ (102)
∂X
 f f 
SΘΘ (µ) SΘV (µ) 0 0
 S f (µ) S f (µ) 0 0 
=  VΘ VV  (103)
 0 0 0 0 
0 0 0 0

f ∂  fT 
SΘΘ (µ) = S µ (104)
∂Θ Θ
∂   h ∗i  
= j [V ] Cf T I f − [V ∗ ] Yf ∗ T [Cf V ] µ (105)
∂Θ
∂  h ∗i 
= j [V ] Cf T I f µ − [V ∗ ] Yf ∗ T [Cf V ] µ (106)
∂Θ

h h ∗i i
∗ ∗
 T T
= j
 [V ] C f [µ] (−jY f [V ]) + C f I f µ j [V ]
| {z } |{z}
∗ ∂V
∂I f
∂Θ ∂Θ

13
5.2 Complex Power Flows 5 BRANCH FLOWS


h i
− [V ∗ ] Yf ∗ T [µ] Cf j [V ] − Yf ∗ T [Cf V ] µ (−j [V ∗ ]) (107)

|{z} | {z }
∂V ∂V ∗
∂Θ ∂Θ

= [V ∗ ] Yf ∗ T [µ] Cf [V ] + [V ] Cf T [µ] Yf ∗ [V ∗ ]
h i
− Yf ∗ T [µ] Cf V [V ∗ ] − Cf T [µ] Yf ∗ V ∗ [V ]
 
(108)
= Ff − D f − E f (109)

f ∂  fT 
SVΘ (µ) = S µ (110)
∂Θ V
∂  h ∗i 
= [E] Cf T I f µ + [E ∗ ] Yf ∗ T [Cf V ] µ (111)
∂Θ h h ∗i i
= [E] Cf T [µ] (−jYf ∗ [V ∗ ]) + Cf T I f µ j [E]
| {z } |{z}
∗ ∂E
∂I f
∂Θ ∂Θ
h i
+ [E ∗ ] Yf ∗ T [µ] Cf j [V ] + Yf ∗ T [Cf V ] µ (−j [E ∗ ]) (112)
|{z} | {z }
∂V ∂E ∗
∂Θ ∂Θ

= j [E ∗ ] Yf ∗ T [µ] Cf [V ] − [E] Cf T [µ] Yf ∗ [V ∗ ]
h i  
− Yf ∗ T [µ] Cf V [E ∗ ] + Cf T [µ] Yf ∗ V ∗ [E]

(113)

−1
= j [V] [V ∗ ] Yf ∗ T [µ] Cf [V ] − [V ] Cf T [µ] Yf ∗ [V ∗ ]
h i  
− Yf ∗ T [µ] Cf V [V ∗ ] + Cf T [µ] Yf ∗ V ∗ [V ]

(114)
= jG(Bf − Bf T − Df + Ef ) (115)

f ∂  fT 
SΘV (µ) = SΘ µ (116)
∂V

= j [V ] Cf T [µ] Yf ∗ [V ∗ ] − [V ∗ ] Yf ∗ T [µ] Cf [V ]
h i  
− Yf ∗ T [µ] Cf V [V ∗ ] + Cf T [µ] Yf ∗ V ∗ [V ] [V]−1

(117)
f T
= SVΘ (µ) (118)

f ∂  fT 
SVV (µ) = SV µ (119)
∂V

14
5.3 Squared Current Magnitudes 5 BRANCH FLOWS

∂  h ∗i 
= [E] Cf T I f µ + [E ∗ ] Yf ∗ T [Cf V ] µ (120)
∂V h h ∗i i
= [E] Cf T [µ] Yf ∗ [E ∗ ] + Cf T I f µ |{z}
0
| {z } ∂E

∂I f ∂V
∂V
h i
∗ ∗T ∗T
+ [E ] Yf [µ] Cf [E] + Yf [Cf V ] µ |{z}
0 (121)
|{z}
∂V ∂E ∗
∂V ∂V
 
= [V]−1 [V ∗ ] Yf ∗ T [µ] Cf [V ] + [V ] Cf T [µ] Yf ∗ [V ∗ ] [V]−1 (122)
= GFf G (123)

Computational savings can be achieved by storing and reusing certain interme-


diate terms during the computation of these second derivatives, as follows:

Af = Yf ∗ T [µ] Cf (124)
Bf = [V ∗ ] Af [V ] (125)
Df = [Af V ] [V ∗ ] (126)
 T ∗
Ef = Af V [V ] (127)
Ff = Bf + Bf T (128)
G = [V]−1 (129)
f
SΘΘ (µ) = Ff − Df − Ef (130)
f
SVΘ (µ) = jG(Bf − Bf T − Df + Ef ) (131)
f f T
SΘV (µ) = SVΘ (µ) (132)
f
SVV (µ) = GFf G (133)

5.3 Squared Current Magnitudes


2
Let Imax denote the vector of the squares of the current magnitude limits. Then the
flow constraint function H(X) can be defined in terms of the square of the current
magnitudes as follows:
h ∗i
H f (X) = I f I f − Imax 2
(134)
= M f M f + N f N f − Imax 2
   
(135)

where I f = M f + jN f .

15
5.3 Squared Current Magnitudes 5 BRANCH FLOWS

5.3.1 First Derivatives

f
h ∗i
f
  f∗
HX = I f IX + I f IX (136)
h ∗i h ∗ i ∗
f f
= I f IX + I f IX (137)
nh ∗ i o
f
= 2 · < I f IX (138)
M − jN f (MXf + jNXf ) + M f + jN f (MXf − jNXf )
 f   
= (139)
 
2 M f MXf + N f NXf
  
= (140)
   n o   n f o
f
= 2 < I f < IX + = I f = IX (141)

5.3.2 Second Derivatives

f ∂  fT 
HXX (µ) = HX µ (142)
∂X
 f f 
HΘΘ (µ) HΘV (µ) 0 0
 H (µ) H f (µ)
f
0 0 
=  VΘ VV  (143)
 0 0 0 0 
0 0 0 0

f ∂ 
fT

HXX (µ) = HX µ (144)
∂X
∂  T h ∗i
f f f ∗T
 f 
= IX I µ + IX I µ (145)
∂X
f∗ f ∗ f ∗T
h ∗i
f fT f
( I f µ) + IX ( I f µ) + IX
 
= IXX [µ] IX + IXX [µ] IX (146)
f∗
n h ∗i o
f f fT
= 2 · < IXX ( I µ) + IX [µ] IX (147)


n h ∗i T
o
f f
HΘΘ (µ) = 2 · < IΘΘ ( I f µ) + IΘf [µ] IΘf (148)
f∗
n h ∗i o
f f f fT
HVΘ (µ) = 2 · < IVΘ ( I µ) + IV [µ] IΘ (149)

n h ∗i T
o
f f
HΘV (µ) = 2 · < IΘV ( I f µ) + IΘf [µ] IVf (150)
f∗
n h ∗i o
f f f fT
HVV (µ) = 2 · < IVV ( I µ) + IV [µ] IV (151)

16
5.4 Squared Apparent Power Magnitudes 5 BRANCH FLOWS

5.4 Squared Apparent Power Magnitudes


2
Let Smax denote the vector of the squares of the apparent power flow limits. Then the
flow constraint function H(X) can be defined in terms of the square of the apparent
power flows as follows:
h ∗i
H f (X) = S f S f − Smax 2
(152)
 f f  f f 2
= P P + Q Q − Smax (153)
where S f = P f + jQf .

5.4.1 First Derivatives


f
h ∗i
f
  f∗
HX = S f SX + S f SX (154)
h ∗i h ∗ i ∗
f f f
= S SX + S f SX (155)
nh ∗ i o
f
= 2 · < S f SX (156)
= P f − jQf (PXf + jQfX ) + P f + jQf (PXf − jQfX )
   
(157)
  
= 2 P f PXf + Qf QfX
 
(158)
   n o  f  n f o
f f
= 2 < S < SX + = S = SX (159)

5.4.2 Second Derivatives

f ∂  fT 
HXX (µ) = HX µ (160)
∂X
 f f 
HΘΘ (µ) HΘV (µ) 0 0
 H f (µ) H f (µ) 0 0 
=  VΘ VV  (161)
 0 0 0 0 
0 0 0 0

f ∂ 
fT

HXX (µ) = HX µ (162)
∂X
∂  T h ∗i
f f ∗T
 f 
= SX S f µ + SX S µ (163)
∂X
f ∗ f ∗ f ∗T
h ∗i
f f T f
( S f µ) + SX ( S f µ) + SX
 
= SXX [µ] SX + SXX [µ] SX (164)
f ∗
n h ∗i o
f f T
= 2 · < SXX ( S f µ) + SX [µ] SX (165)

17
5.5 Squared Real Power Magnitudes 5 BRANCH FLOWS


n h ∗i T
o
f f
HΘΘ (µ) = 2 · < SΘΘ ( S f µ) + SΘf [µ] SΘf (166)

n h ∗i T
o
f f
HVΘ (µ) = 2 · < SVΘ ( S f µ) + SVf [µ] SΘf (167)

n h ∗i T
o
f f
HΘV (µ) = 2 · < SΘV ( S f µ) + SΘf [µ] SVf (168)
f∗
n h ∗i o
f f f fT
HVV (µ) = 2 · < SVV ( S µ) + SV [µ] SV (169)

5.5 Squared Real Power Magnitudes


2
Let Pmax denote the vector of the squares of the real power flow limits. Then the flow
constraint function H(X) can be defined in terms of the square of the real power
flows as follows:

H f (X) = < S f < S f − Pmax 2


   
(170)
 f f 2
= P P − Pmax (171)

5.5.1 First Derivatives

f
= 2 P f PXf
 
HX (172)
   n o
f
= 2 < S f < SX (173)

5.5.2 Second Derivatives

f ∂  fT 
HXX (µ) = HX µ (174)
∂X
 f f 
HΘΘ (µ) HΘV (µ) 0 0
 H f (µ) H f (µ) 0 0 
=  VΘ VV  (175)
 0 0 0 0 
0 0 0 0

f ∂ 
f T

HXX (µ) = HX µ (176)
∂X
∂  T  f 
= 2PXf P µ (177)
∂X

18
6 GENERALIZED AC OPF COSTS

 T

f
( P f µ) + PXf [µ] PXf
 
= 2 PXX (178)
 n   f  o n To n o
f f f
= 2 < SXX ( < S µ) + < SX [µ] < SX (179)

 n    o n To n o
f f
HΘΘ (µ) = 2 < SΘΘ ( < S f µ) + < SΘf [µ] < SΘf (180)
 n    o n To n o
f f
HVΘ (µ) = 2 < SVΘ ( < S f µ) + < SVf [µ] < SΘf (181)
 n   f  o n To n o
f f
HΘV (µ) = 2 < SΘV ( < S µ) + < SΘ [µ] < SVf
f
(182)
 n    o n To n o
f f
HVV (µ) = 2 < SVV ( < S f µ) + < SVf [µ] < SVf (183)

6 Generalized AC OPF Costs


The generalized cost function for the AC OPF consists of three parts,

f (X) = f a (X) + f b (X) + f c (X) (184)

expressed as functions of the full set of optimization variables.


 
Θ
 V 
 
 Pg 
X=   (185)
 Q g


 Y 
Z
where Y is the ny ×1 vector of cost variables associated with piecewise linear generator
costs and Z is an nz × 1 vector of additional linearly constrained user variables.

6.1 Polynomial Generator Costs


Let fPi (pig ) and fQi (qgi ) be polynomial cost functions for real and reactive power for
generator i and F P and F Q be the ng × 1 vectors of these costs.
 
fP1 (p1g )
F P (Pg ) = 
 .. 
(186)
. 
ng ng
fP (pg )

19
6.2 Piecewise Linear Generator Costs 6 GENERALIZED AC OPF COSTS

 
fQ1 (qg1 )
F Q (Qg ) = 
 .. 
(187)
. 
ng ng
fQ (qg )

f a (X) = 1Tng F P (Pg ) + F Q (Qg )



(188)

6.1.1 First Derivatives


0 00
We will use F P and F P to represent the vectors of first and second derivatives of
each of these real power cost functions with respect to the corresponding generator
output. Likewise for the reactive power costs.

∂f a
fXa = (189)
∂Xa
fΘ fVa fPag fQa g fYa fZa

= (190)
h i
0 T 0 T
= P
0 0 (F ) (F ) 0 0Q (191)

6.1.2 Second Derivatives

a ∂fXa T
fXX = (192)
∂X 
0 0 0 0 0 0
 0 0 0 0 0 0 
 0 0 fPa P
 
0 0 0 
= 
 0 0
g g
a
 (193)
 0 fQg Qg 0 0 

 0 0 0 0 0 0 
0 0 0 0 0 0

where
h i
P 00
fPag Pg = F (194)
h i
00
fQa g Qg = FQ (195)

6.2 Piecewise Linear Generator Costs


f b (X) = 1Tny Y (196)

20
6.3 General Cost Term 6 GENERALIZED AC OPF COSTS

6.2.1 First Derivatives

∂f b
fXb = (197)
∂Xb
fΘ fVb fPb g fQb g fYb fZb

= (198)
0 0 0 0 1Tny 0
 
= (199)

6.2.2 Second Derivatives


b
fXX =0 (200)

6.3 General Cost Term


Let the general cost be defined in terms of the nw × nw matrix H w and nw × 1
vector C w of coefficients and the parameters specified in the nw × nx matrix N and
the nw × 1 vectors D, R, b K, and M. The parameters N and R b provide a linear
transformation and shift to the full set of optimization variables X, resulting in a
new set of variables R.
R = NX − R b (201)
Each element of K specifies the size of a “dead zone” in which the cost is zero for
the corresponding element of R. The elements ki are used to define nw × 1 vectors
U , K̄ and R̄, where

0, −ki ≤ ri ≤ ki
ui = (202)
1, otherwise

 ki , ri < −ki
k̄i = 0, −ki ≤ ri ≤ ki (203)
−ki , ri > ki

The “dead zone” costs are zeroed by multiplying by [U ]. The remaining elements
are shifted toward zero by the size of the “dead zone” by adding K̄, before applying
a cost.
R̄ = R + K̄ (204)
Each element of D specifies whether to apply a linear or quadratic function to
the corresponding element of R̄. This can be done via two more nw × 1 vectors, DL

21
6.3 General Cost Term 6 GENERALIZED AC OPF COSTS

and DQ , defined as follows



1, di = 1
dLi = (205)
0, otherwise

1, di = 2
dQ
i = (206)
0, otherwise
The result is scaled by the corresponding element of M to form a new nw × 1
vector
W = [M] [U ] DL + DQ R̄ R̄
     
(207)
 
= DL + DQ R̄ R̄ (208)
where
DL = [M] [U ] DL
 
(209)
DQ = [M] [U ] DQ
 
(210)
The full general cost term is then expressed as a quadratic function of W as
follows
1
f c (X) = W T H w W + C wT W (211)
2

6.3.1 First Derivatives


For simplicity of derivation and computation, we defined A and B as follows

∂W  
A = WR̄ = = DL + 2 DQ R̄ (212)
∂ R̄

c ∂f c
B = fW = = W T H w + C wT (213)
∂W
∂ R̄
R̄X = = N (214)
∂X
∂W
WX = = WR̄ · R̄X (215)
∂X
= AN (216)

∂f c
fXc = c
= fW · WX (217)
∂X
= BAN (218)

22
6.4 Full Cost Function 6 GENERALIZED AC OPF COSTS

6.3.2 Second Derivatives


c
fXc T

fXX = (219)
∂X

N T AB T

= (220)
∂X  
T ∂ w w
 T  ∂ R̄
= N A (H W + C ) + 2 DQ B (221)
∂X ∂X
T w
 T 
= N AH WX + 2 DQ B R̄X (222)
N T AH w A + 2 DQ B T N
 
= (223)

6.4 Full Cost Function

f (X) = f a (X) + f b (X) + f c (X) (224)


1
= 1Tng F P (Pg ) + F Q (Qg ) + 1Tny Y + W T H w W + C wT W

(225)
2

6.4.1 First Derivatives

∂f
fX = = fXa + fXb + fXc (226)
∂X h i
0 T 0 T
= 0 0 (F P ) (F Q ) 1Tny 0 + BAN (227)

6.4.2 Second Derivatives

∂ 2f a b c
fXX = = fXX + fXX + fXX (228)
∂X 2  
0 0 0 0 0 0
 0 0 h 0 i 0 0 0 
 
00
 0 0 FP 0 0 0 
 
=  h
00
i 
 0 0 0 FQ 0 0 
 
 
 0 0 0 0 0 0 
0 0 0 0 0 0
+ N T AH w A + 2 DQ B T N
 
(229)

23
7 LAGRANGIAN OF THE AC OPF

7 Lagrangian of the AC OPF


Consider the following AC OPF problem formulation, where X is defined as in (185),
f is the generalized cost function described above, and X represents the reduced form
of X, consisting of only Θ, V, Pg and Qg , without Y and Z.

min f (X) (230)


X
subject to
G(X) = 0 (231)
H(X) ≤ 0 (232)
where  
<{Gs (X )}
G(X) =  ={Gs (X )}  (233)
AE X − BE
and  
H f (X )
H(X) =  H t (X )  (234)
AI X − BI
Partitioning the corresponding multipliers λ and µ similarly,
   
λP µf
λ =  λQ  , µ =  µt  (235)
λE µI
the Lagrangian for this problem can be written as
L(X, λ, µ) = f (X) + λT G(X) + µT H(X) (236)

7.1 First Derivatives

LX (X, λ, µ) = fX + λT GX + µT HX (237)
Lλ (X, λ, µ) = GT (X) (238)
Lµ (X, λ, µ) = H T (X) (239)
where
   
<{GsX } 0 0 <{GsΘ } <{GsV } −Cg 0 0 0
GX =  ={GsX } 0 0  =  ={GsΘ } ={GsV } 0 −Cg 0 0  (240)
AE AE

24
7.2 Second Derivatives 7 LAGRANGIAN OF THE AC OPF

and
HXf
  f
HΘ HVf 0 0 0 0
 
0 0
HX =  HXt 0 0  =  HΘt HVt 0 0 0 0  (241)
AI AI

7.2 Second Derivatives


LXX (X, λ, µ) = fXX + GXX (λ) + HXX (µ) (242)
where
 
<{GsX X (λP )} + ={GsX X (λQ )} 0 0
GXX (λ) =  0 0 0  (243)
0 0 0
 s 

 GΘΘ (λP ) GsΘV (λP ) 0 0 0 0  
 s
GVΘ (λP ) GsVV (λP ) 0 0 0 0 
 


 
 
0 0 0 0 0 0 
 
= <  



 0 0 0 0 0 0 
0 0 0 0 0 0 

  

 

0 0 0 0 0 0
 
 s s


 GΘΘ (λQ ) GΘV (λQ ) 0 0 0 0  
GsVΘ (λQ ) GsVV (λQ ) 0 0 0 0 

  


 
 
0 0 0 0 0 0 
 
+ =   (244)



 0 0 0 0 0 0 
0 0 0 0 0 0 

  

 

0 0 0 0 0 0
 

and

HXf X (µf ) + HXt X (µt ) 0 0


 

HXX (µ) =  0 0 0  (245)


0 0 0
 f t f t

HΘΘ (µf ) + HΘΘ (µt ) HΘV (µf ) + HΘV (µt ) 0 0 0 0
f f
 H (µf ) + H t (µt ) H (µf ) + H t (µt )
 VΘ VΘ VV VV 0 0 0 0 

 0 0 0 0 0 0 
=   (246)

 0 0 0 0 0 0 

 0 0 0 0 0 0 
0 0 0 0 0 0

25

You might also like