0001 function t_total_load(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 n_tests = 48;
0038
0039 t_begin(n_tests, quiet);
0040
0041
0042 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0043 VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0044 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0045 MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0046 QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0047
0048 mpc = loadcase('t_auction_case');
0049 mpc.gen(8, GEN_BUS) = 2;
0050 mpc.gen(8, [QG QMIN QMAX]) = [ 3 0 3 ];
0051
0052 mpc.gen = [mpc.gen(8, :); mpc.gen(1:7, :); mpc.gen(9, :)];
0053 ld = find(isload(mpc.gen));
0054 for k = 1:3
0055 a{k} = find(mpc.bus(:, BUS_AREA) == k);
0056 [junk, tmp, junk2] = intersect(mpc.gen(ld, GEN_BUS), a{k});
0057 lda{k} = ld(tmp);
0058 end
0059 for k = 1:3
0060 area(k).fixed.p = sum(mpc.bus(a{k}, PD));
0061 area(k).fixed.q = sum(mpc.bus(a{k}, QD));
0062 area(k).disp.p = -sum(mpc.gen(lda{k}, PMIN));
0063 area(k).disp.qmin = -sum(mpc.gen(lda{k}, QMIN));
0064 area(k).disp.qmax = -sum(mpc.gen(lda{k}, QMAX));
0065 area(k).disp.q = area(k).disp.qmin + area(k).disp.qmax;
0066 area(k).both.p = area(k).fixed.p + area(k).disp.p;
0067 area(k).both.q = area(k).fixed.q + area(k).disp.q;
0068 end
0069 total.fixed.p = sum(mpc.bus(:, PD));
0070 total.fixed.q = sum(mpc.bus(:, QD));
0071 total.disp.p = -sum(mpc.gen(ld, PMIN));
0072 total.disp.qmin = -sum(mpc.gen(ld, QMIN));
0073 total.disp.qmax = -sum(mpc.gen(ld, QMAX));
0074 total.disp.q = total.disp.qmin + total.disp.qmax;
0075 total.both.p = total.fixed.p + total.disp.p;
0076 total.both.q = total.fixed.q + total.disp.q;
0077
0078
0079 t = ' Pd = total_load(bus) : ';
0080 Pd = total_load(mpc.bus);
0081 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0082
0083 t = '[Pd, Qd] = total_load(bus) : ';
0084 [Pd, Qd] = total_load(mpc.bus);
0085 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0086 t_is(Qd, [area(1).fixed.q; area(2).fixed.q; area(3).fixed.q], 12, [t 'Qd']);
0087
0088 t = ' Pd = total_load(bus, gen) : ';
0089 Pd = total_load(mpc.bus, mpc.gen);
0090 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0091
0092 t = '[Pd, Qd] = total_load(bus, gen) : ';
0093 [Pd, Qd] = total_load(mpc.bus, mpc.gen);
0094 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0095 t_is(Qd, [area(1).both.q; area(2).both.q; area(3).both.q], 12, [t 'Qd']);
0096
0097 t = ' Pd = total_load(bus, [], ''all'') : ';
0098 Pd = total_load(mpc.bus, [], 'all');
0099 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0100
0101 t = '[Pd, Qd] = total_load(bus, [], ''all'') : ';
0102 [Pd, Qd] = total_load(mpc.bus, [], 'all');
0103 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0104 t_is(Qd, total.fixed.q, 12, [t 'Qd']);
0105
0106 t = ' Pd = total_load(bus, gen, ''all'') : ';
0107 Pd = total_load(mpc.bus, mpc.gen, 'all');
0108 t_is(Pd, total.both.p, 12, [t 'Pd']);
0109
0110 t = '[Pd, Qd] = total_load(bus, gen, ''all'') : ';
0111 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all');
0112 t_is(Pd, total.both.p, 12, [t 'Pd']);
0113 t_is(Qd, total.both.q, 12, [t 'Qd']);
0114
0115 t = ' Pd = total_load(bus, gen, ''all'', ''BOTH'') : ';
0116 Pd = total_load(mpc.bus, mpc.gen, 'all', 'BOTH');
0117 t_is(Pd, total.both.p, 12, [t 'Pd']);
0118
0119 t = '[Pd, Qd] = total_load(bus, gen, ''all'', ''BOTH'') : ';
0120 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'BOTH');
0121 t_is(Pd, total.both.p, 12, [t 'Pd']);
0122 t_is(Qd, total.both.q, 12, [t 'Qd']);
0123
0124 t = ' Pd = total_load(bus, gen, ''all'', ''FIXED'') : ';
0125 Pd = total_load(mpc.bus, mpc.gen, 'all', 'FIXED');
0126 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0127
0128 t = '[Pd, Qd] = total_load(bus, gen, ''all'', ''FIXED'') : ';
0129 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'FIXED');
0130 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0131 t_is(Qd, total.fixed.q, 12, [t 'Qd']);
0132
0133 t = ' Pd = total_load(bus, gen, ''all'', ''DISPATCHABLE'') : ';
0134 Pd = total_load(mpc.bus, mpc.gen, 'all', 'DISPATCHABLE');
0135 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0136
0137 t = '[Pd, Qd] = total_load(bus, gen, ''all'', ''DISPATCHABLE'') : ';
0138 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'DISPATCHABLE');
0139 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0140 t_is(Qd, total.disp.q, 12, [t 'Qd']);
0141
0142 t = ' Pd = total_load(bus, gen, [], ''BOTH'') : ';
0143 Pd = total_load(mpc.bus, mpc.gen, [], 'BOTH');
0144 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0145
0146 t = '[Pd, Qd] = total_load(bus, gen, [], ''BOTH'') : ';
0147 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'BOTH');
0148 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0149 t_is(Qd, [area(1).both.q; area(2).both.q; area(3).both.q], 12, [t 'Qd']);
0150
0151 t = ' Pd = total_load(bus, gen, [], ''FIXED'') : ';
0152 Pd = total_load(mpc.bus, mpc.gen, [], 'FIXED');
0153 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0154
0155 t = '[Pd, Qd] = total_load(bus, gen, [], ''FIXED'') : ';
0156 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'FIXED');
0157 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0158 t_is(Qd, [area(1).fixed.q; area(2).fixed.q; area(3).fixed.q], 12, [t 'Qd']);
0159
0160 t = ' Pd = total_load(bus, gen, [], ''DISPATCHABLE'') : ';
0161 Pd = total_load(mpc.bus, mpc.gen, [], 'DISPATCHABLE');
0162 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0163
0164 t = '[Pd, Qd] = total_load(bus, gen, [], ''DISPATCHABLE'') : ';
0165 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'DISPATCHABLE');
0166 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0167 t_is(Qd, [area(1).disp.q; area(2).disp.q; area(3).disp.q], 12, [t 'Qd']);
0168
0169
0170 nb = size(mpc.bus, 1);
0171 load_zone = zeros(nb, 1);
0172 k = find(mpc.bus(:, BUS_AREA) == 2);
0173 load_zone(k) = 1;
0174 t = ' Pd = total_load(bus, gen, load_zone1, ''BOTH'') : ';
0175 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0176 t_is(Pd, area(2).both.p, 12, [t 'Pd']);
0177
0178 t = '[Pd, Qd] = total_load(bus, gen, load_zone1, ''BOTH'') : ';
0179 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0180 t_is(Pd, area(2).both.p, 12, [t 'Pd']);
0181 t_is(Qd, area(2).both.q, 12, [t 'Qd']);
0182
0183 t = ' Pd = total_load(bus, gen, load_zone1, ''FIXED'') : ';
0184 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0185 t_is(Pd, area(2).fixed.p, 12, [t 'Pd']);
0186
0187 t = '[Pd, Qd] = total_load(bus, gen, load_zone1, ''FIXED'') : ';
0188 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0189 t_is(Pd, area(2).fixed.p, 12, [t 'Pd']);
0190 t_is(Qd, area(2).fixed.q, 12, [t 'Qd']);
0191
0192 t = ' Pd = total_load(bus, gen, load_zone1, ''DISPATCHABLE'') : ';
0193 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0194 t_is(Pd, area(2).disp.p, 12, [t 'Pd']);
0195
0196 t = '[Pd, Qd] = total_load(bus, gen, load_zone1, ''DISPATCHABLE'') : ';
0197 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0198 t_is(Pd, area(2).disp.p, 12, [t 'Pd']);
0199 t_is(Qd, area(2).disp.q, 12, [t 'Qd']);
0200
0201
0202 load_zone = zeros(nb, 1);
0203 k = find(mpc.bus(:, BUS_AREA) == 3);
0204 load_zone(k) = 1;
0205 k = find(mpc.bus(:, BUS_AREA) == 1);
0206 load_zone(k) = 2;
0207 t = ' Pd = total_load(bus, gen, load_zone2, ''BOTH'') : ';
0208 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0209 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0210
0211 t = '[Pd, Qd] = total_load(bus, gen, load_zone2, ''BOTH'') : ';
0212 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0213 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0214 t_is(Qd, [area(3).both.q; area(1).both.q], 12, [t 'Qd']);
0215
0216 t = ' Pd = total_load(bus, gen, load_zone2, ''FIXED'') : ';
0217 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0218 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0219
0220 t = '[Pd, Qd] = total_load(bus, gen, load_zone2, ''FIXED'') : ';
0221 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0222 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0223 t_is(Qd, [area(3).fixed.q; area(1).fixed.q], 12, [t 'Qd']);
0224
0225 t = ' Pd = total_load(bus, gen, load_zone2, ''DISPATCHABLE'') : ';
0226 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0227 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0228
0229 t = '[Pd, Qd] = total_load(bus, gen, load_zone2, ''DISPATCHABLE'') : ';
0230 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0231 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0232 t_is(Qd, [area(3).disp.q; area(1).disp.q], 12, [t 'Qd']);
0233
0234 t_end;