0001 function printpf(baseMVA, bus, gen, branch, f, success, et, fd, mpopt)
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
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0063 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0064 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0065 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0066 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0067 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0068 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0069 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0070
0071
0072 if isstruct(baseMVA)
0073 have_results_struct = 1;
0074 results = baseMVA;
0075 if nargin < 3 || isempty(gen)
0076 mpopt = mpoption;
0077 else
0078 mpopt = gen;
0079 end
0080 if mpopt.out.all == 0
0081 return;
0082 end
0083 if nargin < 2 || isempty(bus)
0084 fd = 1;
0085 else
0086 fd = bus;
0087 end
0088 [baseMVA, bus, gen, branch, success, et] = ...
0089 deal(results.baseMVA, results.bus, results.gen, results.branch, ...
0090 results.success, results.et);
0091 if isfield(results, 'f') && ~isempty(results.f)
0092 f = results.f;
0093 else
0094 f = [];
0095 end
0096 else
0097 have_results_struct = 0;
0098 if nargin < 9
0099 mpopt = mpoption;
0100 if nargin < 8
0101 fd = 1;
0102 end
0103 end
0104 if mpopt.out.all == 0
0105 return;
0106 end
0107 end
0108 isOPF = ~isempty(f);
0109
0110
0111 isDC = strcmp(upper(mpopt.model), 'DC');
0112
0113 SUPPRESS = mpopt.out.suppress_detail;
0114 if SUPPRESS == -1
0115 if size(bus, 1) > 500
0116 SUPPRESS = 1;
0117 else
0118 SUPPRESS = 0;
0119 end
0120 end
0121 OUT_ALL = mpopt.out.all;
0122 OUT_FORCE = mpopt.out.force;
0123 OUT_ANY = OUT_ALL == 1;
0124 OUT_SYS_SUM = OUT_ALL == 1 || (OUT_ALL == -1 && mpopt.out.sys_sum);
0125 OUT_AREA_SUM = OUT_ALL == 1 || (OUT_ALL == -1 && ~SUPPRESS && mpopt.out.area_sum);
0126 OUT_BUS = OUT_ALL == 1 || (OUT_ALL == -1 && ~SUPPRESS && mpopt.out.bus);
0127 OUT_BRANCH = OUT_ALL == 1 || (OUT_ALL == -1 && ~SUPPRESS && mpopt.out.branch);
0128 OUT_GEN = OUT_ALL == 1 || (OUT_ALL == -1 && ~SUPPRESS && mpopt.out.gen);
0129 OUT_ANY = OUT_ANY || (OUT_ALL == -1 && ...
0130 (OUT_SYS_SUM || OUT_AREA_SUM || OUT_BUS || ...
0131 OUT_BRANCH || OUT_GEN));
0132 if OUT_ALL == -1
0133 OUT_ALL_LIM = ~SUPPRESS * mpopt.out.lim.all;
0134 elseif OUT_ALL == 1
0135 OUT_ALL_LIM = 2;
0136 else
0137 OUT_ALL_LIM = 0;
0138 end
0139 OUT_ANY = OUT_ANY || OUT_ALL_LIM >= 1;
0140 if OUT_ALL_LIM == -1
0141 OUT_V_LIM = ~SUPPRESS * mpopt.out.lim.v;
0142 OUT_LINE_LIM = ~SUPPRESS * mpopt.out.lim.line;
0143 OUT_PG_LIM = ~SUPPRESS * mpopt.out.lim.pg;
0144 OUT_QG_LIM = ~SUPPRESS * mpopt.out.lim.qg;
0145 else
0146 OUT_V_LIM = OUT_ALL_LIM;
0147 OUT_LINE_LIM = OUT_ALL_LIM;
0148 OUT_PG_LIM = OUT_ALL_LIM;
0149 OUT_QG_LIM = OUT_ALL_LIM;
0150 end
0151 OUT_ANY = OUT_ANY || (OUT_ALL_LIM == -1 && (OUT_V_LIM || OUT_LINE_LIM || OUT_PG_LIM || OUT_QG_LIM));
0152
0153
0154 if OUT_ANY
0155 ptol = 1e-4;
0156 if isOPF && ~isDC && strcmp(upper(mpopt.opf.ac.solver), 'SDPOPF')
0157 isSDP = 1;
0158 ptol = 0.1;
0159 if have_results_struct && isfield(results, 'mineigratio') && ~isempty(results.mineigratio)
0160 mineigratio = results.mineigratio;
0161 else
0162 mineigratio = [];
0163 end
0164 if have_results_struct && isfield(results, 'zero_eval') && ~isempty(results.zero_eval)
0165 zero_eval = results.zero_eval;
0166 else
0167 zero_eval = [];
0168 end
0169 else
0170 isSDP = 0;
0171 end
0172
0173
0174 i2e = bus(:, BUS_I);
0175 e2i = sparse(max(i2e), 1);
0176 e2i(i2e) = (1:size(bus, 1))';
0177
0178
0179 nb = size(bus, 1);
0180 nl = size(branch, 1);
0181 ng = size(gen, 1);
0182
0183
0184 if isDC
0185 bus(:, [QD, BS]) = zeros(nb, 2);
0186 gen(:, [QG, QMAX, QMIN]) = zeros(ng, 3);
0187 branch(:, [BR_R, BR_B]) = zeros(nl, 2);
0188 end
0189
0190
0191 ties = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) ~= bus(e2i(branch(:, T_BUS)), BUS_AREA));
0192
0193 xfmr = find(branch(:, TAP));
0194 nzld = find((bus(:, PD) | bus(:, QD)) & bus(:, BUS_TYPE) ~= NONE);
0195 sorted_areas = sort(bus(:, BUS_AREA));
0196 s_areas = sorted_areas([1; find(diff(sorted_areas))+1]);
0197 nzsh = find((bus(:, GS) | bus(:, BS)) & bus(:, BUS_TYPE) ~= NONE);
0198 allg = find( ~isload(gen) );
0199 ong = find( gen(:, GEN_STATUS) > 0 & ~isload(gen) );
0200 onld = find( gen(:, GEN_STATUS) > 0 & isload(gen) );
0201 V = bus(:, VM) .* exp(sqrt(-1) * pi/180 * bus(:, VA));
0202 if isDC
0203 loss = zeros(nl, 1);
0204 fchg = loss;
0205 tchg = loss;
0206 else
0207 [loss, fchg, tchg] = get_losses(baseMVA, bus, branch);
0208 end
0209
0210
0211 if success
0212 if isSDP
0213 fprintf(fd, '\nSolution satisfies rank and consistency conditions, %.2f seconds.\nmineigratio = %0.5g, zero_eval = %0.5g', et, mineigratio, zero_eval);
0214 else
0215 fprintf(fd, '\nConverged in %.2f seconds', et);
0216 end
0217 else
0218 if isSDP
0219 fprintf(fd, '\n>>>>> Solution does NOT satisfy rank and/or consistency conditions (%.2f seconds). <<<<<\nmineigratio = %0.5g, zero_eval = %0.5g\n', et, mineigratio, zero_eval);
0220 else
0221 fprintf(fd, '\n>>>>> Did NOT converge (%.2f seconds) <<<<<\n', et);
0222 end
0223 end
0224
0225
0226 if isOPF && (success || OUT_FORCE)
0227 fprintf(fd, '\nObjective Function Value = %.2f $/hr', f);
0228 end
0229 end
0230 if OUT_SYS_SUM && (success || OUT_FORCE)
0231 fprintf(fd, '\n================================================================================');
0232 fprintf(fd, '\n| System Summary |');
0233 fprintf(fd, '\n================================================================================');
0234 fprintf(fd, '\n\nHow many? How much? P (MW) Q (MVAr)');
0235 fprintf(fd, '\n--------------------- ------------------- ------------- -----------------');
0236 fprintf(fd, '\nBuses %6d Total Gen Capacity %7.1f %7.1f to %.1f', nb, sum(gen(allg, PMAX)), sum(gen(allg, QMIN)), sum(gen(allg, QMAX)));
0237 fprintf(fd, '\nGenerators %5d On-line Capacity %7.1f %7.1f to %.1f', length(allg), sum(gen(ong, PMAX)), sum(gen(ong, QMIN)), sum(gen(ong, QMAX)));
0238 fprintf(fd, '\nCommitted Gens %5d Generation (actual) %7.1f %7.1f', length(ong), sum(gen(ong, PG)), sum(gen(ong, QG)));
0239 fprintf(fd, '\nLoads %5d Load %7.1f %7.1f', length(nzld)+length(onld), sum(bus(nzld, PD))-sum(gen(onld, PG)), sum(bus(nzld, QD))-sum(gen(onld, QG)));
0240 fprintf(fd, '\n Fixed %5d Fixed %7.1f %7.1f', length(nzld), sum(bus(nzld, PD)), sum(bus(nzld, QD)));
0241 fprintf(fd, '\n Dispatchable %5d Dispatchable %7.1f of %-7.1f%7.1f', length(onld), -sum(gen(onld, PG)), -sum(gen(onld, PMIN)), -sum(gen(onld, QG)));
0242 fprintf(fd, '\nShunts %5d Shunt (inj) %7.1f %7.1f', length(nzsh), ...
0243 -sum(bus(nzsh, VM) .^ 2 .* bus(nzsh, GS)), sum(bus(nzsh, VM) .^ 2 .* bus(nzsh, BS)) );
0244 fprintf(fd, '\nBranches %5d Losses (I^2 * Z) %8.2f %8.2f', nl, sum(real(loss)), sum(imag(loss)) );
0245 fprintf(fd, '\nTransformers %5d Branch Charging (inj) - %7.1f', length(xfmr), sum(fchg) + sum(tchg) );
0246 fprintf(fd, '\nInter-ties %5d Total Inter-tie Flow %7.1f %7.1f', length(ties), sum(abs(branch(ties, PF)-branch(ties, PT))) / 2, sum(abs(branch(ties, QF)-branch(ties, QT))) / 2);
0247 fprintf(fd, '\nAreas %5d', length(s_areas));
0248 fprintf(fd, '\n');
0249 fprintf(fd, '\n Minimum Maximum');
0250 fprintf(fd, '\n ------------------------- --------------------------------');
0251 [minv, mini] = min(bus(:, VM));
0252 [maxv, maxi] = max(bus(:, VM));
0253 fprintf(fd, '\nVoltage Magnitude %7.3f p.u. @ bus %-4d %7.3f p.u. @ bus %-4d', minv, bus(mini, BUS_I), maxv, bus(maxi, BUS_I));
0254 [minv, mini] = min(bus(:, VA));
0255 [maxv, maxi] = max(bus(:, VA));
0256 fprintf(fd, '\nVoltage Angle %8.2f deg @ bus %-4d %8.2f deg @ bus %-4d', minv, bus(mini, BUS_I), maxv, bus(maxi, BUS_I));
0257 if ~isDC
0258 [maxv, maxi] = max(real(loss));
0259 fprintf(fd, '\nP Losses (I^2*R) - %8.2f MW @ line %d-%d', maxv, branch(maxi, F_BUS), branch(maxi, T_BUS));
0260 [maxv, maxi] = max(imag(loss));
0261 fprintf(fd, '\nQ Losses (I^2*X) - %8.2f MVAr @ line %d-%d', maxv, branch(maxi, F_BUS), branch(maxi, T_BUS));
0262 end
0263 if isOPF
0264 [minv, mini] = min(bus(:, LAM_P));
0265 [maxv, maxi] = max(bus(:, LAM_P));
0266 fprintf(fd, '\nLambda P %8.2f $/MWh @ bus %-4d %8.2f $/MWh @ bus %-4d', minv, bus(mini, BUS_I), maxv, bus(maxi, BUS_I));
0267 [minv, mini] = min(bus(:, LAM_Q));
0268 [maxv, maxi] = max(bus(:, LAM_Q));
0269 fprintf(fd, '\nLambda Q %8.2f $/MWh @ bus %-4d %8.2f $/MWh @ bus %-4d', minv, bus(mini, BUS_I), maxv, bus(maxi, BUS_I));
0270 end
0271 fprintf(fd, '\n');
0272 end
0273
0274 if OUT_AREA_SUM && (success || OUT_FORCE)
0275 fprintf(fd, '\n================================================================================');
0276 fprintf(fd, '\n| Area Summary |');
0277 fprintf(fd, '\n================================================================================');
0278 fprintf(fd, '\nArea # of # of Gens # of Loads # of # of # of # of');
0279 fprintf(fd, '\n Num Buses Total Online Total Fixed Disp Shunt Brchs Xfmrs Ties');
0280 fprintf(fd, '\n---- ----- ----- ------ ----- ----- ----- ----- ----- ----- -----');
0281 for i=1:length(s_areas)
0282 a = s_areas(i);
0283 ib = find(bus(:, BUS_AREA) == a);
0284 ig = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & ~isload(gen));
0285 igon = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & gen(:, GEN_STATUS) > 0 & ~isload(gen));
0286 ildon = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & gen(:, GEN_STATUS) > 0 & isload(gen));
0287 inzld = find(bus(:, BUS_AREA) == a & (bus(:, PD) | bus(:, QD)) & bus(:, BUS_TYPE) ~= NONE);
0288 inzsh = find(bus(:, BUS_AREA) == a & (bus(:, GS) | bus(:, BS)) & bus(:, BUS_TYPE) ~= NONE);
0289 ibrch = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) == a & bus(e2i(branch(:, T_BUS)), BUS_AREA) == a);
0290 in_tie = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) == a & bus(e2i(branch(:, T_BUS)), BUS_AREA) ~= a);
0291 out_tie = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) ~= a & bus(e2i(branch(:, T_BUS)), BUS_AREA) == a);
0292 if isempty(xfmr)
0293 nxfmr = 0;
0294 else
0295 nxfmr = length(find(bus(e2i(branch(xfmr, F_BUS)), BUS_AREA) == a & bus(e2i(branch(xfmr, T_BUS)), BUS_AREA) == a));
0296 end
0297 fprintf(fd, '\n%3d %6d %5d %5d %5d %5d %5d %5d %5d %5d %5d', ...
0298 a, length(ib), length(ig), length(igon), ...
0299 length(inzld)+length(ildon), length(inzld), length(ildon), ...
0300 length(inzsh), length(ibrch), nxfmr, length(in_tie)+length(out_tie));
0301 end
0302 fprintf(fd, '\n---- ----- ----- ------ ----- ----- ----- ----- ----- ----- -----');
0303 fprintf(fd, '\nTot: %6d %5d %5d %5d %5d %5d %5d %5d %5d %5d', ...
0304 nb, length(allg), length(ong), length(nzld)+length(onld), ...
0305 length(nzld), length(onld), length(nzsh), nl, length(xfmr), length(ties));
0306 fprintf(fd, '\n');
0307 fprintf(fd, '\nArea Total Gen Capacity On-line Gen Capacity Generation');
0308 fprintf(fd, '\n Num MW MVAr MW MVAr MW MVAr');
0309 fprintf(fd, '\n---- ------ ------------------ ------ ------------------ ------ ------');
0310 for i=1:length(s_areas)
0311 a = s_areas(i);
0312 ig = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & ~isload(gen));
0313 igon = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & gen(:, GEN_STATUS) > 0 & ~isload(gen));
0314 fprintf(fd, '\n%3d %7.1f %7.1f to %-7.1f %7.1f %7.1f to %-7.1f %7.1f %7.1f', ...
0315 a, sum(gen(ig, PMAX)), sum(gen(ig, QMIN)), sum(gen(ig, QMAX)), ...
0316 sum(gen(igon, PMAX)), sum(gen(igon, QMIN)), sum(gen(igon, QMAX)), ...
0317 sum(gen(igon, PG)), sum(gen(igon, QG)) );
0318 end
0319 fprintf(fd, '\n---- ------ ------------------ ------ ------------------ ------ ------');
0320 fprintf(fd, '\nTot: %7.1f %7.1f to %-7.1f %7.1f %7.1f to %-7.1f %7.1f %7.1f', ...
0321 sum(gen(allg, PMAX)), sum(gen(allg, QMIN)), sum(gen(allg, QMAX)), ...
0322 sum(gen(ong, PMAX)), sum(gen(ong, QMIN)), sum(gen(ong, QMAX)), ...
0323 sum(gen(ong, PG)), sum(gen(ong, QG)) );
0324 fprintf(fd, '\n');
0325 fprintf(fd, '\nArea Disp Load Cap Disp Load Fixed Load Total Load');
0326 fprintf(fd, '\n Num MW MVAr MW MVAr MW MVAr MW MVAr');
0327 fprintf(fd, '\n---- ------ ------ ------ ------ ------ ------ ------ ------');
0328 Qlim = (gen(:, QMIN) == 0) .* gen(:, QMAX) + (gen(:, QMAX) == 0) .* gen(:, QMIN);
0329 for i=1:length(s_areas)
0330 a = s_areas(i);
0331 ildon = find(bus(e2i(gen(:, GEN_BUS)), BUS_AREA) == a & gen(:, GEN_STATUS) > 0 & isload(gen));
0332 inzld = find(bus(:, BUS_AREA) == a & (bus(:, PD) | bus(:, QD)));
0333 fprintf(fd, '\n%3d %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f', ...
0334 a, -sum(gen(ildon, PMIN)), ...
0335 -sum(Qlim(ildon)), ...
0336 -sum(gen(ildon, PG)), -sum(gen(ildon, QG)), ...
0337 sum(bus(inzld, PD)), sum(bus(inzld, QD)), ...
0338 -sum(gen(ildon, PG)) + sum(bus(inzld, PD)), ...
0339 -sum(gen(ildon, QG)) + sum(bus(inzld, QD)) );
0340 end
0341 fprintf(fd, '\n---- ------ ------ ------ ------ ------ ------ ------ ------');
0342 fprintf(fd, '\nTot: %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f %7.1f', ...
0343 -sum(gen(onld, PMIN)), ...
0344 -sum(Qlim(onld)), ...
0345 -sum(gen(onld, PG)), -sum(gen(onld, QG)), ...
0346 sum(bus(nzld, PD)), sum(bus(nzld, QD)), ...
0347 -sum(gen(onld, PG)) + sum(bus(nzld, PD)), ...
0348 -sum(gen(onld, QG)) + sum(bus(nzld, QD)) );
0349 fprintf(fd, '\n');
0350 fprintf(fd, '\nArea Shunt Inj Branch Series Losses Net Export');
0351 fprintf(fd, '\n Num MW MVAr Charging MW MVAr MW MVAr');
0352 fprintf(fd, '\n---- ------ ------ -------- ------ ------ ------ ------');
0353 for i=1:length(s_areas)
0354 a = s_areas(i);
0355 inzsh = find(bus(:, BUS_AREA) == a & (bus(:, GS) | bus(:, BS)));
0356 ibrch = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) == a & bus(e2i(branch(:, T_BUS)), BUS_AREA) == a & branch(:, BR_STATUS));
0357 in_tie = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) ~= a & bus(e2i(branch(:, T_BUS)), BUS_AREA) == a & branch(:, BR_STATUS));
0358 out_tie = find(bus(e2i(branch(:, F_BUS)), BUS_AREA) == a & bus(e2i(branch(:, T_BUS)), BUS_AREA) ~= a & branch(:, BR_STATUS));
0359 fprintf(fd, '\n%3d %7.1f %7.1f %7.1f %7.2f %7.2f %7.1f %7.1f', ...
0360 a, -sum(bus(inzsh, VM) .^ 2 .* bus(inzsh, GS)), ...
0361 sum(bus(inzsh, VM) .^ 2 .* bus(inzsh, BS)), ...
0362 sum(fchg(ibrch)) + sum(tchg(ibrch)) + sum(fchg(out_tie)) + sum(tchg(in_tie)), ...
0363 sum(real(loss(ibrch))) + sum(real(loss([in_tie; out_tie]))) / 2, ...
0364 sum(imag(loss(ibrch))) + sum(imag(loss([in_tie; out_tie]))) / 2, ...
0365 sum(branch(in_tie, PT))+sum(branch(out_tie, PF)) - sum(real(loss([in_tie; out_tie]))) / 2, ...
0366 sum(branch(in_tie, QT))+sum(branch(out_tie, QF)) - sum(imag(loss([in_tie; out_tie]))) / 2 );
0367 end
0368 fprintf(fd, '\n---- ------ ------ -------- ------ ------ ------ ------');
0369 fprintf(fd, '\nTot: %7.1f %7.1f %7.1f %7.2f %7.2f - -', ...
0370 -sum(bus(nzsh, VM) .^ 2 .* bus(nzsh, GS)), ...
0371 sum(bus(nzsh, VM) .^ 2 .* bus(nzsh, BS)), ...
0372 sum(fchg) + sum(tchg), sum(real(loss)), sum(imag(loss)) );
0373 fprintf(fd, '\n');
0374 end
0375
0376
0377 if OUT_GEN && (success || OUT_FORCE)
0378 if isOPF
0379 genlamP = bus(e2i(gen(:, GEN_BUS)), LAM_P);
0380 genlamQ = bus(e2i(gen(:, GEN_BUS)), LAM_Q);
0381 end
0382 fprintf(fd, '\n================================================================================');
0383 fprintf(fd, '\n| Generator Data |');
0384 fprintf(fd, '\n================================================================================');
0385 fprintf(fd, '\n Gen Bus Status Pg Qg ');
0386 if isOPF, fprintf(fd, ' Lambda ($/MVA-hr)'); end
0387 fprintf(fd, '\n # # (MW) (MVAr) ');
0388 if isOPF, fprintf(fd, ' P Q '); end
0389 fprintf(fd, '\n---- ----- ------ -------- --------');
0390 if isOPF, fprintf(fd, ' -------- --------'); end
0391 for k = 1:length(ong)
0392 i = ong(k);
0393 fprintf(fd, '\n%3d %6d %2d ', i, gen(i, GEN_BUS), gen(i, GEN_STATUS));
0394 if gen(i, GEN_STATUS) > 0 && (gen(i, PG) || gen(i, QG))
0395 fprintf(fd, '%10.2f%10.2f', gen(i, PG), gen(i, QG));
0396 else
0397 fprintf(fd, ' - - ');
0398 end
0399 if isOPF, fprintf(fd, '%10.2f%10.2f', genlamP(i), genlamQ(i)); end
0400 end
0401 fprintf(fd, '\n -------- --------');
0402 fprintf(fd, '\n Total: %9.2f%10.2f', sum(gen(ong, PG)), sum(gen(ong, QG)));
0403 fprintf(fd, '\n');
0404 if ~isempty(onld)
0405 fprintf(fd, '\n================================================================================');
0406 fprintf(fd, '\n| Dispatchable Load Data |');
0407 fprintf(fd, '\n================================================================================');
0408 fprintf(fd, '\n Gen Bus Status Pd Qd ');
0409 if isOPF, fprintf(fd, ' Lambda ($/MVA-hr)'); end
0410 fprintf(fd, '\n # # (MW) (MVAr) ');
0411 if isOPF, fprintf(fd, ' P Q '); end
0412 fprintf(fd, '\n---- ----- ------ -------- --------');
0413 if isOPF, fprintf(fd, ' -------- --------'); end
0414 for k = 1:length(onld)
0415 i = onld(k);
0416 fprintf(fd, '\n%3d %6d %2d ', i, gen(i, GEN_BUS), gen(i, GEN_STATUS));
0417 if gen(i, GEN_STATUS) > 0 && (gen(i, PG) || gen(i, QG))
0418 fprintf(fd, '%10.2f%10.2f', -gen(i, PG), -gen(i, QG));
0419 else
0420 fprintf(fd, ' - - ');
0421 end
0422 if isOPF, fprintf(fd, '%10.2f%10.2f', genlamP(i), genlamQ(i)); end
0423 end
0424 fprintf(fd, '\n -------- --------');
0425 fprintf(fd, '\n Total: %9.2f%10.2f', -sum(gen(onld, PG)), -sum(gen(onld, QG)));
0426 fprintf(fd, '\n');
0427 end
0428 end
0429
0430
0431 if OUT_BUS && (success || OUT_FORCE)
0432 fprintf(fd, '\n================================================================================');
0433 fprintf(fd, '\n| Bus Data |');
0434 fprintf(fd, '\n================================================================================');
0435 fprintf(fd, '\n Bus Voltage Generation Load ');
0436 if isOPF, fprintf(fd, ' Lambda($/MVA-hr)'); end
0437 fprintf(fd, '\n # Mag(pu) Ang(deg) P (MW) Q (MVAr) P (MW) Q (MVAr)');
0438 if isOPF, fprintf(fd, ' P Q '); end
0439 fprintf(fd, '\n----- ------- -------- -------- -------- -------- --------');
0440 if isOPF, fprintf(fd, ' ------- -------'); end
0441 for i = 1:nb
0442 fprintf(fd, '\n%5d%7.3f%9.3f', bus(i, [BUS_I, VM, VA]));
0443 if bus(i, BUS_TYPE) == REF
0444 fprintf(fd, '*');
0445 elseif bus(i, BUS_TYPE) == NONE
0446 fprintf(fd, 'x');
0447 else
0448 fprintf(fd, ' ');
0449 end
0450 g = find(gen(:, GEN_STATUS) > 0 & gen(:, GEN_BUS) == bus(i, BUS_I) & ...
0451 ~isload(gen));
0452 ld = find(gen(:, GEN_STATUS) > 0 & gen(:, GEN_BUS) == bus(i, BUS_I) & ...
0453 isload(gen));
0454 if ~isempty(g)
0455 fprintf(fd, '%9.2f%10.2f', sum(gen(g, PG)), sum(gen(g, QG)));
0456 else
0457 fprintf(fd, ' - - ');
0458 end
0459 if bus(i, PD) || bus(i, QD) || ~isempty(ld)
0460 if ~isempty(ld)
0461 fprintf(fd, '%10.2f*%9.2f*', bus(i, PD) - sum(gen(ld, PG)), ...
0462 bus(i, QD) - sum(gen(ld, QG)));
0463 else
0464 fprintf(fd, '%10.2f%10.2f ', bus(i, [PD, QD]));
0465 end
0466 else
0467 fprintf(fd, ' - - ');
0468 end
0469 if isOPF
0470 fprintf(fd, '%9.3f', bus(i, LAM_P));
0471 if abs(bus(i, LAM_Q)) > ptol
0472 fprintf(fd, '%8.3f', bus(i, LAM_Q));
0473 else
0474 fprintf(fd, ' -');
0475 end
0476 end
0477 end
0478 fprintf(fd, '\n -------- -------- -------- --------');
0479 fprintf(fd, '\n Total: %9.2f %9.2f %9.2f %9.2f', ...
0480 sum(gen(ong, PG)), sum(gen(ong, QG)), ...
0481 sum(bus(nzld, PD)) - sum(gen(onld, PG)), ...
0482 sum(bus(nzld, QD)) - sum(gen(onld, QG)));
0483 fprintf(fd, '\n');
0484 end
0485
0486
0487 if OUT_BRANCH && (success || OUT_FORCE)
0488 fprintf(fd, '\n================================================================================');
0489 fprintf(fd, '\n| Branch Data |');
0490 fprintf(fd, '\n================================================================================');
0491 fprintf(fd, '\nBrnch From To From Bus Injection To Bus Injection Loss (I^2 * Z) ');
0492 fprintf(fd, '\n # Bus Bus P (MW) Q (MVAr) P (MW) Q (MVAr) P (MW) Q (MVAr)');
0493 fprintf(fd, '\n----- ----- ----- -------- -------- -------- -------- -------- --------');
0494 fprintf(fd, '\n%4d%7d%7d%10.2f%10.2f%10.2f%10.2f%10.3f%10.2f', ...
0495 [ (1:nl)', branch(:, [F_BUS, T_BUS]), ...
0496 branch(:, [PF, QF]), branch(:, [PT, QT]), ...
0497 real(loss), imag(loss) ...
0498 ]');
0499 fprintf(fd, '\n -------- --------');
0500 fprintf(fd, '\n Total:%10.3f%10.2f', ...
0501 sum(real(loss)), sum(imag(loss)));
0502 fprintf(fd, '\n');
0503 end
0504
0505
0506 if isOPF && (success || OUT_FORCE)
0507 ctol = mpopt.opf.violation;
0508
0509 if ~isDC && (OUT_V_LIM == 2 || (OUT_V_LIM == 1 && ...
0510 (any(bus(:, VM) < bus(:, VMIN) + ctol) || ...
0511 any(bus(:, VM) > bus(:, VMAX) - ctol) || ...
0512 any(bus(:, MU_VMIN) > ptol) || ...
0513 any(bus(:, MU_VMAX) > ptol))))
0514 fprintf(fd, '\n================================================================================');
0515 fprintf(fd, '\n| Voltage Constraints |');
0516 fprintf(fd, '\n================================================================================');
0517 fprintf(fd, '\nBus # Vmin mu Vmin |V| Vmax Vmax mu');
0518 fprintf(fd, '\n----- -------- ----- ----- ----- --------');
0519 for i = 1:nb
0520 if OUT_V_LIM == 2 || (OUT_V_LIM == 1 && ...
0521 (bus(i, VM) < bus(i, VMIN) + ctol || ...
0522 bus(i, VM) > bus(i, VMAX) - ctol || ...
0523 bus(i, MU_VMIN) > ptol || bus(i, MU_VMAX) > ptol))
0524 fprintf(fd, '\n%5d', bus(i, BUS_I));
0525 if bus(i, VM) < bus(i, VMIN) + ctol || bus(i, MU_VMIN) > ptol
0526 fprintf(fd, '%10.3f', bus(i, MU_VMIN));
0527 else
0528 fprintf(fd, ' - ');
0529 end
0530 fprintf(fd, '%8.3f%7.3f%7.3f', bus(i, [VMIN, VM, VMAX]));
0531 if bus(i, VM) > bus(i, VMAX) - ctol || bus(i, MU_VMAX) > ptol
0532 fprintf(fd, '%10.3f', bus(i, MU_VMAX));
0533 else
0534 fprintf(fd, ' - ');
0535 end
0536 end
0537 end
0538 fprintf(fd, '\n');
0539 end
0540
0541
0542 if OUT_PG_LIM == 2 || ...
0543 (OUT_PG_LIM == 1 && (any(gen(ong, PG) < gen(ong, PMIN) + ctol) || ...
0544 any(gen(ong, PG) > gen(ong, PMAX) - ctol) || ...
0545 any(gen(ong, MU_PMIN) > ptol) || ...
0546 any(gen(ong, MU_PMAX) > ptol))) || ...
0547 (~isDC && (OUT_QG_LIM == 2 || ...
0548 (OUT_QG_LIM == 1 && (any(gen(ong, QG) < gen(ong, QMIN) + ctol) || ...
0549 any(gen(ong, QG) > gen(ong, QMAX) - ctol) || ...
0550 any(gen(ong, MU_QMIN) > ptol) || ...
0551 any(gen(ong, MU_QMAX) > ptol)))))
0552 fprintf(fd, '\n================================================================================');
0553 fprintf(fd, '\n| Generation Constraints |');
0554 fprintf(fd, '\n================================================================================');
0555 end
0556 if OUT_PG_LIM == 2 || (OUT_PG_LIM == 1 && ...
0557 (any(gen(ong, PG) < gen(ong, PMIN) + ctol) || ...
0558 any(gen(ong, PG) > gen(ong, PMAX) - ctol) || ...
0559 any(gen(ong, MU_PMIN) > ptol) || ...
0560 any(gen(ong, MU_PMAX) > ptol)))
0561 fprintf(fd, '\n Gen Bus Active Power Limits');
0562 fprintf(fd, '\n # # Pmin mu Pmin Pg Pmax Pmax mu');
0563 fprintf(fd, '\n---- ----- ------- -------- -------- -------- -------');
0564 for k = 1:length(ong)
0565 i = ong(k);
0566 if OUT_PG_LIM == 2 || (OUT_PG_LIM == 1 && ...
0567 (gen(i, PG) < gen(i, PMIN) + ctol || ...
0568 gen(i, PG) > gen(i, PMAX) - ctol || ...
0569 gen(i, MU_PMIN) > ptol || gen(i, MU_PMAX) > ptol))
0570 fprintf(fd, '\n%4d%6d ', i, gen(i, GEN_BUS));
0571 if gen(i, PG) < gen(i, PMIN) + ctol || gen(i, MU_PMIN) > ptol
0572 fprintf(fd, '%8.3f', gen(i, MU_PMIN));
0573 else
0574 fprintf(fd, ' - ');
0575 end
0576 if gen(i, PG)
0577 fprintf(fd, '%10.2f%10.2f%10.2f', gen(i, [PMIN, PG, PMAX]));
0578 else
0579 fprintf(fd, '%10.2f - %10.2f', gen(i, [PMIN, PMAX]));
0580 end
0581 if gen(i, PG) > gen(i, PMAX) - ctol || gen(i, MU_PMAX) > ptol
0582 fprintf(fd, '%9.3f', gen(i, MU_PMAX));
0583 else
0584 fprintf(fd, ' - ');
0585 end
0586 end
0587 end
0588 fprintf(fd, '\n');
0589 end
0590
0591
0592 if ~isDC && (OUT_QG_LIM == 2 || (OUT_QG_LIM == 1 && ...
0593 (any(gen(ong, QG) < gen(ong, QMIN) + ctol) || ...
0594 any(gen(ong, QG) > gen(ong, QMAX) - ctol) || ...
0595 any(gen(ong, MU_QMIN) > ptol) || ...
0596 any(gen(ong, MU_QMAX) > ptol))))
0597 fprintf(fd, '\nGen Bus Reactive Power Limits');
0598 fprintf(fd, '\n # # Qmin mu Qmin Qg Qmax Qmax mu');
0599 fprintf(fd, '\n--- --- ------- -------- -------- -------- -------');
0600 for k = 1:length(ong)
0601 i = ong(k);
0602 if OUT_QG_LIM == 2 || (OUT_QG_LIM == 1 && ...
0603 (gen(i, QG) < gen(i, QMIN) + ctol || ...
0604 gen(i, QG) > gen(i, QMAX) - ctol || ...
0605 gen(i, MU_QMIN) > ptol || gen(i, MU_QMAX) > ptol))
0606 fprintf(fd, '\n%3d%5d', i, gen(i, GEN_BUS));
0607 if gen(i, QG) < gen(i, QMIN) + ctol || gen(i, MU_QMIN) > ptol
0608 fprintf(fd, '%8.3f', gen(i, MU_QMIN));
0609 else
0610 fprintf(fd, ' - ');
0611 end
0612 if gen(i, QG)
0613 fprintf(fd, '%10.2f%10.2f%10.2f', gen(i, [QMIN, QG, QMAX]));
0614 else
0615 fprintf(fd, '%10.2f - %10.2f', gen(i, [QMIN, QMAX]));
0616 end
0617 if gen(i, QG) > gen(i, QMAX) - ctol || gen(i, MU_QMAX) > ptol
0618 fprintf(fd, '%9.3f', gen(i, MU_QMAX));
0619 else
0620 fprintf(fd, ' - ');
0621 end
0622 end
0623 end
0624 fprintf(fd, '\n');
0625 end
0626
0627
0628 if ~isempty(onld) && (OUT_PG_LIM == 2 || OUT_QG_LIM == 2 || ...
0629 (OUT_PG_LIM == 1 && (any(gen(onld, PG) < gen(onld, PMIN) + ctol) || ...
0630 any(gen(onld, PG) > gen(onld, PMAX) - ctol) || ...
0631 any(gen(onld, MU_PMIN) > ptol) || ...
0632 any(gen(onld, MU_PMAX) > ptol))) || ...
0633 (OUT_QG_LIM == 1 && (any(gen(onld, QG) < gen(onld, QMIN) + ctol) || ...
0634 any(gen(onld, QG) > gen(onld, QMAX) - ctol) || ...
0635 any(gen(onld, MU_QMIN) > ptol) || ...
0636 any(gen(onld, MU_QMAX) > ptol))))
0637 fprintf(fd, '\n================================================================================');
0638 fprintf(fd, '\n| Dispatchable Load Constraints |');
0639 fprintf(fd, '\n================================================================================');
0640 end
0641 if ~isempty(onld) && (OUT_PG_LIM == 2 || (OUT_PG_LIM == 1 && ...
0642 (any(gen(onld, PG) < gen(onld, PMIN) + ctol) || ...
0643 any(gen(onld, PG) > gen(onld, PMAX) - ctol) || ...
0644 any(gen(onld, MU_PMIN) > ptol) || ...
0645 any(gen(onld, MU_PMAX) > ptol))))
0646 fprintf(fd, '\nGen Bus Active Power Limits');
0647 fprintf(fd, '\n # # Pmin mu Pmin Pg Pmax Pmax mu');
0648 fprintf(fd, '\n--- --- ------- -------- -------- -------- -------');
0649 for k = 1:length(onld)
0650 i = onld(k);
0651 if OUT_PG_LIM == 2 || (OUT_PG_LIM == 1 && ...
0652 (gen(i, PG) < gen(i, PMIN) + ctol || ...
0653 gen(i, PG) > gen(i, PMAX) - ctol || ...
0654 gen(i, MU_PMIN) > ptol || gen(i, MU_PMAX) > ptol))
0655 fprintf(fd, '\n%3d%5d', i, gen(i, GEN_BUS));
0656 if gen(i, PG) < gen(i, PMIN) + ctol || gen(i, MU_PMIN) > ptol
0657 fprintf(fd, '%8.3f', gen(i, MU_PMIN));
0658 else
0659 fprintf(fd, ' - ');
0660 end
0661 if gen(i, PG)
0662 fprintf(fd, '%10.2f%10.2f%10.2f', gen(i, [PMIN, PG, PMAX]));
0663 else
0664 fprintf(fd, '%10.2f - %10.2f', gen(i, [PMIN, PMAX]));
0665 end
0666 if gen(i, PG) > gen(i, PMAX) - ctol || gen(i, MU_PMAX) > ptol
0667 fprintf(fd, '%9.3f', gen(i, MU_PMAX));
0668 else
0669 fprintf(fd, ' - ');
0670 end
0671 end
0672 end
0673 fprintf(fd, '\n');
0674 end
0675
0676
0677 if ~isDC && ~isempty(onld) && (OUT_QG_LIM == 2 || (OUT_QG_LIM == 1 && ...
0678 (any(gen(onld, QG) < gen(onld, QMIN) + ctol) || ...
0679 any(gen(onld, QG) > gen(onld, QMAX) - ctol) || ...
0680 any(gen(onld, MU_QMIN) > ptol) || ...
0681 any(gen(onld, MU_QMAX) > ptol))))
0682 fprintf(fd, '\nGen Bus Reactive Power Limits');
0683 fprintf(fd, '\n # # Qmin mu Qmin Qg Qmax Qmax mu');
0684 fprintf(fd, '\n--- --- ------- -------- -------- -------- -------');
0685 for k = 1:length(onld)
0686 i = onld(k);
0687 if OUT_QG_LIM == 2 || (OUT_QG_LIM == 1 && ...
0688 (gen(i, QG) < gen(i, QMIN) + ctol || ...
0689 gen(i, QG) > gen(i, QMAX) - ctol || ...
0690 gen(i, MU_QMIN) > ptol || gen(i, MU_QMAX) > ptol))
0691 fprintf(fd, '\n%3d%5d', i, gen(i, GEN_BUS));
0692 if gen(i, QG) < gen(i, QMIN) + ctol || gen(i, MU_QMIN) > ptol
0693 fprintf(fd, '%8.3f', gen(i, MU_QMIN));
0694 else
0695 fprintf(fd, ' - ');
0696 end
0697 if gen(i, QG)
0698 fprintf(fd, '%10.2f%10.2f%10.2f', gen(i, [QMIN, QG, QMAX]));
0699 else
0700 fprintf(fd, '%10.2f - %10.2f', gen(i, [QMIN, QMAX]));
0701 end
0702 if gen(i, QG) > gen(i, QMAX) - ctol || gen(i, MU_QMAX) > ptol
0703 fprintf(fd, '%9.3f', gen(i, MU_QMAX));
0704 else
0705 fprintf(fd, ' - ');
0706 end
0707 end
0708 end
0709 fprintf(fd, '\n');
0710 end
0711
0712
0713 if upper(mpopt.opf.flow_lim(1)) == 'P' || isDC
0714 Ff = branch(:, PF);
0715 Ft = branch(:, PT);
0716 str = '\n # Bus Pf mu Pf |Pmax| Pt Pt mu Bus';
0717 elseif upper(mpopt.opf.flow_lim(1)) == 'I'
0718 Ff = abs( (branch(:, PF) + 1j * branch(:, QF)) ./ V(e2i(branch(:, F_BUS))) );
0719 Ft = abs( (branch(:, PT) + 1j * branch(:, QT)) ./ V(e2i(branch(:, T_BUS))) );
0720 str = '\n # Bus |If| mu |If| |Imax| |It| |It| mu Bus';
0721 else
0722 Ff = abs(branch(:, PF) + 1j * branch(:, QF));
0723 Ft = abs(branch(:, PT) + 1j * branch(:, QT));
0724 str = '\n # Bus |Sf| mu |Sf| |Smax| |St| |St| mu Bus';
0725 end
0726 if any(branch(:, RATE_A) ~= 0) && (OUT_LINE_LIM == 2 || (OUT_LINE_LIM == 1 && ...
0727 (any(abs(Ff) > branch(:, RATE_A) - ctol) || ...
0728 any(abs(Ft) > branch(:, RATE_A) - ctol) || ...
0729 any(branch(:, MU_SF) > ptol) || ...
0730 any(branch(:, MU_ST) > ptol))))
0731 fprintf(fd, '\n================================================================================');
0732 fprintf(fd, '\n| Branch Flow Constraints |');
0733 fprintf(fd, '\n================================================================================');
0734 fprintf(fd, '\nBrnch From "From" End Limit "To" End To');
0735 fprintf(fd, str);
0736 fprintf(fd, '\n----- ----- ------- -------- -------- -------- ------- -----');
0737 for i = 1:nl
0738 if branch(i, RATE_A) ~= 0 && (OUT_LINE_LIM == 2 || (OUT_LINE_LIM == 1 && ...
0739 (abs(Ff(i)) > branch(i, RATE_A) - ctol || ...
0740 abs(Ft(i)) > branch(i, RATE_A) - ctol || ...
0741 branch(i, MU_SF) > ptol || branch(i, MU_ST) > ptol)))
0742 fprintf(fd, '\n%4d%7d', i, branch(i, F_BUS));
0743 if Ff(i) > branch(i, RATE_A) - ctol || branch(i, MU_SF) > ptol
0744 fprintf(fd, '%10.3f', branch(i, MU_SF));
0745 else
0746 fprintf(fd, ' - ');
0747 end
0748 fprintf(fd, '%9.2f%10.2f%10.2f', ...
0749 [Ff(i), branch(i, RATE_A), Ft(i)]);
0750 if Ft(i) > branch(i, RATE_A) - ctol || branch(i, MU_ST) > ptol
0751 fprintf(fd, '%10.3f', branch(i, MU_ST));
0752 else
0753 fprintf(fd, ' - ');
0754 end
0755 fprintf(fd, '%6d', branch(i, T_BUS));
0756 end
0757 end
0758 fprintf(fd, '\n');
0759 end
0760 end
0761
0762
0763 if have_results_struct && isfield(results, 'userfcn') && (success || OUT_FORCE)
0764 if ~isOPF
0765 mpopt = mpoption(mpopt, 'out.lim.all', 0);
0766 end
0767 run_userfcn(results.userfcn, 'printpf', results, fd, mpopt);
0768 end
0769 if OUT_ANY && ~success
0770 if OUT_FORCE
0771 if isSDP
0772 fprintf(fd, '\n>>>>> Solution does NOT satisfy rank and/or consistency conditions (%.2f seconds). <<<<<\nmineigratio = %0.5g, zero_eval = %0.5g\n', et, mineigratio, zero_eval);
0773 else
0774 fprintf(fd, '\n>>>>> Did NOT converge (%.2f seconds) <<<<<\n', et);
0775 end
0776 end
0777 fprintf('\n');
0778 end