Keywords

These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

This chapter provides a solution for optimal power flow OPF problem in GAMS. Different OPF models are investigated, such as single and multi-period DC-AC optimal power flow.

6.1 Single Period Optimal DC Power Flow

There are some necessary conditions that make the DC power flow acceptable as an approximate solution for AC power flow such as:

  • The ratio of \(\frac{x_{ij}} {r_{ij}}\) should be large enough that r ij can be neglected.

  • The voltage magnitudes are approximately 1 pu.

The DC power flow concept for a two-bus network is shown in Fig. 6.1. The basic variables in DC power flow are voltage angles δ i . The angle of the slack bus is assumed to be zero as the reference for the rest of network.

Fig. 6.1
figure 1

DC power flow for a two-bus network

The technical and economic characteristics of generating units shown in Table 6.1 are given as follows:

Table 6.1 The techno-economic data of thermal units in two-bus OPF example

The demand at bus 2 is L 2 = 400 MW, line reactance is X 12 = 0. 2 pu, and line flow limit is P 12 max = 1. 50 pu (per unit on 100 MVA base). The optimization problem which should be solved is formulated in (6.1).

$$\displaystyle{ \min _{P_{g},\delta _{i}}\mathrm{OF} =\sum _{g_{1},g_{2}}a_{g}(P_{g})^{2} + b_{ g}P_{g} + c_{g} }$$
(6.1a)
$$\displaystyle{ P_{ij} = \frac{\delta _{1} -\delta _{2}} {X_{12}} }$$
(6.1b)
$$\displaystyle{ P_{g_{1}} = P_{12} }$$
(6.1c)
$$\displaystyle{ P_{g_{2}} + P_{12} = L_{2} }$$
(6.1d)
$$\displaystyle{ -P_{12}^{\mathrm{max}} \leq P_{ 12} \leq P_{12}^{\mathrm{max}} }$$
(6.1e)
$$\displaystyle{ \delta _{1} = 0\ \ \ \mathrm{Slack} }$$
(6.1f)

The GAMS code for solving the (6.1) is provided in GCode 6.1.

GCode 6.1 The OPF GAMS code for two-bus network, Example (6.1)

Sets Gen /g1 * g2/ bus / 1 * 2 /; Scalars L2   /400/ X12 /0.2/ Sbase /100/ P12_max /1.5/ ; Table data (Gen, * )      a    b     c      Pmin Pmax G1   3    20    100    28   206 G2   4.05 18.07 98.87  90   284; Variables  P( gen ),OF, delta ( bus ),P12; Equations eq1, eq2, eq3, eq4; eq1 ..  OF = e = sum(gen, data (gen, ’a ’ ) * P( gen ) * P( gen )+data (gen, ’b ’ )  * P( gen )+data (gen, ’ c ’ ) ); eq2 ..  P( ’G1 ’ )= e = P12; eq3 ..  P( ’G2 ’ )+ P12 = e = L2/Sbase; eq4 ..  P12 = e=(delta ( ’1 ’ ) −delta ( ’2 ’ ) )/X12; P. lo ( gen )=data (gen, ’Pmin ’ )/Sbase; P. up( gen )=data (gen, ’Pmax ’ )/Sbase; P12. lo=− P12_max; P12. up =+ P12_max; delta. fx ( ’1 ’ ) =0; Model OPF  /all/; Solve OPF  us qcp min of;

The operating costs would be $306.108, P 12 = 150 MW and δ 2 = −0. 3 (rad).

The general power flow concept is shown in Fig. 6.2. As it can be seen in Fig. 6.2, every bus might host some generation and demand. Each bus might be connected to other network buses by multiple branches (with different characteristics). The power balance between generation, demand and power transfers should be satisfied at every bus of the network under study.

Fig. 6.2
figure 2

General power flow concept

The general mathematical formulation of OPF is described in (6.2). It should be noted that the technical terms of (6.2) are all linear. The only nonlinear part is the cost function. This makes the DC-OPF a strong tool for power system studies at the transmission level. This means that if the cost term can be expressed in linear form then the DC-OPF would become a linear programming problem and can be solved using linear solvers in GAMS such as CPLEX [1].

$$\displaystyle{ \mathrm{OF} =\sum _{g\in \varOmega _{G}}a_{g}(P_{g})^{2} + b_{ g}P_{g} + c_{g} }$$
(6.2a)
$$\displaystyle{ P_{ij} = \frac{\delta _{i} -\delta _{j}} {x_{ij}} \ \ \ ij \in \varOmega _{\ell} }$$
(6.2b)
$$\displaystyle{ \sum _{g\in \varOmega _{G}^{i}}P_{g} - L_{i} =\sum _{j\in \varOmega _{\ell}^{i}}P_{ij}:\lambda _{i}\ \ \ i \in \varOmega _{B} }$$
(6.2c)
$$\displaystyle{ -P_{ij}^{\mathrm{max}} \leq P_{ ij} \leq P_{ij}^{\mathrm{max}}\ \ \ ij \in \varOmega _{\ell} }$$
(6.2d)
$$\displaystyle{ P_{g}^{\mathrm{min}} \leq P_{ g} \leq P_{g}^{\mathrm{max}} }$$
(6.2e)

6.1.1 Three-Bus Network DC-OPF

The three-bus network data is shown in Fig. 6.3. This example is taken from [2] (Example 4B, p. 110).

Fig. 6.3
figure 3

Three bus network example (a) data and (b) power flow solution

The GAMS code for solving this problem is given as GCode 6.2: The developed code for solving the OPF problem in three-bus network (Fig. 6.3) is explained here. It is general and can be used for any network with any size.

  • Three sets are defined: bus (all network buses), slack(bus) which shows slack buses with reference angle values, Gen (set of generating units)

  • A scalar value named Sbase is defined for per unit calculations

  • The set node is defined as the similar set to set bus

  • The table GenData defines the technical and economic characteristics of generating units

  • The set GBconect defines the connection point of each generating unit

  • The table BusData specifies the demand values in each bus

  • The set conex specifies how each bus is connected to the other network buses

  • The table branch defines the branch characteristics

  • Four variables are used for this formulation namely: OF (objective function), Pij (active power flow between bus and node), Pg(generating schedule of each generating unit), and delta (voltage angle at each bus)

  • Three equations are defined: const1 (active flow calculation between each pair of connected buses), const2 (nodal active power balance in each bus), and const3 (objective function calculation)

  • The definition of the model loadflow (specifies for GAMS that which constraints should be taken into account)

  • Variables’ limits specification

  • Solve statement

  • Generating report from the solved model

  • The marginal value of const2.m provides the LMP at each bus. This is used for congestion cost calculation.

GCode 6.2 The DC-OPF GAMS code for three-bus network, Example (Sect. 6.1.1)

