0% found this document useful (0 votes)
116 views33 pages

Exercises 2 Opt R1

This document discusses optimization and its applications in smart grid problems. It provides examples of using the NLOpt package in R to solve optimization problems involving minimizing generation costs subject to constraints. One example minimizes total generation costs given cost curves for two generators while satisfying a demand constraint. Another example adds limits on one generator's output. Further examples incorporate power flow constraints by modeling generation amounts as functions of bus voltage angles.

Uploaded by

Wala' Saleh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views33 pages

Exercises 2 Opt R1

This document discusses optimization and its applications in smart grid problems. It provides examples of using the NLOpt package in R to solve optimization problems involving minimizing generation costs subject to constraints. One example minimizes total generation costs given cost curves for two generators while satisfying a demand constraint. Another example adds limits on one generator's output. Further examples incorporate power flow constraints by modeling generation amounts as functions of bus voltage angles.

Uploaded by

Wala' Saleh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

Electrical and Computer

Engineering Department

Using Optimization in Smart Grid


Applications

Dr. Abdalkarim Awad

Several tools
GAMS+Solver
CONDOR
Joptimizer
NLOPT
.

Dr.-Ing. Abdalkarim Awad

Nlopt
+

What is Optimization?
Optimization is the mathematical discipline which
is concerned with finding the maxima and minima
of functions, possibly subject to constraints.

Dr.-Ing. Abdalkarim Awad

What do we optimize?
A real function of n variables

f ( x1 , x2 , , xn )
with or without constraints

Dr.-Ing. Abdalkarim Awad

Unconstrained optimization

min f ( x, y) x 2 y
2

Dr.-Ing. Abdalkarim Awad

Optimization with constraints

min f ( x, y ) x 2 2 y 2
x0

or
min f ( x, y ) x 2 2 y 2
2 x 5, y 1

or
min f ( x, y ) x 2 2 y 2
x y 2
Dr.-Ing. Abdalkarim Awad

Nloptr Package
We are going to use a package called nloptr to
solve non-linear optimization problems.

Dr.-Ing. Abdalkarim Awad

Example1

Max=120 Mvar

GA

GB

LB=300

LA=300

C A (PG A ) 399.8 11.69PG A 0.00334PG A Euro/hr


2

C B (PG B ) 616.9 11.83PG B 0.00149PG B Euro/hr


2

Dr.-Ing. Abdalkarim Awad

Example1

Total Hourly Cost : 8459 $/hr


Area Lambda : 13.02

Bus A

Bus B

300.0 MW
199.6 MW
AGC ON

Dr.-Ing. Abdalkarim Awad

300.0 MW
400.4 MW
AGC ON

10

Generator cost curves

C A (PG A ) 399.8 11.69PG A 0.00334PG A Euro/hr


2

C B (PG B ) 616.9 11.83PG B 0.00149PG B Euro/hr


2

PGA+PGB=600

Dr.-Ing. Abdalkarim Awad

11

Generator cost curves


How much each generator should produce to cover
the 600MW demand
The Problem can be written as:
MINIMIZE (CA(PGA)+CB(PGB))
Subject to
PGA+PGB=600
PGA>=0
PGB>=0

Dr.-Ing. Abdalkarim Awad

12

Code

Dr.-Ing. Abdalkarim Awad

13

Code

Dr.-Ing. Abdalkarim Awad

14

Example2
Add constraints to generator 2
0<PGB<250
What is the total costs now?

Dr.-Ing. Abdalkarim Awad

15

Example3
Max=50 Mvar
Z=0.1j
A

GA

GB
LA=300 MW

LB=300 MW

Write R script to find P1 and P2 that minimizes the operation


costs and takes into considerations line limitations
Dr.-Ing. Abdalkarim Awad

16

Including power Flow


N

Pi ( Bik ( i k ))
k 1

P1=(B12)(1-2)
P1=(B12)1-B12(2)
P2=B21(2- 1)
P2=-B21(1)+(B21)(2)

Z=0.1j y=-10jB=-10

PA 3 10 10 1
PB 3 10 10 2



Dr.-Ing. Abdalkarim Awad

17

PA 3 10 10 1
PB 3 10 10 2

Solve with respect


to bus #1. i.e 1=0
(Slack bus)

PB-3=-(10)2

P12=B12*(1-2)

-PB+3-(10)(2)=0

