5. 5
GAMS code:simple
model simpleopf / a l l / ;
solve simpl eopf using nlp mini m izing z ;
option decimals = 8;
display p 1 . l , p 2 . l , q 1 . l , q 2 . l , v 1 . l ,
v 2 . l , v 3 . l , d 1 . l , d 2 . l ;
9. 9
GAMS code
table Ldat(n,np,*) line
y l
data
t hel yshalf thes cap
n1.n2 9.95037190209989 -1.47112767430373 0 0 0.25
n1.n3 9.95037190209989 -1.47112767430373 0 0 2
n2.n3 9.95037190209989 -1.47112767430373 0 0 2;
L d a t ( n , n p , ' y l ' ) $(ord(n) gt ord(np))=Ldat(np,n,'yl');
Ldat(n,np,'thel')$(ord(n) gt ord(np))=Ldat(np,n,'thel');
Ldat(n,np, 'yshalf') $(ord(n) gt ord(np))=Ldat(np,n,'yshalf');
Ldat(n,np,'thes')$(ord(n) gt ord(np))=Ldat(np,n,'thes');
Ldat(n,np,'cap') $(ord(n) gt ord(np))=Ldat(np,n,'cap');
10. 10
GAMS code
variables
z objective function
p(g) un it g P gener a tion
q(g) un it g Q gener a tion
v(n) node n volta ge m
agni t ude
d(n) node n angle
pf(n,np) P flow per l i n e
qf( n,np) Q f low per l ine;
12. 12
GAMS code
equations
cost objective function
Pfcal(n,np) P flow calculation
Qfcal(n,np) Qflow calculation
Pbal(n)
Qbal(n)
S l im(n,n p)
P node balance
Q node balance
Sflow l i m i t ;
14. 14
GAMS code
c o s t . . z =e= sum(g,Gdat(g,'cost')*p(g));
Pbal(n).. sum(g$g2n(g,n),p(g))-Ndat(n,'Pd')=e=sum(np,pf(n,np));
Qbal(n).. sum(g$g2n(g,n),q(g))-Ndat(n,'Qd')=e=sum(np,qf(n,np));
Slim(n,np).. sqrt(power(pf(n,np),2)+power(qf(n,np),2))=l=Ldat(n,np, 'cap');
15. 15
GAMS code
model opf /all/;
solve opf using nlp minimizing z ;
option decimals = 8
display p . l, q. l , v.l , d .l , pf . l , qf . l ;