Sets bus  / 1 * 3 / slack ( bus ) /3/ Gen /g1 * g3 /; scalars Sbase /100/;  a l i a s (bus, node ); Table GenData(Gen, * )   Generating units  c h a r a c t e r i s t i c s    b    pmin pmax g1 10   0    65 g2 11   0    100;  *  −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− set GBconect(bus,Gen) connectivity  index of  each generating  unit to each bus /1    .     g1  3    .     g2  / ; Table BusData(bus, * )  Demands of  each bus in MW          Pd 2        100; set conex          Bus connectivity  matrix / 1    .     2 2    .     3 1    .     3/; conex (bus, node )$( conex (node, bus ) ) =1; Table branch (bus, node, * )     Network technical  c h a r a c t e r i s t i c s                x         Limit 1    .     2    0.2        100 2    .     3    0.25      100 1    .     3    0.4        100 ; branch (bus, node, ’x ’ )$( branch (bus, node, ’x ’ )=0) = branch (node, bus, ’x ’ ); branch (bus, node, ’ Limit ’ )$( branch (bus, node, ’ Limit ’ )=0) = branch (node, bus, ’ Limit ’ ); branch (bus, node, ’ bij ’ ) $conex (bus, node ) =1/branch (bus, node, ’x ’ ); Variables OF Pij (bus, node ) Pg(Gen) delta ( bus ); Equations const1, const2, const3; const1 (bus, node ) $conex (bus, node ).. Pij (bus, node )= e =                           branch (bus, node, ’ bij ’ ) * ( delta ( bus ) −delta ( node ) ); const2 ( bus ) ..  + sum(Gen$GBconect(bus,Gen),Pg(Gen) ) − BusData(bus, ’pd ’ )/Sbase= e =                           + sum( node$conex (node, bus ), Pij (bus, node ) ); const3    ..  OF = g = sum(Gen, Pg(Gen) * GenData(Gen, ’b ’ ) * Sbase ); Model loadflow     /const1, const2, const3 /; Pg. lo (Gen)= GenData(Gen, ’Pmin ’ )/Sbase; Pg. up(Gen)= GenData(Gen, ’Pmax ’ )/Sbase; delta. up( bus )= pi;  delta. lo ( bus )=− pi;  delta. fx ( slack ) =0; Pij. up(bus, node )$ (( conex (bus, node ) ) ) =1*  branch (bus, node, ’ Limit ’ )/Sbase; Pij. lo (bus, node )$ (( conex (bus, node ) ) )=−1*branch (bus, node, ’ Limit ’ )/Sbase; Solve loadflow minimizing OF  using lp; parameter report (bus, * ), Congestioncost; report (bus, ’Gen( MW ) ’ )=  sum(Gen$GBconect(bus,Gen),Pg. l (Gen) ) * sbase; report (bus, ’ Angle ’ )=delta. l ( bus ); report (bus, ’ load ( MW ) ’ )=  BusData(bus, ’pd ’ ); report (bus, ’LMP($/ MWh ) ’ )=const2.m ( bus )/ sbase ; Congestioncost=  sum(( bus, node ), Pij. l (bus, node ) *( − const2.m ( bus )+const2.m ( node ) ) ) /2 ; display  report, Pij. l, Congestioncost;

The total operating costs will be 1035 $/h and the LMP for all buses are equal to 11 $/h. This means that if the demand value at any bus increases for 1 MW then the operating cost will increase by 11 $/h. Since the generating unit 1 is generating power at its maximum limit (because it is cheaper) the additional demand should be supplied by generating unit 2 with operating cost equal to 11 $/MW h. The detailed three-bus optimal power flow solution with (P ij max = 100 MW) is given in Table 6.2.

Table 6.2 The three-bus optimal power flow solution (P ij max = 100 MW)

Question: What would happen if the flow limit of the branch connecting bus 1 to bus 2 is reduced to 50 MW.

Answer: The answer is straightforward. The operating cost might increase but how much? We can easily decrease the flow limit in the GCode 6.2 (table Branch). The new operating cost would be 1056.250 $/h. The LMP values are different for each bus in this case. The LMP values are λ 1 = 10 $/MW h, λ 2 = 11. 625 $/MW h, λ 3 = 11 $/MW h. The power flow solution is shown in Fig. 6.4. The LMP value in bus 1 is λ 1 = 10 $/MW h because if the load increases in this node it will be supplied by generator 1 (which the operating costs are 10 $/MW h). The LMP value in bus 3 is λ 3 = 11 $/MW h because any increase in load in this node should be supplied by generator 2 (which the operating costs are 11 $/MW h). Generator 1 cannot send more power by line 1 − 2 since it is congested and the direction of the power flow in branch 3 − 1 is from bus 3 to bus 1. Finally, The LMP value in bus 2 is λ 3 = 11. 625 $/MW h because some of this demand will be supplied by generating unit 1 and some part will be supplied by unit 2. If the demand should pay the LMP value for every MW h then the total payment by the demand would be 100 MW × 11. 625 $/MW h = 1162.5 $/h. On the other hand, the generating units are also paid based on the LMP value of the connection point. The total payments to the generating units would be 43. 75 × 10 + 56. 25 × 11 = 1056. 25 $/h. As it can be seen, there is a difference between what demand pays and what generating units receive. This surplus money is equal to 1162. 5 − 1056. 25 = 106. 25 $/h. This is also called the congestion cost. Another technique for calculating the congestion costs (C cg ) is using the following formula [3]:

$$\displaystyle{ C_{cg} =\sum _{ij}P_{ji}(\lambda _{i} -\lambda _{j}) }$$
(6.3)
Fig. 6.4
figure 4

The three-bus network with P 12 max = 50 MW

The power flow solution of three-bus network with P 12 max = 50 MW is shown in Fig. 6.4.

The detailed three-bus optimal power flow solution with (P 12 max = 50 MW) is given in Table 6.3.

Table 6.3 The three-bus optimal power flow solution (P 12 max = 50 MW)

6.1.2 Five-Bus Network DC-OPF

The five-bus network data is shown in Fig. 6.5. This example is taken from [4].

Fig. 6.5
figure 5

The five-bus network data

The GAMS code developed for solving OPF in five-bus network is provided in GCode 6.3.

GCode 6.3 The OPF GAMS code for five-bus network, Example (Sect. 6.1.2)

