0001 function [groupss, isolated] = case_info(mpc, fd)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0030 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0031 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0032 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0033 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0034 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0035 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0036 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0037 c = idx_dcline;
0038
0039 if nargin < 2
0040 fd = 1;
0041 end
0042
0043 tic;
0044
0045
0046 mpc = loadcase(mpc);
0047
0048
0049 nb = size(mpc.bus, 1);
0050 nl = size(mpc.branch, 1);
0051 if isfield(mpc, 'dcline')
0052 ndc = size(mpc.dcline, 1);
0053 else
0054 ndc = 0;
0055 end
0056 ng = size(mpc.gen, 1);
0057
0058
0059 mb = max(abs([mpc.bus(:, BUS_I); mpc.gen(:, GEN_BUS); ...
0060 mpc.branch(:, F_BUS); mpc.branch(:, T_BUS)]));
0061 nbase = 10^(fix(log10(mb))+1);
0062
0063
0064
0065
0066 bus_i = mpc.bus(:, BUS_I);
0067 nonpos_bus = find(bus_i <= 0);
0068 bus_i(nonpos_bus) = -bus_i(nonpos_bus) + nbase;
0069
0070
0071
0072 e2i = sparse(bus_i, ones(nb, 1), 1:nb, nbase+mb, 1);
0073
0074
0075 unknown_gbus = unknown_buses(e2i, nbase, mpc.gen(:, GEN_BUS));
0076 unknown_fbus = unknown_buses(e2i, nbase, mpc.branch(:, F_BUS));
0077 unknown_tbus = unknown_buses(e2i, nbase, mpc.branch(:, T_BUS));
0078 if ndc
0079 unknown_fbusdc = unknown_buses(e2i, nbase, mpc.dcline(:, c.F_BUS));
0080 unknown_tbusdc = unknown_buses(e2i, nbase, mpc.dcline(:, c.T_BUS));
0081 end
0082
0083 if length(nonpos_bus)
0084 fprintf(fd, 'Bad bus numbers: %d\n', length(nonpos_bus));
0085 for k = 1:length(nonpos_bus)
0086 s = sprintf('bus(%d, BUS_I)', nonpos_bus(k));
0087 fprintf(fd, '%24s = %d\n', s, mpc.bus(nonpos_bus(k), BUS_I));
0088 end
0089 end
0090 if ~isempty(unknown_gbus)
0091 fprintf(fd, 'Unknown generator buses: %d\n', length(unknown_gbus));
0092 for k = 1:length(unknown_gbus)
0093 s = sprintf('gen(%d, GEN_BUS)', unknown_gbus(k));
0094 fprintf(fd, '%24s = %d\n', s, mpc.gen(unknown_gbus(k), GEN_BUS));
0095 end
0096
0097
0098 mpc.gen(unknown_gbus, :) = [];
0099 ng = size(mpc.gen, 1);
0100 end
0101 if ~isempty(unknown_fbus)
0102 fprintf(fd, 'Unknown branch "from" buses: %d\n', length(unknown_fbus));
0103 for k = 1:length(unknown_fbus)
0104 s = sprintf('branch(%d, F_BUS)', unknown_fbus(k));
0105 fprintf(fd, '%24s = %d\n', s, mpc.branch(unknown_fbus(k), F_BUS));
0106 end
0107 end
0108 if ~isempty(unknown_tbus)
0109 fprintf(fd, 'Unknown branch "to" buses: %d\n', length(unknown_tbus));
0110 for k = 1:length(unknown_tbus)
0111 s = sprintf('branch(%d, T_BUS)', unknown_tbus(k));
0112 fprintf(fd, '%24s = %d\n', s, mpc.branch(unknown_tbus(k), T_BUS));
0113 end
0114 end
0115
0116 if ~isempty(unknown_fbus) || ~isempty(unknown_tbus)
0117 tmp = unique([unknown_fbus; unknown_tbus]);
0118 mpc.branch(tmp, :) = [];
0119 nl = size(mpc.branch, 1);
0120 end
0121 if ndc
0122 if ~isempty(unknown_fbusdc)
0123 fprintf(fd, 'Unknown DC line "from" buses: %d\n', length(unknown_fbusdc));
0124 for k = 1:length(unknown_fbusdc)
0125 s = sprintf('dcline(%d, c.F_BUS)', unknown_fbusdc(k));
0126 fprintf(fd, '%24s = %d\n', s, mpc.dcline(unknown_fbusdc(k), c.F_BUS));
0127 end
0128 end
0129 if ~isempty(unknown_tbusdc)
0130 fprintf(fd, 'Unknown DC line "to" buses: %d\n', length(unknown_tbusdc));
0131 for k = 1:length(unknown_tbusdc)
0132 s = sprintf('dcline(%d, c.T_BUS)', unknown_tbusdc(k));
0133 fprintf(fd, '%24s = %d\n', s, mpc.dcline(unknown_tbusdc(k), c.T_BUS));
0134 end
0135 end
0136
0137 if ~isempty(unknown_fbusdc) || ~isempty(unknown_tbusdc)
0138 tmp = unique([unknown_fbusdc; unknown_tbusdc]);
0139 mpc.dcline(tmp, :) = [];
0140 ndc = size(mpc.dcline, 1);
0141 end
0142 end
0143
0144 if length(nonpos_bus) == 0
0145
0146
0147 C_on = sparse(1:nl, e2i(mpc.branch(:, F_BUS)), -mpc.branch(:, BR_STATUS), nl, nb) + ...
0148 sparse(1:nl, e2i(mpc.branch(:, T_BUS)), mpc.branch(:, BR_STATUS), nl, nb);
0149 C = sparse(1:nl, e2i(mpc.branch(:, F_BUS)), -1, nl, nb) + ...
0150 sparse(1:nl, e2i(mpc.branch(:, T_BUS)), 1, nl, nb);
0151 if ndc
0152 Cdc_on = sparse(1:ndc, e2i(mpc.dcline(:, c.F_BUS)), -mpc.dcline(:, c.BR_STATUS), ndc, nb) + ...
0153 sparse(1:ndc, e2i(mpc.dcline(:, c.T_BUS)), mpc.dcline(:, c.BR_STATUS), ndc, nb);
0154 Cdc = sparse(1:ndc, e2i(mpc.dcline(:, c.F_BUS)), -1, ndc, nb) + ...
0155 sparse(1:ndc, e2i(mpc.dcline(:, c.T_BUS)), 1, ndc, nb);
0156 end
0157 Cg_on = sparse(1:ng, e2i(mpc.gen(:, GEN_BUS)), mpc.gen(:, GEN_STATUS), ng, nb);
0158 Cg = sparse(1:ng, e2i(mpc.gen(:, GEN_BUS)), 1, ng, nb);
0159
0160
0161 fprintf(fd, 'Checking connectivity ... ');
0162 [groups, isolated] = connected_components(C_on);
0163
0164 ngr = length(groups);
0165 nis = length(isolated);
0166 have_isolated = nis > 0;
0167 if ngr == 1
0168 if have_isolated
0169 if nis == 1, s = ''; else, s = 'es'; end
0170 fprintf(fd, 'single connected network, plus %d isolated bus%s\n', nis, s);
0171 else
0172 fprintf(fd, 'single fully connected network\n');
0173 end
0174 else
0175 if nis == 1, s = ''; else, s = 'es'; end
0176 fprintf(fd, '%d connected groups, %d isolated bus%s\n', ngr, nis, s);
0177 end
0178
0179
0180 bron = mpc.branch(:, BR_STATUS) > 0;
0181 broff = mpc.branch(:, BR_STATUS) <= 0;
0182 if ndc
0183 dcon = mpc.dcline(:, c.BR_STATUS) > 0;
0184 dcoff = mpc.dcline(:, c.BR_STATUS) <= 0;
0185 end
0186 gon = mpc.gen(:, GEN_STATUS) > 0;
0187 goff = mpc.gen(:, GEN_STATUS) <= 0;
0188
0189
0190 d0 = struct( ...
0191 'nb', 0, ...
0192 'nl', 0, ...
0193 'nl_on', 0, ...
0194 'nl_off', 0, ...
0195 'nlt', 0, ...
0196 ...
0197 'nlt_off', 0, ...
0198 'ndc', 0, ...
0199 'ndc_on', 0, ...
0200 'ndc_off', 0, ...
0201 'ndct', 0, ...
0202 'ndct_on', 0, ...
0203 'ndct_off', 0, ...
0204 'ndc_all', 0, ...
0205 'ng', 0, ...
0206 'ng_on', 0, ...
0207 'ng_off', 0, ...
0208 'nsh', 0, ...
0209 'nld', 0, ...
0210 'nld_on', 0, ...
0211 'nld_off', 0, ...
0212 'nfld', 0, ...
0213 'ndld', 0, ...
0214 'ndld_on', 0, ...
0215 'ndld_off', 0, ...
0216 'Pmax', 0, ...
0217 'Qmax', 0, ...
0218 'Pmax_on', 0, ...
0219 'Qmax_on', 0, ...
0220 'Pmax_off', 0, ...
0221 'Qmax_off', 0, ...
0222 'Pmin', 0, ...
0223 'Qmin', 0, ...
0224 'Pmin_on', 0, ...
0225 'Qmin_on', 0, ...
0226 'Pmin_off', 0, ...
0227 'Qmin_off', 0, ...
0228 'Pg', 0, ...
0229 'Qg', 0, ...
0230 'Ps', 0, ...
0231 'Qs', 0, ...
0232 'Ploss', 0, ...
0233 'Qloss', 0, ...
0234 'Pd', 0, ...
0235 'Qd', 0, ...
0236 'Pd_fixed', 0, ...
0237 'Qd_fixed', 0, ...
0238 'Pd_disp_cap', 0, ...
0239 'Qd_disp_cap', 0, ...
0240 'Pd_disp_cap_on', 0, ...
0241 'Qd_disp_cap_on', 0, ...
0242 'Pd_disp_cap_off', 0, ...
0243 'Qd_disp_cap_off', 0, ...
0244 'Pd_disp', 0, ...
0245 'Qd_disp', 0, ...
0246 'Pd_cap', 0, ...
0247 'Qd_cap', 0, ...
0248 'Pd_cap_on', 0, ...
0249 'Qd_cap_on', 0, ...
0250 'Pd_cap_off', 0, ...
0251 'Qd_cap_off', 0, ...
0252 'Pdc', 0, ...
0253 'Pmaxdc', 0, ...
0254 'Pmaxdc_on', 0, ...
0255 'Pmaxdc_off', 0, ...
0256 'Pmindc', 0, ...
0257 'Pmindc_on', 0, ...
0258 'Pmindc_off', 0 ...
0259 );
0260 d = d0;
0261 total = d0;
0262 allrefs = find(mpc.bus(:, BUS_TYPE) == REF);
0263 refs = {};
0264 nrefs = 0;
0265 ibr_tie_all = [];
0266 idc_tie_all = [];
0267 idc_tie_all_on = [];
0268 idc_tie_all_off = [];
0269
0270
0271 fields = fieldnames(d);
0272 for k = 1:ngr+have_isolated
0273
0274 for f = 1:length(fields)
0275 ff = fields{f};
0276 d(k).(ff) = d0.(ff);
0277 end
0278 if k > ngr
0279 b = isolated';
0280 ibr = [];
0281 idc = [];
0282 else
0283 b = groups{k};
0284
0285 ibr = find(sum(abs(C(:, b)), 2) & ~sum(C(:, b), 2));
0286 if ndc
0287 idc = find(sum(abs(Cdc(:, b)), 2) & ~sum(Cdc(:, b), 2));
0288 else
0289 idc = [];
0290 end
0291 end
0292
0293 ibr_tie = find(sum(C(:, b), 2));
0294 if ndc
0295 idc_tie = find(sum(Cdc(:, b), 2));
0296 else
0297 idc_tie = [];
0298 end
0299 refs{k} = b(find(mpc.bus(b, BUS_TYPE) == REF));
0300 nrefs = nrefs + length(refs{k});
0301
0302 ibr_on = ibr(find(bron(ibr)));
0303 ibr_off = ibr(find(broff(ibr)));
0304
0305 ibr_tie_off = ibr_tie(find(broff(ibr_tie)));
0306 ibr_tie_all = unique([ ibr_tie_all; ibr_tie_off ]);
0307 if ndc
0308 idc_on = idc(find(dcon(idc)));
0309 idc_off = idc(find(dcoff(idc)));
0310 idc_tie_on = idc_tie(find(dcon(idc_tie)));
0311 idc_tie_off = idc_tie(find(dcoff(idc_tie)));
0312 idc_tie_all = unique([ idc_tie_all; idc_tie ]);
0313 idc_tie_all_on = unique([ idc_tie_all_on; idc_tie_on ]);
0314 idc_tie_all_off = unique([ idc_tie_all_off; idc_tie_off ]);
0315 end
0316 ig = find(sum(abs(Cg(:, b)), 2));
0317 if isempty(ig)
0318 ig_on = [];
0319 ig_off = [];
0320 idld_on = [];
0321 idld_off= [];
0322 else
0323 ig_on = ig(find(gon(ig) & ~isload(mpc.gen(ig, :))));
0324 ig_off = ig(find(goff(ig) & ~isload(mpc.gen(ig, :))));
0325 idld_on = ig(find(gon(ig) & isload(mpc.gen(ig, :))));
0326 idld_off= ig(find(goff(ig) & isload(mpc.gen(ig, :))));
0327 end
0328
0329 d(k).nb = length(b);
0330 d(k).nl = length(ibr);
0331 d(k).nl_on = length(ibr_on);
0332 d(k).nl_off = length(ibr_off);
0333 d(k).nlt = length(ibr_tie);
0334
0335 d(k).nlt_off = length(ibr_tie_off);
0336 if ndc
0337 d(k).ndc = length(idc);
0338 d(k).ndc_on = length(idc_on);
0339 d(k).ndc_off = length(idc_off);
0340 d(k).ndct = length(idc_tie);
0341 d(k).ndct_on = length(idc_tie_on);
0342 d(k).ndct_off = length(idc_tie_off);
0343 d(k).ndc_all = d(k).ndc + d(k).ndct;
0344 end
0345 d(k).ng = length(ig_on) + length(ig_off);
0346 d(k).ng_on = length(ig_on);
0347 d(k).ng_off = length(ig_off);
0348 d(k).nsh = length(find(mpc.bus(b, GS) ~= 0 | mpc.bus(b, BS) ~= 0));
0349 d(k).nfld = length(find(mpc.bus(b, PD) ~= 0 | mpc.bus(b, QD) ~= 0));
0350 d(k).ndld = length(idld_on) + length(idld_off);
0351 d(k).ndld_on = length(idld_on);
0352 d(k).ndld_off = length(idld_off);
0353 d(k).nld = d(k).nfld + d(k).ndld;
0354 d(k).nld_on = d(k).nfld + d(k).ndld_on;
0355 d(k).nld_off = d(k).ndld_off;
0356
0357 d(k).Pmax_on = sum(mpc.gen(ig_on, PMAX));
0358 d(k).Pmax_off = sum(mpc.gen(ig_off, PMAX));
0359 d(k).Pmax = d(k).Pmax_on + d(k).Pmax_off;
0360 d(k).Pmin_on = sum(mpc.gen(ig_on, PMIN));
0361 d(k).Pmin_off = sum(mpc.gen(ig_off, PMIN));
0362 d(k).Pmin = d(k).Pmin_on + d(k).Pmin_off;
0363 d(k).Pg = sum(mpc.gen(ig_on, PG));
0364
0365 d(k).Qmax_on = sum(mpc.gen(ig_on, QMAX));
0366 d(k).Qmax_off = sum(mpc.gen(ig_off, QMAX));
0367 d(k).Qmax = d(k).Qmax_on + d(k).Qmax_off;
0368 d(k).Qmin_on = sum(mpc.gen(ig_on, QMIN));
0369 d(k).Qmin_off = sum(mpc.gen(ig_off, QMIN));
0370 d(k).Qmin = d(k).Qmin_on + d(k).Qmin_off;
0371 d(k).Qg = sum(mpc.gen(ig_on, QG));
0372
0373 d(k).Ps = sum(-mpc.bus(b, VM) .^ 2 .* mpc.bus(b, GS));
0374 d(k).Qs = sum( mpc.bus(b, VM) .^ 2 .* mpc.bus(b, BS));
0375 if size(mpc.branch, 2) > PF
0376 d(k).Ploss = sum(mpc.branch(ibr_on, PF) + mpc.branch(ibr_on, PT));
0377 d(k).Qloss = sum(mpc.branch(ibr_on, QF) + mpc.branch(ibr_on, QT));
0378 end
0379
0380 d(k).Pd_fixed = sum(mpc.bus(b, PD));
0381 d(k).Qd_fixed = sum(mpc.bus(b, QD));
0382 d(k).Pd_disp_cap_on = sum(-mpc.gen(idld_on, PMIN));
0383 d(k).Qd_disp_cap_on = sum(-mpc.gen(idld_on, QMIN));
0384 d(k).Pd_disp_cap_off = sum(-mpc.gen(idld_off, PMIN));
0385 d(k).Qd_disp_cap_off = sum(-mpc.gen(idld_off, QMIN));
0386 d(k).Pd_disp_cap = d(k).Pd_disp_cap_on + d(k).Pd_disp_cap_off;
0387 d(k).Qd_disp_cap = d(k).Qd_disp_cap_on + d(k).Qd_disp_cap_off;
0388 d(k).Pd_disp = sum(-mpc.gen(idld_on, PG));
0389 d(k).Qd_disp = sum(-mpc.gen(idld_on, QG));
0390 d(k).Pd = d(k).Pd_fixed + d(k).Pd_disp;
0391 d(k).Qd = d(k).Qd_fixed + d(k).Qd_disp;
0392 d(k).Pd_cap = d(k).Pd_fixed + d(k).Pd_disp_cap;
0393 d(k).Qd_cap = d(k).Qd_fixed + d(k).Qd_disp_cap;
0394 d(k).Pd_cap_on = d(k).Pd_fixed + d(k).Pd_disp_cap_on;
0395 d(k).Qd_cap_on = d(k).Qd_fixed + d(k).Qd_disp_cap_on;
0396 d(k).Pd_cap_off = d(k).Pd_disp_cap_off;
0397 d(k).Qd_cap_off = d(k).Qd_disp_cap_off;
0398
0399 if ndc
0400 f = find(sum(Cdc(:, b), 2) < 0);
0401 t = find(sum(Cdc(:, b), 2) > 0);
0402 d(k).Pdc = sum(mpc.dcline(f, c.PF)) - sum(mpc.dcline(t, c.PT));
0403 d(k).Pmaxdc = sum(mpc.dcline(f, c.PMAX)) - sum(mpc.dcline(t, c.PMAX));
0404 d(k).Pmindc = sum(mpc.dcline(f, c.PMIN)) - sum(mpc.dcline(t, c.PMIN));
0405 f = find(sum(Cdc(:, b), 2) < 0 & dcon);
0406 t = find(sum(Cdc(:, b), 2) > 0 & dcon);
0407 d(k).Pmaxdc_on = sum(mpc.dcline(f, c.PMAX)) - sum(mpc.dcline(t, c.PMAX));
0408 d(k).Pmindc_on = sum(mpc.dcline(f, c.PMIN)) - sum(mpc.dcline(t, c.PMIN));
0409 f = find(sum(Cdc(:, b), 2) < 0 & dcoff);
0410 t = find(sum(Cdc(:, b), 2) > 0 & dcoff);
0411 d(k).Pmaxdc_off = sum(mpc.dcline(f, c.PMAX)) - sum(mpc.dcline(t, c.PMAX));
0412 d(k).Pmindc_off = sum(mpc.dcline(f, c.PMIN)) - sum(mpc.dcline(t, c.PMIN));
0413 end
0414
0415
0416 for f = 1:length(fields)
0417 ff = fields{f};
0418 total.(ff) = total.(ff) + d(k).(ff);
0419 end
0420
0421 total.nl = nl;
0422 total.nl_on = length(find(bron));
0423 total.nl_off = length(find(broff));
0424 total.ndc = ndc;
0425 if ndc
0426 total.ndc_on = length(find(dcon));
0427 total.ndc_off = length(find(dcoff));
0428 else
0429 total.ndc_on = 0;
0430 total.ndc_off = 0;
0431 end
0432 end
0433 total.nlt = length(ibr_tie_all);
0434
0435 total.nlt_off = length(ibr_tie_all);
0436 if ndc
0437 total.ndct = length(idc_tie_all);
0438 total.ndct_on = length(idc_tie_all_on);
0439 total.ndct_off = length(idc_tie_all_off);
0440 end
0441
0442
0443 et = toc;
0444 fprintf(fd, 'Elapsed time is %f seconds.\n', et);
0445 fprintf(fd, '================================================================================\n');
0446 pages = ceil((ngr + have_isolated + 1) / 5);
0447 for page = 1:pages
0448 if page == 1
0449 if ngr == 1 && ~have_isolated
0450 islands = [];
0451 else
0452 islands = 1:min(4, ngr+have_isolated);
0453 end
0454 else
0455 fprintf(fd, '--------------------------------------------------------------------------------\n');
0456 islands = (5*(page-1)):min(5*page-1, ngr+have_isolated);
0457 end
0458
0459
0460 fprintf(fd, '%-20s', '');
0461 if page == 1
0462 fprintf(fd, ' Full ');
0463 end
0464 for k = islands
0465 if k > ngr
0466 fprintf(fd, ' Isolated ');
0467 else
0468 fprintf(fd, ' Island ');
0469 end
0470 end
0471 fprintf(fd, '\n');
0472
0473
0474 fprintf(fd, '%-20s', '');
0475 if page == 1
0476 fprintf(fd, ' System ');
0477 end
0478 for k = islands
0479 if k > ngr
0480 fprintf(fd, ' Buses ');
0481 else
0482 fprintf(fd, ' %5d ', k);
0483 end
0484 end
0485 fprintf(fd, '\n');
0486
0487
0488 fprintf(fd, '%-20s', 'Number of:');
0489 if page == 1
0490 fprintf(fd, ' ---------- ');
0491 end
0492 for k = islands
0493 fprintf(fd, ' ---------- ');
0494 end
0495 fprintf(fd, '\n');
0496
0497 p = struct('page', page, 'islands', islands, 'total', total, 'd', d);
0498
0499 print_row(fd, p, ' %8d ', ' buses', 'nb');
0500 print_row(fd, p, ' %8d ', ' loads', 'nld');
0501 print_row(fd, p, ' %8d ', ' on', 'nld_on');
0502 print_row(fd, p, ' %8d ', ' off', 'nld_off');
0503 print_row(fd, p, ' %8d ', ' fixed', 'nfld');
0504 print_row(fd, p, ' %8d ', ' dispatchable', 'ndld');
0505 print_row(fd, p, ' %8d ', ' on', 'ndld_on');
0506 print_row(fd, p, ' %8d ', ' off', 'ndld_off');
0507 print_row(fd, p, ' %8d ', ' generators', 'ng');
0508 print_row(fd, p, ' %8d ', ' on', 'ng_on');
0509 print_row(fd, p, ' %8d ', ' off', 'ng_off');
0510 print_row(fd, p, ' %8d ', ' shunt elements', 'nsh');
0511 print_row(fd, p, ' %8d ', ' branches', 'nl');
0512 print_row(fd, p, ' %8d ', ' on', 'nl_on');
0513 print_row(fd, p, ' %8d ', ' off', 'nl_off');
0514
0515 print_row(fd, p, ' %8d ', ' ties (off)', 'nlt_off');
0516 if ndc
0517 print_row(fd, p, ' %8d ', ' DC lines', 'ndc_all');
0518 print_row(fd, p, ' %8d ', ' within', 'ndc');
0519 print_row(fd, p, ' %8d ', ' on', 'ndc_on');
0520 print_row(fd, p, ' %8d ', ' off', 'ndc_off');
0521 print_row(fd, p, ' %8d ', ' ties', 'ndct');
0522 print_row(fd, p, ' %8d ', ' on', 'ndct_on');
0523 print_row(fd, p, ' %8d ', ' off', 'ndct_off');
0524 end
0525
0526 fprintf(fd, '\n%-20s\n', 'Load');
0527 fprintf(fd, '%-20s\n', ' active (MW)');
0528 print_row(fd, p, '%11.1f ', ' dispatched', 'Pd');
0529 print_row(fd, p, '%11.1f ', ' fixed', 'Pd_fixed');
0530 print_row(fd, p, '%11.1f ', ' dispatchable', 'Pd_disp');
0531 print_row(fd, p, '%11.1f ', ' nominal', 'Pd_cap');
0532 print_row(fd, p, '%11.1f ', ' on', 'Pd_cap_on');
0533 print_row(fd, p, '%11.1f ', ' off', 'Pd_cap_off');
0534 print_row(fd, p, '%11.1f ', ' fixed', 'Pd_fixed');
0535 print_row(fd, p, '%11.1f ', ' dispatchable', 'Pd_disp_cap');
0536 print_row(fd, p, '%11.1f ', ' on', 'Pd_disp_cap_on');
0537 print_row(fd, p, '%11.1f ', ' off', 'Pd_disp_cap_off');
0538 fprintf(fd, '%-20s\n', ' reactive (MVAr)');
0539 print_row(fd, p, '%11.1f ', ' dispatched', 'Qd');
0540 print_row(fd, p, '%11.1f ', ' fixed', 'Qd_fixed');
0541 print_row(fd, p, '%11.1f ', ' dispatchable', 'Qd_disp');
0542 print_row(fd, p, '%11.1f ', ' nominal', 'Qd_cap');
0543 print_row(fd, p, '%11.1f ', ' on', 'Qd_cap_on');
0544 print_row(fd, p, '%11.1f ', ' off', 'Qd_cap_off');
0545 print_row(fd, p, '%11.1f ', ' fixed', 'Qd_fixed');
0546 print_row(fd, p, '%11.1f ', ' dispatchable', 'Qd_disp_cap');
0547 print_row(fd, p, '%11.1f ', ' on', 'Qd_disp_cap_on');
0548 print_row(fd, p, '%11.1f ', ' off', 'Qd_disp_cap_off');
0549
0550 fprintf(fd, '\n%-20s\n', 'Generation');
0551 fprintf(fd, '%-20s\n', ' active (MW)');
0552 print_row(fd, p, '%11.1f ', ' dispatched', 'Pg');
0553 print_row(fd, p, '%11.1f ', ' max capacity', 'Pmax');
0554 print_row(fd, p, '%11.1f ', ' on', 'Pmax_on');
0555 print_row(fd, p, '%11.1f ', ' off', 'Pmax_off');
0556 print_row(fd, p, '%11.1f ', ' min capacity', 'Pmin');
0557 print_row(fd, p, '%11.1f ', ' on', 'Pmin_on');
0558 print_row(fd, p, '%11.1f ', ' off', 'Pmin_off');
0559 fprintf(fd, '%-20s\n', ' reactive (MVAr)');
0560 print_row(fd, p, '%11.1f ', ' dispatched', 'Qg');
0561 print_row(fd, p, '%11.1f ', ' max capacity', 'Qmax');
0562 print_row(fd, p, '%11.1f ', ' on', 'Qmax_on');
0563 print_row(fd, p, '%11.1f ', ' off', 'Qmax_off');
0564 print_row(fd, p, '%11.1f ', ' min capacity', 'Qmin');
0565 print_row(fd, p, '%11.1f ', ' on', 'Qmin_on');
0566 print_row(fd, p, '%11.1f ', ' off', 'Qmin_off');
0567
0568 fprintf(fd, '\n%-20s\n', 'Shunt Injections');
0569 print_row(fd, p, '%11.1f ', ' active (MW)', 'Ps');
0570 print_row(fd, p, '%11.1f ', ' reactive (MVAr)', 'Qs');
0571
0572 fprintf(fd, '\n%-20s\n', 'Branch Losses');
0573 print_row(fd, p, '%11.1f ', ' active (MW)', 'Ploss');
0574 print_row(fd, p, '%11.1f ', ' reactive (MVAr)', 'Qloss');
0575
0576 fprintf(fd, '\n%-20s\n', 'DC line');
0577 fprintf(fd, '%-20s\n', ' export (MW)');
0578 print_row(fd, p, '%11.1f ', ' dispatch', 'Pdc');
0579 print_row(fd, p, '%11.1f ', ' max capacity', 'Pmaxdc');
0580 print_row(fd, p, '%11.1f ', ' on', 'Pmaxdc_on');
0581 print_row(fd, p, '%11.1f ', ' off', 'Pmaxdc_off');
0582 print_row(fd, p, '%11.1f ', ' min capacity', 'Pmindc');
0583 print_row(fd, p, '%11.1f ', ' on', 'Pmindc_on');
0584 print_row(fd, p, '%11.1f ', ' off', 'Pmindc_off');
0585
0586 fprintf(fd, '\n%-20s\n', 'Reference Buses');
0587
0588 fprintf(fd, '%-20s', ' num of ref buses');
0589 if page == 1
0590 fprintf(fd, ' %8d ', nrefs);
0591 end
0592 for k = islands
0593 fprintf(fd, ' %8d ', length(refs{k}));
0594 end
0595 fprintf(fd, '\n');
0596
0597 for j = 1:nrefs
0598 if j == 1
0599 fprintf(fd, '%-20s', ' ref bus numbers');
0600 else
0601 fprintf(fd, '%-20s', '');
0602 end
0603 if page == 1
0604 fprintf(fd, ' %8d ', mpc.bus(allrefs(j), BUS_I));
0605 end
0606 for k = islands
0607 if j <= length(refs{k})
0608 fprintf(fd, ' %8d ', mpc.bus(refs{k}(j), BUS_I));
0609 else
0610 fprintf(fd, ' %8s ', '');
0611 end
0612 end
0613 fprintf(fd, '\n');
0614 end
0615
0616 if page ~= pages
0617 fprintf(fd, '\n\n');
0618 end
0619 end
0620
0621 end
0622
0623
0624 if nargout > 0
0625 groupss = groups;
0626 end
0627
0628
0629 function print_row(fd, p, template, name, field)
0630 templatez = sprintf('%%%ds', length(sprintf(template, 0)));
0631 fprintf(fd, '%-20s', name);
0632 if p.page == 1
0633 if p.total.(field) == 0
0634 fprintf(fd, templatez, '- ');
0635 else
0636 fprintf(fd, template, p.total.(field));
0637 end
0638 end
0639 for k = p.islands
0640 if p.d(k).(field) == 0
0641 fprintf(fd, templatez, '- ');
0642 else
0643 fprintf(fd, template, p.d(k).(field));
0644 end
0645 end
0646 fprintf(fd, '\n');
0647
0648
0649 function unknown = unknown_buses(e2i, nbase, bus_list)
0650 nonpos = find(bus_list <= 0);
0651 bus_list(nonpos) = -bus_list(nonpos) + nbase;
0652 unknown = find(e2i(bus_list) == 0);