Home > matpower7.1 > extras > sdp_pf > t_opf_sdpopf.m

t_opf_sdpopf

PURPOSE ^

T_OPF_SDPOPF Tests for SDP-based AC optimal power flow.

SYNOPSIS ^

function t_opf_sdpopf(quiet)

DESCRIPTION ^

T_OPF_SDPOPF  Tests for SDP-based AC optimal power flow.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_opf_sdpopf(quiet)
0002 %T_OPF_SDPOPF  Tests for SDP-based AC optimal power flow.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2013-2019, Power Systems Engineering Research Center (PSERC)
0006 %   by Daniel Molzahn, PSERC U of Wisc, Madison
0007 %   and Ray Zimmerman, PSERC Cornell
0008 %
0009 %   This file is part of MATPOWER/mx-sdp_pf.
0010 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0011 %   See https://github.com/MATPOWER/mx-sdp_pf/ for more info.
0012 
0013 if nargin < 1
0014     quiet = 0;
0015 end
0016 
0017 num_tests = 36;
0018 
0019 t_begin(num_tests, quiet);
0020 
0021 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0022     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0023 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0024     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0025     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0026 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0027     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0028     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0029 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0030 
0031 casefile = 't_case9mod_opf';
0032 if quiet
0033     verbose = 0;
0034 else
0035     verbose = 0;
0036 end
0037 
0038 if have_feature('octave')
0039     if have_feature('octave', 'vnum') >= 4
0040         file_in_path_warn_id = 'Octave:data-file-in-path';
0041     else
0042         file_in_path_warn_id = 'Octave:load-file-in-path';
0043     end
0044     s1 = warning('query', file_in_path_warn_id);
0045     warning('off', file_in_path_warn_id);
0046 end
0047 
0048 t0 = 'SDPOPF : ';
0049 mpopt = mpoption('opf.violation', 1e-6);
0050 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose, ...
0051     'opf.ac.solver', 'SDPOPF', 'sdp_pf.eps_r', 0);
0052 
0053 %% set up indices
0054 ib_data     = [1:BUS_AREA BASE_KV:VMIN];
0055 ib_voltage  = [VM VA];
0056 ib_lam      = [LAM_P LAM_Q];
0057 ib_mu       = [MU_VMAX MU_VMIN];
0058 ig_data     = [GEN_BUS QMAX QMIN MBASE:APF];
0059 ig_disp     = [PG QG VG];
0060 ig_mu       = (MU_PMAX:MU_QMIN);
0061 ibr_data    = (1:ANGMAX);
0062 ibr_flow    = (PF:QT);
0063 ibr_mu      = [MU_SF MU_ST];
0064 ibr_angmu   = [MU_ANGMIN MU_ANGMAX];
0065 
0066 %% get solved AC power flow case from MAT-file
0067 load soln9mod_opf;     %% defines bus_soln, gen_soln, branch_soln, f_soln
0068 
0069 %% run OPF
0070 t = t0;
0071 [baseMVA, bus, gen, gencost, branch, f, success, et] = runopf(casefile, mpopt);
0072 t_ok(success, [t 'success']);
0073 t_is(f, f_soln, 3, [t 'f']);
0074 t_is(   bus(:,ib_data   ),    bus_soln(:,ib_data   ), 10, [t 'bus data']);
0075 t_is(   bus(:,ib_voltage),    bus_soln(:,ib_voltage),  2.7, [t 'bus voltage']);
0076 t_is(   bus(:,ib_lam    ),    bus_soln(:,ib_lam    ),  3, [t 'bus lambda']);
0077 t_is(   bus(:,ib_mu     ),    bus_soln(:,ib_mu     ),  1, [t 'bus mu']);
0078 t_is(   gen(:,ig_data   ),    gen_soln(:,ig_data   ), 10, [t 'gen data']);
0079 t_is(   gen(:,ig_disp   ),    gen_soln(:,ig_disp   ),  2, [t 'gen dispatch']);
0080 t_is(   gen(:,ig_mu     ),    gen_soln(:,ig_mu     ),  3, [t 'gen mu']);
0081 t_is(branch(:,ibr_data  ), branch_soln(:,ibr_data  ), 10, [t 'branch data']);
0082 t_is(branch(:,ibr_flow  ), branch_soln(:,ibr_flow  ),  2, [t 'branch flow']);
0083 t_is(branch(:,ibr_mu    ), branch_soln(:,ibr_mu    ),  2, [t 'branch mu']);
0084 
0085 %% run with automatic conversion of single-block pwl to linear costs
0086 t = [t0 '(single-block PWL) : '];
0087 mpc = loadcase(casefile);
0088 mpc.gencost(3, NCOST) = 2;
0089 [r, success] = runopf(mpc, mpopt);
0090 [f, bus, gen, branch] = deal(r.f, r.bus, r.gen, r.branch);
0091 t_ok(success, [t 'success']);
0092 t_is(f, f_soln, 3, [t 'f']);
0093 t_is(   bus(:,ib_data   ),    bus_soln(:,ib_data   ), 10, [t 'bus data']);
0094 t_is(   bus(:,ib_voltage),    bus_soln(:,ib_voltage),  2.7, [t 'bus voltage']);
0095 t_is(   bus(:,ib_lam    ),    bus_soln(:,ib_lam    ),  3, [t 'bus lambda']);
0096 t_is(   bus(:,ib_mu     ),    bus_soln(:,ib_mu     ),  1, [t 'bus mu']);
0097 t_is(   gen(:,ig_data   ),    gen_soln(:,ig_data   ), 10, [t 'gen data']);
0098 t_is(   gen(:,ig_disp   ),    gen_soln(:,ig_disp   ),  2, [t 'gen dispatch']);
0099 t_is(   gen(:,ig_mu     ),    gen_soln(:,ig_mu     ),  3, [t 'gen mu']);
0100 t_is(branch(:,ibr_data  ), branch_soln(:,ibr_data  ), 10, [t 'branch data']);
0101 t_is(branch(:,ibr_flow  ), branch_soln(:,ibr_flow  ),  2, [t 'branch flow']);
0102 t_is(branch(:,ibr_mu    ), branch_soln(:,ibr_mu    ),  2, [t 'branch mu']);
0103 
0104 %% get solved AC power flow case from MAT-file
0105 load soln9mod_opf_Plim;       %% defines bus_soln, gen_soln, branch_soln, f_soln
0106 
0107 %% run OPF with active power line limits
0108 t = [t0 '(P line lim) : '];
0109 mpopt1 = mpoption(mpopt, 'opf.flow_lim', 'P');
0110 [baseMVA, bus, gen, gencost, branch, f, success, et] = runopf(casefile, mpopt1);
0111 t_ok(success, [t 'success']);
0112 t_is(f, f_soln, 3, [t 'f']);
0113 t_is(   bus(:,ib_data   ),    bus_soln(:,ib_data   ), 10, [t 'bus data']);
0114 t_is(   bus(:,ib_voltage),    bus_soln(:,ib_voltage),  2.7, [t 'bus voltage']);
0115 t_is(   bus(:,ib_lam    ),    bus_soln(:,ib_lam    ),  3, [t 'bus lambda']);
0116 t_is(   bus(:,ib_mu     ),    bus_soln(:,ib_mu     ),  1, [t 'bus mu']);
0117 t_is(   gen(:,ig_data   ),    gen_soln(:,ig_data   ), 10, [t 'gen data']);
0118 t_is(   gen(:,ig_disp   ),    gen_soln(:,ig_disp   ),  1.3, [t 'gen dispatch']);
0119 t_is(   gen(:,ig_mu     ),    gen_soln(:,ig_mu     ),  3, [t 'gen mu']);
0120 t_is(branch(:,ibr_data  ), branch_soln(:,ibr_data  ), 10, [t 'branch data']);
0121 t_is(branch(:,ibr_flow  ), branch_soln(:,ibr_flow  ),  1.3, [t 'branch flow']);
0122 t_is(branch(:,ibr_mu    ), branch_soln(:,ibr_mu    ),  2, [t 'branch mu']);
0123 
0124 if have_feature('octave')
0125     warning(s1.state, file_in_path_warn_id);
0126 end
0127 
0128 t_end;

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