|P12|=|-10(1-2)|<0.5
-0.5<10 2<0.5
-0.05<2<0.05

Dr.-Ing. Abdalkarim Awad

18

Example
P1

P2

BUS2

BUS3
1MW
Dr.-Ing. Abdalkarim Awad

500 MW

19

Generator cost curves


C1(P1) = 561 + 7.92 x P1 + 0.001562 x (P1)2
100 MW P1 600 MW
C3(P2) = 78 + 7.97 x P2 + 0.004820 x (P2)2
50 MW P2 400 MW

Dr.-Ing. Abdalkarim Awad

20

Optimization Problem
Minimize (C1(P1)+C2(P2))
Subject to:
100 MW P1 600 MW
50 MW P2 400 MW
P1+P2=500-100=400

Dr.-Ing. Abdalkarim Awad

21

Example4
Write R script to find P1 and P2 that minimizes the
operation costs

Dr.-Ing. Abdalkarim Awad

22

Solution
7.92 + 2*0.001562 x (P1)=
7.97 + 2*0.004820 x (P2) =
P1+P2=500-100=400
P1=306.0169
P2=93.98
Minimum Cost = 4000.55

Do they satisfy all constraints?

Dr.-Ing. Abdalkarim Awad

23

P1=306MW
P1

94MW

SB=100 MVA

P12=71

BUS1

BUS2

y12=-10j

P13=235MW

P2

P13<200=2 pu
y13=-10j

P23=165
y23=-10j

BUS3
1MW= 1 pu
Dr.-Ing. Abdalkarim Awad

500= 5 pu

24

Example4
Write R script to find P1 and P2 that minimizes the
operation costs and takes into considerations line
limitations

Dr.-Ing. Abdalkarim Awad

25

Including power Flow


N

Pi ( Bik ( i k ))
k 1

P1=(B12)(1-2)+B13(1-3

P1=(B12+B13)1-B12(2)-B13(3)
P2=-B21(1)+(B21+B23)(2)-B23(3)
P3=-B31(1)-B32(2)+(B31+B32)(3)
B12
B13
P1 B12 B13
P 2 B 21
B 21 B 23
B 23

P3 B31
B32
B 21 B32

1
2

3

Compare to Y matrix!
Dr.-Ing. Abdalkarim Awad

26

10
P1 20 10
P 2 10 20 10

1 5 10
10 20

singular

1
2

3

SB=100 MVA
P1
BUS1

P2
y12=-10j
P13<200=2 pu
y13=-10j

BUS2
y23=-10j
BUS3
500= 5 pu

Dr.-Ing. Abdalkarim Awad

1MW= 1 pu

27

0 1
P1 20 10
Solve
with
respect
P 2 10 20 10 2

to bus #1. i.e 1=0
4 0
10 20 3 (Slack bus)

P 2

4

20 10 2
10 20 3

|P13|<200 |B13(1-3)|<2 (pu) -0.2<3<0.20


(B13=-10)
Dr.-Ing. Abdalkarim Awad

28

Optimization Problem
Minimize (C1(P1)+C2(P2)) (in pu)
Subject to:
1 pu P1 6 pu
0.5 pu P2 4 pu
P1+P2=4


P 2

4


20 10 2
10 20 3

-0.2<3<0.20
Dr.-Ing. Abdalkarim Awad

29

Solution (using R)

1 0
2 0

3 0.2

P1=200 MW
P2=200 MW

P13=-B13(1-3)=-10*(0-0.2)=2 pu=200 MW
Costs=4072.28>4000.55 Euro
Dr.-Ing. Abdalkarim Awad

30

Optimization Problem
Minimize (C1(P1)+C2(P2)) (in pu)
Subject to:
1 pu P1 6 pu
0.5 pu P2 4 pu


P 2

4


20 10 2
10 20 3

|P13|<170 |B13(1-3)|<1.70 -0.17<3<0.17


Dr.-Ing. Abdalkarim Awad

31

P1

P2

BUS2

BUS1

-10j

P13<1.7

-10j

-10j

BUS3
1

Dr.-Ing. Abdalkarim Awad

32

Solution (using R)

P1=110
P2=290
2=-0.06
3=0.17

The total generation cost becomes: 4245.76>


4000.55
Here, we had to sacrifice cost for implementation.

Dr.-Ing. Abdalkarim Awad

33

You might also like