您好,欢迎访问三七文档
学院:电气工程学院专业班级:电气F1104姓名:马路林学号:201123910725潮流计算实验运行程序%本程序的功能是用牛顿——拉夫逊法进行潮流计算%B1矩阵:1、支路首端号;2、末端号;3、支路阻抗;4、支路对地电纳%5、支路的变比;6、支路首端处于K侧为1,1侧为0%B2矩阵:1、该节点发电机功率;2、该节点负荷功率;3、节点电压初始值%4、PV节点电压V的给定值;5、节点所接的无功补偿设备的容量%6、节点分类标号:1为平衡节点(应为1号节点);2为PQ节点;%3为PV节点;clear;n=10;nl=10;isb=1;pr=0.00001;B1=[120.03512+0.08306i0.13455i10;230.0068+0.18375i01.023811;140.05620+0.13289i0.05382i10;450.00811+0.24549i01.023811;160.05620+0.13289i0.05382i10;460.04215+0.09967i0.04037i10;670.0068+0.18375i01.023811;680.02810+0.06645i0.10764i10;8100.00811+0.24549i011;890.03512+0.08306i0.13455i10]B2=[001.11.101;001002;00.343+0.21256i1002;001002;00.204+0.12638i1002;001002;00.306+0.18962i1002;001002;0.501.11.103;00.343+0.21256i1002]Y=zeros(n);e=zeros(1,n);f=zeros(1,n);V=zeros(1,n);sida=zeros(1,n);S1=zeros(nl);fori=1:nlifB1(i,6)==0p=B1(i,1);q=B1(i,2);elsep=B1(i,2);q=B1(i,1);endY(p,q)=Y(p,q)-1./(B1(i,3)*B1(i,5));Y(q,p)=Y(p,q);Y(q,q)=Y(q,q)+1./(B1(i,3)*B1(i,5)^2)+B1(i,4)./2;Y(p,p)=Y(p,p)+1./B1(i,3)+B1(i,4)./2;enddispdisp(Y)%----------------------------------------------------------G=real(Y);B=imag(Y);fori=1:ne(i)=real(B2(i,3));f(i)=imag(B2(i,3));V(i)=B2(i,4);endfori=1:nS(i)=B2(i,1)-B2(i,2);B(i,i)=B(i,i)+B2(i,5);endP=real(S);Q=imag(S);ICT1=0;IT2=1;N0=2*n;N=N0+1;a=0;whileIT2~=0IT2=0;a=a+1;fori=1:nifi~=isbC(i)=0;D(i)=0;forj1=1:nC(i)=C(i)+G(i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J(m,q)=X1;J(m,N)=DP;q=q+1;J(p,q)=X6;J(m,q)=X2;endendendendendfork=3:N0k1=k+1;N1=N;fork2=k1:N1J(k,k2)=J(k,k2)./J(k,k);endJ(k,k)=1;ifk~=3k4=k-1;fork3=3:k4fork2=k1:N1J(k3,k2)=J(k3,k2)-J(k3,k)*J(k,k2);endJ(k3,k)=0;endifk==N0break;endfork3=k1:N0fork2=k1:N1J(k3,k2)=J(k3,k2)-J(k3,k)*J(k,k2);endJ(k3,k)=0;endelsefork3=k1:N0fork2=k1:N1J(k3,k2)=J(k3,k2)-J(k3,k)*J(k,k2);endJ(k3,k)=0;endendendfork=3:2:N0-1L=(k+1)./2;e(L)=e(L)-J(k,N);k1=k+1;f(L)=f(L)-J(k1,N);endfork=3:N0DET=abs(J(k,N));ifDET=prIT2=IT2+1;endendICT2(a)=IT2;ICT1=ICT1+1;enddisp('迭代次数:');disp(ICT1);disp('没有达到精度要求的个数:');disp(ICT2);fork=1:nV(k)=sqrt(e(k)^2+f(k)^2);sida(k)=atan(f(k)./e(k))*180./pi;E(k)=e(k)+f(k)*j;enddisp('各节点的实际电压标幺值E为(节点号从小到大排列):');disp(E);disp('-----------------------------------------------------');disp('各节点的电压大小V为(节点号从小到大排列):');disp(V);disp('-----------------------------------------------------');disp('各节点的电压相角sida为(节点号从小到大排列):');disp(sida);forp=1:nC(p)=0;forq=1:nC(p)=C(p)+conj(Y(p,q))*conj(E(q));endS(p)=E(p)*C(p);enddisp('各节点的功率S为(节点号从小到大排列):');disp(S);disp('-----------------------------------------------------');disp('各条支路的首端功率Si为(顺序同您输入B1时一致):');fori=1:nlp=B1(i,1);q=B1(i,2);ifB1(i,6)==0Si(p,q)=E(p)*(conj(E(p))*conj(B1(i,4)./2)+(conj(E(p)*B1(i,5))...-conj(E(q)))*conj(1./(B1(i,3)*B1(i,5))));Siz(i)=Si(p,q);elseSi(p,q)=E(p)*(conj(E(p))*conj(B1(i,4)./2)+(conj(E(p)./B1(i,5))...-conj(E(q)))*conj(1./(B1(i,3)*B1(i,5))));Siz(i)=Si(p,q);enddisp(Si(p,q));SSi(p,q)=Si(p,q);ZF=['S(',num2str(p),',',num2str(q),')=',num2str(SSi(p,q))];disp(ZF);disp('-----------------------------------------------------');enddisp('各条支路的末端功率Sj为(顺序同您输入B1时一致):');fori=1:nlp=B1(i,1);q=B1(i,2);ifB1(i,6)==0Sj(q,p)=E(q)*(conj(E(q))*conj(B1(i,4)./2)+(conj(E(q)./B1(i,5))...-conj(E(p)))*conj(1./(B1(i,3)*B1(i,5))));Sjy(i)=Sj(q,p);elseSj(q,p)=E(q)*(conj(E(q))*conj(B1(i,4)./2)+(conj(E(q)*B1(i,5))...-conj(E(p)))*conj(1./(B1(i,3)*B1(i,5))));Sjy(i)=Sj(q,p);enddisp(Sj(q,p));SSj(q,p)=Sj(q,p);ZF=['S(',num2str(q),',',num2str(p),')=',num2str(SSj(q,p))];disp(ZF);disp('-----------------------------------------------------');enddisp('各条支路的功率损耗DS为(顺序同您输入B1时一致):');fori=1:nlp=B1(i,1);q=B1(i,2);DS(i)=Si(p,q)+Sj(q,p);disp(DS(i));DDS(i)=DS(i);ZF=['DS(',num2str(p),',',num2str(q),')=',num2str(DDS(i))];disp(ZF);disp('-----------------------------------------------------');endfigure(1);subplot(1,2,1);plot(V);xlabel('节点号');ylabel('电压标幺值');gridon;subplot(1,2,2);plot(sida);xlabel('节点号');ylabel('电压角度');gridon;figure(2);subplot(2,2,1);P=real(S);Q=imag(S);bar(P);xlabel('节点号');ylabel('节点注入有功');gridon;subplot(2,2,2);bar(Q);xlabel('节点号');ylabel('节点注入无功');gridon;subplot(2,2,3);P1=real(Siz);Q
本文标题:实验一潮流计算
链接地址:https://www.777doc.com/doc-2457842 .html