Sets bus  /1*5/,  slack ( bus ) /1/ , Gen /g1 * g5 /; Scalars  Sbase /100/ ;  a l i a s (bus, node ); Table GenData(Gen, * )    b    pmin pmax g1 14   0    40 g2 15   0    170 g3 30   0    520 g4 40   0    200 g5 20   0    600 ; set GBconect(bus,Gen) connectivity  index of  generating  unit /1    .     g1  1    .     g2  3    .     g3  4    .     g4  5    .     g5 / ; Table BusData(bus, * )  Demands of  each bus in MW          Pd 2        300 3        300 4        400; set conex          Bus connectivity  matrix /1    .     2 2    .     3 3    .     4 4    .     1 4    .     5 5    .     1/; conex (bus, node ) $conex (node, bus ) =1; Table branch (bus, node, * )                x         Limit 1    .     2    0.0281    400 1    .     4    0.0304    400 1    .     5    0.0064    400 2    .     3    0.0108    400 3    .     4    0.0297    400 4    .     5    0.0297    240 ; branch (bus, node, ’x ’ )$( branch (bus, node, ’x ’ )=0) = branch (node, bus, ’x ’ ); branch (bus, node, ’ Limit ’ )$( branch (bus, node, ’ Limit ’ )=0) = branch (node, bus, ’ Limit ’ ); branch (bus, node, ’ bij ’ ) $conex (bus, node ) =1/branch (bus, node, ’x ’ ); Variables  OF, Pij (bus, node ),Pg(Gen), delta ( bus ); Equations const1, const2, const3; const1 (bus, node ) $conex (bus, node ).. Pij (bus, node )= e =  branch (bus, node, ’ bij ’ ) * ( delta ( bus ) −delta ( node ) ); const2 ( bus ) ..  + sum(Gen$GBconect(bus,Gen),Pg(Gen) ) − BusData(bus, ’pd ’ )/Sbase= e =                              + sum( node$conex (node, bus ), Pij (bus, node ) ); const3    ..  OF = g = sum(Gen, Pg(Gen) * GenData(Gen, ’b ’ ) * Sbase ); Model loadflow     /const1, const2, const3 /; Pg. lo (Gen)= GenData(Gen, ’Pmin ’ )/Sbase; Pg. up(Gen)= GenData(Gen, ’Pmax ’ )/Sbase; delta. up( bus )= pi; delta. lo ( bus )=− pi; delta. fx ( slack ) =0; Pij. up(bus, node )$ (( conex (bus, node ) ) )=  branch (bus, node, ’ Limit ’ )/Sbase; Pij. lo (bus, node )$ (( conex (bus, node ) ) )= −branch (bus, node, ’ Limit ’ )/Sbase; solve  loadflow minimizing OF  using lp; parameter report (bus, * ), Congestioncost; report (bus, ’Gen( MW ) ’ )=  sum(Gen$GBconect(bus,Gen),Pg. l (Gen) ) * sbase; report (bus, ’ Angle ’ )=delta. l ( bus ); report (bus, ’ load ( MW ) ’ )=  BusData(bus, ’pd ’ ); report (bus, ’LMP($/ MWh ) ’ )=const2.m ( bus )/ sbase ; Congestioncost=  sum(( bus, node ), Pij. l (bus, node ) *( − const2.m ( bus )+const2.m ( node ) ) ) /2; Display report, Pij. l, Congestioncost;

The minimum operating cost is 17,479.897 $/h. The network is highly congested, and the LMP values are different in various buses. The five-bus network flows and directions are depicted in Fig. 6.6. The detailed five-bus optimal power flow solution is given in Table 6.4.

Fig. 6.6
figure 6

The five-bus network flows and directions

Table 6.4 The optimal power flow solution in five-bus network

6.1.3 IEEE Reliability Test System 24 Bus

The IEEE RTS 24-bus network is shown in Fig. 6.7. It is a transmission network with the voltage levels of 138 kV, 230 kV, and Sbase = 100 MVA. The branch data for IEEE RTS 24-bus network is given in Table 6.5 [5]. The from bus, to bus, reactance (X), resistance (r), total line charging susceptance (b), and MVA rating (MVA) are specified in this table. The parallel lines in MATPOWER are merged, and the resultants are given in Table 6.5. The generation data for IEEE RTS 24-bus network is given in Table 6.6. The data of generating units in this network is inspired by Conejo et al. [6] and Bouffard et al. [7] with some modifications. The slack bus is bus 13 in this network.

Fig. 6.7
figure 7

IEEE RTS 24-bus network

Table 6.5 Branch data for IEEE RTS 24-bus network
Table 6.6 Generation data for IEEE RTS 24-bus network

6.1.3.1 IEEE-RTS: Base Case

In this case, it is assumed that the network is intact and all branches and generating units are working in normal condition. The minimum operating cost is $29,574.275 obtained by using the GCode 6.4.

GCode 6.4 The OPF GAMS code for IEEE Reliability test 24-bus network, Example (Sect. 6.1.3)

sets  bus  /1*24/, slack ( bus ) /13/,Gen /g1 * g12 /;  scalar  Sbase /100/; a l i a s (bus, node ); Table GenData(Gen, * )   Generating units  c h a r a c t e r i s t i c s      Pmax Pmin   b     CostsD costst  RU    RD    SU   SD    UT    DT    uini  U0   So g1   400  100    5.47  0      0      47   47   105  108  1    1    1    5    0   ; set GBconect(bus,Gen) connectivity  index of  each generating  unit to each bus /18      .         g1 / ; Table BusData(bus, * )  Demands of  each bus in MW /MVar       Pd   Qd 1     108  22; Table branch (bus, node, * )     Network technical  c h a r a c t e r i s t i c s                r       x       b      limit 1    .     2    0.0026  0.0139  0.4611 175; parameter conex (bus, node ); conex (bus, node ) $branch (bus, node, ’ limit ’ ) =1; conex (bus, node )$( conex (node, bus ) ) =1; branch (bus, node, ’x ’ )$( branch (bus, node, ’x ’ )=0) = branch (node, bus, ’x ’ ); branch (bus, node, ’ Limit ’ )$( branch (bus, node, ’ Limit ’ )=0) = branch (node, bus, ’ Limit ’ ); branch (bus, node, ’ bij ’ ) $conex (bus, node ) =1/branch (bus, node, ’x ’ ); Variables  OF, Pij (bus, node ),Pg(Gen), delta ( bus ); Equations const1, const2, const3; const1 (bus, node )$( conex (bus, node ) ) .. Pij (bus, node )= e =  branch (bus, node, ’ bij ’ ) * ( delta ( bus ) −delta ( node ) ); const2 ( bus ) ..  + sum(Gen$GBconect(bus,Gen),Pg(Gen) ) − BusData(bus, ’pd ’ )/Sbase= e = + sum( node$conex (node, bus ), Pij (bus, node ) ); const3    ..  OF = g = sum(Gen, Pg(Gen) * GenData(Gen, ’b ’ ) * Sbase ); Model loadflow     /const1, const2, const3 /; Pg. lo (Gen)= GenData(Gen, ’Pmin ’ )/Sbase; Pg. up(Gen)= GenData(Gen,  ’Pmax ’ )/Sbase; delta. up( bus )= pi/2;  delta. lo ( bus )=− pi/2; delta. fx ( slack ) =0; Pij. up(bus, node )$ (( conex (bus, node ) ) ) =1*  branch (bus, node, ’ Limit ’ )/Sbase; Pij. lo (bus, node )$ (( conex (bus, node ) ) )=−1*branch (bus, node, ’ Limit ’ )/Sbase; Solve loadflow minimizing OF  using lp;

The base case solution of IEEE RTS 24-bus network without changing the branch flow limits is described in Table 6.7. As it can be observed in Table 6.7, the LMP values are all the same and equal to 20.7 $/MW h. This is because there is no congestion in this network for the given loading values. The congestion cost would be zero in this case.

Table 6.7 Base case solution of IEEE RTS 24-bus network (branch flow limits are unchanged)

