雄关漫道真如铁,而今迈步从头越分享 http://blog.sciencenet.cn/u/max 专业,是一种追求;执着,是一种品质;从容,是一种境界。

博文

Gauss-Seidel潮流计算Matlab程序

已有 6320 次阅读 2010-11-5 14:26 |个人分类:电力系统|系统分类:科研笔记|关键词:学者| MATLAB, 潮流计算, Gauss-Seidel

%  This program is to calculate power flow using Gass-Seidel iterative
%  method. Developed by Wang shisan, 2008-11-22 firstly, 2010-10-22 secondaly.

%  Part 1: Creating admittance matrix Y;
   clear;
   y13=1.17-j*4.71;   % Admittances linked 2-nodes;
   y12=5.88-j*23.5;
   y30=j*0.33;
   Y=[y12+y13  -y12  -y13;
       -y12     y12   0;
       -y13      0    y13+y30];

%  Part 2: Initialing voltage, power value;
   U(1)=1;   % Swing node;
   U3=1.1;   % Magnitude for PV node;
   P(3)=0.4;
   S(2)=-0.8-j*0.6;
   Nmax=10;
   Precision=1E-06;   % Tolerance level;
     
%  Part 3: Iterative process;
   U(2)=1.0;  % Setting initial voltage for 2-th node, need to solve.
   Sita3=0;   % Phase angle for 3th node, need to solve.
   MaxError=0;
   U(3)=U3*exp(j*Sita3);
   for k=1:Nmax
     U_old(2:3)=U(2:3);  %Save old voltage in order to determine congergence;
     % For PQ node, 2th node;
        Temp1=conj(S(2)/U(2))-Y(2,1)*U(1)-Y(2,3)*U(3);   %conjugated value;
        U(2)=Temp1/Y(2,2);
     % For PV nodes, 3th node;
        Temp3=conj(U(3))*(Y(3,3)*U(3)+Y(3,1)*U(1)+Y(3,2)*U(2));
        Q(3)=-imag(Temp3);
        S(3)=P(3)+j*Q(3);
        Temp3=conj(S(3)/U(3))-Y(3,1)*U(1)-Y(3,2)*U(2);
        U(3)=Temp3/Y(3,3);
        Sita3=angle(U(3));
        U(3)=U3*exp(j*Sita3);
     % Convergence criterion;
       for p=2:3
          Error(p)=U(p)-U_old(p);
       end
       MaxError=max(abs(Error(2)),abs(Error(3)));
       if MaxError<Precision
          disp('Iteration successful');
          disp('Iteration number=');
          disp(k);
          MaxError
          break
       end
       k
       U
       Sita3 
       MaxError
   end    
 
% Part 4: Output messages;
   if MaxError>Precision
     disp('Calculation is fail.');
     disp('Inceasing Nmax or deceasing presion!')
   end
%THE END, 2010-10-20, Wang Shishan.  
   
  
  
  



https://m.sciencenet.cn/blog-469261-380689.html

上一篇:Newton_Raphson法潮流计算Matlab程序
下一篇:时速,再创历史新低

2 杨正瓴 杨华磊

发表评论 评论 (1 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-2 19:26

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部