Home > matpower7.1 > lib > 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 https://matpower.org 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-7, '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 % mpopt = mpoption(mpopt, 'opf.ac.solver', 'PDIPM', 'opf.dc.solver', 'GUROBI');
0031 % mpopt = mpoption(mpopt, 'pdipm.gradtol', 1e-8, ...
0032 %         'pdipm.comptol', 1e-8, 'pdipm.costtol', 1e-9);
0033 % mpopt = mpoption(mpopt, 'opf.ac.solver', 'MINOPF', 'opf.dc.solver', 'BPMPD');
0034 
0035 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0036     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0037     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0038 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0039     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0040     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0041 
0042 %% run the OPF with fixed reserves
0043 t = 'fixed reserves : ';
0044 mpc = loadcase(casefile);
0045 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0046 mpc = toggle_reserves(mpc, 'on');
0047 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0048 r = runopf(mpc, mpopt);
0049 t_ok(r.success, [t 'success']);
0050 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'reserves.R']);
0051 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 4, [t 'reserves.prc']);
0052 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0053 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0054 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0055 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0056 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0057 
0058 t = 'toggle_reserves(mpc, ''off'') : ';
0059 mpc = toggle_reserves(mpc, 'off');
0060 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0061 r = runopf(mpc, mpopt);
0062 t_ok(r.success, [t 'success']);
0063 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0064 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0065 
0066 t = 'interface flow lims (DC) : ';
0067 mpc = loadcase(casefile);
0068 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0069 mpc = toggle_iflims(mpc, 'on');
0070 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0071 r = rundcopf(mpc, mpopt);
0072 t_ok(r.success, [t 'success']);
0073 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0074 t_is(r.if.mu.l, [0.048427; 0], 6, [t 'if.mu.l']);
0075 t_is(r.if.mu.u, [0; 0.132573], 6, [t 'if.mu.u']);
0076 t_is(r.branch(14, PF), 8.244, 3, [t 'flow in branch 14']);
0077 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0078 
0079 t = 'reserves + interface flow lims (DC) : ';
0080 mpc = loadcase(casefile);
0081 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0082 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0083 mpc = toggle_reserves(mpc, 'on');
0084 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0085 t_ok(~toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 0');
0086 mpc = toggle_iflims(mpc, 'on');
0087 t_ok(toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 1');
0088 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0089 r = rundcopf(mpc, mpopt);
0090 t_ok(r.success, [t 'success']);
0091 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0092 t_is(r.if.mu.l, [0.048427; 0], 6, [t 'if.mu.l']);
0093 t_is(r.if.mu.u, [0; 0.382573], 6, [t 'if.mu.u']);
0094 t_is(r.reserves.R, [25; 15; 0; 0; 16.9; 3.1], 4, [t 'reserves.R']);
0095 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 4, [t 'reserves.prc']);
0096 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0097 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0098 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0099 t_is(r.reserves.totalcost, 179.05, 4, [t 'totalcost']);
0100 
0101 t = 'interface flow lims (AC) : ';
0102 mpc = toggle_reserves(mpc, 'off');
0103 t_ok(~toggle_reserves(mpc, 'status'), 'toggle_reserves(mpc, ''status'') == 0');
0104 t_ok(toggle_iflims(mpc, 'status'), 'toggle_iflims(  mpc, ''status'') == 1');
0105 r = runopf(mpc, mpopt);
0106 t_ok(r.success, [t 'success']);
0107 t_is(r.if.P, [-9.101; 21.432], 3, [t 'if.P']);
0108 t_is(r.if.mu.l, [0; 0], 6, [t 'if.mu.l']);
0109 t_is(r.if.mu.u, [0; 0.10198], 5, [t 'if.mu.u']);
0110 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0111 
0112 t = 'interface flow lims (line out) : ';
0113 mpc = loadcase(casefile);
0114 mpc = toggle_iflims(mpc, 'on');
0115 mpc.branch(12, BR_STATUS) = 0;      %% take out line 6-10
0116 r = rundcopf(mpc, mpopt);
0117 t_ok(r.success, [t 'success']);
0118 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0119 t_is(r.if.mu.l, [0.048427; 0], 6, [t 'if.mu.l']);
0120 t_is(r.if.mu.u, [0; 0.132573], 6, [t 'if.mu.u']);
0121 t_is(r.branch(14, PF), 10.814, 3, [t 'flow in branch 14']);
0122 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0123 
0124 % r.reserves.R
0125 % r.reserves.prc
0126 % r.reserves.mu.Pmax
0127 % r.reserves.mu.l
0128 % r.reserves.mu.u
0129 % r.reserves.totalcost
0130 %
0131 % r.if.P
0132 % r.if.mu.l
0133 % r.if.mu.u
0134 
0135 t_end;

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005