0001 function t_runopf_w_res(quiet)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 if nargin < 1
0015 quiet = 0;
0016 end
0017
0018 t_begin(46, quiet);
0019
0020 if quiet
0021 verbose = 0;
0022 else
0023 verbose = 0;
0024 end
0025
0026 casefile = 't_case30_userfcns';
0027 mpopt = mpoption('opf.violation', 1e-6, 'mips.gradtol', 1e-8, ...
0028 'mips.comptol', 1e-8, 'mips.costtol', 1e-9);
0029 mpopt = mpoption(mpopt, 'out.all', 0, 'verbose', verbose, 'opf.ac.solver', 'MIPS');
0030
0031
0032 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0033 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0034 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0035
0036 t = 'runopf_w_res(''t_case30_userfcns'') : ';
0037 r = runopf_w_res(casefile, mpopt);
0038 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0039 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0040 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0041 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0042 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0043 mpc = loadcase(casefile);
0044 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0045 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0046 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0047
0048 t = 'gen 5 no reserves : ';
0049 mpc = loadcase(casefile);
0050 mpc.reserves.zones(:, 5) = 0;
0051 mpc.reserves.cost(5) = [];
0052 mpc.reserves.qty(5) = [];
0053 r = runopf_w_res(mpc, mpopt);
0054 t_is(r.reserves.R, [25; 15; 0; 0; 0; 20], 4, [t 'R']);
0055 t_is(r.reserves.prc, [2; 2; 2; 2; 0; 5.5], 6, [t 'prc']);
0056 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0057 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0058 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0059 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0060 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0061 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0062
0063 t = 'extra offline gen : ';
0064 mpc = loadcase(casefile);
0065 idx = [1:3 5 4:6];
0066 mpc.gen = mpc.gen(idx, :);
0067 mpc.gencost = mpc.gencost(idx, :);
0068 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0069 mpc.reserves.cost = mpc.reserves.cost(idx);
0070 mpc.reserves.qty = mpc.reserves.qty(idx);
0071 mpc.gen(4, GEN_STATUS) = 0;
0072 r = runopf_w_res(mpc, mpopt);
0073 t_is(r.reserves.R, [25; 15; 0; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0074 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 5.5; 5.5], 6, [t 'prc']);
0075 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0076 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0077 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0078 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0079 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0080 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0081
0082 t = 'both extra & gen 6 no res : ';
0083 mpc = loadcase(casefile);
0084 idx = [1:3 5 4:6];
0085 mpc.gen = mpc.gen(idx, :);
0086 mpc.gencost = mpc.gencost(idx, :);
0087 mpc.reserves.zones = mpc.reserves.zones(:, idx);
0088 mpc.reserves.cost = mpc.reserves.cost(idx);
0089 mpc.reserves.qty = mpc.reserves.qty(idx);
0090 mpc.gen(4, GEN_STATUS) = 0;
0091 mpc.reserves.zones(:, 6) = 0;
0092 mpc.reserves.cost(6) = [];
0093 mpc.reserves.qty(6) = [];
0094 r = runopf_w_res(mpc, mpopt);
0095 t_is(r.reserves.R, [25; 15; 0; 0; 0; 0; 20], 4, [t 'R']);
0096 t_is(r.reserves.prc, [2; 2; 2; 5.5; 2; 0; 5.5], 6, [t 'prc']);
0097 t_is(r.reserves.mu.l, [0; 0; 1; 0; 2; 0; 0], 7, [t 'mu.l']);
0098 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0; 0], 6, [t 'mu.u']);
0099 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0; 0; 0], 7, [t 'mu.Pmax']);
0100 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0101 t_is(r.reserves.qty, mpc.reserves.qty, 12, [t 'qty']);
0102 t_is(r.reserves.totalcost, 187.5, 4, [t 'totalcost']);
0103
0104 t = 'no qty (Rmax) : ';
0105 mpc = loadcase(casefile);
0106 mpc.reserves = rmfield(mpc.reserves, 'qty');
0107 r = runopf_w_res(mpc, mpopt);
0108 t_is(r.reserves.R, [39.3826; 0.6174; 0; 0; 19.3818; 0.6182], 4, [t 'R']);
0109 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 5, [t 'prc']);
0110 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 5, [t 'mu.l']);
0111 t_is(r.reserves.mu.u, [0; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0112 t_is(r.reserves.mu.Pmax, [0.1; 0; 0; 0; 0.5; 0], 5, [t 'mu.Pmax']);
0113 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0114 t_is(r.reserves.totalcost, 176.3708, 4, [t 'totalcost']);
0115
0116 t = 'RAMP_10, no qty (Rmax) : ';
0117 mpc = loadcase(casefile);
0118 mpc.reserves = rmfield(mpc.reserves, 'qty');
0119 mpc.gen(1, RAMP_10) = 25;
0120 r = runopf_w_res(mpc, mpopt);
0121 t_is(r.reserves.R, [25; 15; 0; 0; 19.3906; 0.6094], 4, [t 'R']);
0122 t_is(r.reserves.prc, [2; 2; 2; 2; 5.5; 5.5], 6, [t 'prc']);
0123 t_is(r.reserves.mu.l, [0; 0; 1; 2; 0; 0], 7, [t 'mu.l']);
0124 t_is(r.reserves.mu.u, [0.1; 0; 0; 0; 0; 0], 7, [t 'mu.u']);
0125 t_is(r.reserves.mu.Pmax, [0; 0; 0; 0; 0.5; 0], 7, [t 'mu.Pmax']);
0126 t_is(r.reserves.cost, mpc.reserves.cost, 12, [t 'cost']);
0127 t_is(r.reserves.totalcost, 177.8047, 4, [t 'totalcost']);
0128
0129 t_end;