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

t_most_3b_1_1_0

PURPOSE ^

T_MOST_3B_1_1_0 Tests for MOST.

SYNOPSIS ^

function t_most_3b_1_1_0(quiet)

DESCRIPTION ^

T_MOST_3B_1_1_0  Tests for MOST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_most_3b_1_1_0(quiet)
0002 %T_MOST_3B_1_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 = 15;
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 xgd = loadxgendata(xgd_table, mpc);
0096 md = loadmd(mpc, [], xgd);
0097 
0098 %%-----  do DC run (most)  -----
0099 r = most(md, mpopt);
0100 
0101 %%-----  test the results  -----
0102 t = 'success1';
0103 t_ok(s.rdc.success, t);
0104 t = 'success2';
0105 t_ok(r.QP.exitflag, t);
0106 
0107 t = 'f';
0108 t_is(r.results.f, s.rdc.f, 4, t);
0109 
0110 t = 'Pg : base';
0111 t_is(r.flow(1,1,1).mpc.gen(:, PG), s.rdc.gen(:, PG), 5, t);
0112 
0113 t = 'gen : base';
0114 t_is(r.flow(1,1,1).mpc.gen(:,1:MU_PMIN), s.rdc.gen(:,1:MU_PMIN), 3, t);
0115 
0116 t = 'energy prices';
0117 t_is(r.results.GenPrices, s.rdc.bus(gbus, LAM_P), 6, t);
0118 
0119 t = 'Pc';
0120 t_is(r.results.Pc, s.rdc.gen(:, PG), 4, t);
0121 
0122 t = 'Gmin';
0123 t_is(r.results.Pc - r.results.Rpm, s.rdc.gen(:, PG), 4, t);
0124 
0125 t = 'Gmax';
0126 t_is(r.results.Pc + r.results.Rpp, s.rdc.gen(:, PG), 4, t);
0127 
0128 t = 'upward contingency reserve quantities';
0129 t_is(r.results.Rpp, zeros(ng, 1), 4, t);
0130 
0131 t = 'downward contingency reserve quantities';
0132 t_is(r.results.Rpm, zeros(ng, 1), 4, t);
0133 
0134 t = 'upward contingency reserve prices';
0135 t_is(r.results.RppPrices, xgd.PositiveActiveReservePrice, 6, t);
0136 
0137 t = 'downward contingency reserve prices';
0138 t_is(r.results.RpmPrices, xgd.NegativeActiveReservePrice, 6, t);
0139 
0140 t = 'Rpmax_pos';
0141 vv = r.om.get_idx();
0142 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;
0143 t_is(Rpmax_pos, zeros(ng, 1), 6, t);
0144 
0145 t = 'Rpmax_neg';
0146 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;
0147 t_is(Rpmax_neg, zeros(ng, 1), 6, t);
0148 
0149 
0150 
0151 % g1 = s.rdc.base.gen(:, PG);
0152 % g2 = r.flow(1,1,1).mpc.gen(:, PG);
0153 % for k = 1:nc
0154 %     g1 = [ g1 s.rdc.cont(k).gen(:, PG) ];
0155 %     g2 = [ g2 r.flow(1,1,k+1).mpc.gen(:, PG) ];
0156 % end
0157 % [m,n] = size(g1);
0158 % for j = 1:n
0159 %     fprintf('\n');
0160 %     for i = 1:m
0161 %         fprintf('%9.2f  %9.2f\n', g1(i,j), g2(i,j));
0162 %     end
0163 % end
0164 
0165 %%-----  do AC run (most)  -----
0166 %mostac;
0167 
0168 
0169 
0170 
0171 %% turn warnings back on
0172 warning(s7.state, 'MATLAB:nearlySingularMatrix');
0173 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0174 
0175 t_end;

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