0001 function t_pf(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(25, quiet);
0038
0039 casefile = 't_case9_pf';
0040 if quiet
0041 verbose = 0;
0042 else
0043 verbose = 1;
0044 end
0045 if have_fcn('octave')
0046 s1 = warning('query', 'Octave:load-file-in-path');
0047 warning('off', 'Octave:load-file-in-path');
0048 end
0049 mpopt = mpoption('OUT_ALL', 0, 'VERBOSE', verbose);
0050
0051 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0052 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0053 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0054
0055
0056 load soln9_pf;
0057
0058
0059 t = 'Newton PF : ';
0060 mpopt = mpoption(mpopt, 'PF_ALG', 1);
0061 [baseMVA, bus, gen, branch, success, et] = runpf(casefile, mpopt);
0062 t_ok(success, [t 'success']);
0063 t_is(bus, bus_soln, 6, [t 'bus']);
0064 t_is(gen, gen_soln, 6, [t 'gen']);
0065 t_is(branch, branch_soln, 6, [t 'branch']);
0066
0067
0068 t = 'Fast Decoupled (XB) PF : ';
0069 mpopt = mpoption(mpopt, 'PF_ALG', 2);
0070 [baseMVA, bus, gen, branch, success, et] = runpf(casefile, mpopt);
0071 t_ok(success, [t 'success']);
0072 t_is(bus, bus_soln, 6, [t 'bus']);
0073 t_is(gen, gen_soln, 6, [t 'gen']);
0074 t_is(branch, branch_soln, 6, [t 'branch']);
0075
0076
0077 t = 'Fast Decoupled (BX) PF : ';
0078 mpopt = mpoption(mpopt, 'PF_ALG', 3);
0079 [baseMVA, bus, gen, branch, success, et] = runpf(casefile, mpopt);
0080 t_ok(success, [t 'success']);
0081 t_is(bus, bus_soln, 6, [t 'bus']);
0082 t_is(gen, gen_soln, 6, [t 'gen']);
0083 t_is(branch, branch_soln, 6, [t 'branch']);
0084
0085
0086 t = 'Gauss-Seidel PF : ';
0087 mpopt = mpoption(mpopt, 'PF_ALG', 4);
0088 [baseMVA, bus, gen, branch, success, et] = runpf(casefile, mpopt);
0089 t_ok(success, [t 'success']);
0090 t_is(bus, bus_soln, 5, [t 'bus']);
0091 t_is(gen, gen_soln, 5, [t 'gen']);
0092 t_is(branch, branch_soln, 5, [t 'branch']);
0093
0094
0095 load soln9_dcpf;
0096
0097
0098 t = 'DC PF : ';
0099 [baseMVA, bus, gen, branch, success, et] = rundcpf(casefile, mpopt);
0100 t_ok(success, [t 'success']);
0101 t_is(bus, bus_soln, 6, [t 'bus']);
0102 t_is(gen, gen_soln, 6, [t 'gen']);
0103 t_is(branch, branch_soln, 6, [t 'branch']);
0104
0105
0106 t = 'check Qg : ';
0107 mpopt = mpoption(mpopt, 'PF_ALG', 1, 'VERBOSE', 0);
0108 mpc = loadcase(casefile);
0109 mpc.gen(1, [QMIN QMAX]) = [20 20];
0110 [baseMVA, bus, gen, branch, success, et] = runpf(mpc, mpopt);
0111 t_is(gen(1, QG), 24.07, 2, [t 'single gen, Qmin = Qmax']);
0112
0113 mpc.gen = [mpc.gen(1, :); mpc.gen];
0114 mpc.gen(1, [QMIN QMAX]) = [10 10];
0115 mpc.gen(2, [QMIN QMAX]) = [0 50];
0116 [baseMVA, bus, gen, branch, success, et] = runpf(mpc, mpopt);
0117 t_is(gen(1:2, QG), [10; 14.07], 2, [t '2 gens, Qmin = Qmax for one']);
0118
0119 mpc.gen(1, [QMIN QMAX]) = [10 10];
0120 mpc.gen(2, [QMIN QMAX]) = [-50 -50];
0121 [baseMVA, bus, gen, branch, success, et] = runpf(mpc, mpopt);
0122 t_is(gen(1:2, QG), [12.03; 12.03], 2, [t '2 gens, Qmin = Qmax for both']);
0123
0124 mpc.gen(1, [QMIN QMAX]) = [0 50];
0125 mpc.gen(2, [QMIN QMAX]) = [0 100];
0126 [baseMVA, bus, gen, branch, success, et] = runpf(mpc, mpopt);
0127 t_is(gen(1:2, QG), [8.02; 16.05], 2, [t '2 gens, proportional']);
0128
0129 mpc.gen(1, [QMIN QMAX]) = [-50 0];
0130 mpc.gen(2, [QMIN QMAX]) = [50 150];
0131 [baseMVA, bus, gen, branch, success, et] = runpf(mpc, mpopt);
0132 t_is(gen(1:2, QG), [-50+8.02; 50+16.05], 2, [t '2 gens, proportional']);
0133
0134 if have_fcn('octave')
0135 warning(s1.state, 'Octave:load-file-in-path');
0136 end
0137
0138 t_end;