-
Notifications
You must be signed in to change notification settings - Fork 0
/
myG_branchtypes.m
31 lines (23 loc) · 975 Bytes
/
myG_branchtypes.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function [tree,connect, compressor,after_compressor] = myG_branchtypes(branch)
%% constants
[TREE,CONNECT, COMPRESSOR, FBUS, TBUS, LENGTH, DIAMETER, BRANCH_TYPE] = myG_idx_branch;
%% form index lists for slack, PV, and PQ buses
tree = find(branch(:, BRANCH_TYPE) == TREE ); %% reference bus index
connect = find(branch(:, BRANCH_TYPE) == CONNECT ); %% PV bus indices
compressor = find(branch(:, BRANCH_TYPE) == COMPRESSOR); %% PQ bus indices
len = length(compressor);
after_compressor = zeros(len,2);
for k = 1:len
temp = find(branch(:,FBUS) == branch(compressor(k),TBUS));
temp2 = find(branch(:,TBUS) == branch(compressor(k),TBUS) & branch(:,FBUS) ~= branch(compressor(k),FBUS));
if (length(temp)+length(temp2)~=1 )
error('压缩机后支路不唯一或缺少')
end
if(isempty(temp))
after_compressor(k,:) = [temp2,1];
else
after_compressor(k,:) = [temp,2];%%%???;
end
end
%% after compressor
end