-
Notifications
You must be signed in to change notification settings - Fork 3
/
eqmodel.asv
60 lines (51 loc) · 1.35 KB
/
eqmodel.asv
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function [Yred,Y_saffet,no_gen,no_pv,no_pq]=eqmodel(bus_type,...
bus_condc,bus_suscp,no_bus,...
tap_bus,z_bus,brch_r,brch_x,...
no_lines,C_Flag)
% EqModel assembles classical power system equilibrium equations
%Identify the number of all buses
no_gen=0;
no_pv=0;
no_pq=0;
no_ca=0;
for count=1:no_bus
if (bus_type(count)==3)
no_gen=no_gen+1;
end;
% if (bus_type(count)==2)
% no_gen=no_gen+1;
% end;
%if (bus_type(count)==2)
%no_pv=no_pv+1;
%end;
if (bus_type(count)==1)
no_pq=no_pq+1;
end;
if (bus_type(count)==0)
no_ca=no_ca+1;
end;
end;
% Calculate the FULL admittance matrix
Ybus=busadmat(bus_type,...
bus_condc,bus_suscp,no_bus,...
tap_bus,z_bus,brch_r,brch_x,...
no_lines);
Y_saffet=Ybus; % 07/31/00, Y_bus matrix (non_sparse)
% Calculate the REDUCED admittance matrix
Yred=redbusad(Ybus,no_ca);
% Identify all the zero elements in reduced admitt. matrix
[zi,zj]=find(Yred==0);
% Call mex C routine to build the symbolic model
X=[no_gen no_pv no_pq];
zn=size(zi);
% Save some memory
clear Ybus;
% clear bus_type bus_condc bus_suscp no_bus;
% clear tap_bus z_bus brch_r brch_x no_lines;
%[mb]=model_build(X,zi,zj,zn)
if C_Flag==1
[mb]=model_c(X,zi,zj,zn)
else
[mb]=model_m(X,zi,zj,zn)
end
clear mex