Home > matpower7.1 > most > lib > t > t_most_3b_3_1_0.m

t_most_3b_3_1_0

PURPOSE ^

T_MOST_3B_3_1_0 Tests for MOST.

SYNOPSIS ^

function t_most_3b_3_1_0(quiet)

DESCRIPTION ^

T_MOST_3B_3_1_0  Tests for MOST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_most_3b_3_1_0(quiet)
0002 %T_MOST_3B_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 https://github.com/MATPOWER/most 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_case3_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 mpoptac = mpoption(mpopt, 'model', 'AC');
0031 mpoptdc = mpoption(mpopt, 'model', 'DC');
0032 mpopt = mpoption(mpopt, 'most.solver', 'DEFAULT');
0033     
0034 %% turn off warnings
0035 s7 = warning('query', 'MATLAB:nearlySingularMatrix');
0036 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0037 warning('off', 'MATLAB:nearlySingularMatrix');
0038 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0039 
0040 %% define named indices into data matrices
0041 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0042     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0043 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0044     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0045     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0046 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0047     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0048     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0049 [CT_LABEL, CT_PROB, CT_TABLE, CT_TBUS, CT_TGEN, CT_TBRCH, CT_TAREABUS, ...
0050     CT_TAREAGEN, CT_TAREABRCH, CT_ROW, CT_COL, CT_CHGTYPE, CT_REP, ...
0051     CT_REL, CT_ADD, CT_NEWVAL, CT_TLOAD, CT_TAREALOAD, CT_LOAD_ALL_PQ, ...
0052     CT_LOAD_FIX_PQ, CT_LOAD_DIS_PQ, CT_LOAD_ALL_P, CT_LOAD_FIX_P, ...
0053     CT_LOAD_DIS_P, CT_TGENCOST, CT_TAREAGENCOST, CT_MODCOST_F, ...
0054     CT_MODCOST_X] = idx_ct;
0055 
0056 %% reserve and delta offers
0057 xgd_table.colnames = {
0058     'PositiveActiveReservePrice', ...
0059             'PositiveActiveReserveQuantity', ...
0060                     'NegativeActiveReservePrice', ...
0061                             'NegativeActiveReserveQuantity', ...
0062                                     'PositiveActiveDeltaPrice', ...
0063                                             'NegativeActiveDeltaPrice', ...
0064 };
0065 xgd_table.data = [
0066     1       400     2       400     0.01    0.01;
0067     3       300     4       300     0.01    0.01;
0068     0.001   450     0.002   450     0       0;
0069 ];
0070 
0071 %% contingency table
0072 % label probty  type        row column      chgtype newvalue
0073 contab = [
0074 %    1   0.01    CT_TBRCH    1   BR_STATUS   CT_REP  0;      %% line 1-2
0075 %    2   0.01    CT_TGEN     1   GEN_STATUS  CT_REP  0;      %% gen 1 at bus 1
0076 %   2   0.00049621965   CT_TGEN     1   GEN_STATUS  CT_REP  0;      %% gen 1 at bus 1
0077 ];
0078 clist = [];
0079 nc = length(clist);
0080 
0081 %% load the case
0082 mpc = loadcase(casename);
0083 gbus = mpc.gen(:, GEN_BUS);
0084 
0085 %%-----  get OPF results  -----
0086 rdc = rundcopf(mpc, mpoptdc);
0087 % rac = runopf(mpc, mpoptac);
0088 % save t_most5_soln rdc rac -v6
0089 % s = load('t_most5_soln');
0090 s.rdc = rdc;
0091 % s.rac = rac;
0092 
0093 %%-----  set up data for DC run (most)  -----
0094 ng = size(mpc.gen, 1);      %% number of gens
0095 nt = 3;
0096 xgd = loadxgendata(xgd_table, mpc);
0097 md = loadmd(mpc, nt, xgd);
0098 
0099 %%-----  do DC run (most)  -----
0100 r = most(md, mpopt);
0101 
0102 %%-----  test the results  -----
0103 t = 'success1';
0104 t_ok(s.rdc.success, t);
0105 t = 'success2';
0106 t_ok(r.QP.exitflag, t);
0107 
0108 t = 'f';
0109 t_is(r.results.f/sum(r.StepProb), s.rdc.f, 4, t);
0110 
0111 for tt = 1:nt
0112 
0113 t = sprintf('(t=%d) Pg : base', tt);
0114 t_is(r.flow(tt,1,1).mpc.gen(:, PG), s.rdc.gen(:, PG), 5, t);
0115 
0116 t = sprintf('(t=%d) gen : base', tt);
0117 t_is(r.flow(tt,1,1).mpc.gen(:,1:MU_PMIN), s.rdc.gen(:,1:MU_PMIN), 3, t);
0118 
0119 t = sprintf('(t=%d) energy prices', tt);
0120 t_is(r.results.GenPrices(:,tt), s.rdc.bus(gbus, LAM_P), 6, t);
0121 
0122 t = sprintf('(t=%d) Pc', tt);
0123 t_is(r.results.Pc(:,tt), s.rdc.gen(:, PG), 4, t);
0124 
0125 t = sprintf('(t=%d) Gmin', tt);
0126 t_is(r.results.Pc(:,tt) - r.results.Rpm(:,tt), s.rdc.gen(:, PG), 4, t);
0127 
0128 t = sprintf('(t=%d) Gmax', tt);
0129 t_is(r.results.Pc(:,tt) + r.results.Rpp(:,tt), s.rdc.gen(:, PG), 4, t);
0130 
0131 t = sprintf('(t=%d) upward contingency reserve quantities', tt);
0132 t_is(r.results.Rpp(:,tt), zeros(ng, 1), 4, t);
0133 
0134 t = sprintf('(t=%d) downward contingency reserve quantities', tt);
0135 t_is(r.results.Rpm(:,tt), zeros(ng, 1), 4, t);
0136 
0137 t = sprintf('(t=%d) upward contingency reserve prices', tt);
0138 t_is(r.results.RpmPrices(:,tt), xgd.NegativeActiveReservePrice, 6, t);
0139 
0140 t = sprintf('(t=%d) downward contingency reserve prices', tt);
0141 t_is(r.results.RpmPrices(:,tt), xgd.NegativeActiveReservePrice, 6, t);
0142 
0143 t = sprintf('(t=%d) Rpmax_pos', tt);
0144 vv = r.om.get_idx();
0145 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;
0146 t_is(Rpmax_pos, zeros(ng, 1), 6, t);
0147 
0148 t = sprintf('(t=%d) Rpmax_neg', tt);
0149 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;
0150 t_is(Rpmax_neg, zeros(ng, 1), 6, t);
0151 
0152 end
0153 
0154 
0155 % g1 = s.rdc.base.gen(:, PG);
0156 % g2 = r.flow(1,1,1).mpc.gen(:, PG);
0157 % for k = 1:nc
0158 %     g1 = [ g1 s.rdc.cont(k).gen(:, PG) ];
0159 %     g2 = [ g2 r.flow(1,1,k+1).mpc.gen(:, PG) ];
0160 % end
0161 % [m,n] = size(g1);
0162 % for j = 1:n
0163 %     fprintf('\n');
0164 %     for i = 1:m
0165 %         fprintf('%9.2f  %9.2f\n', g1(i,j), g2(i,j));
0166 %     end
0167 % end
0168 
0169 %%-----  do AC run (most)  -----
0170 %mostac;
0171 
0172 
0173 
0174 
0175 %% turn warnings back on
0176 warning(s7.state, 'MATLAB:nearlySingularMatrix');
0177 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0178 
0179 t_end;

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005