马上加入,结交更多好友,共享更多资料,让你轻松玩转电力研学社区!
您需要 登录 才可以下载或查看,没有账号?立即加入
×
clear %清除工作空间原有的变量- r2 m1 X3 ~% X, E! ?0 s
clc
& y2 X3 e: Q3 ]) n" |1 da=textread('IEEE14.dat'); %读数据文件
/ ^0 b) ?9 w# F8 W4 h3 i7 Wn=a(1,1); %节点数4 r7 F% f# d( r3 y$ V K# f% |
line=a(1,2); %支路数# m1 s, w7 z) h; l0 {
blance=a(1,3); %平衡节点
) c2 Q/ A: D6 c" cSB=a(1,4); %基准功率
3 J/ S3 {& m) B( i' O4 K* Nkmax=a(1,5); %最大迭代次数+ k& P6 Q4 b; V* G/ ?
ab=a(2,1); %计算精度
* C+ R# F6 g7 U7 P' l" et=find(a(:,1)==0); : V' d$ s2 V6 s
xianlu=a([3:t(1)-1],:); %形成线路参数矩阵3 d, }# x8 y# l3 f
jiedi=a([t(1)+1:t(2)-1],:); %接地支路参数矩阵* O8 l- C7 m% B& h; X
bianya=a([t(2)+1:t(3)-1],:); %形成变压器支路参数矩阵
% y6 [8 ]# m/ J# }4 F) n: cjiedian=a([t(3)+1:t(4)-1],:);%节点功率数据矩阵
* P0 @' j9 H5 |6 k& n$ ipv=a([t(4)+1:t(5)-1],:); %pv节点数据矩阵- ]1 g' C. c3 D$ z
%读线路参数# |' Q' o7 D# j( I7 r
linei=xianlu(:,2)';2 d2 j: Z; |9 \
linej=xianlu(:,3)';
: S1 b- i) L; I: F g: c) F: [* Pr=xianlu(:,4)';" V* w# N8 E7 P# u, \
x=xianlu(:,5)';& u; p9 z+ ^# b8 ^: n/ K+ l
b0=xianlu(:,6)';6 ]' Z9 H* N( f; v" V5 }
0 E% _% }3 O0 t: Y
g=r./(r.*r+x.*x);
' n2 b" \& n7 }: |b=-x./(r.*r+x.*x);) g2 o4 T% g1 l' g: x
G=sparse(linei,linej,-g,n,n)+sparse(linej,linei,-g,n,n)+sparse(linei,linei,g,n,n)+sparse(linej,linej,g,n,n);1 s# K) H7 h: X+ M9 @+ J8 P
B=sparse(linei,linej,-b,n,n)+sparse(linej,linei,-b,n,n)+sparse(linei,linei,b+b0,n,n)+sparse(linej,linej,b+b0,n,n);
+ z0 x- N" t4 L' X0 _8 W3 E& ^6 o% 读变压器参数- N9 }% ]' B' C! V. c, Q9 n
linei=bianya(:,2)';
8 ]0 y& ~9 \- m# Wlinej=bianya(:,3)';0 R- o7 E! J; Y
r=bianya(:,4)';; W, @4 N* ~% b+ ~. Z, D, q
x=bianya(:,5)';/ C0 c& ]/ h+ o+ L$ _4 N d$ t
k0=bianya(:,6)'; r7 v! b2 E1 B' `- s& B" L
g=r./(r.*r+x.*x);3 A! u6 I* C0 @) s* T* j3 }- H6 R
b=-x./(r.*r+x.*x);* M+ h& K5 p1 e. ?$ g9 r, O
G=G+sparse(linei,linej,-g./k0,n,n)+sparse(linej,linei,-g./k0,n,n)+sparse(linei,linei,g./k0./k0,n,n)+sparse(linej,linej,g,n,n); r: ~. V. j0 K! ]3 j: G3 S, s4 h) H
B=B+sparse(linei,linej,-b./k0,n,n)+sparse(linej,linei,-b./k0,n,n)+sparse(linei,linei,b./k0./k0,n,n)+sparse(linej,linej,b,n,n);
; V X" M, o* ?; i% 读接地支路参数
- E+ W/ K1 |, H5 _/ t: f; s5 njiedidian=jiedi(:,1)';& _0 o7 P" p+ U4 Y+ B I( r7 b
branchib=jiedi(:,2)';$ Q c. u* W/ z' R
B=B+sparse(jiedidian,jiedidian,branchib,n,n);
7 h- b3 k8 \; D%节点导纳矩阵. a X, J+ _3 y
Y=sparse(G+i*B);# U1 o6 C6 e! h3 N
% 读节点功率数据2 L5 k& ^+ Y% v& V- A7 J3 u/ o
pg=jiedian(:,2)/SB;% N( B1 H8 |& l% p9 _ g
pd=jiedian(:,4)/SB;
! I4 @$ ^4 Q Aqg=jiedian(:,3)/SB;
7 ~6 z6 x k( m- H/ u8 kqd=jiedian(:,5)/SB;! e; i! Y2 ^2 V, y$ M7 p
3 s$ R, b* v; Q2 a1 v, p3 W9 c
p=zeros(n,1);" H! i+ j7 ?8 B8 N: e$ _( a
q=zeros(n,1);
, }, M7 c) A) ~! [9 C K9 P2 Kp(jiedian(:,1))=pg-pd;
4 r) N+ G# @( v) _0 r7 L% x/ Wq(jiedian(:,1))=qg-qd;
# G4 A. _/ V+ o5 _% 读pv节点数据" T8 I; `( S m2 y: X) Q1 P
pvjiedian=pv(:,1);! _8 z0 R# O+ N3 y3 k: a
vpv=pv(:,2);
7 v7 y( H2 N( X9 ?% e' a, Pv=ones(n,1); %电压初始值5 V6 X2 L- j2 w$ O
v(pvjiedian)=vpv; %pv节点(及平衡节点)电压已知; ^5 h n# \5 z! E
delt=zeros(n,1); %相角初始值* J* Z, ~1 b! v) |& s
deltp=zeros(n,1); % 失配有功功率初值( L% v8 J( z" \
deltq=zeros(n,1); % 失配无功功率初值
: x( z( w* F& }
c* O$ P8 W- [, c) p8 l%迭代求潮流计算; Y+ o7 I- u, d
for diedai=1:10 %置最大循环次数
. r# ^: j% `3 D4 x- Q5 y& D clear i! w: c3 V, z3 s2 W9 b' G }4 D
% 失配功率方程5 |: U3 A* s' t. [
V=v.*cos(delt)+i*v.*sin(delt);6 E! f9 r; R) a0 i) y$ `8 |
a2=conj(Y*V).*V;
( Q" @- K! w2 }+ ~# U% T: Y9 Z4 l deltp=p-real(a2);
& y- Q4 @, y8 c3 ~. s7 b$ ~1 G deltq=q-imag(a2);, K) O* \2 O4 [" `
6 f+ ^8 |) M" p % 求雅可比矩阵, B! J& O! T" b! ]& q
for i=1:n
7 {; f. |$ i; M- r: [) E" p for j=1:n
) ^ i1 J% Z) B/ v3 ? if i~=j
/ {0 E/ D5 e9 v( e8 o H(i,j)=-v(i)*v(j)*(G(i,j)*sin(delt(i)-delt(j))-B(i,j)*cos(delt(i)-delt(j)));
# Q' A9 U0 d% F8 u4 X( H else2 x4 [3 s8 @8 Y% M" T! e, y9 [' X
H(i,i)=v(i)*v(i)*B(i,i)+q(i)-deltq(i);* p1 [2 p: M; K4 n4 u: I G
end7 _+ I0 ^9 j) ^$ j. x
end; i8 _; _1 s4 w$ Z( u0 Y, o# V
end
# T9 x; A d7 e! ~" b + h1 C- L( \/ G z, b
for i=1:n7 q ]5 W5 ~( g: b( }
for j=1:n$ X" }5 w: u4 S4 w% j, y! o; j& S
if i~=j
! g1 r$ [+ x1 O N(i,j)=-v(i)*(G(i,j)*cos(delt(i)-delt(j))+B(i,j)*sin(delt(i)-delt(j)));8 K" y/ s+ u9 \# [
else
. I- B# E, `0 d. S: u D) a N(i,i)=-v(i)*G(i,i)-(p(i)-deltp(i))/v(i);
" I2 R' v" ^9 @2 ~* A# _4 [; i end( S$ n5 y D& Q- F1 h6 M
end' R) U9 C# Y5 F( z$ {
end " t! M/ Y1 ?& s Z) J- q6 q4 F2 ], D
$ p" c* V. D) c5 ~
for i=1:n' S6 ?/ G8 _- _2 f5 s2 k
for j=1:n3 M& Z1 w4 A2 w/ n- A* \( |" Z% T) Y
if i~=j8 `5 `" ?9 c+ Q9 o& K2 a8 h
J(i,j)=v(i)*v(j)*(G(i,j)*cos(delt(i)-delt(j))+B(i,j)*sin(delt(i)-delt(j)));# \1 t0 n0 Y" n# E% o
else$ M) e) q! f, m! y) \
J(i,i)=v(i)*v(i)*G(i,i)-(p(i)-deltp(i));
6 Y2 I5 z7 r" S! a' j" m% `- S end# @, e9 \6 A2 Q/ `
end3 v& E% [' Z* s+ Y. r! e- V/ h) v/ ?
end : N5 B5 I" K: q3 J8 G4 C# S- c0 o
; L2 U" s0 n4 W1 ]# h0 O
for i=1:n
3 \/ q8 A' J# O for j=1:n' F4 c+ |- |. j1 N5 F8 O
if i~=j! E, E& a- l! y
L(i,j)=-v(i)*(G(i,j)*sin(delt(i)-delt(j))-B(i,j)*cos(delt(i)-delt(j)));
4 @/ C; Q# c" l% ^" c/ [0 B' o else
$ c" L5 Q k' W" V9 F L(i,i)=v(i)*B(i,i)-(q(i)-deltq(i))/v(i);
5 K+ |6 }* A7 D A end
3 j7 Y/ r7 X: _% W/ C/ i end
9 A$ x2 x% r4 f" U) }- F end
5 F" N( R7 C p' [- R, W %修正雅克比矩阵, n" V: S0 V) S5 h7 j
Ya=[H N;J L]; w4 @" V/ |( o, e% R5 l
Ya([blance blance+n],:)=0;2 v: h- f+ H9 n3 l
Ya(:,[blance blance+n])=0; u: k) J* L1 X( ? T3 C
Ya(blance,blance)=1; %平衡节点
0 o B' w' l( T2 c Ya(blance+n,blance+n)=1;2 E0 a- q( J) N. v _5 O
Ya(pvjiedian+n,:)=0;' L# ^5 b% W% Z% V' G: H v
Ya(:,pvjiedian+n)=0;, E( q4 T6 h* `. ] ~ Y
for h=1:length(pvjiedian)- X. m/ b8 w3 \% u% W9 k1 n- Y3 T
Ya(pvjiedian(h)+n,pvjiedian(h)+n)=1;% b: y& o* Q7 Q0 G5 C1 |: Q7 T
end& b* V. C( k% G9 v, _
8 ^# F0 g8 K8 i
% ' Y3 r! m# i+ i8 d4 D. t
deltp(blance)=0; %平衡节点deltp=01 d, T6 X6 f+ [0 ^3 _) M7 i& o- R
deltq(blance)=0; %平衡节点deltq=0! k2 |! r* ^: Y, {* [; |9 ~
% ~2 c) p* e" K8 m
deltq(pvjiedian)=0; %pv节点deltq=07 R4 Y/ S# G0 }
deltpq=[deltp;deltq];( P/ c9 I' M4 h/ p& ?7 |
if max(abs(deltpq))<ab % 如果结果满足精度2 {( t! I- e2 W8 d# Z
break % 退出循环 2 \/ P4 L/ X% ]- |1 N
end # n/ ~; t: E9 u$ Z& M7 q7 N% [" h
R=Ya\(-deltpq);' f: _, P) x1 f" m) Y
delt=delt+R([1:n]);5 J$ n s- y. H, d
deltt=delt*180/pi
! R+ _1 f3 ]( _2 f0 l5 m5 c$ v v=v+R([n+1:2*n])4 g6 ?: o/ H& C8 a& L" j
end
0 Z4 @0 ?8 E, E+ h4 A" [! I: U
9 X8 b7 B7 d, P8 g' B; \2 e
& m5 |0 c7 e& J7 Z8 h- Z数据格式8 M0 Q1 y1 `3 Z+ P- [; a; d1 h
14 | 20 | 1 | 100 | 20 | 0.1 | | 1.00E-06 | 1 | | | | | | 1 | 1 | 2 | 0.01938 | 0.05917 | 0.0264 | | 2 | 1 | 5 | 0.05403 | 0.22304 | 0.0246 | | 3 | 2 | 3 | 0.04699 | 0.19797 | 0.0219 | | 4 | 2 | 4 | 0.05811 | 0.17632 | 0.017 | | 5 | 2 | 5 | 0.05695 | 0.17388 | 0.0173 | | 6 | 3 | 4 | 0.06701 | 0.17103 | 0.0064 | | 7 | 4 | 5 | 0.01335 | 0.04211 | 0 | | 11 | 6 | 11 | 0.09498 | 0.1989 | 0 | | 12 | 6 | 12 | 0.12291 | 0.25581 | 0 | | 13 | 6 | 13 | 0.06615 | 0.13027 | 0 | | 14 | 7 | 8 | 0 | 0.17615 | 0 | | 15 | 7 | 9 | 0 | 0.11001 | 0 | | 16 | 9 | 10 | 0.03181 | 0.0845 | 0 | | 19 | 12 | 13 | 0.22092 | 0.19988 | 0 | | 20 | 13 | 14 | 0.17093 | 0.34802 | 0 | | 4 | 14 | 9 | 0.12711 | 0.27038 | 0 | | 5 | 10 | 11 | 0.08205 | 0.19207 | 0 | | 0 | | | | | | | 9 | 0.19 | | | | | | 0 | | | | | | | 1 | 4 | 7 | 0 | 0.20912 | 0.978 | 0.9 | 2 | 4 | 9 | 0 | 0.55618 | 0.969' f, Z& \4 S" I6 F
0.9 | 1.1 | 3 | 5 | 6 | 0 | 0.25202 | 0.932 | 0.9 | 0 | | | | | | | 1 | 60 | 0 | 0 | 0 | | | 2 | 65 | 42.4 | 21.7 | 12.7 | | | 3 | 0 | 23.39 | 94.2 | 19 | | | 4 | 0 | 0 | 47.8 | -3.9 | | | 5 | 0 | 0 | 7.6 | 1.6 | | | 6 | 85 | 12.24 | 11.2 | 7.5 | | | 7 | 0 | 0 | 0 | 0 | | | 8 | 0 | 17.36 | 0 | 0 | | | 9 | 0 | 0 | 29.5 | 16.6 | | | 10 | 0 | 0 | 9 | 5.8 | | | 11 | 0 | 0 | 3.5 | 1.8 | | | 12 | 0 | 0 | 6.1 | 1.6 | | | 13 | 0 | 0 | 13.5 | 5.8 | | | 14 | 0 | 0 | 14.9 | 5 | | | 0 | | | | | | | 1 | 1.06 | -40 | 50 | | | | 2 | 1.045 | -40 | 50 | | | | 3 | 1.01 | 0 | 40 | | | | 6 | 1.07 | -30 | 40 | | | | 8 | 1.09 | -30 | 45 | | | | 0 | | | | | | | 1 | 105 | 2.45 | 0.005 | 50 | 200 | | 2 | 44.4 | 3.51 | 0.005 | 20 | 100 | | 6 | 40.6 | 3.89 | 0.005 | 20 | 100 | | 0 | | | | | | | 0 | | | | | | | 0 | | | | | | | | | | | | | |
|