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