0001 function outputpfsoln(baseMVA, bus, gen, branch, converged, et, type_solver, iterNum)
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 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0037 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0038 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, ...
0039 GEN_STATUS, PMAX, PMIN, MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN] = idx_gen;
0040 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, ...
0041 RATE_C, TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST] = idx_brch;
0042
0043 fd = 1;
0044
0045
0046 nb = size(bus, 1);
0047 nl = size(branch, 1);
0048 ng = size(gen, 1);
0049
0050
0051 ong = find( gen(:, GEN_STATUS) > 0);
0052 nzld = find(bus(:, PD) | bus(:, QD));
0053
0054
0055 loss = branch(:, PF) + j*branch(:, QF) + branch(:, PT) + j*branch(:, QT);
0056
0057
0058 fprintf(fd, '\n\n');
0059 if type_solver == 1
0060 fprintf(fd, 'Newton''s method is chosen to solve Power Flow.\n');
0061 elseif type_solver == 2
0062 fprintf(fd, 'Decoupled method is chosen to solve Power Flow.\n');
0063 else
0064 fprintf('Error: unknow ''type_solver''.\n');
0065 pause
0066 end
0067
0068 if converged
0069 fprintf(fd, '\nConverged in %.2f seconds\n', et);
0070 else
0071 fprintf(fd, '\nDid not converge (%.2f seconds)\n', et);
0072 end
0073 fprintf(fd, '\n[iteration number]: %d\n', iterNum);
0074
0075
0076 fprintf(fd, '\n================================================================================');
0077 fprintf(fd, '\n| Generator Data |');
0078 fprintf(fd, '\n================================================================================');
0079 fprintf(fd, '\n Gen Bus Status Pg Qg ');
0080 fprintf(fd, '\n # # (MW) (MVAr) ');
0081 fprintf(fd, '\n---- ----- ------ -------- --------');
0082 for k = 1:length(ong)
0083 i = ong(k);
0084 fprintf(fd, '\n%3d %6d %2d ', i, gen(i, GEN_BUS), gen(i, GEN_STATUS));
0085 if gen(i, GEN_STATUS) > 0 & (gen(i, PG) | gen(i, QG))
0086 fprintf(fd, '%10.2f%10.2f', gen(i, PG), gen(i, QG));
0087 else
0088 fprintf(fd, ' - - ');
0089 end
0090 end
0091 fprintf(fd, '\n -------- --------');
0092 fprintf(fd, '\n Total: %9.2f%10.2f', sum(gen(ong, PG)), sum(gen(ong, QG)));
0093 fprintf(fd, '\n');
0094
0095
0096 fprintf(fd, '\n================================================================================');
0097 fprintf(fd, '\n| Bus Data |');
0098 fprintf(fd, '\n================================================================================');
0099 fprintf(fd, '\n Bus Voltage Generation Load ');
0100 fprintf(fd, '\n # Mag(pu) Ang(deg) P (MW) Q (MVAr) P (MW) Q (MVAr)');
0101 fprintf(fd, '\n----- ------- -------- -------- -------- -------- --------');
0102 for i = 1:nb
0103 fprintf(fd, '\n%5d%7.3f%9.3f', bus(i, [BUS_I, VM, VA]));
0104 g = find(gen(:, GEN_STATUS) > 0 & gen(:, GEN_BUS) == bus(i, BUS_I));
0105 if ~isempty(g)
0106 fprintf(fd, '%10.2f%10.2f', sum(gen(g, PG)), sum(gen(g, QG)));
0107 else
0108 fprintf(fd, ' - - ');
0109 end
0110 if bus(i, PD) | bus(i, QD)
0111 fprintf(fd, '%10.2f%10.2f ', bus(i, [PD, QD]));
0112 else
0113 fprintf(fd, ' - - ');
0114 end
0115 end
0116 fprintf(fd, '\n -------- -------- -------- --------');
0117 fprintf(fd, '\n Total: %9.2f %9.2f %9.2f %9.2f', ...
0118 sum(gen(ong, PG)), sum(gen(ong, QG)), ...
0119 sum(bus(nzld, PD)), ...
0120 sum(bus(nzld, QD)));
0121 fprintf(fd, '\n');
0122
0123
0124 fprintf(fd, '\n================================================================================');
0125 fprintf(fd, '\n| Branch Data |');
0126 fprintf(fd, '\n================================================================================');
0127 fprintf(fd, '\nBrnch From To From Bus Injection To Bus Injection Loss (I^2 * Z) ');
0128 fprintf(fd, '\n # Bus Bus P (MW) Q (MVAr) P (MW) Q (MVAr) P (MW) Q (MVAr)');
0129 fprintf(fd, '\n----- ----- ----- -------- -------- -------- -------- -------- --------');
0130 fprintf(fd, '\n%4d%7d%7d%10.2f%10.2f%10.2f%10.2f%10.3f%10.2f', ...
0131 [ [1:nl]', branch(:, [F_BUS, T_BUS]), ...
0132 branch(:, [PF, QF]), branch(:, [PT, QT]), ...
0133 real(loss), imag(loss) ...
0134 ]');
0135 fprintf(fd, '\n -------- --------');
0136 fprintf(fd, '\n Total:%10.3f%10.2f', ...
0137 sum(real(loss)), sum(imag(loss)));
0138 fprintf(fd, '\n');