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

t_most_3b_1_1_2

PURPOSE ^

T_MOST_3B_1_1_2 Tests for MOST.

SYNOPSIS ^

function t_most_3b_1_1_2(quiet)

DESCRIPTION ^

T_MOST_3B_1_1_2  Tests for MOST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_most_3b_1_1_2(quiet)
0002 %T_MOST_3B_1_1_2  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 = 22;
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 algs.dc     = {'DEFAULT'};  %% opf.dc.solver sequence to try for c3sopf (DC run)
0029 algs.ac     = {'DEFAULT'};  %% opf.ac.solver sequence to try for c3sopf (AC run)
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);  %% don't constrain contracted == base case dispatch
0033 mpoptac = mpoption(mpopt, 'model', 'AC');
0034 mpoptdc = mpoption(mpopt, 'model', 'DC');
0035 mpopt = mpoption(mpopt, 'most.solver', algs.dc{1});
0036 
0037 %% turn off warnings
0038 s7 = warning('query', 'MATLAB:nearlySingularMatrix');
0039 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0040 warning('off', 'MATLAB:nearlySingularMatrix');
0041 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0042 
0043 %% define named indices into data matrices
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 %% reserve and delta offers
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 %% contingency table
0073 % label probty  type        row column      chgtype newvalue
0074 contab = [
0075     1   0.01    CT_TBRCH    1   BR_STATUS   CT_REP  0;      %% line 1-2
0076     2   0.01    CT_TGEN     1   GEN_STATUS  CT_REP  0;      %% gen 1 at bus 1
0077 %   2   0.00049621965   CT_TGEN     1   GEN_STATUS  CT_REP  0;      %% gen 1 at bus 1
0078 ];
0079 clist = unique(contab(:, CT_LABEL));
0080 nc = length(clist);
0081 
0082 %% load the case
0083 mpc = loadcase(casename);
0084 gbus = mpc.gen(:, GEN_BUS);
0085 
0086 %%-----  get c3sopf results  -----
0087 rdc = c3sopf_retry(algs.dc, mpc, xgd_table.data, contab, mpoptdc);
0088 % rac = c3sopf_retry(algs.ac, mpc, xgd_table.data, contab, mpoptac);
0089 % save t_most3_soln rdc rac -v6
0090 % s = load('t_most3_soln');
0091 s.rdc = rdc;
0092 % s.rac = rac;
0093 
0094 %%-----  set up data for DC run (most)  -----
0095 ng = size(mpc.gen, 1);      %% number of gens
0096 xgd = loadxgendata(xgd_table, mpc);
0097 md = loadmd(mpc, [], xgd, [], contab);
0098 
0099 %%-----  do DC run (most)  -----
0100 r = most(md, mpopt);
0101 
0102 %%-----  test the results  -----
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 % g1 = s.rdc.base.gen(:, PG);
0181 % g2 = r.flow(1,1,1).mpc.gen(:, PG);
0182 % for k = 1:nc
0183 %     g1 = [ g1 s.rdc.cont(k).gen(:, PG) ];
0184 %     g2 = [ g2 r.flow(1,1,k+1).mpc.gen(:, PG) ];
0185 % end
0186 % [m,n] = size(g1);
0187 % for j = 1:n
0188 %     fprintf('\n');
0189 %     for i = 1:m
0190 %         fprintf('%9.2f  %9.2f\n', g1(i,j), g2(i,j));
0191 %     end
0192 % end
0193 
0194 %%-----  do AC run (most)  -----
0195 %mostac;
0196 
0197 
0198 %% turn warnings back on
0199 warning(s7.state, 'MATLAB:nearlySingularMatrix');
0200 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0201 
0202 t_end;

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