0001 function compare_case(mpc1, mpc2)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0018 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0019 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0020 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0021 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0022 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0023 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0024 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0025
0026
0027 [baseMVA1, bus1, gen1, branch1] = loadcase(mpc1);
0028 [baseMVA2, bus2, gen2, branch2] = loadcase(mpc2);
0029
0030
0031 solvedPF = 0;
0032 solvedOPF = 0;
0033 Nb = VMIN;
0034 Ng = APF;
0035 Nl = ANGMAX;
0036
0037
0038 if size(branch1, 2) >= QT && size(branch2, 2) >= QT
0039 solvedPF = 1;
0040 Nl = QT;
0041
0042 if size(branch1, 2) >= MU_ST && size(branch2, 2) >= MU_ST
0043 solvedOPF = 1;
0044 Nb = MU_VMIN;
0045 Ng = MU_QMIN;
0046 Nl = MU_ST;
0047 end
0048 end
0049
0050
0051 buscols = char( 'BUS_I', ...
0052 'BUS_TYPE', ...
0053 'PD', ...
0054 'QD', ...
0055 'GS', ...
0056 'BS', ...
0057 'BUS_AREA', ...
0058 'VM', ...
0059 'VA', ...
0060 'BASE_KV', ...
0061 'ZONE', ...
0062 'VMAX', ...
0063 'VMIN' );
0064 gencols = char( 'GEN_BUS', ...
0065 'PG', ...
0066 'QG', ...
0067 'QMAX', ...
0068 'QMIN', ...
0069 'VG', ...
0070 'MBASE', ...
0071 'GEN_STATUS', ...
0072 'PMAX', ...
0073 'PMIN', ...
0074 'PC1', ...
0075 'PC2', ...
0076 'QC1MIN', ...
0077 'QC1MAX', ...
0078 'QC2MIN', ...
0079 'QC2MAX', ...
0080 'RAMP_AGC', ...
0081 'RAMP_10', ...
0082 'RAMP_30', ...
0083 'RAMP_Q', ...
0084 'APF' );
0085 brcols = char( 'F_BUS', ...
0086 'T_BUS', ...
0087 'BR_R', ...
0088 'BR_X', ...
0089 'BR_B', ...
0090 'RATE_A', ...
0091 'RATE_B', ...
0092 'RATE_C', ...
0093 'TAP', ...
0094 'SHIFT', ...
0095 'BR_STATUS', ...
0096 'ANGMIN', ...
0097 'ANGMAX');
0098 if solvedPF
0099 brcols = char( brcols, ...
0100 'PF', ...
0101 'QF', ...
0102 'PT', ...
0103 'QT' );
0104 if solvedOPF
0105 buscols = char( buscols, ...
0106 'LAM_P', ...
0107 'LAM_Q', ...
0108 'MU_VMAX', ...
0109 'MU_VMIN' );
0110 gencols = char( gencols, ...
0111 'MU_PMAX', ...
0112 'MU_PMIN', ...
0113 'MU_QMAX', ...
0114 'MU_QMIN' );
0115 brcols = char( brcols, ...
0116 'MU_SF', ...
0117 'MU_ST' );
0118 end
0119 end
0120
0121
0122 fprintf('---------------- -------------- -------------- -------------- -----\n');
0123 fprintf(' matrix / col case 1 case 2 difference row \n');
0124 fprintf('---------------- -------------- -------------- -------------- -----\n');
0125
0126
0127 [temp, i] = max(abs(bus1(:, 1:Nb) - bus2(:, 1:Nb)));
0128 [v, gmax] = max(temp);
0129 i = i(gmax);
0130 fprintf('bus');
0131 nodiff = ' : no differences found';
0132 for j = 1:size(buscols, 1)
0133 [v, i] = max(abs(bus1(:, j) - bus2(:, j)));
0134 if v
0135 nodiff = '';
0136 if j == gmax, s = ' *'; else s = ''; end
0137 fprintf('\n %-12s%16g%16g%16g%7d%s', buscols(j, :), bus1(i, j), bus2(i, j), v, i, s );
0138 end
0139 end
0140 fprintf('%s\n', nodiff);
0141
0142
0143 [temp, i] = max(abs(gen1(:, 1:Ng) - gen2(:, 1:Ng)));
0144 [v, gmax] = max(temp);
0145 i = i(gmax);
0146 fprintf('\ngen');
0147 nodiff = ' : no differences found';
0148 for j = 1:size(gencols, 1)
0149 [v, i] = max(abs(gen1(:, j) - gen2(:, j)));
0150 if v
0151 nodiff = '';
0152 if j == gmax, s = ' *'; else s = ''; end
0153 fprintf('\n %-12s%16g%16g%16g%7d%s', gencols(j, :), gen1(i, j), gen2(i, j), v, i, s );
0154 end
0155 end
0156 fprintf('%s\n', nodiff);
0157
0158
0159 [temp, i] = max(abs(branch1(:, 1:Nl) - branch2(:, 1:Nl)));
0160 [v, gmax] = max(temp);
0161 i = i(gmax);
0162 fprintf('\nbranch');
0163 nodiff = ' : no differences found';
0164 for j = 1:size(brcols, 1)
0165 [v, i] = max(abs(branch1(:, j) - branch2(:, j)));
0166 if v
0167 nodiff = '';
0168 if j == gmax, s = ' *'; else s = ''; end
0169 fprintf('\n %-12s%16g%16g%16g%7d%s', brcols(j, :), branch1(i, j), branch2(i, j), v, i, s );
0170 end
0171 end
0172 fprintf('%s\n', nodiff);