6.1.3.2 IEEE-RTS: Branch Flow Limit Reduction

Now the branch flow limits are reduced by 30%. The problem is solved again, and the angle values are found as given in Table 6.8. The minimum operating cost is $29,747.745 obtained by using the GCode 6.4. The congestion cost is $4597.217 in this case. The solution of IEEE RTS 24-bus network (branch flow limits are reduced by 30%) is given in Table 6.8. Reducing the branch flow limit will not only increase the operating cost but also makes the LMP values different across the network.

Table 6.8 Solution of IEEE RTS 24-bus network (branch flow limits are reduced by 30%)

6.1.3.3 IEEE-RTS: Branch Outage

In this case, some branch contingencies are examined. In order to simulate the branch outage, the following equation should be satisfied.

$$\displaystyle{ P_{ij} -\frac{\delta _{i} -\delta _{j}} {x_{ij}} \leq M\xi _{ij} }$$
(6.4)
$$\displaystyle{ P_{ij} -\frac{\delta _{i} -\delta _{j}} {x_{ij}} \geq -M\xi _{ij} }$$
(6.5)

where ξ ij is a binary parameter which shows the status of the branch connecting bus i to bus j. In the developed GAMS code, if the branch limit is set to 0 it is considered as an outaged branch. This is because const1 which models the flow calculation in line ij is calculated for every branch which has conex(bus, node) > 0. Now some different contingencies are evaluated as follows:

  • Contingency 1: branch 20−19,  12−23 are out. Congestion costs are $4905.000 and OF = $29,888.196. The congested lines are 13−23. The LMP values are not the same in different buses.

  • Contingency 2: branch 14−16,  16−19 are out. Congestion costs are $6224.250 and OF = $32,199.855. The congested lines are 24−3,  8−7. The LMP values are not the same in different buses.

  • Contingency 3: branch 1−5,  4−2 are out. Congestion costs are $0 and OF = $29,574.275. No line would be congested and therefore the LMP values are the same in all buses.

The OPF solutions for these three contingency cases are provided in Table 6.9.

Table 6.9 Solution of IEEE RTS 24-bus network (branch outage contingencies)

6.1.3.4 IEEE-RTS: Generator Outage

In this case, some generating units are out of service. This can be because of unplanned outage or maintenance purpose. Now some different contingencies are evaluated as follows:

  • Contingency 1: The generating unit g 9 (connected to bus 7) is out. Solving the problem shows that no line is congested but removing the g 9 will cause an increase in total operating costs which becomes OF = $29,633.420.

  • Contingency 2: The generating unit g 5 (connected to bus 15) is out. Solving the problem shows that line 8−7 is congested but removing the g 5 will cause an increase in total operating costs which becomes OF = $30,328.570. The LMP values are different on different buses, and the congestion costs are $40.250.

  • Contingency 3: The generating unit g 8 (connected to bus 23) is out. Solving the problem shows that line 8−7 is congested but removing the g 8 will cause an increase in total operating costs which becomes OF = $33,078.420. The LMP values are different on different buses, and the congestion costs are $40.250.

  • Contingency 4: The generating unit g 10 (connected to bus 13) is out. The problem becomes infeasible, and GAMS cannot find any solution for it. This is because no solution is found which satisfies the technical constraints. Some load shedding action should take place.

The OPF solutions for first three contingency cases are given in Table 6.10. In order to analyze the contingency case 4, the load shedding is modeled using a virtual generating unit connected to bus i as shown in Fig. 6.8. The production cost of this specific unit is set to a high value. It is usually called the value of the loss of load. The production level of this generating unit is equal to the load shedding that should happen in bus i. The maximum power of this unit is equal to the load connected to the bus i (0 ≤ LS i L i ). The DC-OPF problem considering the load shedding concept is formulated in (6.6).

$$\displaystyle{ \mathrm{OF} =\sum _{g\in \varOmega _{G}}a_{g}(P_{g})^{2} + b_{ g}P_{g} + c_{g} +\sum _{i}\mathrm{VOLL} \times \mathrm{LS}_{i} }$$
(6.6a)
$$\displaystyle{ P_{ij} = \frac{\delta _{i} -\delta _{j}} {x_{ij}} \ \ \ ij \in \varOmega _{\ell} }$$
(6.6b)
$$\displaystyle{ \sum _{g\in \varOmega _{G}^{i}}P_{g} + \mathrm{LS}_{i} - L_{i} =\sum _{j\in \varOmega _{\ell}^{i}}P_{ij}:\lambda _{i}\ \ \ i \in \varOmega _{B} }$$
(6.6c)
$$\displaystyle{ -P_{ij}^{\mathrm{max}} \leq P_{ ij} \leq P_{ij}^{\mathrm{max}}\ \ \ ij \in \varOmega _{\ell} }$$
(6.6d)
$$\displaystyle{ P_{g}^{\mathrm{min}} \leq P_{ g} \leq P_{g}^{\mathrm{max}} }$$
(6.6e)
$$\displaystyle{ 0 \leq \mathrm{LS}_{i} \leq L_{i} }$$
(6.6f)
Table 6.10 Solution of IEEE RTS 24-bus network (generator outage contingencies)
Fig. 6.8
figure 8

Load shedding modeling using virtual generating unit

The GAMS code for modeling and calculating the load shedding values is given in GCode 6.5:

GCode 6.5 The OPF GAMS code for IEEE Reliability test 24-bus network with load shedding modeling

