Home > matpower5.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 2263 2014-01-16 17:41:44Z ray $
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(51, 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, 'mips.gradtol', 1e-8, ...
0047         'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0048 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose);
0049 mpopt = mpoption(mpopt, 'opf.ac.solver', 'MIPS', 'opf.dc.solver', 'MIPS');
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 %% run the OPF with fixed reserves
0060 t = 'fixed reserves : ';
0061 mpc = loadcase(casefile);
0062 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0063 mpc = toggle_reserves(mpc, 'on');
0064 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0065 r = runopf(mpc, mpopt);
0066 t_ok(r.success, [t 'success']);
0067 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'reserves.R']);
0068 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 4, [t 'reserves.prc']);
0069 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0070 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0071 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0072 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0073 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0074 
0075 t = 'toggle_reserves(mpc, ''off'') : ';
0076 mpc = toggle_reserves(mpc, 'off');
0077 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
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 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0086 mpc = toggle_iflims(mpc, 'on');
0087 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0088 r = rundcopf(mpc, mpopt);
0089 t_ok(r.success, [t 'success']);
0090 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0091 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0092 t_is(r.if.mu.u, [0; 13.2573], 4, [t 'if.mu.u']);
0093 t_is(r.branch(14, PF), 8.244, 3, [t 'flow in branch 14']);
0094 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0095 
0096 t = 'reserves + interface flow lims (DC) : ';
0097 mpc = loadcase(casefile);
0098 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0099 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0100 mpc = toggle_reserves(mpc, 'on');
0101 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0102 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0103 mpc = toggle_iflims(mpc, 'on');
0104 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0105 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0106 r = rundcopf(mpc, mpopt);
0107 t_ok(r.success, [t 'success']);
0108 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0109 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0110 t_is(r.if.mu.u, [0; 38.2573], 4, [t 'if.mu.u']);
0111 t_is(r.reserves.R, [25; 15; 0; 0; 16.9; 3.1], 4, [t 'reserves.R']);
0112 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 4, [t 'reserves.prc']);
0113 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0114 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0115 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0116 t_is(r.reserves.totalcost, 179.05, 4, [t 'totalcost']);
0117 
0118 t = 'interface flow lims (AC) : ';
0119 mpc = toggle_reserves(mpc, 'off');
0120 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0121 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0122 r = runopf(mpc, mpopt);
0123 t_ok(r.success, [t 'success']);
0124 t_is(r.if.P, [-9.101; 21.432], 3, [t 'if.P']);
0125 t_is(r.if.mu.l, [0; 0], 4, [t 'if.mu.l']);
0126 t_is(r.if.mu.u, [0; 10.198], 3, [t 'if.mu.u']);
0127 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0128 
0129 t = 'interface flow lims (line out) : ';
0130 mpc = loadcase(casefile);
0131 mpc = toggle_iflims(mpc, 'on');
0132 mpc.branch(12, BR_STATUS) = 0;      %% take out line 6-10
0133 r = rundcopf(mpc, mpopt);
0134 t_ok(r.success, [t 'success']);
0135 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0136 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0137 t_is(r.if.mu.u, [0; 13.2573], 4, [t 'if.mu.u']);
0138 t_is(r.branch(14, PF), 10.814, 3, [t 'flow in branch 14']);
0139 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0140 
0141 % r.reserves.R
0142 % r.reserves.prc
0143 % r.reserves.mu.Pmax
0144 % r.reserves.mu.l
0145 % r.reserves.mu.u
0146 % r.reserves.totalcost
0147 %
0148 % r.if.P
0149 % r.if.mu.l
0150 % r.if.mu.u
0151 
0152 t_end;

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