Home > matpower5.1 > t > t_total_load.m

t_total_load

PURPOSE ^

T_TOTAL_LOAD Tests for code in TOTAL_LOAD.

SYNOPSIS ^

function t_total_load(quiet)

DESCRIPTION ^

T_TOTAL_LOAD  Tests for code in TOTAL_LOAD.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_total_load(quiet)
0002 %T_TOTAL_LOAD  Tests for code in TOTAL_LOAD.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2008-2015 by Power System Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   $Id: t_total_load.m 2644 2015-03-11 19:34:22Z ray $
0009 %
0010 %   This file is part of MATPOWER.
0011 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0012 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0013 
0014 if nargin < 1
0015     quiet = 0;
0016 end
0017 
0018 n_tests = 128;
0019 
0020 t_begin(n_tests, quiet);
0021 
0022 %% define named indices into data matrices
0023 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0024     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0025 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0026     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0027     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0028 
0029 mpc = loadcase('t_auction_case');
0030 mpc.gen(8, GEN_BUS) = 2;    %% multiple d. loads per area, same bus as gen
0031 mpc.gen(8, [PG QG QMIN QMAX]) = [-20 2 0 3 ];
0032 %% put load before gen in matrix
0033 mpc.gen = [mpc.gen(8, :); mpc.gen(1:7, :); mpc.gen(9, :)];
0034 %% add an isolated bus (with both kinds of load)
0035 k = 12;
0036 mpc.bus = [mpc.bus(1:k, :); mpc.bus(k, :); mpc.bus(k+1:end, :)];
0037 mpc.bus(k, BUS_I) = mpc.bus(k, BUS_I)*10;
0038 mpc.bus(k, BUS_TYPE) = NONE;
0039 mpc.gen = [mpc.gen; mpc.gen(end, :)];
0040 mpc.gen(end, GEN_BUS) = mpc.bus(k, BUS_I);
0041 
0042 ld = find(isload(mpc.gen(1:end-1, :)));
0043 for k = 1:3
0044     a{k} = find(mpc.bus(:, BUS_AREA) == k & mpc.bus(:, BUS_TYPE) ~= NONE); %% buses in area k
0045     [junk, tmp, junk2] = intersect(mpc.gen(ld, GEN_BUS), a{k});
0046     lda{k} = ld(tmp);                       %% disp loads in area k
0047 end
0048 for k = 1:3
0049     area(k).fixed.p = sum(mpc.bus(a{k}, PD));
0050     area(k).fixed.q = sum(mpc.bus(a{k}, QD));
0051     area(k).disp.pnom = -sum(mpc.gen(lda{k}, PMIN));
0052     area(k).disp.p = -sum(mpc.gen(lda{k}, PG));
0053     area(k).disp.qmin = -sum(mpc.gen(lda{k}, QMIN));
0054     area(k).disp.qmax = -sum(mpc.gen(lda{k}, QMAX));
0055     area(k).disp.qnom = area(k).disp.qmin + area(k).disp.qmax;
0056     area(k).disp.q = -sum(mpc.gen(lda{k}, QG));
0057     area(k).both.pnom = area(k).fixed.p + area(k).disp.pnom;
0058     area(k).both.qnom = area(k).fixed.q + area(k).disp.qnom;
0059     area(k).both.p = area(k).fixed.p + area(k).disp.p;
0060     area(k).both.q = area(k).fixed.q + area(k).disp.q;
0061 end
0062 k = find(mpc.bus(:, BUS_TYPE) ~= NONE);
0063 total.fixed.p = sum(mpc.bus(k, PD));
0064 total.fixed.q = sum(mpc.bus(k, QD));
0065 total.disp.p = -sum(mpc.gen(ld, PG));
0066 total.disp.pnom = -sum(mpc.gen(ld, PMIN));
0067 total.disp.qmin = -sum(mpc.gen(ld, QMIN));
0068 total.disp.qmax = -sum(mpc.gen(ld, QMAX));
0069 total.disp.q = -sum(mpc.gen(ld, QG));
0070 total.disp.qnom = total.disp.qmin + total.disp.qmax;
0071 total.both.pnom = total.fixed.p + total.disp.pnom;
0072 total.both.qnom = total.fixed.q + total.disp.qnom;
0073 total.both.p = total.fixed.p + total.disp.p;
0074 total.both.q = total.fixed.q + total.disp.q;
0075 
0076 %%-----  all load  -----
0077 t = '      Pd = total_load(bus) : ';
0078 Pd = total_load(mpc.bus);
0079 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0080 
0081 t = '[Pd, Qd] = total_load(bus) : ';
0082 [Pd, Qd] = total_load(mpc.bus);
0083 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0084 t_is(Qd, [area(1).fixed.q; area(2).fixed.q; area(3).fixed.q], 12, [t 'Qd']);
0085 
0086 t = '      Pd = total_load(bus, gen) : ';
0087 Pd = total_load(mpc.bus, mpc.gen);
0088 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0089 
0090 t = '[Pd, Qd] = total_load(bus, gen) : ';
0091 [Pd, Qd] = total_load(mpc.bus, mpc.gen);
0092 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0093 t_is(Qd, [area(1).both.q; area(2).both.q; area(3).both.q], 12, [t 'Qd']);
0094 
0095 t = '      Pd = total_load(bus, [], ''all'') : ';
0096 Pd = total_load(mpc.bus, [], 'all');
0097 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0098 
0099 t = '[Pd, Qd] = total_load(bus, [], ''all'') : ';
0100 [Pd, Qd] = total_load(mpc.bus, [], 'all');
0101 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0102 t_is(Qd, total.fixed.q, 12, [t 'Qd']);
0103 
0104 t = '      Pd = total_load(b, g, ''all'') : ';
0105 Pd = total_load(mpc.bus, mpc.gen, 'all');
0106 t_is(Pd, total.both.p, 12, [t 'Pd']);
0107 
0108 t = '[Pd, Qd] = total_load(b, g, ''all'') : ';
0109 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all');
0110 t_is(Pd, total.both.p, 12, [t 'Pd']);
0111 t_is(Qd, total.both.q, 12, [t 'Qd']);
0112 
0113 t = '      Pd = total_load(b, g, ''all'', .type = ''BOTH'') : ';
0114 opt = struct('type', 'BOTH');
0115 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0116 t_is(Pd, total.both.p, 12, [t 'Pd']);
0117 
0118 t = '      Pd = total_load(b, g, ''all'', .type = ''BOTH'' .nominal = 1) : ';
0119 opt = struct('type', 'BOTH', 'nominal', 1);
0120 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0121 t_is(Pd, total.both.pnom, 12, [t 'Pd']);
0122 
0123 t = '      Pd = total_load(b, g, ''all'', .type = ''BOTH'' .nominal = 0) : ';
0124 opt = struct('type', 'BOTH', 'nominal', 0);
0125 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0126 t_is(Pd, total.both.p, 12, [t 'Pd']);
0127 
0128 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''BOTH'') : ';
0129 opt = struct('type', 'BOTH');
0130 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0131 t_is(Pd, total.both.p, 12, [t 'Pd']);
0132 t_is(Qd, total.both.q, 12, [t 'Qd']);
0133 
0134 t = '      Pd = total_load(b, g, ''all'', .type = ''FIXED'') : ';
0135 opt = struct('type', 'FIXED');
0136 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0137 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0138 
0139 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''FIXED'') : ';
0140 opt = struct('type', 'FIXED');
0141 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0142 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0143 t_is(Qd, total.fixed.q, 12, [t 'Qd']);
0144 
0145 t = '      Pd = total_load(b, g, ''all'', .type = ''DISPATCHABLE'') : ';
0146 opt = struct('type', 'DISPATCHABLE');
0147 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0148 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0149 
0150 t = '      Pd = total_load(b, g, ''all'', .type = ''DISP'' .nominal = 1) : ';
0151 opt = struct('type', 'DISP', 'nominal', 1);
0152 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0153 t_is(Pd, total.disp.pnom, 12, [t 'Pd']);
0154 
0155 t = '      Pd = total_load(b, g, ''all'', .type = ''DISP'' .nominal = 0) : ';
0156 opt = struct('type', 'DISP', 'nominal', 0);
0157 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0158 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0159 
0160 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''DISPATCHABLE'') : ';
0161 opt = struct('type', 'DISPATCHABLE');
0162 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0163 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0164 t_is(Qd, total.disp.q, 12, [t 'Qd']);
0165 
0166 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''DISP'' .nominal = 1) : ';
0167 opt = struct('type', 'DISP', 'nominal', 1);
0168 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0169 t_is(Pd, total.disp.pnom, 12, [t 'Pd']);
0170 t_is(Qd, total.disp.qnom, 12, [t 'Qd']);
0171 
0172 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''DISP'' .nominal = 0) : ';
0173 opt = struct('type', 'DISP', 'nominal', 0);
0174 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0175 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0176 t_is(Qd, total.disp.q, 12, [t 'Qd']);
0177 
0178 t = '      Pd = total_load(b, g, [], .type = ''BOTH'') : ';
0179 opt = struct('type', 'BOTH');
0180 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0181 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0182 
0183 t = '      Pd = total_load(b, g, [], .type = ''BOTH'' .nominal = 1) : ';
0184 opt = struct('type', 'BOTH', 'nominal', 1);
0185 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0186 t_is(Pd, [area(1).both.pnom; area(2).both.pnom; area(3).both.pnom], 12, [t 'Pd']);
0187 
0188 t = '      Pd = total_load(b, g, [], .type = ''BOTH'' .nominal = 0) : ';
0189 opt = struct('type', 'BOTH', 'nominal', 0);
0190 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0191 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0192 
0193 t = '[Pd, Qd] = total_load(b, g, [], .type = ''BOTH'') : ';
0194 opt = struct('type', 'BOTH');
0195 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0196 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0197 t_is(Qd, [area(1).both.q; area(2).both.q; area(3).both.q], 12, [t 'Qd']);
0198 
0199 t = '[Pd, Qd] = total_load(b, g, [], .type = ''BOTH'' .nominal = 1) : ';
0200 opt = struct('type', 'BOTH', 'nominal', 1);
0201 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0202 t_is(Pd, [area(1).both.pnom; area(2).both.pnom; area(3).both.pnom], 12, [t 'Pd']);
0203 t_is(Qd, [area(1).both.qnom; area(2).both.qnom; area(3).both.qnom], 12, [t 'Qd']);
0204 
0205 t = '[Pd, Qd] = total_load(b, g, [], .type = ''BOTH'' .nominal = 0) : ';
0206 opt = struct('type', 'BOTH', 'nominal', 0);
0207 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0208 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0209 t_is(Qd, [area(1).both.q; area(2).both.q; area(3).both.q], 12, [t 'Qd']);
0210 
0211 t = '      Pd = total_load(b, g, [], .type = ''FIXED'') : ';
0212 opt = struct('type', 'FIXED');
0213 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0214 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0215 
0216 t = '[Pd, Qd] = total_load(b, g, [], .type = ''FIXED'') : ';
0217 opt = struct('type', 'FIXED');
0218 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0219 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0220 t_is(Qd, [area(1).fixed.q; area(2).fixed.q; area(3).fixed.q], 12, [t 'Qd']);
0221 
0222 t = '      Pd = total_load(b, g, [], .type = ''DISPATCHABLE'') : ';
0223 opt = struct('type', 'DISPATCHABLE');
0224 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0225 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0226 
0227 t = '      Pd = total_load(b, g, [], .type = ''DISP'' .nominal = 1) : ';
0228 opt = struct('type', 'DISP', 'nominal', 1);
0229 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0230 t_is(Pd, [area(1).disp.pnom; area(2).disp.pnom; area(3).disp.pnom], 12, [t 'Pd']);
0231 
0232 t = '      Pd = total_load(b, g, [], .type = ''DISP'' .nominal = 0) : ';
0233 opt = struct('type', 'DISP', 'nominal', 0);
0234 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0235 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0236 
0237 t = '[Pd, Qd] = total_load(b, g, [], .type = ''DISPATCHABLE'') : ';
0238 opt = struct('type', 'DISPATCHABLE');
0239 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0240 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0241 t_is(Qd, [area(1).disp.q; area(2).disp.q; area(3).disp.q], 12, [t 'Qd']);
0242 
0243 t = '[Pd, Qd] = total_load(b, g, [], .type = ''DISP'' .nominal = 1) : ';
0244 opt = struct('type', 'DISP', 'nominal', 1);
0245 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0246 t_is(Pd, [area(1).disp.pnom; area(2).disp.pnom; area(3).disp.pnom], 12, [t 'Pd']);
0247 t_is(Qd, [area(1).disp.qnom; area(2).disp.qnom; area(3).disp.qnom], 12, [t 'Qd']);
0248 
0249 t = '[Pd, Qd] = total_load(b, g, [], .type = ''DISP'' .nominal = 0) : ';
0250 opt = struct('type', 'DISP', 'nominal', 0);
0251 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0252 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0253 t_is(Qd, [area(1).disp.q; area(2).disp.q; area(3).disp.q], 12, [t 'Qd']);
0254 
0255 %%-----  explicit single load zone  -----
0256 nb = size(mpc.bus, 1);
0257 load_zone = zeros(nb, 1);
0258 k = find(mpc.bus(:, BUS_AREA) == 1);    %% area 1
0259 load_zone(k) = 1;
0260 t = '      Pd = total_load(b, g, ld_zone1, .type = ''BOTH'') : ';
0261 opt = struct('type', 'BOTH');
0262 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0263 t_is(Pd, area(1).both.p, 12, [t 'Pd']);
0264 
0265 t = '      Pd = total_load(b, g, ld_zone1, .type = ''BOTH'' .nominal = 1) : ';
0266 opt = struct('type', 'BOTH', 'nominal', 1);
0267 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0268 t_is(Pd, area(1).both.pnom, 12, [t 'Pd']);
0269 
0270 t = '      Pd = total_load(b, g, ld_zone1, .type = ''BOTH'' .nominal = 0) : ';
0271 opt = struct('type', 'BOTH', 'nominal', 0);
0272 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0273 t_is(Pd, area(1).both.p, 12, [t 'Pd']);
0274 
0275 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''BOTH'') : ';
0276 opt = struct('type', 'BOTH');
0277 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0278 t_is(Pd, area(1).both.p, 12, [t 'Pd']);
0279 t_is(Qd, area(1).both.q, 12, [t 'Qd']);
0280 
0281 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''BOTH'' .nominal = 1) : ';
0282 opt = struct('type', 'BOTH', 'nominal', 1);
0283 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0284 t_is(Pd, area(1).both.pnom, 12, [t 'Pd']);
0285 t_is(Qd, area(1).both.qnom, 12, [t 'Qd']);
0286 
0287 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''BOTH'' .nominal = 0) : ';
0288 opt = struct('type', 'BOTH', 'nominal', 0);
0289 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0290 t_is(Pd, area(1).both.p, 12, [t 'Pd']);
0291 t_is(Qd, area(1).both.q, 12, [t 'Qd']);
0292 
0293 t = '      Pd = total_load(b, g, ld_zone1, .type = ''FIXED'') : ';
0294 opt = struct('type', 'FIXED');
0295 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0296 t_is(Pd, area(1).fixed.p, 12, [t 'Pd']);
0297 
0298 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''FIXED'') : ';
0299 opt = struct('type', 'FIXED');
0300 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0301 t_is(Pd, area(1).fixed.p, 12, [t 'Pd']);
0302 t_is(Qd, area(1).fixed.q, 12, [t 'Qd']);
0303 
0304 t = '      Pd = total_load(b, g, ld_zone1, .type = ''DISPATCHABLE'') : ';
0305 opt = struct('type', 'DISPATCHABLE');
0306 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0307 t_is(Pd, area(1).disp.p, 12, [t 'Pd']);
0308 
0309 t = '      Pd = total_load(b, g, ld_zone1, .type = ''DISP'' .nominal = 1) : ';
0310 opt = struct('type', 'DISP', 'nominal', 1);
0311 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0312 t_is(Pd, area(1).disp.pnom, 12, [t 'Pd']);
0313 
0314 t = '      Pd = total_load(b, g, ld_zone1, .type = ''DISP'' .nominal = 0) : ';
0315 opt = struct('type', 'DISP', 'nominal', 0);
0316 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0317 t_is(Pd, area(1).disp.p, 12, [t 'Pd']);
0318 
0319 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''DISPATCHABLE'') : ';
0320 opt = struct('type', 'DISPATCHABLE');
0321 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0322 t_is(Pd, area(1).disp.p, 12, [t 'Pd']);
0323 t_is(Qd, area(1).disp.q, 12, [t 'Qd']);
0324 
0325 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''DISP'' .nominal = 1) : ';
0326 opt = struct('type', 'DISP', 'nominal', 1);
0327 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0328 t_is(Pd, area(1).disp.pnom, 12, [t 'Pd']);
0329 t_is(Qd, area(1).disp.qnom, 12, [t 'Qd']);
0330 
0331 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''DISP'' .nominal = 0) : ';
0332 opt = struct('type', 'DISP', 'nominal', 0);
0333 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0334 t_is(Pd, area(1).disp.p, 12, [t 'Pd']);
0335 t_is(Qd, area(1).disp.q, 12, [t 'Qd']);
0336 
0337 %%-----  explicit multiple load zone  -----
0338 load_zone = zeros(nb, 1);
0339 k = find(mpc.bus(:, BUS_AREA) == 3);    %% area 3
0340 load_zone(k) = 1;
0341 k = find(mpc.bus(:, BUS_AREA) == 1);    %% area 1
0342 load_zone(k) = 2;
0343 t = '      Pd = total_load(b, g, ld_zone2, .type = ''BOTH'') : ';
0344 opt = struct('type', 'BOTH');
0345 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0346 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0347 
0348 t = '      Pd = total_load(b, g, ld_zone2, .type = ''BOTH'' .nominal = 1) : ';
0349 opt = struct('type', 'BOTH', 'nominal', 1);
0350 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0351 t_is(Pd, [area(3).both.pnom; area(1).both.pnom], 12, [t 'Pd']);
0352 
0353 t = '      Pd = total_load(b, g, ld_zone2, .type = ''BOTH'' .nominal = 0) : ';
0354 opt = struct('type', 'BOTH', 'nominal', 0);
0355 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0356 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0357 
0358 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''BOTH'') : ';
0359 opt = struct('type', 'BOTH');
0360 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0361 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0362 t_is(Qd, [area(3).both.q; area(1).both.q], 12, [t 'Qd']);
0363 
0364 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''BOTH'' .nominal = 1) : ';
0365 opt = struct('type', 'BOTH', 'nominal', 1);
0366 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0367 t_is(Pd, [area(3).both.pnom; area(1).both.pnom], 12, [t 'Pd']);
0368 t_is(Qd, [area(3).both.qnom; area(1).both.qnom], 12, [t 'Qd']);
0369 
0370 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''BOTH'' .nominal = 0) : ';
0371 opt = struct('type', 'BOTH', 'nominal', 0);
0372 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0373 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0374 t_is(Qd, [area(3).both.q; area(1).both.q], 12, [t 'Qd']);
0375 
0376 t = '      Pd = total_load(b, g, ld_zone2, .type = ''FIXED'') : ';
0377 opt = struct('type', 'FIXED');
0378 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0379 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0380 
0381 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''FIXED'') : ';
0382 opt = struct('type', 'FIXED');
0383 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0384 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0385 t_is(Qd, [area(3).fixed.q; area(1).fixed.q], 12, [t 'Qd']);
0386 
0387 t = '      Pd = total_load(b, g, ld_zone2, .type = ''DISPATCHABLE'') : ';
0388 opt = struct('type', 'DISPATCHABLE');
0389 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0390 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0391 
0392 t = '      Pd = total_load(b, g, ld_zone2, .type = ''DISP'' .nominal = 1) : ';
0393 opt = struct('type', 'DISP', 'nominal', 1);
0394 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0395 t_is(Pd, [area(3).disp.pnom; area(1).disp.pnom], 12, [t 'Pd']);
0396 
0397 t = '      Pd = total_load(b, g, ld_zone2, .type = ''DISP'' .nominal = 0) : ';
0398 opt = struct('type', 'DISP', 'nominal', 0);
0399 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0400 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0401 
0402 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''DISPATCHABLE'') : ';
0403 opt = struct('type', 'DISPATCHABLE');
0404 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0405 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0406 t_is(Qd, [area(3).disp.q; area(1).disp.q], 12, [t 'Qd']);
0407 
0408 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''DISP'' .nominal = 1) : ';
0409 opt = struct('type', 'DISP', 'nominal', 1);
0410 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0411 t_is(Pd, [area(3).disp.pnom; area(1).disp.pnom], 12, [t 'Pd']);
0412 t_is(Qd, [area(3).disp.qnom; area(1).disp.qnom], 12, [t 'Qd']);
0413 
0414 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''DISP'' .nominal = 0) : ';
0415 opt = struct('type', 'DISP', 'nominal', 0);
0416 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0417 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0418 t_is(Qd, [area(3).disp.q; area(1).disp.q], 12, [t 'Qd']);
0419 
0420 %%-----  old DEPRECATED string options, below  -----
0421 %%-----  all load  -----
0422 t = '      Pd = total_load(b, g, ''all'', ''BOTH'') : ';
0423 Pd = total_load(mpc.bus, mpc.gen, 'all', 'BOTH');
0424 t_is(Pd, total.both.pnom, 12, [t 'Pd']);
0425 
0426 t = '[Pd, Qd] = total_load(b, g, ''all'', ''BOTH'') : ';
0427 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'BOTH');
0428 t_is(Pd, total.both.pnom, 12, [t 'Pd']);
0429 t_is(Qd, total.both.qnom, 12, [t 'Qd']);
0430 
0431 t = '      Pd = total_load(b, g, ''all'', ''FIXED'') : ';
0432 Pd = total_load(mpc.bus, mpc.gen, 'all', 'FIXED');
0433 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0434 
0435 t = '[Pd, Qd] = total_load(b, g, ''all'', ''FIXED'') : ';
0436 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'FIXED');
0437 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0438 t_is(Qd, total.fixed.q, 12, [t 'Qd']);
0439 
0440 t = '      Pd = total_load(b, g, ''all'', ''DISPATCHABLE'') : ';
0441 Pd = total_load(mpc.bus, mpc.gen, 'all', 'DISPATCHABLE');
0442 t_is(Pd, total.disp.pnom, 12, [t 'Pd']);
0443 
0444 t = '[Pd, Qd] = total_load(b, g, ''all'', ''DISPATCHABLE'') : ';
0445 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'DISPATCHABLE');
0446 t_is(Pd, total.disp.pnom, 12, [t 'Pd']);
0447 t_is(Qd, total.disp.qnom, 12, [t 'Qd']);
0448 
0449 t = '      Pd = total_load(b, g, [], ''BOTH'') : ';
0450 Pd = total_load(mpc.bus, mpc.gen, [], 'BOTH');
0451 t_is(Pd, [area(1).both.pnom; area(2).both.pnom; area(3).both.pnom], 12, [t 'Pd']);
0452 
0453 t = '[Pd, Qd] = total_load(b, g, [], ''BOTH'') : ';
0454 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'BOTH');
0455 t_is(Pd, [area(1).both.pnom; area(2).both.pnom; area(3).both.pnom], 12, [t 'Pd']);
0456 t_is(Qd, [area(1).both.qnom; area(2).both.qnom; area(3).both.qnom], 12, [t 'Qd']);
0457 
0458 t = '      Pd = total_load(b, g, [], ''FIXED'') : ';
0459 Pd = total_load(mpc.bus, mpc.gen, [], 'FIXED');
0460 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0461 
0462 t = '[Pd, Qd] = total_load(b, g, [], ''FIXED'') : ';
0463 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'FIXED');
0464 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0465 t_is(Qd, [area(1).fixed.q; area(2).fixed.q; area(3).fixed.q], 12, [t 'Qd']);
0466 
0467 t = '      Pd = total_load(b, g, [], ''DISPATCHABLE'') : ';
0468 Pd = total_load(mpc.bus, mpc.gen, [], 'DISPATCHABLE');
0469 t_is(Pd, [area(1).disp.pnom; area(2).disp.pnom; area(3).disp.pnom], 12, [t 'Pd']);
0470 
0471 t = '[Pd, Qd] = total_load(b, g, [], ''DISPATCHABLE'') : ';
0472 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'DISPATCHABLE');
0473 t_is(Pd, [area(1).disp.pnom; area(2).disp.pnom; area(3).disp.pnom], 12, [t 'Pd']);
0474 t_is(Qd, [area(1).disp.qnom; area(2).disp.qnom; area(3).disp.qnom], 12, [t 'Qd']);
0475 
0476 %%-----  explicit single load zone  -----
0477 nb = size(mpc.bus, 1);
0478 load_zone = zeros(nb, 1);
0479 k = find(mpc.bus(:, BUS_AREA) == 1);    %% area 1
0480 load_zone(k) = 1;
0481 t = '      Pd = total_load(b, g, ld_zone1, ''BOTH'') : ';
0482 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0483 t_is(Pd, area(1).both.pnom, 12, [t 'Pd']);
0484 
0485 t = '[Pd, Qd] = total_load(b, g, ld_zone1, ''BOTH'') : ';
0486 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0487 t_is(Pd, area(1).both.pnom, 12, [t 'Pd']);
0488 t_is(Qd, area(1).both.qnom, 12, [t 'Qd']);
0489 
0490 t = '      Pd = total_load(b, g, ld_zone1, ''FIXED'') : ';
0491 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0492 t_is(Pd, area(1).fixed.p, 12, [t 'Pd']);
0493 
0494 t = '[Pd, Qd] = total_load(b, g, ld_zone1, ''FIXED'') : ';
0495 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0496 t_is(Pd, area(1).fixed.p, 12, [t 'Pd']);
0497 t_is(Qd, area(1).fixed.q, 12, [t 'Qd']);
0498 
0499 t = '      Pd = total_load(b, g, ld_zone1, ''DISPATCHABLE'') : ';
0500 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0501 t_is(Pd, area(1).disp.pnom, 12, [t 'Pd']);
0502 
0503 t = '[Pd, Qd] = total_load(b, g, ld_zone1, ''DISPATCHABLE'') : ';
0504 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0505 t_is(Pd, area(1).disp.pnom, 12, [t 'Pd']);
0506 t_is(Qd, area(1).disp.qnom, 12, [t 'Qd']);
0507 
0508 %%-----  explicit multiple load zone  -----
0509 load_zone = zeros(nb, 1);
0510 k = find(mpc.bus(:, BUS_AREA) == 3);    %% area 3
0511 load_zone(k) = 1;
0512 k = find(mpc.bus(:, BUS_AREA) == 1);    %% area 1
0513 load_zone(k) = 2;
0514 t = '      Pd = total_load(b, g, ld_zone2, ''BOTH'') : ';
0515 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0516 t_is(Pd, [area(3).both.pnom; area(1).both.pnom], 12, [t 'Pd']);
0517 
0518 t = '[Pd, Qd] = total_load(b, g, ld_zone2, ''BOTH'') : ';
0519 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0520 t_is(Pd, [area(3).both.pnom; area(1).both.pnom], 12, [t 'Pd']);
0521 t_is(Qd, [area(3).both.qnom; area(1).both.qnom], 12, [t 'Qd']);
0522 
0523 t = '      Pd = total_load(b, g, ld_zone2, ''FIXED'') : ';
0524 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0525 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0526 
0527 t = '[Pd, Qd] = total_load(b, g, ld_zone2, ''FIXED'') : ';
0528 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0529 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0530 t_is(Qd, [area(3).fixed.q; area(1).fixed.q], 12, [t 'Qd']);
0531 
0532 t = '      Pd = total_load(b, g, ld_zone2, ''DISPATCHABLE'') : ';
0533 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0534 t_is(Pd, [area(3).disp.pnom; area(1).disp.pnom], 12, [t 'Pd']);
0535 
0536 t = '[Pd, Qd] = total_load(b, g, ld_zone2, ''DISPATCHABLE'') : ';
0537 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0538 t_is(Pd, [area(3).disp.pnom; area(1).disp.pnom], 12, [t 'Pd']);
0539 t_is(Qd, [area(3).disp.qnom; area(1).disp.qnom], 12, [t 'Qd']);
0540 
0541 t_end;

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005