Sets bus  /1*24/ slack ( bus ) /13/ Gen /g1 * g12/ scalars Sbase /100/ VOLL /10000/;  a l i a s (bus, node ); table  GenData(Gen, * )   Generating units  c h a r a c t e r i s t i c s      Pmax Pmin   b  * * * * * * * * REMOVED  FOR  SAVING  SPACE * * * * * * ; set GBconect(bus,Gen) connectivity  index of  each generating  unit to each bus /  * * REMOVED  FOR  SAVING  SPACE * * * * * *  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  / ; Table BusData(bus, * )  Demands of  each bus in MW       Pd   Qd  * * * * * * * * REMOVED  FOR  SAVING  SPACE * * * * * * ; table  branch (bus, node, * )     Network technical  c h a r a c t e r i s t i c s                r       x       b      limit  * * * * * * * * REMOVED  FOR  SAVING  SPACE * * * * * * ; branch (bus, node, ’x ’ )$( branch (bus, node, ’x ’ )=0) = branch (node, bus, ’x ’ ); branch (bus, node, ’ Limit ’ )$( branch (bus, node, ’ Limit ’ )=0) = branch (node, bus, ’ Limit ’ ); branch (bus, node, ’ bij ’ ) $branch (bus, node, ’ Limit ’ ) =1/branch (bus, node, ’x ’ ); parameter conex (bus, node ); conex (bus, node )$( branch (bus, node, ’ limit ’ )and branch (node, bus, ’ limit ’ ) ) =1; conex (bus, node )$( conex (node, bus ) ) =1; Variables OF, Pij (bus, node ),Pg(Gen), delta ( bus ), lsh ( bus ); Equations const1, const2, const3; const1 (bus, node )$( conex (bus, node ) ) ..  Pij (bus, node )= e =                     branch (bus, node, ’ bij ’ ) * ( delta ( bus ) −delta ( node ) ); const2 ( bus ) .. lsh ( bus ) + sum(Gen$GBconect(bus,Gen),Pg(Gen) ) − BusData(bus, ’pd ’ )/Sbase                                       = e =+ sum( node$conex (node, bus ), Pij (bus, node ) ); const3    ..  OF = g = sum(( bus,Gen) $GBconect (bus,Gen),Pg(Gen) * GenData(Gen, ’b ’ ) * Sbase )+ sum(bus,VOLL * lsh ( bus ) * Sbase ); model loadflow     /const1, const2, const3 /; Pg. lo (Gen)= GenData(Gen, ’Pmin ’ )/Sbase; Pg. up(Gen)= GenData(Gen, ’Pmax ’ )/Sbase; delta. up( bus )= pi/2; delta. lo ( bus )=− pi/2; delta. fx ( slack ) =0; Pij. up(bus, node )$ (( conex (bus, node ) ) ) =1*  branch (bus, node, ’ Limit ’ )/Sbase; Pij. lo (bus, node )$ (( conex (bus, node ) ) )=−1*branch (bus, node, ’ Limit ’ )/Sbase; lsh. up( bus )=  BusData(bus, ’pd ’ )/Sbase; lsh. lo ( bus )=  0; solve  loadflow minimizing OF  using lp; parameter report (bus, * ), Congestioncost; report (bus, ’Gen( MW ) ’ )=  1 * sum(Gen$GBconect(bus,Gen),Pg. l (Gen) ) * sbase; report (bus, ’ Angle ’ )=delta. l ( bus ); report (bus, ’ load ( MW ) ’ )=  BusData(bus, ’pd ’ ); report (bus, ’LSH ’ )=lsh. l ( bus ) * sbase ; report (bus, ’LMP($/ MWh ) ’ )=const2.m ( bus )/ sbase ; Congestioncost=  sum(( bus, node ), Pij. l (bus, node ) *( − const2.m ( bus )+const2.m ( node ) ) ) /2 ; display  report, Pij. l, Congestioncost; execute_unload ”opf. gdx” report execute ’gdxxrw. exe  OPF. gdx o = OPF. xls  par =report  rng =report !A1 ’ display  GBconect;

The OPF solution for contingency case 4 is given in Table 6.11. The simulation results show that the demand in bus 18 should be reduced by 116 MW as given in Table 6.11. It should be noted that the LMP values are not meaningful in this case. The LMP values are calculated and shown in Table 6.12.

Table 6.11 Solution of IEEE RTS 24-bus network (generator g 10 outage with load shedding modeling)
Table 6.12 Solution of IEEE RTS 24-bus network (generator g 10 outage with load shedding modeling and LMP calculation)

In order to calculate the LMP in a network with load shedding, the calculated amount of load shedding should be curtailed from the demand in the specific bus (here bus 18) and the problem should be resolved.

Nomenclature

Indices and Sets

g :

Index of thermal generating units.

i, j :

Index of network buses.

Ω G :

Set of all thermal generating units.

Ω G i :

Set of all thermal generating units connected to bus i.

Ω i :

Set of all buses connected to bus i.

Ω B :

Set of network buses.

Ω :

Set of network branches.

Parameters

L i :

Electric power demand in bus i

a g , b g , c g :

Fuel cost coefficients of thermal unit g.

P g max∕min :

Maximum/minimum limits of power generation of thermal unit g.

P ij max :

Maximum power flow limits of branch connecting bus i to j.

x ij :

Reactance of branch connecting bus i to j.

r ij :

Resistance of branch connecting bus i to j.

Variables

P ij :

Active power flow of branch connecting bus i to j.

P g :

Active power generated by thermal unit g(MW).

λ i :

Locational marginal price in bus i ($/MW h).

LS i :

Load shedding in bus i (MW).

OF:

Total operating costs ($/h).

δ i :

Voltage angle in bus i (rad).

6.2 Multi-Period Optimal Wind-DC OPF

The load flow model considering wind power and load shedding is shown in Fig. 6.9. The multi-period wind DC-OPF is formulated as follows:

$$\displaystyle{ \mathrm{OF} =\sum _{g,t}a_{g}(P_{g,t})^{2} + b_{ g}P_{g,t} + c_{g} +\sum _{i,t}\mathrm{VOLL} \times \mathrm{LS}_{i,t} + \mathrm{VWC} \times P_{i,t}^{\mathrm{wc}} }$$
(6.7a)
$$\displaystyle{ \sum _{g\in \varOmega _{G}^{i}}P_{g,t} + \mathrm{LS}_{i,t} + P_{i,t}^{w} - L_{ i,t} =\sum _{j\in \varOmega _{\ell}^{i}}P_{ij,t}:\lambda _{i,t} }$$
(6.7b)
$$\displaystyle{ P_{ij,t} = \frac{\delta _{i,t} -\delta _{j,t}} {x_{ij}} }$$
(6.7c)
$$\displaystyle{ -P_{ij}^{\mathrm{max}} \leq P_{ ij,t} \leq P_{ij}^{\mathrm{max}} }$$
(6.7d)
$$\displaystyle{ P_{g}^{\mathrm{min}} \leq P_{ g,t} \leq P_{g}^{\mathrm{max}} }$$
(6.7e)
$$\displaystyle{ P_{g,t} - P_{g,t-1} \leq \mathrm{RU}_{g} }$$
(6.7f)
$$\displaystyle{ P_{g,t-1} - P_{g,t} \leq \mathrm{RD}_{g} }$$
(6.7g)
$$\displaystyle{ 0 \leq \mathrm{LS}_{i,t} \leq L_{i,t} }$$
(6.7h)
$$\displaystyle{ P_{i,t}^{\mathrm{wc}} = w_{ t}\varLambda _{i}^{w} - P_{ i,t}^{w} }$$
(6.7i)
$$\displaystyle{ 0 \leq P_{i,t}^{w} \leq w_{ t}\varLambda _{i}^{w} }$$
(6.7j)

The objective function in (6.7a) consists of operating costs of thermal units, load shedding costs, and wind curtailment costs. The nodal power balance is formulated in (6.7b). This equation is also providing the LMP value in bus i at time t (λ i, t ). The active flow in branch connecting bus i to bus j is calculated in (6.7c). The branch flow limits of every branch is formulated in (6.7d). The operating limits of the thermal generating unit are modeled in (6.7e). The ramp rates of thermal units are described in (6.7f) and (6.7g). The load shedding of bus i is limited to the existing demand at time t as stated in (6.7h). The wind power curtailment is formulated in (6.7i). At any bus i hosting wind turbine, the amount of wind power generation depends on wind power availability and wind power capacity as described in (6.7j). It should bear in mind that the demand and wind power availability change vs time. These variations are reflected in L i, t and w t , respectively. The wind power connection points to the network are indicated in Fig. 6.10.

Fig. 6.9
figure 9

