Home > matpower5.1 > 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 %   Copyright (c) 2009-2015 by Power System Engineering Research Center (PSERC)
0007 %   by Ray Zimmerman, PSERC Cornell
0008 %
0009 %   $Id: t_opf_userfcns.m 2644 2015-03-11 19:34:22Z ray $
0010 %
0011 %   This file is part of MATPOWER.
0012 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0013 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0014 
0015 if nargin < 1
0016     quiet = 0;
0017 end
0018 
0019 t_begin(51, quiet);
0020 
0021 casefile = 't_case30_userfcns';
0022 if quiet
0023     verbose = 0;
0024 else
0025     verbose = 0;
0026 end
0027 mpopt = mpoption('opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0028         'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0029 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose);
0030 mpopt = mpoption(mpopt, 'opf.ac.solver', 'MIPS', 'opf.dc.solver', 'MIPS');
0031 % mpopt = mpoption(mpopt, 'verbose', 2, 'out.all', -1, 'out.gen', 1);
0032 
0033 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0034     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0035     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0036 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0037     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0038     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0039 
0040 %% run the OPF with fixed reserves
0041 t = 'fixed reserves : ';
0042 mpc = loadcase(casefile);
0043 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0044 mpc = toggle_reserves(mpc, 'on');
0045 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0046 r = runopf(mpc, mpopt);
0047 t_ok(r.success, [t 'success']);
0048 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'reserves.R']);
0049 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 4, [t 'reserves.prc']);
0050 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0051 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0052 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0053 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0054 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0055 
0056 t = 'toggle_reserves(mpc, ''off'') : ';
0057 mpc = toggle_reserves(mpc, 'off');
0058 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0059 r = runopf(mpc, mpopt);
0060 t_ok(r.success, [t 'success']);
0061 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0062 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0063 
0064 t = 'interface flow lims (DC) : ';
0065 mpc = loadcase(casefile);
0066 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0067 mpc = toggle_iflims(mpc, 'on');
0068 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0069 r = rundcopf(mpc, mpopt);
0070 t_ok(r.success, [t 'success']);
0071 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0072 t_is(r.if.mu.l, [0.048427; 0], 6, [t 'if.mu.l']);
0073 t_is(r.if.mu.u, [0; 0.132573], 6, [t 'if.mu.u']);
0074 t_is(r.branch(14, PF), 8.244, 3, [t 'flow in branch 14']);
0075 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0076 
0077 t = 'reserves + interface flow lims (DC) : ';
0078 mpc = loadcase(casefile);
0079 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0080 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0081 mpc = toggle_reserves(mpc, 'on');
0082 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0083 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0084 mpc = toggle_iflims(mpc, 'on');
0085 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0086 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0087 r = rundcopf(mpc, mpopt);
0088 t_ok(r.success, [t 'success']);
0089 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0090 t_is(r.if.mu.l, [0.048427; 0], 6, [t 'if.mu.l']);
0091 t_is(r.if.mu.u, [0; 0.382573], 6, [t 'if.mu.u']);
0092 t_is(r.reserves.R, [25; 15; 0; 0; 16.9; 3.1], 4, [t 'reserves.R']);
0093 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 4, [t 'reserves.prc']);
0094 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0095 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0096 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0097 t_is(r.reserves.totalcost, 179.05, 4, [t 'totalcost']);
0098 
0099 t = 'interface flow lims (AC) : ';
0100 mpc = toggle_reserves(mpc, 'off');
0101 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0102 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0103 r = runopf(mpc, mpopt);
0104 t_ok(r.success, [t 'success']);
0105 t_is(r.if.P, [-9.101; 21.432], 3, [t 'if.P']);
0106 t_is(r.if.mu.l, [0; 0], 6, [t 'if.mu.l']);
0107 t_is(r.if.mu.u, [0; 0.10198], 5, [t 'if.mu.u']);
0108 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0109 
0110 t = 'interface flow lims (line out) : ';
0111 mpc = loadcase(casefile);
0112 mpc = toggle_iflims(mpc, 'on');
0113 mpc.branch(12, BR_STATUS) = 0;      %% take out line 6-10
0114 r = rundcopf(mpc, mpopt);
0115 t_ok(r.success, [t 'success']);
0116 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0117 t_is(r.if.mu.l, [0.048427; 0], 6, [t 'if.mu.l']);
0118 t_is(r.if.mu.u, [0; 0.132573], 6, [t 'if.mu.u']);
0119 t_is(r.branch(14, PF), 10.814, 3, [t 'flow in branch 14']);
0120 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0121 
0122 % r.reserves.R
0123 % r.reserves.prc
0124 % r.reserves.mu.Pmax
0125 % r.reserves.mu.l
0126 % r.reserves.mu.u
0127 % r.reserves.totalcost
0128 %
0129 % r.if.P
0130 % r.if.mu.l
0131 % r.if.mu.u
0132 
0133 t_end;

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005