0001 function t_most_30b_1_1_17(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if nargin < 1
0013 quiet = 0;
0014 end
0015
0016 n_tests = 34;
0017
0018 t_begin(n_tests, quiet);
0019
0020 casename = 't_case30_most';
0021 fudging = struct( ...
0022 'fudge', 0.05, ...
0023 'step', 0.01, ...
0024 'lim', 0.1);
0025
0026
0027
0028 algs.dc = {'DEFAULT'};
0029 algs.ac = {'DEFAULT'};
0030 mpopt = mpoption('verbose', 0, 'out.all', 0);
0031 mpopt = mpoption(mpopt, 'opf.violation', 5e-7, 'mips.comptol', 5e-8);
0032 mpopt = mpoption(mpopt, 'sopf.force_Pc_eq_P0', 0);
0033 if have_fcn('linprog')
0034 if have_fcn('linprog_ds')
0035 mpopt = mpoption(mpopt, 'linprog.Algorithm', 'dual-simplex');
0036 else
0037 mpopt = mpoption(mpopt, 'linprog.Algorithm', 'simplex');
0038 end
0039 end
0040 mpoptac = mpoption(mpopt, 'model', 'AC');
0041 mpoptdc = mpoption(mpopt, 'model', 'DC');
0042 mpopt = mpoption(mpopt, 'most.solver', algs.dc{1});
0043
0044
0045 s7 = warning('query', 'MATLAB:nearlySingularMatrix');
0046 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0047 warning('off', 'MATLAB:nearlySingularMatrix');
0048 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0049
0050
0051 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0052 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0053 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0054 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0055 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0056 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0057 [CT_LABEL, CT_PROB, CT_TABLE, CT_TBUS, CT_TGEN, CT_TBRCH, CT_TAREABUS, ...
0058 CT_TAREAGEN, CT_TAREABRCH, CT_ROW, CT_COL, CT_CHGTYPE, CT_REP, ...
0059 CT_REL, CT_ADD, CT_NEWVAL, CT_TLOAD, CT_TAREALOAD, CT_LOAD_ALL_PQ, ...
0060 CT_LOAD_FIX_PQ, CT_LOAD_DIS_PQ, CT_LOAD_ALL_P, CT_LOAD_FIX_P, ...
0061 CT_LOAD_DIS_P, CT_TGENCOST, CT_TAREAGENCOST, CT_MODCOST_F, ...
0062 CT_MODCOST_X] = idx_ct;
0063
0064
0065 xgd_table.colnames = {
0066 'PositiveActiveReservePrice', ...
0067 'PositiveActiveReserveQuantity', ...
0068 'NegativeActiveReservePrice', ...
0069 'NegativeActiveReserveQuantity', ...
0070 'PositiveActiveDeltaPrice', ...
0071 'NegativeActiveDeltaPrice', ...
0072 };
0073 xgd_table.data = [
0074 10.1 15 10.0 15 0.1 0.0;
0075 10.3 30 10.2 30 0.3 0.2;
0076 10.5 20 10.4 20 0.5 0.4;
0077 10.7 25 10.6 25 0.7 0.6;
0078 20.1 25 20.0 25 60.1 60.0;
0079 20.3 15 20.2 15 15.1 15.0;
0080 20.5 30 20.4 30 60.3 60.2;
0081 20.7 15 20.6 15 15.3 15.2;
0082 30.1 15 30.0 15 60.3 60.4;
0083 30.3 30 30.2 30 30.1 30.0;
0084 30.5 25 30.4 25 60.7 60.6;
0085 30.7 30 30.6 30 30.3 30.2;
0086 0.001 50 0.002 50 0 0;
0087 0.001 50 0.002 50 0 0;
0088 0.001 50 0.002 50 0 0;
0089 0.001 50 0.002 50 0 0;
0090 0.001 50 0.002 50 0 0;
0091 0.001 50 0.002 50 0 0;
0092 0.001 50 0.002 50 0 0;
0093 0.001 50 0.002 50 0 0;
0094 0.001 50 0.002 50 0 0;
0095 0.001 50 0.002 50 0 0;
0096 0.001 50 0.002 50 0 0;
0097 0.001 50 0.002 50 0 0;
0098 0.001 50 0.002 50 0 0;
0099 0.001 50 0.002 50 0 0;
0100 0.001 50 0.002 50 0 0;
0101 0.001 50 0.002 50 0 0;
0102 0.001 50 0.002 50 0 0;
0103 0.001 50 0.002 50 0 0;
0104 0.001 50 0.002 50 0 0;
0105 0.001 50 0.002 50 0 0;
0106 ];
0107
0108
0109
0110 contab = [
0111 1 0.002 CT_TBRCH 1 BR_STATUS CT_REP 0;
0112 2 0.002 CT_TBRCH 2 BR_STATUS CT_REP 0;
0113 3 0.002 CT_TBRCH 3 BR_STATUS CT_REP 0;
0114 4 0.002 CT_TBRCH 5 BR_STATUS CT_REP 0;
0115 5 0.002 CT_TBRCH 6 BR_STATUS CT_REP 0;
0116 6 0.002 CT_TBRCH 36 BR_STATUS CT_REP 0;
0117 7 0.002 CT_TBRCH 15 BR_STATUS CT_REP 0;
0118 8 0.002 CT_TBRCH 12 BR_STATUS CT_REP 0;
0119 9 0.002 CT_TBRCH 14 BR_STATUS CT_REP 0;
0120 10 0.002 CT_TGEN 1 GEN_STATUS CT_REP 0;
0121 11 0.002 CT_TGEN 2 GEN_STATUS CT_REP 0;
0122 12 0.002 CT_TGEN 3 GEN_STATUS CT_REP 0;
0123 13 0.002 CT_TGEN 4 GEN_STATUS CT_REP 0;
0124 14 0.002 CT_TGEN 5 GEN_STATUS CT_REP 0;
0125 15 0.002 CT_TGEN 6 GEN_STATUS CT_REP 0;
0126 20 0.010 CT_TGEN 0 PMIN CT_REL 1.1;
0127 20 0.010 CT_TGEN 0 QMIN CT_REL 1.1;
0128 21 0.010 CT_TGEN 0 PMIN CT_REL 0.9;
0129 21 0.010 CT_TGEN 0 QMIN CT_REL 0.9;
0130 ];
0131 clist = unique(contab(:, CT_LABEL));
0132 nc = length(clist);
0133
0134
0135 mpc = loadcase(casename);
0136 gbus = mpc.gen(:, GEN_BUS);
0137
0138
0139 rdc = c3sopf_retry(algs.dc, mpc, xgd_table.data, contab, mpoptdc);
0140
0141
0142
0143 s.rdc = rdc;
0144
0145
0146
0147 ng = size(mpc.gen, 1);
0148 xgd = loadxgendata(xgd_table, mpc);
0149 md = loadmd(mpc, [], xgd, [], contab);
0150
0151
0152 r = most(md, mpopt);
0153
0154
0155 t = 'success1';
0156 t_ok(s.rdc.opf_results.success, t);
0157 t = 'success2';
0158 t_ok(r.QP.exitflag, t);
0159
0160 t = 'f';
0161 t_is(r.results.f, s.rdc.opf_results.f, 4, t);
0162
0163 t = 'Pg : base';
0164 t_is(r.flow(1,1,1).mpc.gen(:, PG), s.rdc.base.gen(:, PG), 5, t);
0165 t = 'Pg : cont ';
0166 for k = 1:nc
0167 t_is(r.flow(1,1,k+1).mpc.gen(:, PG), s.rdc.cont(k).gen(:, PG), 5, sprintf('%s %d', t, k));
0168 end
0169
0170
0171
0172
0173
0174
0175
0176
0177 t = 'energy prices';
0178 t_is(r.results.GenPrices, s.rdc.energy.prc.sum_bus_lam_p(gbus), 6, t);
0179
0180 t = 'Pc';
0181 t_is(r.results.Pc, s.rdc.energy.Pc, 4, t);
0182
0183 t = 'Gmin';
0184 t_is(r.results.Pc - r.results.Rpm, s.rdc.energy.Gmin, 4, t);
0185
0186 t = 'Gmax';
0187 t_is(r.results.Pc + r.results.Rpp, s.rdc.energy.Gmax, 4, t);
0188
0189 t = 'upward contingency reserve quantities';
0190 t_is(r.results.Rpp, s.rdc.reserve.qty.Rp_pos, 4, t);
0191
0192 t = 'downward contingency reserve quantities';
0193 t_is(r.results.Rpm, s.rdc.reserve.qty.Rp_neg, 4, t);
0194
0195 t = 'upward contingency reserve prices';
0196 t_is(r.results.RppPrices, s.rdc.reserve.prc.Rp_pos, 6, t);
0197
0198 t = 'downward contingency reserve prices';
0199 t_is(r.results.RpmPrices, s.rdc.reserve.prc.Rp_neg, 6, t);
0200
0201 t = 'contingency physical ramp price';
0202 [vv, ll] = get_idx(r.om);
0203 Ramp_P_max = zeros(ng, nc);
0204 sum_muPmax = zeros(ng, 1);
0205 sum_muPmin = zeros(ng, 1);
0206 for k = 1:nc+1
0207 ii = find(r.flow(1,1,k).mpc.gen(:, GEN_STATUS) > 0);
0208 if k > 1
0209 Ramp_P_max(ii,k-1) = (r.QP.lambda.mu_u(ll.i1.rampcont(1,1,k):ll.iN.rampcont(1,1,k)) - r.QP.lambda.mu_l(ll.i1.rampcont(1,1,k):ll.iN.rampcont(1,1,k))) / mpc.baseMVA;
0210 end
0211 sum_muPmax(ii) = sum_muPmax(ii) + r.flow(1,1,k).mpc.gen(ii, MU_PMAX);
0212 sum_muPmin(ii) = sum_muPmin(ii) + r.flow(1,1,k).mpc.gen(ii, MU_PMIN);
0213 end
0214 t_is(Ramp_P_max, s.rdc.energy.mu.Ramp_P_max, 2, t);
0215
0216 t = 'sum_muPmax';
0217 t_is(sum_muPmax, s.rdc.energy.sum_muPmax, 1, t);
0218
0219 t = 'sum_muPmin';
0220 t_is(sum_muPmin, s.rdc.energy.sum_muPmin, 0.9, t);
0221
0222 t = 'Rpmax_pos';
0223 Rpmax_pos = (r.QP.lambda.upper(vv.i1.Rpp(1):vv.iN.Rpp(1)) - r.QP.lambda.lower(vv.i1.Rpp(1):vv.iN.Rpp(1))) / mpc.baseMVA;
0224 t_is(Rpmax_pos, s.rdc.reserve.mu.Rpmax_pos, 6, t);
0225
0226 t = 'Rpmax_neg';
0227 Rpmax_neg = (r.QP.lambda.upper(vv.i1.Rpm(1):vv.iN.Rpm(1)) - r.QP.lambda.lower(vv.i1.Rpm(1):vv.iN.Rpm(1))) / mpc.baseMVA;
0228 t_is(Rpmax_neg, s.rdc.reserve.mu.Rpmax_neg, 6, t);
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251 warning(s7.state, 'MATLAB:nearlySingularMatrix');
0252 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0253
0254 t_end;