Home > matpower7.0 > lib > t > t_runopf_w_res.m

t_runopf_w_res

PURPOSE ^

T_RUNOPF_W_RES Tests RUNOPF_W_RES and the associated callbacks.

SYNOPSIS ^

function t_runopf_w_res(quiet)

DESCRIPTION ^

T_RUNOPF_W_RES  Tests RUNOPF_W_RES and the associated callbacks.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_runopf_w_res(quiet)
0002 %T_RUNOPF_W_RES  Tests RUNOPF_W_RES and the associated callbacks.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2009-2016, Power Systems Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   This file is part of MATPOWER.
0009 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0010 %   See https://matpower.org for more info.
0011 
0012 if nargin < 1
0013     quiet = 0;
0014 end
0015 
0016 t_begin(46, quiet);
0017 
0018 if quiet
0019     verbose = 0;
0020 else
0021     verbose = 0;
0022 end
0023 
0024 casefile = 't_case30_userfcns';
0025 mpopt = mpoption('opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0026         'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0027 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose, 'opf.ac.solver', 'MIPS');
0028 
0029 %% define named indices into data matrices
0030 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0031     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0032     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0033 
0034 t = 'runopf_w_res(''t_case30_userfcns'') : ';
0035 r = runopf_w_res(casefile, mpopt);
0036 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0037 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0038 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0039 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0040 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0041 mpc = loadcase(casefile);
0042 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0043 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0044 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0045 
0046 t = 'gen 5 no reserves : ';
0047 mpc = loadcase(casefile);
0048 mpc.reserves.zones(:, 5) = 0;
0049 mpc.reserves.cost(5) = [];
0050 mpc.reserves.qty(5) = [];
0051 r = runopf_w_res(mpc, mpopt);
0052 t_is(r.reserves.R, [25; 15; 0; 0; 0; 20], 4, [t 'R']);
0053 t_is(r.reserves.prc, [2; 2; 2; 2; 0; 5.5], 6, [t 'prc']);
0054 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0055 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0056 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0057 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0058 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0059 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0060 
0061 t = 'extra offline gen : ';
0062 mpc = loadcase(casefile);
0063 idx = [1:3 5 4:6];
0064 mpc.gen = mpc.gen(idx, :);
0065 mpc.gencost = mpc.gencost(idx, :);
0066 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0067 mpc.reserves.cost = mpc.reserves.cost(idx);
0068 mpc.reserves.qty = mpc.reserves.qty(idx);
0069 mpc.gen(4, GEN_STATUS) = 0;
0070 r = runopf_w_res(mpc, mpopt);
0071 t_is(r.reserves.R, [25; 15; 0; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0072 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 5.5; 5.5], 6, [t 'prc']);
0073 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0074 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0075 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0076 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0077 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0078 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0079 
0080 t = 'both extra & gen 6 no res : ';
0081 mpc = loadcase(casefile);
0082 idx = [1:3 5 4:6];
0083 mpc.gen = mpc.gen(idx, :);
0084 mpc.gencost = mpc.gencost(idx, :);
0085 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0086 mpc.reserves.cost = mpc.reserves.cost(idx);
0087 mpc.reserves.qty = mpc.reserves.qty(idx);
0088 mpc.gen(4, GEN_STATUS) = 0;
0089 mpc.reserves.zones(:, 6) = 0;
0090 mpc.reserves.cost(6) = [];
0091 mpc.reserves.qty(6) = [];
0092 r = runopf_w_res(mpc, mpopt);
0093 t_is(r.reserves.R, [25; 15; 0; 0; 0; 0; 20], 4, [t 'R']);
0094 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 0; 5.5], 6, [t 'prc']);
0095 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0096 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0097 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0098 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0099 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0100 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0101 
0102 t = 'no qty (Rmax) : ';
0103 mpc = loadcase(casefile);
0104 mpc.reserves = rmfield(mpc.reserves, 'qty');
0105 r = runopf_w_res(mpc, mpopt);
0106 t_is(r.reserves.R, [39.3826; 0.6174; 0; 0; 19.3818; 0.6182], 4, [t 'R']);
0107 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 5, [t 'prc']);
0108 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 5, [t 'mu.l']);
0109 t_is(r.reserves.mu.u, [0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0110 t_is(r.reserves.mu.Pmax, [0.1; 0; 0; 0; 0.5; 0], 5, [t 'mu.Pmax']);
0111 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0112 t_is(r.reserves.totalcost, 176.3708, 4, [t 'totalcost']);
0113 
0114 t = 'RAMP_10, no qty (Rmax) : ';
0115 mpc = loadcase(casefile);
0116 mpc.reserves = rmfield(mpc.reserves, 'qty');
0117 mpc.gen(1, RAMP_10) = 25;
0118 r = runopf_w_res(mpc, mpopt);
0119 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0120 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0121 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0122 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0123 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0124 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0125 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0126 
0127 t_end;

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005