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

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005