Load flow model considering wind power and load shedding

Fig. 6.10
figure 10

Wind power connection points to the network

The wind-demand variation pattern vs time is shown in Fig. 6.11. The optimal thermal unit power generation schedules of multi-period wind DC-OPF is given in Table 6.13.

Fig. 6.11
figure 11

Wind-demand variation patterns vs time

Table 6.13 Thermal unit power generation schedules of multi-period wind DC-OPF

GCode 6.6 Multi-period DC-OPF for modified IEEE RTS 24-bus system

Sets bus  /1*24/  , slack ( bus ) /13/,Gen /g1 * g12 /, t /t1 * t24 /; Scalars  Sbase /100/  ,VOLL /10000/,VWC /50/; a l i a s (bus, node ); table  GD(Gen, * )   Generating units  c h a r a c t e r i s t i c s      Pmax Pmin   b     CostsD costst  RU    RD    SU   SD    UT    DT    uini  U0   So  *  Removed for saving space Set GB(bus,Gen) connectivity  index of  each generating  unit to each bus  / *  Removed for saving space  / ; Table BusData(bus, * )  Demands of  each bus in MW  * * * * * * * * * * Omitted for saving space   ; table  branch (bus, node, * )     Network technical  c h a r a c t e r i s t i c s  * * * * * * * * * * Omitted for saving space  ; Table WD ( t, * )       w                   d t1    0.0786666666666667 0.684511335492475 t2    0.0866666666666667 0.644122690036197 t3    0.117333333333333  0.61306915602972 t4    0.258666666666667  0.599733282530006 t5    0.361333333333333  0.588874071251667 t10   0.548              0.787007048961707 t20   0.561333333333333  0.936368832158506 t21   0.565333333333333  0.887597637645266 t22   0.556              0.809297008954087 t23   0.724              0.74585635359116 t24   0.84               0.733473042484283; Parameter Wcap( bus ) /8   200 19  150 21  100/; branch (bus, node, ’x ’ )$( branch (bus, node, ’x ’ )=0) = branch (node, bus, ’x ’ ); branch (bus, node, ’ Limit ’ )$( branch (bus, node, ’ Limit ’ )=0) = branch (node, bus, ’ Limit ’ ); branch (bus, node, ’ bij ’ ) $branch (bus, node, ’ Limit ’ ) =1/branch (bus, node, ’x ’ ); branch (bus, node, ’ z ’ ) $branch (bus, node, ’ Limit ’ )= sqrt( power ( branch (bus, node, ’x ’ ),2)+ power ( branch (bus, node, ’ r ’ ),2) ); branch (node, bus, ’ z ’ )= branch (bus, node, ’ z ’ ); parameter conex (bus, node ); conex (bus, node )$( branch (bus, node, ’ limit ’ )and branch (node, bus, ’ limit ’ ) ) =1; conex (bus, node )$( conex (node, bus ) ) =1; Variables OF, Pij (bus, node, t ),Pg(Gen, t ), delta (bus, t ), lsh (bus, t ),Pw(bus, t ), pc (bus, t ); Equations const1, const2, const3, const4, const5, const6; const1 (bus, node, t )$( conex (bus, node ) ) ..  Pij (bus, node, t )= e = branch (bus, node, ’ bij ’ ) * ( delta (bus, t ) −delta (node, t ) ); const2 (bus, t ) ..  lsh (bus, t )$BusData(bus, ’pd ’ ) + Pw(bus, t )$Wcap( bus )+ sum(Gen$GB(bus,Gen),Pg(Gen, t ) ) − WD ( t, ’d ’ ) * BusData(bus, ’pd ’ )/Sbase= e =+ sum( node$conex (node, bus ), Pij (bus, node, t ) ); const3    ..  OF = g = sum(( bus,Gen, t )$GB(bus,Gen),Pg(Gen, t ) * GD (Gen, ’b ’ ) * Sbase )                   + sum(( bus, t ),VOLL * lsh (bus, t ) * Sbase$BusData                   + VWC* Pc(bus, t ) * sbase$Wcap ( bus ) ); const4 (gen, t ) ..  pg(gen, t+1) − pg(gen, t )=l= GD (gen, ’RU’ )/Sbase; const5 (gen, t ) ..  pg(gen, t −1) − pg(gen, t )=l= GD (gen, ’RD’ )/Sbase; const6 (bus, t )$Wcap( bus ) ..  pc (bus, t )= e = WD ( t, ’w’ ) * Wcap( bus )/Sbase− pw(bus, t ); model loadflow     /const1, const2, const3, const4, const5, const6 /; Pg. lo (Gen, t )= GD (Gen, ’Pmin ’ )/Sbase;  Pg. up(Gen, t )= GD (Gen, ’Pmax ’ )/Sbase; delta. up(bus, t )= pi/2;  delta. lo (bus, t )=− pi/2;  delta. fx ( slack, t ) =0; Pij. up(bus, node, t )$ (( conex (bus, node ) ) ) =1*  branch (bus, node, ’ Limit ’ )/Sbase; Pij. lo (bus, node, t )$ (( conex (bus, node ) ) )=−1*branch (bus, node, ’ Limit ’ )/Sbase; lsh. up(bus, t )=  WD ( t, ’d ’ ) * BusData(bus, ’pd ’ )/Sbase;  lsh. lo (bus, t )=  0; Pw. up(bus, t )= WD ( t, ’w’ ) * Wcap( bus )/Sbase;  Pw. lo (bus, t ) =0; Pc. up(bus, t )= WD ( t, ’w’ ) * Wcap( bus )/Sbase;  Pc. lo (bus, t ) =0; Solve loadflow minimizing OF  using lp;

The wind power generations at efferent buses vs time are shown in Fig. 6.12.

Fig. 6.12
figure 12

Wind power generations at efferent buses vs time

The wind power curtailment is occurring in bus 19 at time t 17 equal to 38.76 and also in bus 21 at time t 16 equal to 15.32 MW and also at time t 17 equal to 86.93 MW. The total operating cost (including the wind curtailment cost) would be $4. 3229 × 105.

Nomenclature

Indices and Sets

g :

Index of thermal generating units.

w :

Index of wind turbine units.

i, j :

Index of network buses.

Ω G :

Set of all thermal generating units.

Ω G i :

Set of all thermal generating units connected to bus i.

Ω i :

Set of all buses connected to bus i.

Ω B :

Set of network buses.

Ω :

Set of network branches.

Parameters

w i, t :

Availability of wind turbine connected to bus i at time t

Λ i w :

Capacity of wind turbine connected to bus i

L i, t :

Electric power demand in bus i at time t

a g , b g , c g :

Fuel cost coefficients of thermal unit g.

P g max∕min :

Maximum/minimum limits of power generation of thermal unit g.

P ij max :

Maximum power flow limits of branch connecting bus i to j.

x ij :

Reactance of branch connecting bus i to j.

r ij :

Resistance of branch connecting bus i to j.

VOLL:

Value of loss of load ($/MW h)

VWC:

Value of loss of wind ($/MW h)

Variables

P ij, t :

