Professional Documents
Culture Documents
TN3 More OPF Derivatives PDF
TN3 More OPF Derivatives PDF
c 2008, 2010, 2011, 2017, 2018 Power Systems Engineering Research Center (Pserc)
All Rights Reserved
CONTENTS CONTENTS
Contents
1 Notation 3
2 Introduction 4
3 Voltages 5
3.1 Bus Voltages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 5
4 Bus Injections 6
4.1 Complex Current Injections . . . . . . . . . . . . . . . . . . . . . . . 6
4.1.1 First Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . 6
4.1.2 Second Derivatives . . . . . . . . . . . . . . . . . . . . . . . . 7
4.2 Complex Power Injections . . . . . . . . . . . . . . . . . . . . . . . . 13
5 Branch Flows 13
References 16
2
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
1
V, Λ nb × 1 vector of complex bus voltages vi and their inverses vi
3
2 INTRODUCTION
2 Introduction
This document is a supplement to Matpower Technical Note 2 “AC Power Flows,
Generalized OPF Costs and their Derivatives using Complex Matrix Notation” [1],
adding formulas for full nodal current balance, including injections from generators
and loads. Matpower Technical Note 4 [2] presents formulas for variations based
on a cartesian coordinate representation of bus voltages.
The purpose of these documents is to show how the AC power balance and flow
equations 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
computed efficiently using complex sparse matrix manipulations. The relevant code
in Matpower [3, 4] is based on the formulas found in these three notes.
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 ∂x 2 · · · ∂x∂1 ∂x n
∂ 2f
1
∂ ∂f . . .
fXX = = = .
. . . .
. . (3)
∂X 2 ∂X ∂X ∂2f ∂2f
∂xn ∂x1
··· ∂x2 n
the first derivatives form the Jacobian matrix, where row i is the transpose of the
gradient of fi . ∂f1 ∂f1
∂x1
· · · ∂xn
∂F
FX = = ... .. .. (5)
. .
∂X ∂fm ∂fm
∂x1
· · · ∂xn
4
3 VOLTAGES
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
the Jacobian of the vector function obtained by multiplying the transpose of the
Jacobian of F by a constant vector λ, using the following notation.
∂ T
FXX (α) = FX λ (6)
∂X λ=α
3 Voltages
3.1 Bus Voltages
See the corresponding section in Matpower Technical Note 2. Consider also the
vector of inverses of bus voltages v1i , denoted by Λ. Note that
1 1 |vi |e−jθi vi ∗
= = = (10)
vi |vi |ejθi |vi |2 |vi |2
Λ = V −1 = [V]−2 V ∗ (11)
∂Λ
ΛΘ = = − [V ]−2 VΘ = −j [V ]−1 = −j [Λ] (12)
∂Θ
∂Λ
ΛV = = − [V ]−2 VV = − [V ]−1 [V]−1 = − [V]−1 [Λ] (13)
∂V
5
4 BUS INJECTIONS
4 Bus Injections
4.1 Complex Current Injections
Consider the complex current balance equation, Gc (X) = 0, where
and
∂I bus ∂V
IΘbus = = Ybus = jYbus [V ] (18)
∂Θ ∂Θ
∂I bus ∂V
IVbus = = Ybus = Ybus [V ] [V]−1 = Ybus [E] (19)
∂V ∂V
dg ∂I dg h dg dg dg dg i
IX = = IΘ IV IPg IQg (20)
∂X
∂I dg
IΘdg = = j[Sd − Cg Sg ]∗ [Λ∗ ] (21)
∂Θ
∂I dg
IVdg = = −[Sd − Cg Sg ]∗ [V]−1 [Λ∗ ] (22)
∂V
∂I dg
IPdgg = = − [Λ∗ ] Cg (23)
∂Pg
∂I dg
IQdgg = = j [Λ∗ ] Cg (24)
∂Qg
6
4.1 Complex Current Injections 4 BUS INJECTIONS
∂Gc c
GcX = = GΘ GcV GcPg GcQg
(25)
∂X
∂Gc
GcΘ = = IΘbus + IΘdg = j (Ybus [V ] + [Sd − Cg Sg ]∗ [Λ∗ ]) (26)
∂Θ
∂Gc
GcV = = IVbus + IVdg = Ybus [E] − [Sd − Cg Sg ]∗ [V]−1 [Λ∗ ] (27)
∂V
∂Gc
GcPg = = IPdgg = − [Λ∗ ] Cg (28)
∂Pg
∂Gc
GcQg = = IQdgg = j [Λ∗ ] Cg (29)
∂Qg
bus ∂ bus T
IXX (λ) = I λ (30)
∂X X
bus bus
IΘΘ (λ) IΘV (λ) 0 0
bus
IVΘ bus
(λ) IVV (λ) 0 0
= (31)
0 0 0 0
0 0 0 0
B C 0 0
C 0 0 0
=
0
(32)
0 0 0
0 0 0 0
bus ∂ bus T
IΘΘ (λ) = I λ (33)
∂Θ Θ
∂
j [V ] Ybus T λ
= (34)
∂Θ
= j Ybus T λ VΘ
(35)
= − Ybus T λ [V ]
(36)
=B (37)
7
4.1 Complex Current Injections 4 BUS INJECTIONS
bus ∂ bus T
IVΘ (λ) = I λ (38)
∂Θ V
∂
[E] Ybus T λ
= (39)
∂Θ T
= Ybus λ EΘ (40)
= j Ybus T λ [E]
(41)
=C (42)
bus ∂ bus T
IΘV (λ) = I λ (43)
∂V Θ
∂
j [V ] Ybus T λ
= (44)
∂V
= j Ybus T λ VV
(45)
= j Ybus T λ [E]
(46)
bus T
= IVΘ (λ) =C (47)
bus ∂ bus T
IVV (λ) = I λ (48)
∂V V
∂
[E] Ybus T λ
= (49)
∂V
= Ybus T λ EV
(50)
=0 (51)
dg ∂ dg T
IXX (λ) = I λ (52)
∂X X
dg dg dg dg
IΘΘ (λ) IΘV (λ) IΘP g
(λ) IΘQ g
(λ)
I dg (λ) I dg (λ) I dg (λ) I dg (λ)
VΘ VV VPg VQg
= dg (53)
IPg Θ (λ) IPdgg V (λ) 0 0
dg dg
IQg Θ (λ) IQg V (λ) 0 0
−G −jH −jKT −KT
−jH 2DH LT −jLT
=
−jK
(54)
L 0 0
−K −jL 0 0
8
4.1 Complex Current Injections 4 BUS INJECTIONS
dg ∂ dg T
IΘΘ (λ) = I λ (55)
∂Θ Θ
∂
= (j[Sd − Cg Sg ]∗ [Λ∗ ] λ) (56)
∂Θ
= j[Sd − Cg Sg ]∗ [λ] Λ∗Θ (57)
= −[Sd − Cg Sg ]∗ [λ] [Λ∗ ] (58)
= −G (59)
dg ∂ dg T
IVΘ (λ) = I λ (60)
∂Θ V
∂
−[Sd − Cg Sg ]∗ [V]−1 [Λ∗ ] λ
= (61)
∂Θ
= −[Sd − Cg Sg ]∗ [λ] [V]−1 Λ∗Θ (62)
∗ −1 ∗
= −j[Sd − Cg Sg ] [λ] [V] [Λ ] (63)
= −jH (64)
∂ dg T
IPdgg Θ (λ) = I λ (65)
∂Θ Pg
∂
−Cg T [Λ∗ ] λ
= (66)
∂Θ
= −Cg T [λ] Λ∗Θ (67)
T ∗
= −jCg [λ] [Λ ] (68)
= −jK (69)
∂ dg T
IQdgg Θ (λ) = I λ (70)
∂Θ Qg
∂
jCg T [Λ∗ ] λ
= (71)
∂Θ
= jCg T [λ] Λ∗Θ (72)
= −Cg T [λ] [Λ∗ ] (73)
= −K (74)
dg ∂ dg T
IΘV (λ) = I λ (75)
∂V Θ
9
4.1 Complex Current Injections 4 BUS INJECTIONS
∂
= (j[Sd − Cg Sg ]∗ [Λ∗ ] λ) (76)
∂V
= j[Sd − Cg Sg ]∗ [λ] Λ∗V (77)
∗ −1 ∗
= −j[Sd − Cg Sg ] [λ] [V] [Λ ] (78)
dg T
= IVΘ (λ) = −jH (79)
dg ∂ dg T
IVV (λ) = I λ (80)
∂V V
∂
−[Sd − Cg Sg ]∗ [V]−1 [Λ∗ ] λ
= (81)
∂V
∂V −1
∗ −1
= −[Sd − Cg Sg ] [λ] [V] Λ∗V ∗
+ [Λ ] (82)
∂V
= −[Sd − Cg Sg ]∗ [λ] [V]−1 (− [V]−1 [Λ∗ ]) − [Λ∗ ] [V]−2
(83)
= 2[Sd − Cg Sg ]∗ [λ] [V]−2 [Λ∗ ] (84)
= 2DH (85)
∂ dg T
IPdgg V (λ) = I λ (86)
∂V Pg
∂
−Cg T [Λ∗ ] λ
= (87)
∂V
= −Cg T [λ] Λ∗V (88)
T −1 ∗
= Cg [λ] [V] [Λ ] (89)
=L (90)
∂ dg T
IQdgg V (λ) = I λ (91)
∂V Qg
∂
jCg T [Λ∗ ] λ
= (92)
∂V
= jCg T [λ] Λ∗V (93)
−1
= −jCg T [λ] [V] [Λ∗ ] (94)
= −jL (95)
10
4.1 Complex Current Injections 4 BUS INJECTIONS
dg ∂ dg T
IΘP (λ) = I λ (96)
g
∂Pg Θ
∂
= (j[Sd − Cg Sg ]∗ [Λ∗ ] λ) (97)
∂Pg
= −j [λ] [Λ∗ ] Cg (98)
T
= IPdgg Θ (λ) = −jKT (99)
dg ∂ dg T
IVP (λ) = I λ (100)
g
∂Pg V
∂
−[Sd − Cg Sg ]∗ [V]−1 [Λ∗ ] λ
= (101)
∂Pg
= [λ] [V]−1 [Λ∗ ] Cg (102)
T
= IPdgg V (λ) = LT (103)
dg ∂ dg T
IΘQ (λ) = I λ (104)
g
∂Qg Θ
∂
= (j[Sd − Cg Sg ]∗ [Λ∗ ] λ) (105)
∂Qg
= − [λ] [Λ∗ ] Cg (106)
T
= IQdgg Θ (λ) = −KT (107)
dg ∂ dg T
IVQ (λ) = I λ (108)
g
∂Qg V
∂
−[Sd − Cg Sg ]∗ [V]−1 [Λ∗ ] λ
= (109)
∂Qg
= −j [λ] [V]−1 [Λ∗ ] Cg (110)
T
= IQdgg V (λ) = −jLT (111)
∂
GcXX (λ) = GcX T λ
(112)
∂X
11
4.1 Complex Current Injections 4 BUS INJECTIONS
bus dg
= IXX (λ) + IXX (λ) (114)
B − G C − jH −jKT −KT
C − jH 2DH LT −jLT
=
−jK
(115)
L 0 0
−K −jL 0 0
Computational savings can be achieved by storing and reusing certain interme-
diate terms during the computation of these second derivatives, as follows:
A = Ybus T λ
(116)
B = −A [V ] (117)
C = jA [E] (118)
D = [V]−1 (119)
E = [λ] [Λ∗ ] (120)
F = [Sd − Cg Sg ]∗ (121)
G = EF (122)
H = DG (123)
K = Cg T E (124)
L = KD (125)
c
GΘΘ (λ) = B − G (126)
GcVΘ (λ) = C − jH (127)
GcPg Θ (λ) = −jK (128)
GcQg Θ (λ) = −K (129)
GcVV (λ) = 2DH (130)
GcPg V (λ) = L (131)
GcQg V (λ) = −jL (132)
GcΘV (λ) = GcVΘ (λ) (133)
GcΘPg (λ) = GcPg Θ T (λ) (134)
12
4.2 Complex Power Injections 7 LAGRANGIAN OF THE AC OPF
5 Branch Flows
See the corresponding section in Matpower Technical Note 2.
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.
See the corresponding section in Matpower Technical Note 2 for additional
details.
13
7.1 Nodal Current Balance 7 LAGRANGIAN OF THE AC OPF
subject to
G(X) = 0 (140)
H(X) ≤ 0 (141)
where
<{Gc (X )}
G(X) = ={Gc (X )} (142)
AE X − BE
and
H f (X )
H(X) = H t (X ) (143)
AI X − BI
Partitioning the corresponding multipliers λ and µ similarly,
λM µf
λ = λN , µ = µt (144)
λE µI
the Lagrangian for this problem can be written as
L(X, λ, µ) = f (X) + λT G(X) + µT H(X) (145)
LX (X, λ, µ) = fX + λT GX + µT HX (146)
T
Lλ (X, λ, µ) = G (X) (147)
Lµ (X, λ, µ) = H T (X) (148)
where
<{GcΘ } <{GcV } <{GcPg } <{GcQg } 0 0
<{GcX } 0 0
GX = ={GcX } 0 0 = ={GcΘ } ={GcV } ={GcPg } ={GcQg } 0 0
AE AE
(149)
and f f
HΘ HVf 0 0 0 0
HX 0 0
HX = HXt 0 0 = HΘt HVt 0 0 0 0 (150)
AI AI
14
7.2 Nodal Power Balance 7 LAGRANGIAN OF THE AC OPF
and
15
REFERENCES REFERENCES
References
[1] R. D. Zimmerman, AC Power Flows, Generalized OPF Costs and their Deriva-
tives using Complex Matrix Notation, Matpower Technical Note 2, Febru-
ary 2010. [Online]. Available: http://www.pserc.cornell.edu/matpower/
TN2-OPF-Derivatives.pdf 2
[2] B. Sereeter and R. D. Zimmerman, AC Power Flows and their Derivatives us-
ing Complex Matrix Notation and Cartesian Coordinate Voltages, Matpower
Technical Note 4, April 2018. [Online]. Available: http://www.pserc.cornell.
edu/matpower/TN4-OPF-Derivatives-Cartesian.pdf 2
16