8

179728115-53438896-Gams-Power

Embed Size (px)

DESCRIPTION

Power Systems

Citation preview

Page 1: 179728115-53438896-Gams-Power

GAMSPOWERVersion 1.0

Ray D. Zimmerman; PSERC, Cornell University, Ithaca, NY 14853Jagadisan Viswanathan; Verilogic LLC, Pittsburgh, PA 15235

Alex Meeraus; GAMS Development Corporation, Washington, DC 20007

January 2008

Contents1 Introduction 1

2 AC Power Flow 22.1 Admittance matrix of the network . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.2 Equations for power injections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.3 Speci�cations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.4 Other aspects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 AC Optimal Power Flow 33.1 Power �ow limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43.2 Cost functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43.3 Optimization problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.4 Solving AC OPF incrementally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

4 Implementation in GAMS 64.1 Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64.2 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74.3 AC Power Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74.4 AC Optimal Power Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1 IntroductionGAMSPOWER is a collection of AC Power Flow (PF) and AC Optimal Power Flow (OPF)problems formulated in the GAMS modeling language (http://www.gams.com/). The data forthese problems are the same as the corresponding cases in MATPOWER (http://www.pserc.cornell.edu/matpower/). This document brie�y describes

- the mathematical models used in the AC PF and OPF problems. It is based on the materialin MATPOWER User Manual [1].

- some of the details of the implementation in the GAMS framework.After this work was completed, we learned that Antonio Conejo and his colleagues at the Universityof Castilla-La Mancha, Ciudad Real, Spain have been using GAMS to solve AC OPF problems formore than 15 years! Three of their recent works on optimization problems with AC Power Flowat the centre stage�modeled and solved in GAMS framework�are cited in the References.1

Page 2: 179728115-53438896-Gams-Power

2 AC POWER FLOW 2

2 AC Power Flow2.1 Admittance matrix of the networkThe admittance matrix of the network Y is obtained by combining elements described below:

- The shunt admittance of bus k is computed as

Yk,sh = (Gk,sh + jBk,sh)/baseMVA

where Gk,sh is the shunt conductance (in MW (demanded) at V = 1.0 p.u.) and Bk,sh isthe shunt susceptance (in MVAr (injected) at V = 1.0 p.u.).

- Let (f, t, c) denote a branch where f is the �from� bus, t is the �to� bus and c is the circuitidenti�er. The branch could be a transmission line, transformer or phase shifter. The branchis considered as a standard π-model transmission line, with series resistance R and reactanceX and total line charging susceptance Bc in series with an ideal transformer and phase shifter,at the from end, with tap ratio τ and and phase shift angle θshift. For simplicity, the branchparameters are written without the subscript ftc.Here, τ and θshift are considered as known parameters. More generally, they can be consid-ered as variables whose values have to be determined.The branch currents and the bus voltages at the from and to ends of the branch are relatedby: (

If,c

It,c

)= Yftc

(Ef

Et

)=

(yff,c yft,c

ytf,c ytt,c

)(Ef

Et

)

whereYftc =

( (Ys + j Bc

2

)1τ2 −Ys

1τejθshift

−Ys1

τe−jθshiftYs + j Bc

2

)and Ys =

1R + jX

Let B denote the set of branches and let N denote the number of buses. The elements of Y areobtained as folllows:

Ykk = Yk,sh +∑

(f,t,c)∈B:f=k

yff,c +∑

(f,t,c)∈B:t=k

ytt,c for all k = 1, 2, . . . , N

Yik =∑

(f,t,c)∈B:f=i,t=k

yft,c +∑

(f,t,c)∈B:f=k,t=i

ytf,c i 6= k, for all i, k = 1, 2, . . . , N

2.2 Equations for power injectionsLet N denote the number of buses, let Yik = Gik + jBik denote ik-th element of Y and let Pi andQi denote the active and reactive power injected at bus i. From

Ii =N∑

k=1

YikEk

follows that (Wood and Wollenberg [5], p. 100)

Pi + jQi = EiI∗i

= Ei

(N∑

k=1

YikEk

)∗

=N∑

k=1

|Ei||Ek|(Gik − jBik)ej(θi−θk)

Page 3: 179728115-53438896-Gams-Power

3 AC OPTIMAL POWER FLOW 3

where θi and θk are the angles, |Ei| and |Ek|, the magnitudes, of the voltages at the buses i andk, respectively. Equating the real and imaginary parts of both the sides results in:

Pi =N∑

k=1

|Ei||Ek|[Gik cos(θi − θk) + Bik sin(θi − θk)] (1)

Qi =N∑

k=1

|Ei||Ek|[Gik sin(θi − θk)−Bik cos(θi − θk)] (2)

2.3 Speci�cationsThere are 4 variables (|E|, θ, P and Q) and two equations, (1) and (2), per bus. So, to solve thePower Flow problem, the values of two variables must be speci�ed, in a consistent manner, foreach bus. The simplest cases of Power Flow problems deal with following types of buses:

Reference bus : The magnitude of the bus voltage and the bus angle are �xed. Obviously, therecan be only one reference bus for a given problem.

PV bus : Here, at least one generator is assigned to the bus. The active power power injected(= sum of active power outputs of generators assigned to the bus - demand) and magnitudeof the bus voltage are speci�ed.

PQ bus : The active and reactive power injected are speci�ed.

So, simply stated, the Power Flow problem is to �nd the solution of a system of nonlinear equations.In the GAMS framework, the Power Flow problem is formulated as a dummy optimization problem.The optimal solution is a (or, most likely, the unique) feasible solution satisfying the constraints(more on this below).

2.4 Other aspectsThe following aspects also need to be considered when solving AC PF:

- It may happen that all the generators assigned to a PV bus are o�ine. In that case, thespeci�cations must be changed so that it becomes a PQ bus.

- Note that the value of reactive power injected for a PV bus is determined by the solutionof AC PF. Sometimes, this may result in the reactive power output of the generator fallingoutside its bounds: that is, either it is less than Qmin or greater than Qmax. In that case,the PV speci�cations are changed to PQ speci�cations with Q �xed at the violated bound.So, the problem is solved again with |E| allowed to vary to satisfy the bound on Q.

- After solving AC PF, one must check whether the power �ow limits (de�ned below) on allbranches are observed. So, this is a `post-processing' step after the solution.

3 AC Optimal Power FlowIn AC PF, the active power output of generators assigned to PV buses is given. In AC OPF, theactive and reactive power outputs of the generators and the magnitudes and angles of the busvoltages are all variables whose values will be determined as the solution of an (techno-economic)optimization problem. The constraints include

- the power �ow equations, (1) and (2).

- the power �ow limits de�ned below.

Page 4: 179728115-53438896-Gams-Power

3 AC OPTIMAL POWER FLOW 4

The classi�cation into PV or PQ buses does not apply anymore: but a reference bus is stillneeded to �x one of the bus angles (most often, to zero).

The MATPOWER User Manual [1] shows how the optimization framework also allows addi-tional constraints to be taken into consideration. For example, consider the P-Q capability curveof a generator. This means the point (p, q), where p and q are the active and reactive poweroutputs, respectively, must lie within a (bounded, convex) polyhedron de�ned by a set of linearinequalities.

Other possibilities are to treat the phase shifter angle θshift and the transformer tap ratio τ ofsome branches as variables.

3.1 Power �ow limitsLet (f, t, c) denote a branch where f is the �from� bus, t is the �to� bus and c is the circuit identi�er.Let PFF (f, t, c) and QFF (f, t, c) denote the active and reactive power �ows at the �from� end ofthe branch. Similarly, for PFT (f, t, c) and QFT (f, t, c) at the �to� end. Then

PFF (f, t, c) = |Ef |[|Ef |yff,r(f, t, c) + |Et|(yft,r(f, t, c) cos(θf − θt)+yft,i(f, t, c) sin(θf − θt))]

QFF (f, t, c) = |Ef |[−|Ef |yff,i(f, t, c) + |Et|(yft,r(f, t, c) sin(θf − θt)−yft,i(f, t, c) cos(θf − θt))]

PFT (f, t, c) = |Et|[|Et|ytt,r(f, t, c) + |Ef |(ytf,r(f, t, c) cos(θt − θf )+ytf,i(f, t, c) sin(θt − θf ))]

QFT (f, t, c) = |Et|[−|Et|ytt,i(f, t, c) + |Ef |(ytf,r(f, t, c) sin(θt − θf )−ytf,i(f, t, c) cos(θt − θf ))]

where yff , yft, ytf and ytt are the entries of the branch admittance matrix Yftc, de�ned insubsection 2.1. The power �ow limits are the constraints:

P 2FF (f, t, c) + Q2

FF (f, t, c) ≤ (rateA(f, t, c)/baseMVA)2 (3)P 2

FT (f, t, c) + Q2FT (f, t, c) ≤ (rateA(f, t, c)/baseMVA)2 (4)

where rateA(f, t, c) is the long-term rating of the branch.

3.2 Cost functionsIn our case, the cost functions are either piecewise-linear or quadratic. For piecewise linear costfunctions, the cost data is given in the form:

(x0, y0), (x1, y1), . . . , (xn, yn)

with0 = x0 < x1 < . . . < xn and 0 = y0 < y1 < . . . < yn

Assuming that the slopes

mi = (yi − yi−1)/(xi − xi−1) for i = 1, 2, . . . ..n

are non-decreasing, i.e., 0 < m1 ≤ m2 . . . ≤ mn, it is shown in MATPOWER User Manual [1], thecost y for active power output p satis�es the inequalities:

y ≥ mi(p− xi−1) + yi−1 for i = 1, 2, . . . ..n

Page 5: 179728115-53438896-Gams-Power

3 AC OPTIMAL POWER FLOW 5

Similarly, if(u0, v0), (u1, v1), . . . , (un, vn)

de�ne the segments for the piecwise-linear cost for reactive power, then the cost z for reactivepower output q satis�es the inequalities

z ≥ ni(q − ui−1) + vi−1 for i = 1, 2, . . . ..n

whereni = (vi − vi−1)/(ui − ui−1) for i = 1, 2, . . . ..n

For quadratic cost functions, the generation cost for active power p is computed as c0 + c1p +c2p

2. The cost for reactive power q is similarly computed as d0 + d1q + d2q2.

3.3 Optimization problemLet G denote the set of generators and Gi denote the subset of G assigned to the bus i. If pj andqj denote, respectively, the active and reactive power outputs of j, then

Pi = (∑

j∈Gi

pj − P di )/baseMVA (5)

Qi = (∑

j∈Gi

qj −Qdi )/baseMVA (6)

where P di and Qd

i are the active and reactive power demands at i with

pminj ≤ pj ≤ pmax

j and qminj ≤ qj ≤ qmax

j if j is online (7)

and

pj = 0 and qj = 0 if j is offline (8)

If yj denotes the cost for active power output pj , then either

yj = c0 + c1pj + c2p2j (9)

or

yj ≥ mji(pj − xj,i−1) + yj,i−1 for i = 1, 2, . . . n (10)

Similarly, for the cost for reactive power zj , either

zj = d0 + d1qj + d2q2j (11)

or

zj ≥ nji(qj − uj,i−1) + vj,i−1 for i = 1, 2, . . . n (12)

The objective function (the total cost) can now be de�ned:

C =∑

j∈G

(yj + zj) (13)

The optimization problem is to minimize C subject to all the constraints described earlier.

Page 6: 179728115-53438896-Gams-Power

4 IMPLEMENTATION IN GAMS 6

3.4 Solving AC OPF incrementallyWe illustrate the facilities that GAMS framework provides for implementing algorithms by solvingAC OPF incrementally.

Consider the power �ow limits de�ned in (3) and (4). If Nbr is the number of branches, thenthere are 2Nbr such constraints in the problem. It seems reasonable to think that only a smallfraction of these constraints will be active when the optimal solution is found. So, here is a simplescheme to solve AC OPF incrementally:

1. Solve AC OPF without the constraints (3) and (4).

2. For the solution just found, identify the subsets of branches, Naff and Na

tt, at which theconstraints (3) and (4), respectively, are violated.

3. If both Naff and Na

tt are empty, then exit: the optimal solution has been found.

4. Add the constraints identi�ed in step 2 and solve AC OPF again, using the last solution asthe starting point.

5. Go to step 2.

4 Implementation in GAMSThe GAMS input �le for any problem is quite self-explanatory. The following brief descriptionsof some details are simply meant to guide a new user.

4.1 SetsIn GAMS, the basic building blocks are sets. The model is created with parameters, variablesand equations de�ned on sets. For the PF and OPF problems, the basic sets are the busesand generarors de�ned by their identi�ers. The relationship between objects is expressed throughsubsets of the product sets. For example, the association between generators and buses is expressedin statements like:

Set ab(gen, bus) Generator and its associated bus /1.1, 2.2, 3.22, 4.27, 5.23, 6.13 /;

So, 3.22 means that generator (identi�ed by the number) 3 is assigned to the bus (identi�ed bythe number) 22. Similarly, branches are de�ned through statements like:

Set branch(bus, bus, ckt) /1.2.1, 1.4.1, 1.5.1, 2.3.12.4.1, 2.5.1, 2.6.1, 3.5.13.6.1, 4.5.1, 5.6.1 /;

So, 2.4.1 is the branch connecting (�from�) bus 2 and (�to�) bus 4 with the circuit identi�er 1.Other subsets are de�ned as needed: For example:

Setpq(bus) pq buses (bus_type == 1)pv(bus) pv buses (bus_type == 2)ref(bus) reference bus (bus_type == 3)iso(bus) isolated bus (bus_type == 4) ;

pq(bus) = yes$(bus_type(bus) eq 1);

Page 7: 179728115-53438896-Gams-Power

4 IMPLEMENTATION IN GAMS 7

pv(bus) = yes$(bus_type(bus) eq 2);ref(bus) = yes$(bus_type(bus) eq 3);iso(bus) = yes$(bus_type(bus) eq 4);

4.2 DataData are entered as scalars, parameters and tables. Parameters are lists of values de�ned oversets. Tables are similar to matrices used in MATPOWER case �les. Additional data may becreated as needed using GAMS modeling language statements.

Some parameters have been de�ned in `main.gms' simply to show additional possibilities. Someof them are redundant and can be easily removed. To illustrate, consider the parameter ratiode�ned by

ratio(fbus,tbus,ckt) = branch_data(fbus,tbus,ckt, 'ratio');

Looking at `main.gms' one �nds that this parameter is used only once:

denom(fbus,tbus,ckt)$branch(fbus,tbus,ckt)= ratio(fbus,tbus,ckt)$(ratio(fbus,tbus,ckt) ne 0)+ 1$(ratio(fbus,tbus,ckt) eq 0);

We can avoid the parameter ratio altogether by changing the above to:

denom(fbus,tbus,ckt)$branch(fbus,tbus,ckt)= branch_data(fbus,tbus,ckt, 'ratio')

$(branch_data(fbus,tbus,ckt, 'ratio') ne 0)+ 1$(branch_data(fbus,tbus,ckt, 'ratio') eq 0);

From the given data, additional parameters needed in the model are generated. See the declara-tion : Parameters ysh_r(bus), ysh_i(bus), etc. and the following statements in `main.gms'where the terms related to the admittance matrix of the network (subsection 2.1) are computed.

4.3 AC Power FlowThe GAMS formulation of the model described in subsection 2.2 is quite transparent: it begins(in `main.gms') with the declaration:

Positive variables

E(bus) Magnitude of bus voltage (p.u.)

If some generators are o�ine, then one checks if any PV bus must be converted to a PQ bus. Thespeci�cations for the buses are made as shown:

E.fx(ref) = Vm(ref); theta.fx(ref) = 0;P.fx(pq) = -Pd(pq)/baseMVA; Q.fx(pq) = -Qd(pq)/baseMVA;E.fx(pv) = Vm(pv);P.fx(pv) = (sum(ab(gen,pv)$online(gen),Pg(gen))-Pd(pv))/baseMVA;

The AC PF is solved as a dummy nonlinear optimization problem with the statement:

Solve power_flow minimizing zdummy using nlp;

If a feasible solution to the AC PF model is found, then the power �ows can be computed: seethe �le `p�ows.gms' .

Page 8: 179728115-53438896-Gams-Power

REFERENCES 8

4.4 AC Optimal Power FlowFor AC OPF, additional variables are declared as shown in `main.gms' :

Variables

Pgen(gen) Active power output of the generatorQgen(gen) Reactive power output of the generatortotal_cost Total cost of generation

Positive variables

pcost(gen) Active power generation costqcost(gen) Reactive power generation cost

The declarations and de�nitions of cost functions correspond to the optimization model describedin subsections 3.2 and 3.3. Bounds on the variables Pgen and Qgen are speci�ed in:

Pgen.lo(gen) = Pmin(gen)$online(gen);Pgen.up(gen) = Pmax(gen)$online(gen);Qgen.lo(gen) = Qmin(gen)$online(gen);Qgen.up(gen) = Qmax(gen)$online(gen);

So, for generators that are o�ine, the above bounds are all zero.The AC OPF is solved as a nonlinear optimization problem with the objective function

total_cost with the statement:

Solve opf minimizing total_cost using nlp;

The last part of `main.gms' implements the algorithm described in subsection 3.4 for solvingAC OPF incrementally.

References[1] MATPOWER 3.2 User's Manual: Available online at: (http://www.pserc.cornell.edu/

matpower/).

[2] F. Milano, C. A. Canizares and A. J. Conejo: Sensitivity-Based Security-Constrained OPFMarket Clearing Model, IEEE Trans. on Power systems, 20(4), 2051-2060, November 2005.

[3] A. J. Conejo, F. Milano and R. Garcia-Bertrand: Congestion Management Ensuring VoltageStability, IEEE Trans. on Power systems, 21(1), 357-364, February 2006.

[4] R. Minguez, F. Milano, R. Zarate-Minano and A. J. Conejo: Optimal Network Placement ofSVC Devices, IEEE Trans. on Power systems, 22(4), 1851-1860, November 2007.

[5] A. J. Wood and B. F. Wollenberg: Power Generation, Operation and Control, second edition,Wiley, New York (1996).