Active power flow of branch connecting bus i to j at time t (MW).

P g, t :

Active power generated by thermal unit g at time t (MW).

P i, t w :

Active power generated by wind turbine connected to bus i at time t (MW).

P i, t wc :

Curtailed power of wind turbine connected to bus i at time t (MW).

λ i, t :

Locational marginal price in bus i at time t ($/MW h).

LS i, t :

Load shedding in bus i at time t (MW).

OF:

Total operating costs ($).

δ i, t :

Voltage angle of bus i at time t (rad).

6.3 Multi-Period Optimal AC Power Flow

The AC power flow considering wind generation and load shedding is shown in Fig. 6.13.

Fig. 6.13
figure 13

AC power flow considering wind generation and load shedding

The optimal power flow equations are described in (6.8) as follows:

$$\displaystyle{ \mathrm{OF} =\sum _{i,t}a_{g}(P_{i,t}^{g})^{2} + b_{ g}P_{i,t}^{g} + c_{ g} +\sum _{i,t}\mathrm{VOLL} \times P_{i,t}^{\mathrm{LS}} + \mathrm{VWC} \times P_{ i,t}^{\mathrm{wc}} }$$
(6.8a)
$$\displaystyle{ P_{i,t}^{g} + P_{ i,t}^{\mathrm{LS}} + P_{ i,t}^{w} - P_{ i,t}^{L} =\sum _{ j\in \varOmega _{\ell}^{i}}P_{ij,t}:\lambda _{ i,t}^{p} }$$
(6.8b)
$$\displaystyle{ Q_{i,t}^{g} + Q_{ i,t}^{\mathrm{LS}} + Q_{ i,t}^{w} - Q_{ i,t}^{L} =\sum _{ j\in \varOmega _{\ell}^{i}}Q_{ij,t}:\lambda _{ i,t}^{q} }$$
(6.8c)
$$\displaystyle{ I_{ij,t} = \frac{V _{i,t}\angle \delta _{i,t} - V _{j,t}\angle \delta _{j,t}} {Z_{ij}\angle \theta _{ij}} + \frac{bV _{i,t}} {2} \angle \left (\delta _{i,t} + \frac{\pi } {2}\right ) }$$
(6.8d)
$$\displaystyle{ S_{ij,t} = (V _{i,t}\angle \delta _{i,t})I_{ij,t}^{{\ast}} }$$
(6.8e)
$$\displaystyle{ P_{ij,t} = \mathrm{real}\left \{S_{ij,t}\right \} = \frac{V _{i,t}^{2}} {Z_{ij}} \cos (\theta _{ij}) -\frac{V _{i,t}V _{j,t}} {Z_{ij}} \cos (\delta _{i,t} -\delta _{j,t} +\theta _{ij}) }$$
(6.8f)
$$\displaystyle{ Q_{ij,t} = \mathrm{Img}\left \{S_{ij,t}\right \} = \frac{V _{i,t}^{2}} {Z_{ij}} \sin (\theta _{ij}) -\frac{V _{i,t}V _{j,t}} {Z_{ij}} \sin (\delta _{i,t} -\delta _{j,t} +\theta _{ij}) -\frac{bV _{i,t}^{2}} {2} }$$
(6.8g)
$$\displaystyle{ -S_{ij}^{\mathrm{max}} \leq S_{ ij,t} \leq S_{ij}^{\mathrm{max}} }$$
(6.8h)
$$\displaystyle{ P_{i}^{g,\mathrm{min}} \leq P_{ i,t}^{g} \leq P_{ i}^{g,\mathrm{max}} }$$
(6.8i)
$$\displaystyle{ Q_{i}^{g,\mathrm{min}} \leq Q_{ i,t}^{g} \leq Q_{ i}^{g,\mathrm{max}} }$$
(6.8j)
$$\displaystyle{ P_{i,t}^{g} - P_{ i,t-1}^{g} \leq \mathrm{RU}_{ g} }$$
(6.8k)
$$\displaystyle{ P_{i,t-1}^{g} - P_{ i,t}^{g} \leq \mathrm{RD}_{ g} }$$
(6.8l)
$$\displaystyle{ 0 \leq P_{i,t}^{\mathrm{LS}} \leq P_{ i,t}^{L} }$$
(6.8m)
$$\displaystyle{ 0 \leq Q_{i,t}^{\mathrm{LS}} \leq Q_{ i,t}^{L} }$$
(6.8n)
$$\displaystyle{ P_{i,t}^{\mathrm{wc}} = w_{ t}\varLambda _{i}^{w} - P_{ i,t}^{w} }$$
(6.8o)
$$\displaystyle{ 0 \leq P_{i,t}^{w} \leq w_{ t}\varLambda _{i}^{w} }$$
(6.8p)

The GAMS code developed for solving the minimum cost OPF is given in GCode 6.7. The optimal active/reactive power generation of thermal units in MP-AC OPF are given in Figs. 6.14 and 6.15, respectively.

Fig. 6.14
figure 14

Active power generation of thermal units in MP-AC OPF

Fig. 6.15
figure 15

Reactive power generation of thermal units in MP-AC OPF

GCode 6.7 Multi-period AC OPF for modified IEEE RTS 24 bus system

