0001 function t_most_3b_1_1_2(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if nargin < 1
0013 quiet = 0;
0014 end
0015
0016 n_tests = 22;
0017
0018 t_begin(n_tests, quiet);
0019
0020 casename = 't_case3_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 mpoptac = mpoption(mpopt, 'model', 'AC');
0034 mpoptdc = mpoption(mpopt, 'model', 'DC');
0035 mpopt = mpoption(mpopt, 'most.solver', algs.dc{1});
0036
0037
0038 s7 = warning('query', 'MATLAB:nearlySingularMatrix');
0039 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0040 warning('off', 'MATLAB:nearlySingularMatrix');
0041 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0042
0043
0044 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0045 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0046 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0047 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0048 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0049 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0050 [CT_LABEL, CT_PROB, CT_TABLE, CT_TBUS, CT_TGEN, CT_TBRCH, CT_TAREABUS, ...
0051 CT_TAREAGEN, CT_TAREABRCH, CT_ROW, CT_COL, CT_CHGTYPE, CT_REP, ...
0052 CT_REL, CT_ADD, CT_NEWVAL, CT_TLOAD, CT_TAREALOAD, CT_LOAD_ALL_PQ, ...
0053 CT_LOAD_FIX_PQ, CT_LOAD_DIS_PQ, CT_LOAD_ALL_P, CT_LOAD_FIX_P, ...
0054 CT_LOAD_DIS_P, CT_TGENCOST, CT_TAREAGENCOST, CT_MODCOST_F, ...
0055 CT_MODCOST_X] = idx_ct;
0056
0057
0058 xgd_table.colnames = {
0059 'PositiveActiveReservePrice', ...
0060 'PositiveActiveReserveQuantity', ...
0061 'NegativeActiveReservePrice', ...
0062 'NegativeActiveReserveQuantity', ...
0063 'PositiveActiveDeltaPrice', ...
0064 'NegativeActiveDeltaPrice', ...
0065 };
0066 xgd_table.data = [
0067 1 400 2 400 0.01 0.01;
0068 3 300 4 300 0.01 0.01;
0069 0.001 450 0.002 450 0 0;
0070 ];
0071
0072
0073
0074 contab = [
0075 1 0.01 CT_TBRCH 1 BR_STATUS CT_REP 0;
0076 2 0.01 CT_TGEN 1 GEN_STATUS CT_REP 0;
0077
0078 ];
0079 clist = unique(contab(:, CT_LABEL));
0080 nc = length(clist);
0081
0082
0083 mpc = loadcase(casename);
0084 gbus = mpc.gen(:, GEN_BUS);
0085
0086
0087 rdc = c3sopf_retry(algs.dc, mpc, xgd_table.data, contab, mpoptdc);
0088
0089
0090
0091 s.rdc = rdc;
0092
0093
0094
0095 ng = size(mpc.gen, 1);
0096 xgd = loadxgendata(xgd_table, mpc);
0097 md = loadmd(mpc, [], xgd, [], contab);
0098
0099
0100 r = most(md, mpopt);
0101
0102
0103 t = 'success1';
0104 t_ok(s.rdc.opf_results.success, t);
0105 t = 'success2';
0106 t_ok(r.QP.exitflag, t);
0107
0108 t = 'f';
0109 t_is(r.results.f, s.rdc.opf_results.f, 4, t);
0110
0111 t = 'Pg : base';
0112 t_is(r.flow(1,1,1).mpc.gen(:, PG), s.rdc.base.gen(:, PG), 5, t);
0113 t = 'Pg : cont ';
0114 for k = 1:nc
0115 t_is(r.flow(1,1,k+1).mpc.gen(:, PG), s.rdc.cont(k).gen(:, PG), 5, sprintf('%s %d', t, k));
0116 end
0117
0118 t = 'gen : base';
0119 t_is(r.flow(1,1,1).mpc.gen(:,1:MU_PMIN), s.rdc.base.gen(:,1:MU_PMIN), 3, t);
0120 t = 'gen : cont ';
0121 for k = 1:nc
0122 t_is(r.flow(1,1,k+1).mpc.gen(:,1:MU_PMIN), s.rdc.cont(k).gen(:,1:MU_PMIN), 3, sprintf('%s %d', t, k));
0123 end
0124
0125 t = 'energy prices';
0126 t_is(r.results.GenPrices, s.rdc.energy.prc.sum_bus_lam_p(gbus), 5, t);
0127
0128 t = 'Pc';
0129 t_is(r.results.Pc, s.rdc.energy.Pc, 4, t);
0130
0131 t = 'Gmin';
0132 t_is(r.results.Pc - r.results.Rpm, s.rdc.energy.Gmin, 3.3, t);
0133
0134 t = 'Gmax';
0135 t_is(r.results.Pc + r.results.Rpp, s.rdc.energy.Gmax, 3.5, t);
0136
0137 t = 'upward contingency reserve quantities';
0138 t_is(r.results.Rpp, s.rdc.reserve.qty.Rp_pos, 3.5, t);
0139
0140 t = 'downward contingency reserve quantities';
0141 t_is(r.results.Rpm, s.rdc.reserve.qty.Rp_neg, 3.2, t);
0142
0143 t = 'upward contingency reserve prices';
0144 t_is(r.results.RppPrices, s.rdc.reserve.prc.Rp_pos, 6, t);
0145
0146 t = 'downward contingency reserve prices';
0147 t_is(r.results.RpmPrices, s.rdc.reserve.prc.Rp_neg, 6, t);
0148
0149 t = 'contingency physical ramp price';
0150 [vv, ll] = get_idx(r.om);
0151 Ramp_P_max = zeros(ng, nc);
0152 sum_muPmax = zeros(ng, 1);
0153 sum_muPmin = zeros(ng, 1);
0154 for k = 1:nc+1
0155 ii = find(r.flow(1,1,k).mpc.gen(:, GEN_STATUS) > 0);
0156 if k > 1
0157 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;
0158 end
0159 sum_muPmax(ii) = sum_muPmax(ii) + r.flow(1,1,k).mpc.gen(ii, MU_PMAX);
0160 sum_muPmin(ii) = sum_muPmin(ii) + r.flow(1,1,k).mpc.gen(ii, MU_PMIN);
0161 end
0162 t_is(Ramp_P_max, s.rdc.energy.mu.Ramp_P_max, 5, t);
0163
0164 t = 'sum_muPmax';
0165 t_is(sum_muPmax, s.rdc.energy.sum_muPmax, 2, t);
0166
0167 t = 'sum_muPmin';
0168 t_is(sum_muPmin, s.rdc.energy.sum_muPmin, 2, t);
0169
0170 t = 'Rpmax_pos';
0171 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;
0172 t_is(Rpmax_pos, s.rdc.reserve.mu.Rpmax_pos, 6, t);
0173
0174 t = 'Rpmax_neg';
0175 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;
0176 t_is(Rpmax_neg, s.rdc.reserve.mu.Rpmax_neg, 6, t);
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199 warning(s7.state, 'MATLAB:nearlySingularMatrix');
0200 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0201
0202 t_end;