Home > matpower4.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,v 1.10 2010/04/26 19:45:26 ray Exp $
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, 'PDIPM_GRADTOL', 1e-8, ...
0047         'PDIPM_COMPTOL', 1e-8, 'PDIPM_COSTTOL', 1e-9);
0048 mpopt = mpoption(mpopt, 'OUT_ALL', 0, 'VERBOSE', verbose, 'OPF_ALG', 560);
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 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0056 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0057 
0058 t = 'runopf_w_res(''t_case30_userfcns'') : ';
0059 r = runopf_w_res(casefile, mpopt);
0060 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0061 t_is(r.reserves.prc, [2; 2; 2; 2; 3.5; 3.5], 6, [t 'prc']);
0062 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0063 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0064 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0065 mpc = loadcase(casefile);
0066 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0067 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0068 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0069 
0070 t = 'gen 5 no reserves : ';
0071 mpc = loadcase(casefile);
0072 mpc.reserves.zones(:, 5) = 0;
0073 mpc.reserves.cost(5) = [];
0074 mpc.reserves.qty(5) = [];
0075 r = runopf_w_res(mpc, mpopt);
0076 t_is(r.reserves.R, [25; 15; 0; 0; 0; 20], 4, [t 'R']);
0077 t_is(r.reserves.prc, [2; 2; 2; 2; 0; 3.5], 6, [t 'prc']);
0078 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0079 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0080 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0081 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0082 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0083 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0084 
0085 t = 'extra offline gen : ';
0086 mpc = loadcase(casefile);
0087 idx = [1:3 5 4:6];
0088 mpc.gen = mpc.gen(idx, :);
0089 mpc.gencost = mpc.gencost(idx, :);
0090 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0091 mpc.reserves.cost = mpc.reserves.cost(idx);
0092 mpc.reserves.qty = mpc.reserves.qty(idx);
0093 mpc.gen(4, GEN_STATUS) = 0;
0094 r = runopf_w_res(mpc, mpopt);
0095 t_is(r.reserves.R, [25; 15; 0; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0096 t_is(r.reserves.prc, [2; 2; 2; 3.5; 2; 3.5; 3.5], 6, [t 'prc']);
0097 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0098 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0099 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0100 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0101 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0102 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0103 
0104 t = 'both extra & gen 6 no res : ';
0105 mpc = loadcase(casefile);
0106 idx = [1:3 5 4:6];
0107 mpc.gen = mpc.gen(idx, :);
0108 mpc.gencost = mpc.gencost(idx, :);
0109 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0110 mpc.reserves.cost = mpc.reserves.cost(idx);
0111 mpc.reserves.qty = mpc.reserves.qty(idx);
0112 mpc.gen(4, GEN_STATUS) = 0;
0113 mpc.reserves.zones(:, 6) = 0;
0114 mpc.reserves.cost(6) = [];
0115 mpc.reserves.qty(6) = [];
0116 r = runopf_w_res(mpc, mpopt);
0117 t_is(r.reserves.R, [25; 15; 0; 0; 0; 0; 20], 4, [t 'R']);
0118 t_is(r.reserves.prc, [2; 2; 2; 3.5; 2; 0; 3.5], 6, [t 'prc']);
0119 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0120 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0121 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0122 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0123 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0124 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0125 
0126 t = 'no qty (Rmax) : ';
0127 mpc = loadcase(casefile);
0128 mpc.reserves = rmfield(mpc.reserves, 'qty');
0129 r = runopf_w_res(mpc, mpopt);
0130 t_is(r.reserves.R, [39.3826; 0.6174; 0; 0; 19.3818; 0.6182], 4, [t 'R']);
0131 t_is(r.reserves.prc, [2; 2; 2; 2; 3.5; 3.5], 5, [t 'prc']);
0132 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 5, [t 'mu.l']);
0133 t_is(r.reserves.mu.u, [0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0134 t_is(r.reserves.mu.Pmax, [0.1; 0; 0; 0; 0.5; 0], 5, [t 'mu.Pmax']);
0135 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0136 t_is(r.reserves.totalcost, 176.3708, 4, [t 'totalcost']);
0137 
0138 t = 'RAMP_10, no qty (Rmax) : ';
0139 mpc = loadcase(casefile);
0140 mpc.reserves = rmfield(mpc.reserves, 'qty');
0141 mpc.gen(1, RAMP_10) = 25;
0142 r = runopf_w_res(mpc, mpopt);
0143 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0144 t_is(r.reserves.prc, [2; 2; 2; 2; 3.5; 3.5], 6, [t 'prc']);
0145 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0146 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0147 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0148 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0149 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0150 
0151 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0152 
0153 t_end;

Generated on Mon 26-Jan-2015 14:56:45 by m2html © 2005