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 if solvedPF
0118 brcols = char( brcols, ...
0119 'PF', ...
0120 'QF', ...
0121 'PT', ...
0122 'QT' );
0123 if solvedOPF
0124 buscols = char( buscols, ...
0125 'LAM_P', ...
0126 'LAM_Q', ...
0127 'MU_VMAX', ...
0128 'MU_VMIN' );
0129 gencols = char( gencols, ...
0130 'MU_PMAX', ...
0131 'MU_PMIN', ...
0132 'MU_QMAX', ...
0133 'MU_QMIN' );
0134 brcols = char( brcols, ...
0135 'MU_SF', ...
0136 'MU_ST' );
0137 end
0138 end
0139
0140
0141 fprintf('---------------- -------------- -------------- -------------- -----\n');
0142 fprintf(' matrix / col case 1 case 2 difference row \n');
0143 fprintf('---------------- -------------- -------------- -------------- -----\n');
0144
0145
0146 [temp, i] = max(abs(bus1(:, 1:Nb) - bus2(:, 1:Nb)));
0147 [v, gmax] = max(temp);
0148 i = i(gmax);
0149 fprintf('bus');
0150 nodiff = ' : no differences found';
0151 for j = 1:size(buscols, 1)
0152 [v, i] = max(abs(bus1(:, j) - bus2(:, j)));
0153 if v
0154 nodiff = '';
0155 if j == gmax, s = ' *'; else s = ''; end
0156 fprintf('\n %-12s%16g%16g%16g%7d%s', buscols(j, :), bus1(i, j), bus2(i, j), v, i, s );
0157 end
0158 end
0159 fprintf('%s\n', nodiff);
0160
0161
0162 [temp, i] = max(abs(gen1(:, 1:Ng) - gen2(:, 1:Ng)));
0163 [v, gmax] = max(temp);
0164 i = i(gmax);
0165 fprintf('\ngen');
0166 nodiff = ' : no differences found';
0167 for j = 1:size(gencols, 1)
0168 [v, i] = max(abs(gen1(:, j) - gen2(:, j)));
0169 if v
0170 nodiff = '';
0171 if j == gmax, s = ' *'; else s = ''; end
0172 fprintf('\n %-12s%16g%16g%16g%7d%s', gencols(j, :), gen1(i, j), gen2(i, j), v, i, s );
0173 end
0174 end
0175 fprintf('%s\n', nodiff);
0176
0177
0178 [temp, i] = max(abs(branch1(:, 1:Nl) - branch2(:, 1:Nl)));
0179 [v, gmax] = max(temp);
0180 i = i(gmax);
0181 fprintf('\nbranch');
0182 nodiff = ' : no differences found';
0183 for j = 1:size(brcols, 1)
0184 [v, i] = max(abs(branch1(:, j) - branch2(:, j)));
0185 if v
0186 nodiff = '';
0187 if j == gmax, s = ' *'; else s = ''; end
0188 fprintf('\n %-12s%16g%16g%16g%7d%s', brcols(j, :), branch1(i, j), branch2(i, j), v, i, s );
0189 end
0190 end
0191 fprintf('%s\n', nodiff);