Home > matpower5.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-2015 by Power System Engineering Research Center (PSERC)
0006 %   by Daniel Molzahn, PSERC U of Wisc, Madison
0007 %   and Ray Zimmerman, PSERC Cornell
0008 %
0009 %   $Id: t_opf_sdpopf.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 num_tests = 36;
0020 
0021 t_begin(num_tests, quiet);
0022 
0023 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0024     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0025 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0026     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0027     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0028 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0029     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0030     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0031 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0032 
0033 casefile = 't_case9mod_opf';
0034 if quiet
0035     verbose = 0;
0036 else
0037     verbose = 0;
0038 end
0039 
0040 t0 = 'SDPOPF : ';
0041 mpopt = mpoption('opf.violation', 1e-6);
0042 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose, ...
0043     'opf.ac.solver', 'SDPOPF', 'sdp_pf.eps_r', 0);
0044 
0045 %% set up indices
0046 ib_data     = [1:BUS_AREA BASE_KV:VMIN];
0047 ib_voltage  = [VM VA];
0048 ib_lam      = [LAM_P LAM_Q];
0049 ib_mu       = [MU_VMAX MU_VMIN];
0050 ig_data     = [GEN_BUS QMAX QMIN MBASE:APF];
0051 ig_disp     = [PG QG VG];
0052 ig_mu       = (MU_PMAX:MU_QMIN);
0053 ibr_data    = (1:ANGMAX);
0054 ibr_flow    = (PF:QT);
0055 ibr_mu      = [MU_SF MU_ST];
0056 ibr_angmu   = [MU_ANGMIN MU_ANGMAX];
0057 
0058 %% get solved AC power flow case from MAT-file
0059 load soln9mod_opf;     %% defines bus_soln, gen_soln, branch_soln, f_soln
0060 
0061 %% run OPF
0062 t = t0;
0063 [baseMVA, bus, gen, gencost, branch, f, success, et] = runopf(casefile, mpopt);
0064 t_ok(success, [t 'success']);
0065 t_is(f, f_soln, 3, [t 'f']);
0066 t_is(   bus(:,ib_data   ),    bus_soln(:,ib_data   ), 10, [t 'bus data']);
0067 t_is(   bus(:,ib_voltage),    bus_soln(:,ib_voltage),  3, [t 'bus voltage']);
0068 t_is(   bus(:,ib_lam    ),    bus_soln(:,ib_lam    ),  3, [t 'bus lambda']);
0069 t_is(   bus(:,ib_mu     ),    bus_soln(:,ib_mu     ),  1, [t 'bus mu']);
0070 t_is(   gen(:,ig_data   ),    gen_soln(:,ig_data   ), 10, [t 'gen data']);
0071 t_is(   gen(:,ig_disp   ),    gen_soln(:,ig_disp   ),  2, [t 'gen dispatch']);
0072 t_is(   gen(:,ig_mu     ),    gen_soln(:,ig_mu     ),  3, [t 'gen mu']);
0073 t_is(branch(:,ibr_data  ), branch_soln(:,ibr_data  ), 10, [t 'branch data']);
0074 t_is(branch(:,ibr_flow  ), branch_soln(:,ibr_flow  ),  2, [t 'branch flow']);
0075 t_is(branch(:,ibr_mu    ), branch_soln(:,ibr_mu    ),  2, [t 'branch mu']);
0076 
0077 %% run with automatic conversion of single-block pwl to linear costs
0078 t = [t0 '(single-block PWL) : '];
0079 mpc = loadcase(casefile);
0080 mpc.gencost(3, NCOST) = 2;
0081 [r, success] = runopf(mpc, mpopt);
0082 [f, bus, gen, branch] = deal(r.f, r.bus, r.gen, r.branch);
0083 t_ok(success, [t 'success']);
0084 t_is(f, f_soln, 3, [t 'f']);
0085 t_is(   bus(:,ib_data   ),    bus_soln(:,ib_data   ), 10, [t 'bus data']);
0086 t_is(   bus(:,ib_voltage),    bus_soln(:,ib_voltage),  3, [t 'bus voltage']);
0087 t_is(   bus(:,ib_lam    ),    bus_soln(:,ib_lam    ),  3, [t 'bus lambda']);
0088 t_is(   bus(:,ib_mu     ),    bus_soln(:,ib_mu     ),  1, [t 'bus mu']);
0089 t_is(   gen(:,ig_data   ),    gen_soln(:,ig_data   ), 10, [t 'gen data']);
0090 t_is(   gen(:,ig_disp   ),    gen_soln(:,ig_disp   ),  2, [t 'gen dispatch']);
0091 t_is(   gen(:,ig_mu     ),    gen_soln(:,ig_mu     ),  3, [t 'gen mu']);
0092 t_is(branch(:,ibr_data  ), branch_soln(:,ibr_data  ), 10, [t 'branch data']);
0093 t_is(branch(:,ibr_flow  ), branch_soln(:,ibr_flow  ),  2, [t 'branch flow']);
0094 t_is(branch(:,ibr_mu    ), branch_soln(:,ibr_mu    ),  2, [t 'branch mu']);
0095 
0096 %% get solved AC power flow case from MAT-file
0097 load soln9mod_opf_Plim;       %% defines bus_soln, gen_soln, branch_soln, f_soln
0098 
0099 %% run OPF with active power line limits
0100 t = [t0 '(P line lim) : '];
0101 mpopt1 = mpoption(mpopt, 'opf.flow_lim', 'P');
0102 [baseMVA, bus, gen, gencost, branch, f, success, et] = runopf(casefile, mpopt1);
0103 t_ok(success, [t 'success']);
0104 t_is(f, f_soln, 3, [t 'f']);
0105 t_is(   bus(:,ib_data   ),    bus_soln(:,ib_data   ), 10, [t 'bus data']);
0106 t_is(   bus(:,ib_voltage),    bus_soln(:,ib_voltage),  3, [t 'bus voltage']);
0107 t_is(   bus(:,ib_lam    ),    bus_soln(:,ib_lam    ),  3, [t 'bus lambda']);
0108 t_is(   bus(:,ib_mu     ),    bus_soln(:,ib_mu     ),  1, [t 'bus mu']);
0109 t_is(   gen(:,ig_data   ),    gen_soln(:,ig_data   ), 10, [t 'gen data']);
0110 t_is(   gen(:,ig_disp   ),    gen_soln(:,ig_disp   ),  2, [t 'gen dispatch']);
0111 t_is(   gen(:,ig_mu     ),    gen_soln(:,ig_mu     ),  3, [t 'gen mu']);
0112 t_is(branch(:,ibr_data  ), branch_soln(:,ibr_data  ), 10, [t 'branch data']);
0113 t_is(branch(:,ibr_flow  ), branch_soln(:,ibr_flow  ),  2, [t 'branch flow']);
0114 t_is(branch(:,ibr_mu    ), branch_soln(:,ibr_mu    ),  2, [t 'branch mu']);
0115 
0116 t_end;

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