Home > matpower6.0 > most > t > t_most_30b_3_1_0.m

t_most_30b_3_1_0

PURPOSE ^

T_MOST_30B_3_1_0 Tests for MOST.

SYNOPSIS ^

function t_most_30b_3_1_0(quiet)

DESCRIPTION ^

T_MOST_30B_3_1_0  Tests for MOST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_most_30b_3_1_0(quiet)
0002 %T_MOST_30B_3_1_0  Tests for MOST.
0003 
0004 %   MOST
0005 %   Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MOST.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 n_tests = 39;
0017 
0018 t_begin(n_tests, quiet);
0019 
0020 casename = 't_case30_most';
0021 fudging = struct( ...       %% paramters for fudging reserve contract for sopf2
0022     'fudge',    0.05, ...   %% initial value (MW)
0023     'step',     0.01, ...   %% if necessary, increase by this amount and retry (MW)
0024     'lim',      0.1);       %% upper limit (MW), give up if no convergence
0025                             %% with fudge equal to this limit
0026 
0027 %% options
0028 mpopt = mpoption('verbose', 0, 'out.all', 0);
0029 mpopt = mpoption(mpopt, 'opf.violation', 5e-7, 'mips.comptol', 5e-8);
0030 if have_fcn('linprog')
0031     if have_fcn('linprog_ds')
0032         mpopt = mpoption(mpopt, 'linprog.Algorithm', 'dual-simplex');
0033     else
0034         mpopt = mpoption(mpopt, 'linprog.Algorithm', 'simplex');
0035     end
0036 end
0037 mpoptac = mpoption(mpopt, 'model', 'AC');
0038 mpoptdc = mpoption(mpopt, 'model', 'DC');
0039 mpopt = mpoption(mpopt, 'most.solver', 'DEFAULT');
0040 
0041 %% turn off warnings
0042 s7 = warning('query', 'MATLAB:nearlySingularMatrix');
0043 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0044 warning('off', 'MATLAB:nearlySingularMatrix');
0045 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0046 
0047 %% define named indices into data matrices
0048 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0049     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0050 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0051     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0052     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0053 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0054     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0055     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0056 [CT_LABEL, CT_PROB, CT_TABLE, CT_TBUS, CT_TGEN, CT_TBRCH, CT_TAREABUS, ...
0057     CT_TAREAGEN, CT_TAREABRCH, CT_ROW, CT_COL, CT_CHGTYPE, CT_REP, ...
0058     CT_REL, CT_ADD, CT_NEWVAL, CT_TLOAD, CT_TAREALOAD, CT_LOAD_ALL_PQ, ...
0059     CT_LOAD_FIX_PQ, CT_LOAD_DIS_PQ, CT_LOAD_ALL_P, CT_LOAD_FIX_P, ...
0060     CT_LOAD_DIS_P, CT_TGENCOST, CT_TAREAGENCOST, CT_MODCOST_F, ...
0061     CT_MODCOST_X] = idx_ct;
0062 
0063 %% reserve and delta offers
0064 xgd_table.colnames = {
0065     'PositiveActiveReservePrice', ...
0066             'PositiveActiveReserveQuantity', ...
0067                     'NegativeActiveReservePrice', ...
0068                             'NegativeActiveReserveQuantity', ...
0069                                     'PositiveActiveDeltaPrice', ...
0070                                             'NegativeActiveDeltaPrice', ...
0071 };
0072 xgd_table.data = [
0073     10.1    15      10.0    15      0.1     0.0;
0074     10.3    30      10.2    30      0.3     0.2;  
0075     10.5    20      10.4    20      0.5     0.4;  
0076     10.7    25      10.6    25      0.7     0.6;
0077     20.1    25      20.0    25      60.1    60.0; 
0078     20.3    15      20.2    15      15.1    15.0;
0079     20.5    30      20.4    30      60.3    60.2;
0080     20.7    15      20.6    15      15.3    15.2;
0081     30.1    15      30.0    15      60.3    60.4;
0082     30.3    30      30.2    30      30.1    30.0;
0083     30.5    25      30.4    25      60.7    60.6;
0084     30.7    30      30.6    30      30.3    30.2;
0085     0.001   50      0.002   50      0       0;
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 ];
0106 
0107 %% contingency table
0108 % label probty  type        row column      chgtype newvalue
0109 contab = [
0110 %     1   0.002   CT_TBRCH    1   BR_STATUS   CT_REP  0;      %% line 1-2
0111 %     2   0.002   CT_TBRCH    2   BR_STATUS   CT_REP  0;      %% line 1-3, all power from gen1 flows via gen2
0112 %     3   0.002   CT_TBRCH    3   BR_STATUS   CT_REP  0;      %% line 2-4, a path to loads @ buses 7 & 8
0113 %     4   0.002   CT_TBRCH    5   BR_STATUS   CT_REP  0;      %% line 2-5, a path to loads @ buses 7 & 8
0114 %     5   0.002   CT_TBRCH    6   BR_STATUS   CT_REP  0;      %% line 2-6, a path to loads @ buses 7 & 8
0115 %     6   0.002   CT_TBRCH    36  BR_STATUS   CT_REP  0;      %% line 28-27, tie line between areas 1 & 3
0116 %     7   0.002   CT_TBRCH    15  BR_STATUS   CT_REP  0;      %% line 4-12, tie line between areas 1 & 2
0117 %     8   0.002   CT_TBRCH    12  BR_STATUS   CT_REP  0;      %% line 6-10, tie line between areas 1 & 3
0118 %     9   0.002   CT_TBRCH    14  BR_STATUS   CT_REP  0;      %% line 9-10, tie line between areas 1 & 3
0119 %     10  0.002   CT_TGEN     1   GEN_STATUS  CT_REP  0;      %% gen 1 at bus 1
0120 %     11  0.002   CT_TGEN     2   GEN_STATUS  CT_REP  0;      %% gen 2 at bus 2
0121 %     12  0.002   CT_TGEN     3   GEN_STATUS  CT_REP  0;      %% gen 3 at bus 22
0122 %     13  0.002   CT_TGEN     4   GEN_STATUS  CT_REP  0;      %% gen 4 at bus 27
0123 %     14  0.002   CT_TGEN     5   GEN_STATUS  CT_REP  0;      %% gen 5 at bus 23
0124 %     15  0.002   CT_TGEN     6   GEN_STATUS  CT_REP  0;      %% gen 6 at bus 13
0125 %     20  0.010   CT_TGEN     0   PMIN        CT_REL  1.1;    %% 10% load increase
0126 %     20  0.010   CT_TGEN     0   QMIN        CT_REL  1.1;
0127 %     21  0.010   CT_TGEN     0   PMIN        CT_REL  0.9;    %% 10% load decrease
0128 %     21  0.010   CT_TGEN     0   QMIN        CT_REL  0.9;
0129 ];
0130 clist = [];
0131 nc = length(clist);
0132 
0133 %% load the case
0134 mpc = loadcase(casename);
0135 gbus = mpc.gen(:, GEN_BUS);
0136 
0137 %%-----  get OPF results  -----
0138 rdc = rundcopf(mpc, mpoptdc);
0139 % rac = runopf(mpc, mpoptac);
0140 % save t_most4_soln rdc rac -v6
0141 % s = load('t_most4_soln');
0142 s.rdc = rdc;
0143 % s.rac = rac;
0144 
0145 %%-----  set up data for DC run (most)  -----
0146 ng = size(mpc.gen, 1);      %% number of gens
0147 nt = 3;
0148 xgd = loadxgendata(xgd_table, mpc);
0149 md = loadmd(mpc, nt, xgd);
0150 
0151 %%-----  do DC run (most)  -----
0152 r = most(md, mpopt);
0153 
0154 %%-----  test the results  -----
0155 t = 'success1';
0156 t_ok(s.rdc.success, t);
0157 t = 'success2';
0158 t_ok(r.QP.exitflag, t);
0159 
0160 t = 'f';
0161 t_is(r.results.f/sum(r.StepProb), s.rdc.f, 4, t);
0162 
0163 for tt = 1:nt
0164 
0165 t = sprintf('(t=%d) Pg : base', tt);
0166 t_is(r.flow(tt,1,1).mpc.gen(:, PG), s.rdc.gen(:, PG), 5, t);
0167 
0168 t = sprintf('(t=%d) gen : base', tt);
0169 t_is(r.flow(tt,1,1).mpc.gen(:,1:MU_PMIN), s.rdc.gen(:,1:MU_PMIN), 3, t);
0170 
0171 t = sprintf('(t=%d) energy prices', tt);
0172 t_is(r.results.GenPrices(:,tt), s.rdc.bus(gbus, LAM_P), 6, t);
0173 
0174 t = sprintf('(t=%d) Pc', tt);
0175 t_is(r.results.Pc(:,tt), s.rdc.gen(:, PG), 4, t);
0176 
0177 t = sprintf('(t=%d) Gmin', tt);
0178 t_is(r.results.Pc(:,tt) - r.results.Rpm(:,tt), s.rdc.gen(:, PG), 4, t);
0179 
0180 t = sprintf('(t=%d) Gmax', tt);
0181 t_is(r.results.Pc(:,tt) + r.results.Rpp(:,tt), s.rdc.gen(:, PG), 4, t);
0182 
0183 t = sprintf('(t=%d) upward contingency reserve quantities', tt);
0184 t_is(r.results.Rpp(:,tt), zeros(ng, 1), 4, t);
0185 
0186 t = sprintf('(t=%d) downward contingency reserve quantities', tt);
0187 t_is(r.results.Rpm(:,tt), zeros(ng, 1), 4, t);
0188 
0189 t = sprintf('(t=%d) upward contingency reserve prices', tt);
0190 t_is(r.results.RpmPrices(:,tt), xgd.NegativeActiveReservePrice, 6, t);
0191 
0192 t = sprintf('(t=%d) downward contingency reserve prices', tt);
0193 t_is(r.results.RpmPrices(:,tt), xgd.NegativeActiveReservePrice, 6, t);
0194 
0195 t = sprintf('(t=%d) Rpmax_pos', tt);
0196 vv = get_idx(r.om);
0197 Rpmax_pos = (r.QP.lambda.upper(vv.i1.Rpp(tt):vv.iN.Rpp(tt)) - r.QP.lambda.lower(vv.i1.Rpp(tt):vv.iN.Rpp(tt))) / mpc.baseMVA;
0198 t_is(Rpmax_pos, zeros(ng, 1), 6, t);
0199 
0200 t = sprintf('(t=%d) Rpmax_neg', tt);
0201 Rpmax_neg = (r.QP.lambda.upper(vv.i1.Rpm(tt):vv.iN.Rpm(tt)) - r.QP.lambda.lower(vv.i1.Rpm(tt):vv.iN.Rpm(tt))) / mpc.baseMVA;
0202 t_is(Rpmax_neg, zeros(ng, 1), 6, t);
0203 
0204 end
0205 
0206 
0207 % g1 = s.rdc.base.gen(:, PG);
0208 % g2 = r.flow(1,1,1).mpc.gen(:, PG);
0209 % for k = 1:nc
0210 %     g1 = [ g1 s.rdc.cont(k).gen(:, PG) ];
0211 %     g2 = [ g2 r.flow(1,1,k+1).mpc.gen(:, PG) ];
0212 % end
0213 % [m,n] = size(g1);
0214 % for j = 1:n
0215 %     fprintf('\n');
0216 %     for i = 1:m
0217 %         fprintf('%9.2f  %9.2f\n', g1(i,j), g2(i,j));
0218 %     end
0219 % end
0220 
0221 %%-----  do AC run (most)  -----
0222 %mostac;
0223 
0224 
0225 
0226 
0227 %% turn warnings back on
0228 warning(s7.state, 'MATLAB:nearlySingularMatrix');
0229 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0230 
0231 t_end;

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005