Home > matpower5.0 > 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 %   $Id: t_runopf_w_res.m 2229 2013-12-11 01:28:09Z ray $
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %   Copyright (c) 2009-2010 by Power System Engineering Research Center (PSERC)
0008 %
0009 %   This file is part of MATPOWER.
0010 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0011 %
0012 %   MATPOWER is free software: you can redistribute it and/or modify
0013 %   it under the terms of the GNU General Public License as published
0014 %   by the Free Software Foundation, either version 3 of the License,
0015 %   or (at your option) any later version.
0016 %
0017 %   MATPOWER is distributed in the hope that it will be useful,
0018 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0019 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0020 %   GNU General Public License for more details.
0021 %
0022 %   You should have received a copy of the GNU General Public License
0023 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0024 %
0025 %   Additional permission under GNU GPL version 3 section 7
0026 %
0027 %   If you modify MATPOWER, or any covered work, to interface with
0028 %   other modules (such as MATLAB code and MEX-files) available in a
0029 %   MATLAB(R) or comparable environment containing parts covered
0030 %   under other licensing terms, the licensors of MATPOWER grant
0031 %   you additional permission to convey the resulting work.
0032 
0033 if nargin < 1
0034     quiet = 0;
0035 end
0036 
0037 t_begin(46, quiet);
0038 
0039 if quiet
0040     verbose = 0;
0041 else
0042     verbose = 0;
0043 end
0044 
0045 casefile = 't_case30_userfcns';
0046 mpopt = mpoption('opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0047         'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0048 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose, 'opf.ac.solver', 'MIPS');
0049 
0050 %% define named indices into data matrices
0051 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0052     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0053     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0054 
0055 t = 'runopf_w_res(''t_case30_userfcns'') : ';
0056 r = runopf_w_res(casefile, mpopt);
0057 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0058 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0059 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0060 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0061 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0062 mpc = loadcase(casefile);
0063 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0064 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0065 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0066 
0067 t = 'gen 5 no reserves : ';
0068 mpc = loadcase(casefile);
0069 mpc.reserves.zones(:, 5) = 0;
0070 mpc.reserves.cost(5) = [];
0071 mpc.reserves.qty(5) = [];
0072 r = runopf_w_res(mpc, mpopt);
0073 t_is(r.reserves.R, [25; 15; 0; 0; 0; 20], 4, [t 'R']);
0074 t_is(r.reserves.prc, [2; 2; 2; 2; 0; 5.5], 6, [t 'prc']);
0075 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0076 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0077 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0078 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0079 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0080 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0081 
0082 t = 'extra offline gen : ';
0083 mpc = loadcase(casefile);
0084 idx = [1:3 5 4:6];
0085 mpc.gen = mpc.gen(idx, :);
0086 mpc.gencost = mpc.gencost(idx, :);
0087 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0088 mpc.reserves.cost = mpc.reserves.cost(idx);
0089 mpc.reserves.qty = mpc.reserves.qty(idx);
0090 mpc.gen(4, GEN_STATUS) = 0;
0091 r = runopf_w_res(mpc, mpopt);
0092 t_is(r.reserves.R, [25; 15; 0; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0093 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 5.5; 5.5], 6, [t 'prc']);
0094 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0095 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0096 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0097 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0098 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0099 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0100 
0101 t = 'both extra & gen 6 no res : ';
0102 mpc = loadcase(casefile);
0103 idx = [1:3 5 4:6];
0104 mpc.gen = mpc.gen(idx, :);
0105 mpc.gencost = mpc.gencost(idx, :);
0106 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0107 mpc.reserves.cost = mpc.reserves.cost(idx);
0108 mpc.reserves.qty = mpc.reserves.qty(idx);
0109 mpc.gen(4, GEN_STATUS) = 0;
0110 mpc.reserves.zones(:, 6) = 0;
0111 mpc.reserves.cost(6) = [];
0112 mpc.reserves.qty(6) = [];
0113 r = runopf_w_res(mpc, mpopt);
0114 t_is(r.reserves.R, [25; 15; 0; 0; 0; 0; 20], 4, [t 'R']);
0115 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 0; 5.5], 6, [t 'prc']);
0116 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0117 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0118 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0119 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0120 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0121 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0122 
0123 t = 'no qty (Rmax) : ';
0124 mpc = loadcase(casefile);
0125 mpc.reserves = rmfield(mpc.reserves, 'qty');
0126 r = runopf_w_res(mpc, mpopt);
0127 t_is(r.reserves.R, [39.3826; 0.6174; 0; 0; 19.3818; 0.6182], 4, [t 'R']);
0128 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 5, [t 'prc']);
0129 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 5, [t 'mu.l']);
0130 t_is(r.reserves.mu.u, [0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0131 t_is(r.reserves.mu.Pmax, [0.1; 0; 0; 0; 0.5; 0], 5, [t 'mu.Pmax']);
0132 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0133 t_is(r.reserves.totalcost, 176.3708, 4, [t 'totalcost']);
0134 
0135 t = 'RAMP_10, no qty (Rmax) : ';
0136 mpc = loadcase(casefile);
0137 mpc.reserves = rmfield(mpc.reserves, 'qty');
0138 mpc.gen(1, RAMP_10) = 25;
0139 r = runopf_w_res(mpc, mpopt);
0140 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0141 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0142 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0143 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0144 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0145 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0146 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0147 
0148 t_end;

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005