Home > matpower6.0 > extras > reduction > BuildYMat.m

BuildYMat

PURPOSE ^

Subroutine BuildYMat construct the addmittance matrix and store it in a

SYNOPSIS ^

function [CIndx,ERP,DataB]=BuildYMat(NFROM,NTO,BraNum,LineB,BCIRC,BusNum,NUMB,SelfB)

DESCRIPTION ^

 Subroutine BuildYMat construct the addmittance matrix and store it in a
 compact storage format in order to apply sparse technique.

   [CIndx,ERP,DataB]=BuildYMat(NFROM,NTO,BraNum,LineB,BCIRC,BusNum,NUMB,SelfB)

 INPUT DATA:
   NFROM: 1*n array, includes bus indices of from end buses of every
       branch
   NTO: 1*n array, includes bus indices of to end buses of every branch
   BraNum: scalar, number of branaches
   NUMB: 1*n array, bus indices
   SelfB: 1*n array, total B shunts on every bus (B shunt on bus and half
   the branch B shunt) 

 OUTPUT DATA:
   CIndx: 1*n array, includes column indices of every row in the
       addmittance matrix
   ERP: 1*n array, includes end of row pointers of the admittance matrix
   DataB: 1*n array, includes admittance values in the admittance matrix

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [CIndx,ERP,DataB]=BuildYMat(NFROM,NTO,BraNum,LineB,BCIRC,BusNum,NUMB,SelfB)
0002 % Subroutine BuildYMat construct the addmittance matrix and store it in a
0003 % compact storage format in order to apply sparse technique.
0004 %
0005 %   [CIndx,ERP,DataB]=BuildYMat(NFROM,NTO,BraNum,LineB,BCIRC,BusNum,NUMB,SelfB)
0006 %
0007 % INPUT DATA:
0008 %   NFROM: 1*n array, includes bus indices of from end buses of every
0009 %       branch
0010 %   NTO: 1*n array, includes bus indices of to end buses of every branch
0011 %   BraNum: scalar, number of branaches
0012 %   NUMB: 1*n array, bus indices
0013 %   SelfB: 1*n array, total B shunts on every bus (B shunt on bus and half
0014 %   the branch B shunt)
0015 %
0016 % OUTPUT DATA:
0017 %   CIndx: 1*n array, includes column indices of every row in the
0018 %       addmittance matrix
0019 %   ERP: 1*n array, includes end of row pointers of the admittance matrix
0020 %   DataB: 1*n array, includes admittance values in the admittance matrix
0021 
0022 %   MATPOWER
0023 %   Copyright (c) 2014-2016, Power Systems Engineering Research Center (PSERC)
0024 %   by Yujia Zhu, PSERC ASU
0025 %
0026 %   This file is part of MATPOWER.
0027 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0028 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0029 
0030 %% Initialization
0031 ERP = 0:BusNum; % consider two things: 1. 0 at the begining, 2. diagonal element is non-zero for every row
0032 %%%% Be aware of 1. Isolated buses; 2. Offline branches
0033 %% Read the branch one by one
0034 %first generate the ERP array
0035 for i=1:BraNum
0036     if BCIRC(i)==1 % if the circuit number is not 1, then the line is parallel line and the index will not increment
0037         ERP((NFROM(i)+1):(BusNum+1)) = ERP((NFROM(i)+1):(BusNum+1))+1;
0038         ERP((NTO(i)+1):(BusNum+1)) = ERP((NTO(i)+1):(BusNum+1))+1;
0039     end
0040 end
0041 %second generate the CIndx and Data array;
0042 DataB = zeros(1,ERP(BusNum+1));
0043 % DataG = AssignSpace(ERP(BusNum+1));
0044 CIndx = zeros(1,ERP(BusNum+1));
0045 ICLP = ERP;
0046 ICLP = ICLP+1;
0047 ICLP(BusNum+1) = [];
0048 ICLP=[0,ICLP];
0049 CIndx(ICLP(2:BusNum+1))=NUMB;
0050 ICLP(2:BusNum+1)=ICLP(2:BusNum+1)+1; % first consider all diagonal elements
0051 
0052 %b = 1./BranchData(:,4);
0053 for i = 1:BraNum;
0054 
0055 %%
0056     DataB(ICLP([NFROM(i)+1,NTO(i)+1]))=DataB(ICLP([NFROM(i)+1,NTO(i)+1]))-LineB(i);
0057 %%
0058 if i<BraNum
0059     if BCIRC(i+1)==1
0060         CIndx(ICLP([NFROM(i)+1,NTO(i)+1]))=[NTO(i),NFROM(i)];
0061         ICLP([NFROM(i)+1,NTO(i)+1])=ICLP([NFROM(i)+1,NTO(i)+1])+1;
0062     end
0063 else
0064     CIndx(ICLP([NFROM(i)+1,NTO(i)+1]))=[NTO(i),NFROM(i)];
0065 end
0066     
0067 end
0068 for i = 1:BusNum
0069     DataB(ERP(NUMB(i))+1)=DataB(ERP(NUMB(i))+1)+SelfB(i);
0070 end
0071 
0072 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005