clear all;clc;
y=0;
y(1,2)=1/(0.04+0.25i);
y(1,3)=1/(0.1+0.35i);
y(2,3)=1/(0.08+0.3i);
y(2,4)=1/0.015i/1.05;
y(3,5)=1/0.03i/1.05;
y(1,1)=0.25i;
y(2,2)=0.25i+0.25i+1/0.015i*(1-1.05)/1.05^2;
y(3,3)=0.25i+1/0.03i*(1-1.05)/1.05^2;
y(4,4)=1/0.015i*(1.05-1)/1.05;
y(5,5)=1/0.03i*(1.05-1)/1.05;
for i=1:5
for j=i+1:5
g(i,j)=-real(y(i,j));
b(i,j)=-imag(y(i,j));
g(j,i)=g(i,j);
b(j,i)=b(i,j); %互导纳
end
g(i,i)=real(y(i,i))-sum(g(:,i));
b(i,i)=imag(y(i,i))-sum(b(:,i)); %自导纳
end
v=ones(1,5);
a=zeros(1,5);
v(4:5)=[1.05,1.05]; %电压初值
ps=[-1.6,-2,-3.7,5,0];
qs=[-0.8,-1,-1.3,0,0]; %给定注入功率,4节点PV,5 节点 slack
k=0; %迭代次数
while 1
p=zeros(1,5);
q=zeros(1,5);
for i=1:5
for j=1:5
p(i)=p(i)+v(i)*v(j)*(g(i,j)*cos(a(i)-a(j))
+b(i,j)*sin(a(i)-a(j)));
q(i)=q(i)+v(i)*v(j)*(g(i,j)*sin(a(i)-a(j))-
b(i,j)*cos(a(i)-a(j))); %各节点注入功率
end
op(i)=ps(i)-p(i);oq(i)=qs(i)-q(i);
end
op=op(1:4);
oq=oq(1:3); %偏移量
if max([op,oq]')<1e-5
break;
end
for i=1:5
for j=1:5
if i~=j
h(i,j)=-v(i)*v(j)*(g(i,j)*sin(a(i)-a(j))-
b(i,j)*cos(a(i)-a(j)));
n(i,j)=-v(i)*v(j)*(g(i,j)*cos(a(i)-a(j))
+b(i,j)*sin(a(i)-a(j)));
m(i,j)=-n(i,j);
l(i,j)=h(i,j);
- 1
- 2
- 3
前往页