Home > matpower4.0 > t > t_opf_userfcns.m

t_opf_userfcns

PURPOSE ^

T_OPF_USERFCNS Tests for userfcn callbacks (reserves/iflims) w/OPF.

SYNOPSIS ^

function t_opf_userfcns(quiet)

DESCRIPTION ^

T_OPF_USERFCNS  Tests for userfcn callbacks (reserves/iflims) w/OPF.
   Includes high-level tests of reserves and iflims implementations.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_opf_userfcns(quiet)
0002 %T_OPF_USERFCNS  Tests for userfcn callbacks (reserves/iflims) w/OPF.
0003 %   Includes high-level tests of reserves and iflims implementations.
0004 
0005 %   MATPOWER
0006 %   $Id: t_opf_userfcns.m,v 1.9 2010/04/26 19:45:26 ray Exp $
0007 %   by Ray Zimmerman, PSERC Cornell
0008 %   Copyright (c) 2009-2010 by Power System Engineering Research Center (PSERC)
0009 %
0010 %   This file is part of MATPOWER.
0011 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0012 %
0013 %   MATPOWER is free software: you can redistribute it and/or modify
0014 %   it under the terms of the GNU General Public License as published
0015 %   by the Free Software Foundation, either version 3 of the License,
0016 %   or (at your option) any later version.
0017 %
0018 %   MATPOWER is distributed in the hope that it will be useful,
0019 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0020 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0021 %   GNU General Public License for more details.
0022 %
0023 %   You should have received a copy of the GNU General Public License
0024 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0025 %
0026 %   Additional permission under GNU GPL version 3 section 7
0027 %
0028 %   If you modify MATPOWER, or any covered work, to interface with
0029 %   other modules (such as MATLAB code and MEX-files) available in a
0030 %   MATLAB(R) or comparable environment containing parts covered
0031 %   under other licensing terms, the licensors of MATPOWER grant
0032 %   you additional permission to convey the resulting work.
0033 
0034 if nargin < 1
0035     quiet = 0;
0036 end
0037 
0038 t_begin(38, quiet);
0039 
0040 casefile = 't_case30_userfcns';
0041 if quiet
0042     verbose = 0;
0043 else
0044     verbose = 0;
0045 end
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);
0049 mpopt = mpoption(mpopt, 'OPF_ALG', 560, 'OPF_ALG_DC', 200);
0050 % mpopt = mpoption(mpopt, 'VERBOSE', 2, 'OUT_ALL', -1, 'OUT_GEN', 1);
0051 
0052 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0053     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0054     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0055 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0056     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0057     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0058 
0059 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0060 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0061 
0062 %% run the OPF with fixed reserves
0063 t = 'fixed reserves : ';
0064 mpc = loadcase(casefile);
0065 mpc = toggle_reserves(mpc, 'on');
0066 r = runopf(mpc, mpopt);
0067 t_ok(r.success, [t 'success']);
0068 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'reserves.R']);
0069 t_is(r.reserves.prc, [2; 2; 2; 2; 3.5; 3.5], 4, [t 'reserves.prc']);
0070 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0071 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0072 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0073 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0074 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0075 
0076 t = 'toggle_reserves(mpc, ''off'') : ';
0077 mpc = toggle_reserves(mpc, 'off');
0078 r = runopf(mpc, mpopt);
0079 t_ok(r.success, [t 'success']);
0080 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0081 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0082 
0083 t = 'interface flow lims (DC) : ';
0084 mpc = loadcase(casefile);
0085 mpc = toggle_iflims(mpc, 'on');
0086 r = rundcopf(mpc, mpopt);
0087 t_ok(r.success, [t 'success']);
0088 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0089 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0090 t_is(r.if.mu.u, [0; 13.2573], 4, [t 'if.mu.u']);
0091 t_is(r.branch(14, PF), 8.244, 3, [t 'flow in branch 14']);
0092 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0093 
0094 t = 'reserves + interface flow lims (DC) : ';
0095 mpc = loadcase(casefile);
0096 mpc = toggle_reserves(mpc, 'on');
0097 mpc = toggle_iflims(mpc, 'on');
0098 r = rundcopf(mpc, mpopt);
0099 t_ok(r.success, [t 'success']);
0100 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0101 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0102 t_is(r.if.mu.u, [0; 38.2573], 4, [t 'if.mu.u']);
0103 t_is(r.reserves.R, [25; 15; 0; 0; 16.9; 3.1], 4, [t 'reserves.R']);
0104 t_is(r.reserves.prc, [2; 2; 2; 2; 3.5; 3.5], 4, [t 'reserves.prc']);
0105 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0106 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0107 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0108 t_is(r.reserves.totalcost, 179.05, 4, [t 'totalcost']);
0109 
0110 t = 'interface flow lims (AC) : ';
0111 mpc = toggle_reserves(mpc, 'off');
0112 r = runopf(mpc, mpopt);
0113 t_ok(r.success, [t 'success']);
0114 t_is(r.if.P, [-9.101; 21.432], 3, [t 'if.P']);
0115 t_is(r.if.mu.l, [0; 0], 4, [t 'if.mu.l']);
0116 t_is(r.if.mu.u, [0; 10.198], 3, [t 'if.mu.u']);
0117 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0118 
0119 t = 'interface flow lims (line out) : ';
0120 mpc = loadcase(casefile);
0121 mpc = toggle_iflims(mpc, 'on');
0122 mpc.branch(12, BR_STATUS) = 0;      %% take out line 6-10
0123 r = rundcopf(mpc, mpopt);
0124 t_ok(r.success, [t 'success']);
0125 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0126 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0127 t_is(r.if.mu.u, [0; 13.2573], 4, [t 'if.mu.u']);
0128 t_is(r.branch(14, PF), 10.814, 3, [t 'flow in branch 14']);
0129 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0130 
0131 % r.reserves.R
0132 % r.reserves.prc
0133 % r.reserves.mu.Pmax
0134 % r.reserves.mu.l
0135 % r.reserves.mu.u
0136 % r.reserves.totalcost
0137 %
0138 % r.if.P
0139 % r.if.mu.l
0140 % r.if.mu.u
0141 
0142 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0143 
0144 t_end;

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