0001 function t_opf_userfcns(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
0034 if nargin < 1
0035 quiet = 0;
0036 end
0037
0038 t_begin(38, quiet);
0039
0040 casefile = 't_case30_userfcns';
0041 if quiet
0042 verbose = 0;
0043 else
0044 verbose = 0;
0045 end
0046 mpopt = mpoption('OPF_VIOLATION', 1e-6, 'PDIPM_GRADTOL', 1e-8, ...
0047 'PDIPM_COMPTOL', 1e-8, 'PDIPM_COSTTOL', 1e-9);
0048 mpopt = mpoption(mpopt, 'OUT_ALL', 0, 'VERBOSE', verbose);
0049 mpopt = mpoption(mpopt, 'OPF_ALG', 560, 'OPF_ALG_DC', 200);
0050
0051
0052 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0053 TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0054 ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0055 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0056 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0057 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0058
0059 s6 = warning('query', 'MATLAB:nearlySingularMatrixUMFPACK');
0060 warning('off', 'MATLAB:nearlySingularMatrixUMFPACK');
0061
0062
0063 t = 'fixed reserves : ';
0064 mpc = loadcase(casefile);
0065 mpc = toggle_reserves(mpc, 'on');
0066 r = runopf(mpc, mpopt);
0067 t_ok(r.success, [t 'success']);
0068 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'reserves.R']);
0069 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 4, [t 'reserves.prc']);
0070 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0071 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0072 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0073 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0074 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0075
0076 t = 'toggle_reserves(mpc, ''off'') : ';
0077 mpc = toggle_reserves(mpc, 'off');
0078 r = runopf(mpc, mpopt);
0079 t_ok(r.success, [t 'success']);
0080 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0081 t_ok(~isfield(r.if, 'P'), [t 'no iflims']);
0082
0083 t = 'interface flow lims (DC) : ';
0084 mpc = loadcase(casefile);
0085 mpc = toggle_iflims(mpc, 'on');
0086 r = rundcopf(mpc, mpopt);
0087 t_ok(r.success, [t 'success']);
0088 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0089 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0090 t_is(r.if.mu.u, [0; 13.2573], 4, [t 'if.mu.u']);
0091 t_is(r.branch(14, PF), 8.244, 3, [t 'flow in branch 14']);
0092 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0093
0094 t = 'reserves + interface flow lims (DC) : ';
0095 mpc = loadcase(casefile);
0096 mpc = toggle_reserves(mpc, 'on');
0097 mpc = toggle_iflims(mpc, 'on');
0098 r = rundcopf(mpc, mpopt);
0099 t_ok(r.success, [t 'success']);
0100 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0101 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0102 t_is(r.if.mu.u, [0; 38.2573], 4, [t 'if.mu.u']);
0103 t_is(r.reserves.R, [25; 15; 0; 0; 16.9; 3.1], 4, [t 'reserves.R']);
0104 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 4, [t 'reserves.prc']);
0105 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 4, [t 'reserves.mu.Pmax']);
0106 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 4, [t 'reserves.mu.l']);
0107 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 4, [t 'reserves.mu.u']);
0108 t_is(r.reserves.totalcost, 179.05, 4, [t 'totalcost']);
0109
0110 t = 'interface flow lims (AC) : ';
0111 mpc = toggle_reserves(mpc, 'off');
0112 r = runopf(mpc, mpopt);
0113 t_ok(r.success, [t 'success']);
0114 t_is(r.if.P, [-9.101; 21.432], 3, [t 'if.P']);
0115 t_is(r.if.mu.l, [0; 0], 4, [t 'if.mu.l']);
0116 t_is(r.if.mu.u, [0; 10.198], 3, [t 'if.mu.u']);
0117 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0118
0119 t = 'interface flow lims (line out) : ';
0120 mpc = loadcase(casefile);
0121 mpc = toggle_iflims(mpc, 'on');
0122 mpc.branch(12, BR_STATUS) = 0;
0123 r = rundcopf(mpc, mpopt);
0124 t_ok(r.success, [t 'success']);
0125 t_is(r.if.P, [-15; 20], 4, [t 'if.P']);
0126 t_is(r.if.mu.l, [4.8427; 0], 4, [t 'if.mu.l']);
0127 t_is(r.if.mu.u, [0; 13.2573], 4, [t 'if.mu.u']);
0128 t_is(r.branch(14, PF), 10.814, 3, [t 'flow in branch 14']);
0129 t_ok(~isfield(r.reserves, 'R'), [t 'no reserves']);
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 warning(s6.state, 'MATLAB:nearlySingularMatrixUMFPACK');
0143
0144 t_end;