Home > matpower5.0 > t > t_cpf.m

t_cpf

PURPOSE ^

T_CPF Tests for continuation power flow.

SYNOPSIS ^

function res = t_cpf(quiet)

DESCRIPTION ^

T_CPF  Tests for continuation power flow.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function res = t_cpf(quiet)
0002 %T_CPF  Tests for continuation power flow.
0003 
0004 %   MATPOWER
0005 %   $Id: t_cpf.m 2235 2013-12-11 13:44:13Z ray $
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %   Copyright (c) 2013 by Power System Engineering Research Center (PSERC)
0008 %
0009 %   This file is part of MATPOWER.
0010 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0011 %
0012 %   MATPOWER is free software: you can redistribute it and/or modify
0013 %   it under the terms of the GNU General Public License as published
0014 %   by the Free Software Foundation, either version 3 of the License,
0015 %   or (at your option) any later version.
0016 %
0017 %   MATPOWER is distributed in the hope that it will be useful,
0018 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0019 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0020 %   GNU General Public License for more details.
0021 %
0022 %   You should have received a copy of the GNU General Public License
0023 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0024 %
0025 %   Additional permission under GNU GPL version 3 section 7
0026 %
0027 %   If you modify MATPOWER, or any covered work, to interface with
0028 %   other modules (such as MATLAB code and MEX-files) available in a
0029 %   MATLAB(R) or comparable environment containing parts covered
0030 %   under other licensing terms, the licensors of MATPOWER grant
0031 %   you additional permission to convey the resulting work.
0032 
0033 if nargin < 1
0034     quiet = 0;
0035 end
0036 
0037 t_begin(81, quiet);
0038 plot_nose_curve = 0;
0039 verbose = 0;
0040 
0041 casefile = 't_case9_pfv2';
0042 if have_fcn('octave')
0043     s1 = warning('query', 'Octave:load-file-in-path');
0044     warning('off', 'Octave:load-file-in-path');
0045 end
0046 mpopt = mpoption('out.all', 0, 'verbose', verbose);
0047 %mpopt = mpoption(mpopt, 'cpf.stop_at', 'FULL', );
0048 mpopt = mpoption(mpopt, 'cpf.step', 0.02);
0049 %mpopt = mpoption(mpopt, 'cpf.adapt_step', 1);
0050 %mpopt = mpoption(mpopt, 'cpf.error_tol', 2e-5);
0051 mpopt = mpoption(mpopt, 'cpf.plot.level', plot_nose_curve);
0052 %mpopt = mpoption(mpopt, 'cpf.plot.bus', 9);
0053 
0054 %% define named indices into bus, gen, branch matrices
0055 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0056     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0057 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0058     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0059     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0060 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0061     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0062     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0063 
0064 %% set up base and target cases
0065 mpcb = loadcase(casefile);
0066 %% add isolated bus to make sure int2ext works for V_p, V_c
0067 mpcb.bus = [mpcb.bus(1:3, :); mpcb.bus(3, :); mpcb.bus(4:end, :)];
0068 mpcb.bus(4, BUS_I) = 50;
0069 mpcb.bus(4, BUS_TYPE) = NONE;
0070 % r = runpf(mpcb, mpopt);
0071 % mpcb.gen(1, [PG QG]) = r.gen(1, [PG QG]); %% solved values for slack gen
0072 mpct = mpcb;
0073 factor = 2.5;
0074 mpct.gen(:, [PG QG]) = mpct.gen(:, [PG QG]) * factor;
0075 mpct.bus(:, [PD QD]) = mpct.bus(:, [PD QD]) * factor;
0076 
0077 %% run CPF
0078 t = 'Continuation PF to lambda = 0.7 (natural) : ';
0079 mpopt = mpoption(mpopt, 'cpf.stop_at', 0.7, 'cpf.parameterization', 1);
0080 r = runcpf(mpcb, mpct, mpopt);
0081 iterations = 35;
0082 t_ok(r.success, [t 'success']);
0083 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0084 t_is(r.cpf.max_lam, 0.7, 12, [t 'max_lam']);
0085 t_is(size(r.cpf.V_p), [10 iterations+1], 12, [t 'size(V_p)']);
0086 t_is(size(r.cpf.V_c), [10 iterations+1], 12, [t 'size(V_c)']);
0087 t_is(size(r.cpf.lam_p), [1 iterations+1], 12, [t 'size(lam_p)']);
0088 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0089 
0090 t = 'Continuation PF to lambda = 0.7 (arc length) : ';
0091 mpopt = mpoption(mpopt, 'cpf.stop_at', 0.7, 'cpf.parameterization', 2);
0092 r = runcpf(mpcb, mpct, mpopt);
0093 iterations = 41;
0094 t_ok(r.success, [t 'success']);
0095 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0096 t_is(r.cpf.max_lam, 0.7, 12, [t 'max_lam']);
0097 t_is(size(r.cpf.V_p), [10 iterations+1], 12, [t 'size(V_p)']);
0098 t_is(size(r.cpf.V_c), [10 iterations+1], 12, [t 'size(V_c)']);
0099 t_is(size(r.cpf.lam_p), [1 iterations+1], 12, [t 'size(lam_p)']);
0100 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0101 
0102 t = 'Continuation PF to lambda = 0.7 (pseudo arc length) : ';
0103 mpopt = mpoption(mpopt, 'cpf.stop_at', 0.7, 'cpf.parameterization', 3);
0104 r = runcpf(mpcb, mpct, mpopt);
0105 iterations = 41;
0106 t_ok(r.success, [t 'success']);
0107 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0108 t_is(r.cpf.max_lam, 0.7, 12, [t 'max_lam']);
0109 t_is(size(r.cpf.V_p), [10 iterations+1], 12, [t 'size(V_p)']);
0110 t_is(size(r.cpf.V_c), [10 iterations+1], 12, [t 'size(V_c)']);
0111 t_is(size(r.cpf.lam_p), [1 iterations+1], 12, [t 'size(lam_p)']);
0112 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0113 
0114 t = 'Continuation PF to nose point (arc length) : ';
0115 mpopt = mpoption(mpopt, 'cpf.stop_at', 'NOSE', 'cpf.parameterization', 2);
0116 mpopt = mpoption(mpopt, 'cpf.adapt_step', 1);
0117 r = runcpf(mpcb, mpct, mpopt);
0118 iterations = 22;
0119 t_ok(r.success, [t 'success']);
0120 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0121 t_is(r.cpf.max_lam, 0.99025, 3, [t 'max_lam']);
0122 t_is(size(r.cpf.V_p), [10 iterations+1], 12, [t 'size(V_p)']);
0123 t_is(size(r.cpf.V_c), [10 iterations+1], 12, [t 'size(V_c)']);
0124 t_is(size(r.cpf.lam_p), [1 iterations+1], 12, [t 'size(lam_p)']);
0125 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0126 
0127 t = 'Continuation PF to nose point (pseudo arc length) : ';
0128 mpopt = mpoption(mpopt, 'cpf.stop_at', 'NOSE', 'cpf.parameterization', 3);
0129 mpopt = mpoption(mpopt, 'cpf.adapt_step', 1);
0130 r = runcpf(mpcb, mpct, mpopt);
0131 iterations = 22;
0132 t_ok(r.success, [t 'success']);
0133 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0134 t_is(r.cpf.max_lam, 0.99025, 3, [t 'max_lam']);
0135 t_is(size(r.cpf.V_p), [10 iterations+1], 12, [t 'size(V_p)']);
0136 t_is(size(r.cpf.V_c), [10 iterations+1], 12, [t 'size(V_c)']);
0137 t_is(size(r.cpf.lam_p), [1 iterations+1], 12, [t 'size(lam_p)']);
0138 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0139 
0140 t = 'Continuation PF (full trace) (arc length) : ';
0141 mpopt = mpoption(mpopt, 'cpf.stop_at', 'FULL', 'cpf.parameterization', 2);
0142 r = runcpf(mpcb, mpct, mpopt);
0143 iterations = 45;
0144 t_ok(r.success, [t 'success']);
0145 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0146 t_is(r.cpf.max_lam, 0.99025, 3, [t 'max_lam']);
0147 t_is(size(r.cpf.V_p), [10 iterations+1], 12, [t 'size(V_p)']);
0148 t_is(size(r.cpf.V_c), [10 iterations+1], 12, [t 'size(V_c)']);
0149 t_is(size(r.cpf.lam_p), [1 iterations+1], 12, [t 'size(lam_p)']);
0150 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0151 
0152 t = 'Continuation PF (full trace) (pseudo arc length) : ';
0153 mpopt = mpoption(mpopt, 'cpf.stop_at', 'FULL', 'cpf.parameterization', 3);
0154 r = runcpf(mpcb, mpct, mpopt);
0155 iterations = 45;
0156 t_ok(r.success, [t 'success']);
0157 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0158 t_is(r.cpf.max_lam, 0.99025, 3, [t 'max_lam']);
0159 t_is(size(r.cpf.V_p), [10 iterations+1], 12, [t 'size(V_p)']);
0160 t_is(size(r.cpf.V_c), [10 iterations+1], 12, [t 'size(V_c)']);
0161 t_is(size(r.cpf.lam_p), [1 iterations+1], 12, [t 'size(lam_p)']);
0162 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0163 
0164 t = '1 user callback : ';
0165 mpopt = mpoption(mpopt, 'cpf.stop_at', 0.7, 'cpf.parameterization', 3);
0166 mpopt = mpoption(mpopt, 'cpf.adapt_step', 1);
0167 mpopt = mpoption(mpopt, 'cpf.user_callback', 't_cpf_cb1');
0168 r = runcpf(mpcb, mpct, mpopt);
0169 iterations = 7;
0170 t_ok(r.success, [t 'success']);
0171 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0172 t_is(r.cpf.max_lam, 0.7, 12, [t 'max_lam']);
0173 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0174 t_ok(isfield(r.cpf, 'cb1'), [t 'isfield cpf.cb1']);
0175 t_ok(isstruct(r.cpf.cb1), [t 'isstruct cpf.cb1']);
0176 t_ok(isfield(r.cpf.cb1, 'initial'), [t 'isfield cpf.cb1.initial']);
0177 t_ok(isfield(r.cpf.cb1, 'iteration'), [t 'isfield cpf.cb1.iteration']);
0178 t_ok(isfield(r.cpf.cb1, 'final'), [t 'isfield cpf.cb1.final']);
0179 t_is(r.cpf.cb1.initial, 1, 12, [t 'r.cpf.cb1.initial']);
0180 t_is(r.cpf.cb1.iteration, iterations, 12, [t 'r.cpf.cb1.iterations']);
0181 t_is(r.cpf.cb1.final, 1, 12, [t 'r.cpf.cb1.final']);
0182 
0183 t = '2 user callbacks (with args) : ';
0184 mpopt = mpoption(mpopt, 'cpf.user_callback', {'t_cpf_cb1', 't_cpf_cb2'});
0185 cb_args = struct('cb2', struct('initial', 20, 'iteration', 2, 'final', 200));
0186 mpopt = mpoption(mpopt, 'cpf.user_callback_args', cb_args);
0187 r = runcpf(mpcb, mpct, mpopt);
0188 iterations = 7;
0189 t_ok(r.success, [t 'success']);
0190 t_is(r.cpf.iterations, iterations, 12, [t 'iterations']);
0191 t_is(r.cpf.max_lam, 0.7, 12, [t 'max_lam']);
0192 t_is(size(r.cpf.lam_c), [1 iterations+1], 12, [t 'size(lam_c)']);
0193 t_ok(isfield(r.cpf, 'cb1'), [t 'isfield cpf.cb1']);
0194 t_ok(isstruct(r.cpf.cb1), [t 'isstruct cpf.cb1']);
0195 t_ok(isfield(r.cpf.cb1, 'initial'), [t 'isfield cpf.cb1.initial']);
0196 t_ok(isfield(r.cpf.cb1, 'iteration'), [t 'isfield cpf.cb1.iteration']);
0197 t_ok(isfield(r.cpf.cb1, 'final'), [t 'isfield cpf.cb1.final']);
0198 t_is(r.cpf.cb1.initial, 1, 12, [t 'r.cpf.cb1.initial']);
0199 t_is(r.cpf.cb1.iteration, iterations, 12, [t 'r.cpf.cb1.iterations']);
0200 t_is(r.cpf.cb1.final, 1, 12, [t 'r.cpf.cb1.final']);
0201 t_ok(isfield(r.cpf, 'cb2'), [t 'isfield cpf.cb2']);
0202 t_ok(isstruct(r.cpf.cb2), [t 'isstruct cpf.cb2']);
0203 t_ok(isfield(r.cpf.cb2, 'initial'), [t 'isfield cpf.cb2.initial']);
0204 t_ok(isfield(r.cpf.cb2, 'iteration'), [t 'isfield cpf.cb2.iteration']);
0205 t_ok(isfield(r.cpf.cb2, 'final'), [t 'isfield cpf.cb2.final']);
0206 t_is(r.cpf.cb2.initial, 20, 12, [t 'r.cpf.cb2.initial']);
0207 t_is(r.cpf.cb2.iteration, 2*iterations, 12, [t 'r.cpf.cb2.iterations']);
0208 t_is(r.cpf.cb2.final, 200, 12, [t 'r.cpf.cb2.final']);
0209 
0210 if have_fcn('octave')
0211     warning(s1.state, 'Octave:load-file-in-path');
0212 end
0213 
0214 t_end;
0215 
0216 if nargout
0217     res = r;
0218 end

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005