0% found this document useful (0 votes)
17 views4 pages

Nodenum S

This document describes a function that sorts bus and line data for a power system model. The function takes in bus and line data, identifies slack, PV and PQ buses, reorders the data with slack last and returns the reordered data along with mapping of old to new bus numbers.

Uploaded by

tahaahmed93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views4 pages

Nodenum S

This document describes a function that sorts bus and line data for a power system model. The function takes in bus and line data, identifies slack, PV and PQ buses, reorders the data with slack last and returns the reordered data along with mapping of old to new bus numbers.

Uploaded by

tahaahmed93
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

function [bus,line,nPQ,nPV,node_number] = sortbus(bus,line)

% returns the sheetsheetmatrix in the required sequence of sheettype

% [BUS,LINE,NPQ,NPV,NODE_NUMBER]= sortbus(BUS,LINE) returns the standard sheet

% sheetand line sheetwith preparation;

% nPQ and nPV are the counts of the PQ & PV sheetnumbers;

% node_number is the matrix to record which sheetnumber to be changed.

% Author(s):Long

% $Date:2010/06/27 13:31$

% Sheetdata

% SheetSheet Voltage Angle ---Load--- ------Generator---- Injected

% No Type Mag. Degree MW Mvar MW Mvar Qmin Qmax Mvar

sheet= [1 2 1.06 0 0 0 0 0 0 0 0

2 3 1 0 -0.2 -0.1 0.4 0.3 0 0 0

3 2 1 0 -0.45 -0.15 0 0 0 0 0

4 2 1 0 -0.4 -0.05 0 0 0 0 0

5 2 1 0 -0.6 -0.1 0 0 0 0 0 ];

% Line data

% Sheet Sheet R X 1/2 B Tr.tap Setting

% nl nr p.u. p.u. p.u. p.u.

line = [1 2 0.02 0.06 0.03 1

1 3 0.08 0.24 0.025 1

2 3 0.06 0.25 0.02 1

2 4 0.06 0.18 0.02 1

2 5 0.04 0.12 0.015 1

3 4 0.01 0.03 0.01 1

4 5 0.08 0.24 0.025 1];


[nb,mb] = size(bus);

[n1,m1] = size(line);

n = nb;

nSB = 1;

nPV = 0;

nPQ = 0;

for i = 1:n

type=bus(i,2);

if type==3 % Slack Bus

SB(nSB,:) = bus(i,:);

elseif type==2 % PV bus

nPV = nPV+1;

PV(nPV,:) = bus(i,:);

else nPQ = nPQ+1; % PQ bus

PQ(nPQ,:) = bus(i,:);

end

end

if nPV == 0

sheet= [PQ;SB] % sort sheetnumbers

node_number = [[1:nb]' bus(:,1)];

elseif nPV ~= 0

sheet= [PQ;PV;SB] % sort sheetnumbers


node_number = [[1:nb]' bus(:,1)];

end

% change sheetnumbers in line matrix

for i = 1:n1

for j = 1:2

for k = 1:nb

if line(i,j)==node_number(k,2);

line(i,j) = node_number(k,1);

break

end

end

end

end

bus(:,1) = [1:nb]'; % update sheetnumbers

You might also like