0001 function res = t_cpf(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
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
0048 mpopt = mpoption(mpopt, 'cpf.step', 0.02);
0049
0050
0051 mpopt = mpoption(mpopt, 'cpf.plot.level', plot_nose_curve);
0052
0053
0054
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
0065 mpcb = loadcase(casefile);
0066
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
0071
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
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