Lfybus.m
资源名称:power.rar [点击查看]
上传用户:eighthdate
上传日期:2014-05-24
资源大小:270k
文件大小:1k
源码类别:
其他行业
开发平台:
Matlab
- % This program obtains th Bus Admittance Matrix for power flow solution
- % Copyright (c) 1998 by H. Saadat
- j=sqrt(-1); i = sqrt(-1);
- nl = linedata(:,1); nr = linedata(:,2); R = linedata(:,3);
- X = linedata(:,4); Bc = j*linedata(:,5); a = linedata(:, 6);
- nbr=length(linedata(:,1)); nbus = max(max(nl), max(nr));
- Z = R + j*X; y= ones(nbr,1)./Z; %branch admittance
- for n = 1:nbr
- if a(n) <= 0 a(n) = 1; else end
- Ybus=zeros(nbus,nbus); % initialize Ybus to zero
- % formation of the off diagonal elements
- for k=1:nbr;
- Ybus(nl(k),nr(k))=Ybus(nl(k),nr(k))-y(k)/a(k);
- Ybus(nr(k),nl(k))=Ybus(nl(k),nr(k));
- end
- end
- % formation of the diagonal elements
- for n=1:nbus
- for k=1:nbr
- if nl(k)==n
- Ybus(n,n) = Ybus(n,n)+y(k)/(a(k)^2) + Bc(k);
- elseif nr(k)==n
- Ybus(n,n) = Ybus(n,n)+y(k) +Bc(k);
- else, end
- end
- end
- clear Pgg