Sets i   network buses /1*24/  , slack ( i ) /13/, t /t1 * t24/ GB( i ) generating  buses /1,2,7,15*16,18,21*23/; scalars  Sbase /100/  ,VOLL /10000/,VWC /50/; a l i a s ( i, j ); Table GenD( i, * )   Generating units  c h a r a c t e r i s t i c s      pmax pmin   b     Qmax  Qmin Vg    RU    RD 1    152  30.4   13.32 192  −50  1.035 21   21 2    152  30.4   13.32 192  −50  1.035 21   21 7    350  75     20.7  300  0    1.025 43   43 13   591  206.85 20.93 591  0    1.02  31   31 15   215  66.25  21    215  −100 1.014 31   31 16   155  54.25  10.52 155  −50  1.017 31   31 18   400  100    5.47  400  −50  1.05  70   70 21   400  100    5.47  400  −50  1.05  70   70 22   300  0      0     300  −60  1.05  53   53 23   360  248.5  10.52 310  −125 1.05  31   31      ; Table BD( i, * )  Demands of  each bus in MW       Pd   Qd  *   removed for saving space; table  LN( i, j, * )     Network technical  c h a r a c t e r i s t i c s                r       x       b      limit  *   removed for saving space; Table WD ( t, * )       w                   d  *   removed for saving space ; parameter Wcap( i ) /8   200 19  150 21  100/; LN( i, j, ’x ’ )$(LN( i, j, ’x ’ )=0) = LN( j, i, ’x ’ );LN( i, j, ’ r ’ )$(LN( i, j, ’ r ’ )=0) = LN( j, i, ’ r ’ ); LN( i, j, ’b ’ )$(LN( i, j, ’b ’ )=0) = LN( j, i, ’b ’ );LN( i, j, ’ bij ’ )$LN( i, j, ’ Limit ’ )=1/ LN( i, j, ’x ’ ); LN( i, j, ’ Limit ’ )$(LN( i, j, ’ Limit ’ )=0) = LN( j, i, ’ Limit ’ ); LN( i, j, ’ z ’ )$LN( i, j, ’ Limit ’ )= sqrt( power (LN( i, j, ’x ’ ),2)+ power (LN( i, j, ’ r ’ ),2) ); LN( j, i, ’ z ’ )$(LN( i, j, ’ z ’ )=0) = LN( i, j, ’ z ’ ); LN( i, j, ’ th ’ )$(LN( i, j, ’ Limit ’ ) and  LN( i, j, ’x ’ ) and LN( i, j, ’ r ’ ) )                                =arctan (LN( i, j, ’x ’ ) /(LN( i, j, ’ r ’ ) ) ); LN( i, j, ’ th ’ )$(LN( i, j, ’ Limit ’ ) and  LN( i, j, ’x ’ ) and LN( i, j, ’ r ’ )=0) = pi/2; LN( i, j, ’ th ’ )$(LN( i, j, ’ Limit ’ ) and  LN( i, j, ’ r ’ ) and LN( i, j, ’x ’ )=0) =0; LN( j, i, ’ th ’ )$LN( i, j, ’ Limit ’ )= LN( i, j, ’ th ’ );  Parameter cx ( i, j ); cx ( i, j )$(LN( i, j, ’ limit ’ )and LN( j, i, ’ limit ’ ) ) =1; cx ( i, j )$( cx ( j, i ) ) =1; Variables  OF, Pij ( i, j, t ), Qij ( i, j, t ),Pg( i, t ),Qg( i, t ),Va( i, t ),V( i, t ),Pw( i, t ); Equations eq1, eq2, eq3, eq4, eq5, eq6, eq7; eq1 ( i, j, t ) $cx ( i, j ).. Pij ( i, j, t )= e=( V( i, t ) * V( i, t ) * cos(LN( j, i, ’ th ’ ) )                  − V( i, t ) * V( j, t ) * cos(Va( i, t ) − Va( j, t )+ LN( j, i, ’ th ’ ) ) )/ LN( j, i, ’ z ’ ); eq2 ( i, j, t ) $cx ( i, j ).. Qij ( i, j, t )= e=( V( i, t ) * V( i, t ) * sin(LN( j, i, ’ th ’ ) )                  − V( i, t ) * V( j, t ) * sin(Va( i, t ) − Va( j, t )+ LN( j, i, ’ th ’ ) ) )/ LN( j, i, ’ z ’ )                                                   − LN( j, i, ’b ’ ) * V( i, t ) * V( i, t ) /2; eq3 ( i, t ) ..  Pw( i, t )$Wcap( i )+ Pg( i, t )$GenD( i, ’Pmax ’ ) − WD ( t, ’d ’ ) * BD( i, ’pd ’ )/Sbase= e = + sum( j$cx ( j, i ), Pij ( i, j, t ) ); eq4 ( i, t ) ..                Qg( i, t )$GenD( i, ’Qmax ’ ) − WD ( t, ’d ’ ) * BD( i, ’qd ’ )/Sbase= e = + sum( j$cx ( j, i ), Qij ( i, j, t ) ); eq5        ..  OF = g = sum(( i, t ),Pg( i, t ) * GenD( i, ’b ’ ) * Sbase$GenD( i, ’Pmax ’ ) ); eq6 ( i, t )$(GenD( i, ’Pmax ’ ) and ord ( t )>1) .. Pg( i, t ) − Pg( i, t −1) =l= GenD( i, ’RU’ )/Sbase; eq7 ( i, t )$(GenD( i, ’Pmax ’ ) and ord ( t ) <card ( t ) ) .. Pg( i, t ) − Pg( i, t+1) =l=                                               GenD( i, ’RD’ )/Sbase; Model loadflow    /eq1, eq2, eq3, eq4, eq5, eq6, eq7 /; Pg. lo ( i, t )= GenD( i, ’Pmin ’ )/Sbase;  Pg. up( i, t )= GenD( i, ’Pmax ’ )/Sbase; Qg. lo ( i, t )= GenD( i, ’Qmin ’ )/Sbase;  Qg. up( i, t )= GenD( i, ’Qmax ’ )/Sbase; Va. up( i, t )= pi/2;  Va. lo ( i, t )=− pi/2;  Va. l ( i, t ) =0; Va. fx ( slack, t ) =0; Pij. up( i, j, t )$ (( cx ( i, j ) ) ) =+1*LN( i, j, ’ Limit ’ )/Sbase; Pij. lo ( i, j, t )$ (( cx ( i, j ) ) )=−1* LN( i, j, ’ Limit ’ )/Sbase; Qij. up( i, j, t )$ (( cx ( i, j ) ) ) =+1*LN( i, j, ’ Limit ’ )/Sbase; Qij. lo ( i, j, t )$ (( cx ( i, j ) ) )=−1* LN( i, j, ’ Limit ’ )/Sbase;  V. lo ( i, t ) =0.9; V. up( i, t ) =1.1; Pw. up( i, t )= WD ( t, ’d ’ ) * Wcap( i )/ sbase;  Pw. lo ( i, t ) =0; Solve loadflow minimizing OF  using nlp;

Nomenclature

Parameters

w i, t :

Availability of wind turbine connected to bus i at time t

Λ i w :

Capacity of wind turbine connected to bus i

P i, t L :

Active power component of demand in bus i at time t

P i, t w :

Active power generation by wind turbine connected to bus i at time t

Q i, t w :

Reactive power generation by wind turbine connected to bus i at time t

a g , b g , c g :

Fuel cost coefficients of thermal unit g.

P i g, max∕min :

Maximum/minimum limits of power generation of thermal unit g connected to bus i.

P ij max :

Maximum power flow limits of branch connecting bus i to j.

x ij :

Reactance of branch connecting bus i to j.

r ij :

Resistance of branch connecting bus i to j.

VOLL:

Value of loss of load ($/MW h)

VWC:

Value of loss of wind ($/MW h)

b :

Total line charging susceptance of branch connecting bus i to j (pu).

Variables

S ij, t :

Apparent power flow of branch connecting bus i to j at time t.

P i, t g :

Active power generated by thermal unit g connected to bus i at time t (MW).

P i, t w :

Active power generated by wind turbine connected to bus i at time t (MW).

λ i, t p :

Active locational marginal price (LMP) in bus i at time t ($/MW h).

P i, t LS :

Active Load shedding in bus i at time t (MW).

P i, t wc :

Curtailed power of wind turbine connected to bus i at time t (MW).

I ij, t :

Current flow of branch connecting bus i to j at time t.

Q i, t LS :

Reactive Load shedding in bus i at time t (MVAr).

Q i, t g :

Reactive power generated by thermal unit g connected to bus i at time t (MW).

λ i, t q :

Reactive locational marginal price (LMP) in bus i at time t ($/MVArh).

OF:

Total operating costs ($).

δ i, t :

Voltage angle in bus i at time t (rad).

V i, t :

Voltage magnitude in bus i at time t (pu).