Home > matpower5.0 > 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 %   $Id: t_total_load.m 2417 2014-11-12 15:57:35Z ray $
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %   Copyright (c) 2008-2010 by Power System Engineering Research Center (PSERC)
0008 %
0009 %   This file is part of MATPOWER.
0010 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0011 %
0012 %   MATPOWER is free software: you can redistribute it and/or modify
0013 %   it under the terms of the GNU General Public License as published
0014 %   by the Free Software Foundation, either version 3 of the License,
0015 %   or (at your option) any later version.
0016 %
0017 %   MATPOWER is distributed in the hope that it will be useful,
0018 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0019 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0020 %   GNU General Public License for more details.
0021 %
0022 %   You should have received a copy of the GNU General Public License
0023 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0024 %
0025 %   Additional permission under GNU GPL version 3 section 7
0026 %
0027 %   If you modify MATPOWER, or any covered work, to interface with
0028 %   other modules (such as MATLAB code and MEX-files) available in a
0029 %   MATLAB(R) or comparable environment containing parts covered
0030 %   under other licensing terms, the licensors of MATPOWER grant
0031 %   you additional permission to convey the resulting work.
0032 
0033 if nargin < 1
0034     quiet = 0;
0035 end
0036 
0037 n_tests = 128;
0038 
0039 t_begin(n_tests, quiet);
0040 
0041 %% define named indices into data matrices
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;    %% multiple d. loads per area, same bus as gen
0050 mpc.gen(8, [PG QG QMIN QMAX]) = [-20 2 0 3 ];
0051 %% put load before gen in matrix
0052 mpc.gen = [mpc.gen(8, :); mpc.gen(1:7, :); mpc.gen(9, :)];
0053 %% add an isolated bus (with both kinds of load)
0054 k = 12;
0055 mpc.bus = [mpc.bus(1:k, :); mpc.bus(k, :); mpc.bus(k+1:end, :)];
0056 mpc.bus(k, BUS_I) = mpc.bus(k, BUS_I)*10;
0057 mpc.bus(k, BUS_TYPE) = NONE;
0058 mpc.gen = [mpc.gen; mpc.gen(end, :)];
0059 mpc.gen(end, GEN_BUS) = mpc.bus(k, BUS_I);
0060 
0061 ld = find(isload(mpc.gen(1:end-1, :)));
0062 for k = 1:3
0063     a{k} = find(mpc.bus(:, BUS_AREA) == k & mpc.bus(:, BUS_TYPE) ~= NONE); %% buses in area k
0064     [junk, tmp, junk2] = intersect(mpc.gen(ld, GEN_BUS), a{k});
0065     lda{k} = ld(tmp);                       %% disp loads in area k
0066 end
0067 for k = 1:3
0068     area(k).fixed.p = sum(mpc.bus(a{k}, PD));
0069     area(k).fixed.q = sum(mpc.bus(a{k}, QD));
0070     area(k).disp.pnom = -sum(mpc.gen(lda{k}, PMIN));
0071     area(k).disp.p = -sum(mpc.gen(lda{k}, PG));
0072     area(k).disp.qmin = -sum(mpc.gen(lda{k}, QMIN));
0073     area(k).disp.qmax = -sum(mpc.gen(lda{k}, QMAX));
0074     area(k).disp.qnom = area(k).disp.qmin + area(k).disp.qmax;
0075     area(k).disp.q = -sum(mpc.gen(lda{k}, QG));
0076     area(k).both.pnom = area(k).fixed.p + area(k).disp.pnom;
0077     area(k).both.qnom = area(k).fixed.q + area(k).disp.qnom;
0078     area(k).both.p = area(k).fixed.p + area(k).disp.p;
0079     area(k).both.q = area(k).fixed.q + area(k).disp.q;
0080 end
0081 k = find(mpc.bus(:, BUS_TYPE) ~= NONE);
0082 total.fixed.p = sum(mpc.bus(k, PD));
0083 total.fixed.q = sum(mpc.bus(k, QD));
0084 total.disp.p = -sum(mpc.gen(ld, PG));
0085 total.disp.pnom = -sum(mpc.gen(ld, PMIN));
0086 total.disp.qmin = -sum(mpc.gen(ld, QMIN));
0087 total.disp.qmax = -sum(mpc.gen(ld, QMAX));
0088 total.disp.q = -sum(mpc.gen(ld, QG));
0089 total.disp.qnom = total.disp.qmin + total.disp.qmax;
0090 total.both.pnom = total.fixed.p + total.disp.pnom;
0091 total.both.qnom = total.fixed.q + total.disp.qnom;
0092 total.both.p = total.fixed.p + total.disp.p;
0093 total.both.q = total.fixed.q + total.disp.q;
0094 
0095 %%-----  all load  -----
0096 t = '      Pd = total_load(bus) : ';
0097 Pd = total_load(mpc.bus);
0098 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0099 
0100 t = '[Pd, Qd] = total_load(bus) : ';
0101 [Pd, Qd] = total_load(mpc.bus);
0102 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0103 t_is(Qd, [area(1).fixed.q; area(2).fixed.q; area(3).fixed.q], 12, [t 'Qd']);
0104 
0105 t = '      Pd = total_load(bus, gen) : ';
0106 Pd = total_load(mpc.bus, mpc.gen);
0107 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0108 
0109 t = '[Pd, Qd] = total_load(bus, gen) : ';
0110 [Pd, Qd] = total_load(mpc.bus, mpc.gen);
0111 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0112 t_is(Qd, [area(1).both.q; area(2).both.q; area(3).both.q], 12, [t 'Qd']);
0113 
0114 t = '      Pd = total_load(bus, [], ''all'') : ';
0115 Pd = total_load(mpc.bus, [], 'all');
0116 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0117 
0118 t = '[Pd, Qd] = total_load(bus, [], ''all'') : ';
0119 [Pd, Qd] = total_load(mpc.bus, [], 'all');
0120 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0121 t_is(Qd, total.fixed.q, 12, [t 'Qd']);
0122 
0123 t = '      Pd = total_load(b, g, ''all'') : ';
0124 Pd = total_load(mpc.bus, mpc.gen, 'all');
0125 t_is(Pd, total.both.p, 12, [t 'Pd']);
0126 
0127 t = '[Pd, Qd] = total_load(b, g, ''all'') : ';
0128 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all');
0129 t_is(Pd, total.both.p, 12, [t 'Pd']);
0130 t_is(Qd, total.both.q, 12, [t 'Qd']);
0131 
0132 t = '      Pd = total_load(b, g, ''all'', .type = ''BOTH'') : ';
0133 opt = struct('type', 'BOTH');
0134 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0135 t_is(Pd, total.both.p, 12, [t 'Pd']);
0136 
0137 t = '      Pd = total_load(b, g, ''all'', .type = ''BOTH'' .nominal = 1) : ';
0138 opt = struct('type', 'BOTH', 'nominal', 1);
0139 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0140 t_is(Pd, total.both.pnom, 12, [t 'Pd']);
0141 
0142 t = '      Pd = total_load(b, g, ''all'', .type = ''BOTH'' .nominal = 0) : ';
0143 opt = struct('type', 'BOTH', 'nominal', 0);
0144 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0145 t_is(Pd, total.both.p, 12, [t 'Pd']);
0146 
0147 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''BOTH'') : ';
0148 opt = struct('type', 'BOTH');
0149 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0150 t_is(Pd, total.both.p, 12, [t 'Pd']);
0151 t_is(Qd, total.both.q, 12, [t 'Qd']);
0152 
0153 t = '      Pd = total_load(b, g, ''all'', .type = ''FIXED'') : ';
0154 opt = struct('type', 'FIXED');
0155 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0156 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0157 
0158 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''FIXED'') : ';
0159 opt = struct('type', 'FIXED');
0160 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0161 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0162 t_is(Qd, total.fixed.q, 12, [t 'Qd']);
0163 
0164 t = '      Pd = total_load(b, g, ''all'', .type = ''DISPATCHABLE'') : ';
0165 opt = struct('type', 'DISPATCHABLE');
0166 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0167 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0168 
0169 t = '      Pd = total_load(b, g, ''all'', .type = ''DISP'' .nominal = 1) : ';
0170 opt = struct('type', 'DISP', 'nominal', 1);
0171 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0172 t_is(Pd, total.disp.pnom, 12, [t 'Pd']);
0173 
0174 t = '      Pd = total_load(b, g, ''all'', .type = ''DISP'' .nominal = 0) : ';
0175 opt = struct('type', 'DISP', 'nominal', 0);
0176 Pd = total_load(mpc.bus, mpc.gen, 'all', opt);
0177 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0178 
0179 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''DISPATCHABLE'') : ';
0180 opt = struct('type', 'DISPATCHABLE');
0181 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0182 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0183 t_is(Qd, total.disp.q, 12, [t 'Qd']);
0184 
0185 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''DISP'' .nominal = 1) : ';
0186 opt = struct('type', 'DISP', 'nominal', 1);
0187 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0188 t_is(Pd, total.disp.pnom, 12, [t 'Pd']);
0189 t_is(Qd, total.disp.qnom, 12, [t 'Qd']);
0190 
0191 t = '[Pd, Qd] = total_load(b, g, ''all'', .type = ''DISP'' .nominal = 0) : ';
0192 opt = struct('type', 'DISP', 'nominal', 0);
0193 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', opt);
0194 t_is(Pd, total.disp.p, 12, [t 'Pd']);
0195 t_is(Qd, total.disp.q, 12, [t 'Qd']);
0196 
0197 t = '      Pd = total_load(b, g, [], .type = ''BOTH'') : ';
0198 opt = struct('type', 'BOTH');
0199 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0200 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0201 
0202 t = '      Pd = total_load(b, g, [], .type = ''BOTH'' .nominal = 1) : ';
0203 opt = struct('type', 'BOTH', 'nominal', 1);
0204 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0205 t_is(Pd, [area(1).both.pnom; area(2).both.pnom; area(3).both.pnom], 12, [t 'Pd']);
0206 
0207 t = '      Pd = total_load(b, g, [], .type = ''BOTH'' .nominal = 0) : ';
0208 opt = struct('type', 'BOTH', 'nominal', 0);
0209 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0210 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0211 
0212 t = '[Pd, Qd] = total_load(b, g, [], .type = ''BOTH'') : ';
0213 opt = struct('type', 'BOTH');
0214 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0215 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0216 t_is(Qd, [area(1).both.q; area(2).both.q; area(3).both.q], 12, [t 'Qd']);
0217 
0218 t = '[Pd, Qd] = total_load(b, g, [], .type = ''BOTH'' .nominal = 1) : ';
0219 opt = struct('type', 'BOTH', 'nominal', 1);
0220 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0221 t_is(Pd, [area(1).both.pnom; area(2).both.pnom; area(3).both.pnom], 12, [t 'Pd']);
0222 t_is(Qd, [area(1).both.qnom; area(2).both.qnom; area(3).both.qnom], 12, [t 'Qd']);
0223 
0224 t = '[Pd, Qd] = total_load(b, g, [], .type = ''BOTH'' .nominal = 0) : ';
0225 opt = struct('type', 'BOTH', 'nominal', 0);
0226 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0227 t_is(Pd, [area(1).both.p; area(2).both.p; area(3).both.p], 12, [t 'Pd']);
0228 t_is(Qd, [area(1).both.q; area(2).both.q; area(3).both.q], 12, [t 'Qd']);
0229 
0230 t = '      Pd = total_load(b, g, [], .type = ''FIXED'') : ';
0231 opt = struct('type', 'FIXED');
0232 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0233 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0234 
0235 t = '[Pd, Qd] = total_load(b, g, [], .type = ''FIXED'') : ';
0236 opt = struct('type', 'FIXED');
0237 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0238 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0239 t_is(Qd, [area(1).fixed.q; area(2).fixed.q; area(3).fixed.q], 12, [t 'Qd']);
0240 
0241 t = '      Pd = total_load(b, g, [], .type = ''DISPATCHABLE'') : ';
0242 opt = struct('type', 'DISPATCHABLE');
0243 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0244 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0245 
0246 t = '      Pd = total_load(b, g, [], .type = ''DISP'' .nominal = 1) : ';
0247 opt = struct('type', 'DISP', 'nominal', 1);
0248 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0249 t_is(Pd, [area(1).disp.pnom; area(2).disp.pnom; area(3).disp.pnom], 12, [t 'Pd']);
0250 
0251 t = '      Pd = total_load(b, g, [], .type = ''DISP'' .nominal = 0) : ';
0252 opt = struct('type', 'DISP', 'nominal', 0);
0253 Pd = total_load(mpc.bus, mpc.gen, [], opt);
0254 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0255 
0256 t = '[Pd, Qd] = total_load(b, g, [], .type = ''DISPATCHABLE'') : ';
0257 opt = struct('type', 'DISPATCHABLE');
0258 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0259 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0260 t_is(Qd, [area(1).disp.q; area(2).disp.q; area(3).disp.q], 12, [t 'Qd']);
0261 
0262 t = '[Pd, Qd] = total_load(b, g, [], .type = ''DISP'' .nominal = 1) : ';
0263 opt = struct('type', 'DISP', 'nominal', 1);
0264 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0265 t_is(Pd, [area(1).disp.pnom; area(2).disp.pnom; area(3).disp.pnom], 12, [t 'Pd']);
0266 t_is(Qd, [area(1).disp.qnom; area(2).disp.qnom; area(3).disp.qnom], 12, [t 'Qd']);
0267 
0268 t = '[Pd, Qd] = total_load(b, g, [], .type = ''DISP'' .nominal = 0) : ';
0269 opt = struct('type', 'DISP', 'nominal', 0);
0270 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], opt);
0271 t_is(Pd, [area(1).disp.p; area(2).disp.p; area(3).disp.p], 12, [t 'Pd']);
0272 t_is(Qd, [area(1).disp.q; area(2).disp.q; area(3).disp.q], 12, [t 'Qd']);
0273 
0274 %%-----  explicit single load zone  -----
0275 nb = size(mpc.bus, 1);
0276 load_zone = zeros(nb, 1);
0277 k = find(mpc.bus(:, BUS_AREA) == 1);    %% area 1
0278 load_zone(k) = 1;
0279 t = '      Pd = total_load(b, g, ld_zone1, .type = ''BOTH'') : ';
0280 opt = struct('type', 'BOTH');
0281 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0282 t_is(Pd, area(1).both.p, 12, [t 'Pd']);
0283 
0284 t = '      Pd = total_load(b, g, ld_zone1, .type = ''BOTH'' .nominal = 1) : ';
0285 opt = struct('type', 'BOTH', 'nominal', 1);
0286 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0287 t_is(Pd, area(1).both.pnom, 12, [t 'Pd']);
0288 
0289 t = '      Pd = total_load(b, g, ld_zone1, .type = ''BOTH'' .nominal = 0) : ';
0290 opt = struct('type', 'BOTH', 'nominal', 0);
0291 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0292 t_is(Pd, area(1).both.p, 12, [t 'Pd']);
0293 
0294 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''BOTH'') : ';
0295 opt = struct('type', 'BOTH');
0296 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0297 t_is(Pd, area(1).both.p, 12, [t 'Pd']);
0298 t_is(Qd, area(1).both.q, 12, [t 'Qd']);
0299 
0300 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''BOTH'' .nominal = 1) : ';
0301 opt = struct('type', 'BOTH', 'nominal', 1);
0302 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0303 t_is(Pd, area(1).both.pnom, 12, [t 'Pd']);
0304 t_is(Qd, area(1).both.qnom, 12, [t 'Qd']);
0305 
0306 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''BOTH'' .nominal = 0) : ';
0307 opt = struct('type', 'BOTH', 'nominal', 0);
0308 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0309 t_is(Pd, area(1).both.p, 12, [t 'Pd']);
0310 t_is(Qd, area(1).both.q, 12, [t 'Qd']);
0311 
0312 t = '      Pd = total_load(b, g, ld_zone1, .type = ''FIXED'') : ';
0313 opt = struct('type', 'FIXED');
0314 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0315 t_is(Pd, area(1).fixed.p, 12, [t 'Pd']);
0316 
0317 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''FIXED'') : ';
0318 opt = struct('type', 'FIXED');
0319 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0320 t_is(Pd, area(1).fixed.p, 12, [t 'Pd']);
0321 t_is(Qd, area(1).fixed.q, 12, [t 'Qd']);
0322 
0323 t = '      Pd = total_load(b, g, ld_zone1, .type = ''DISPATCHABLE'') : ';
0324 opt = struct('type', 'DISPATCHABLE');
0325 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0326 t_is(Pd, area(1).disp.p, 12, [t 'Pd']);
0327 
0328 t = '      Pd = total_load(b, g, ld_zone1, .type = ''DISP'' .nominal = 1) : ';
0329 opt = struct('type', 'DISP', 'nominal', 1);
0330 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0331 t_is(Pd, area(1).disp.pnom, 12, [t 'Pd']);
0332 
0333 t = '      Pd = total_load(b, g, ld_zone1, .type = ''DISP'' .nominal = 0) : ';
0334 opt = struct('type', 'DISP', 'nominal', 0);
0335 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0336 t_is(Pd, area(1).disp.p, 12, [t 'Pd']);
0337 
0338 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''DISPATCHABLE'') : ';
0339 opt = struct('type', 'DISPATCHABLE');
0340 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0341 t_is(Pd, area(1).disp.p, 12, [t 'Pd']);
0342 t_is(Qd, area(1).disp.q, 12, [t 'Qd']);
0343 
0344 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''DISP'' .nominal = 1) : ';
0345 opt = struct('type', 'DISP', 'nominal', 1);
0346 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0347 t_is(Pd, area(1).disp.pnom, 12, [t 'Pd']);
0348 t_is(Qd, area(1).disp.qnom, 12, [t 'Qd']);
0349 
0350 t = '[Pd, Qd] = total_load(b, g, ld_zone1, .type = ''DISP'' .nominal = 0) : ';
0351 opt = struct('type', 'DISP', 'nominal', 0);
0352 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0353 t_is(Pd, area(1).disp.p, 12, [t 'Pd']);
0354 t_is(Qd, area(1).disp.q, 12, [t 'Qd']);
0355 
0356 %%-----  explicit multiple load zone  -----
0357 load_zone = zeros(nb, 1);
0358 k = find(mpc.bus(:, BUS_AREA) == 3);    %% area 3
0359 load_zone(k) = 1;
0360 k = find(mpc.bus(:, BUS_AREA) == 1);    %% area 1
0361 load_zone(k) = 2;
0362 t = '      Pd = total_load(b, g, ld_zone2, .type = ''BOTH'') : ';
0363 opt = struct('type', 'BOTH');
0364 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0365 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0366 
0367 t = '      Pd = total_load(b, g, ld_zone2, .type = ''BOTH'' .nominal = 1) : ';
0368 opt = struct('type', 'BOTH', 'nominal', 1);
0369 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0370 t_is(Pd, [area(3).both.pnom; area(1).both.pnom], 12, [t 'Pd']);
0371 
0372 t = '      Pd = total_load(b, g, ld_zone2, .type = ''BOTH'' .nominal = 0) : ';
0373 opt = struct('type', 'BOTH', 'nominal', 0);
0374 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0375 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0376 
0377 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''BOTH'') : ';
0378 opt = struct('type', 'BOTH');
0379 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0380 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0381 t_is(Qd, [area(3).both.q; area(1).both.q], 12, [t 'Qd']);
0382 
0383 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''BOTH'' .nominal = 1) : ';
0384 opt = struct('type', 'BOTH', 'nominal', 1);
0385 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0386 t_is(Pd, [area(3).both.pnom; area(1).both.pnom], 12, [t 'Pd']);
0387 t_is(Qd, [area(3).both.qnom; area(1).both.qnom], 12, [t 'Qd']);
0388 
0389 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''BOTH'' .nominal = 0) : ';
0390 opt = struct('type', 'BOTH', 'nominal', 0);
0391 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0392 t_is(Pd, [area(3).both.p; area(1).both.p], 12, [t 'Pd']);
0393 t_is(Qd, [area(3).both.q; area(1).both.q], 12, [t 'Qd']);
0394 
0395 t = '      Pd = total_load(b, g, ld_zone2, .type = ''FIXED'') : ';
0396 opt = struct('type', 'FIXED');
0397 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0398 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0399 
0400 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''FIXED'') : ';
0401 opt = struct('type', 'FIXED');
0402 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0403 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0404 t_is(Qd, [area(3).fixed.q; area(1).fixed.q], 12, [t 'Qd']);
0405 
0406 t = '      Pd = total_load(b, g, ld_zone2, .type = ''DISPATCHABLE'') : ';
0407 opt = struct('type', 'DISPATCHABLE');
0408 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0409 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0410 
0411 t = '      Pd = total_load(b, g, ld_zone2, .type = ''DISP'' .nominal = 1) : ';
0412 opt = struct('type', 'DISP', 'nominal', 1);
0413 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0414 t_is(Pd, [area(3).disp.pnom; area(1).disp.pnom], 12, [t 'Pd']);
0415 
0416 t = '      Pd = total_load(b, g, ld_zone2, .type = ''DISP'' .nominal = 0) : ';
0417 opt = struct('type', 'DISP', 'nominal', 0);
0418 Pd = total_load(mpc.bus, mpc.gen, load_zone, opt);
0419 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0420 
0421 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''DISPATCHABLE'') : ';
0422 opt = struct('type', 'DISPATCHABLE');
0423 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0424 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0425 t_is(Qd, [area(3).disp.q; area(1).disp.q], 12, [t 'Qd']);
0426 
0427 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''DISP'' .nominal = 1) : ';
0428 opt = struct('type', 'DISP', 'nominal', 1);
0429 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0430 t_is(Pd, [area(3).disp.pnom; area(1).disp.pnom], 12, [t 'Pd']);
0431 t_is(Qd, [area(3).disp.qnom; area(1).disp.qnom], 12, [t 'Qd']);
0432 
0433 t = '[Pd, Qd] = total_load(b, g, ld_zone2, .type = ''DISP'' .nominal = 0) : ';
0434 opt = struct('type', 'DISP', 'nominal', 0);
0435 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, opt);
0436 t_is(Pd, [area(3).disp.p; area(1).disp.p], 12, [t 'Pd']);
0437 t_is(Qd, [area(3).disp.q; area(1).disp.q], 12, [t 'Qd']);
0438 
0439 %%-----  old DEPRECATED string options, below  -----
0440 %%-----  all load  -----
0441 t = '      Pd = total_load(b, g, ''all'', ''BOTH'') : ';
0442 Pd = total_load(mpc.bus, mpc.gen, 'all', 'BOTH');
0443 t_is(Pd, total.both.pnom, 12, [t 'Pd']);
0444 
0445 t = '[Pd, Qd] = total_load(b, g, ''all'', ''BOTH'') : ';
0446 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'BOTH');
0447 t_is(Pd, total.both.pnom, 12, [t 'Pd']);
0448 t_is(Qd, total.both.qnom, 12, [t 'Qd']);
0449 
0450 t = '      Pd = total_load(b, g, ''all'', ''FIXED'') : ';
0451 Pd = total_load(mpc.bus, mpc.gen, 'all', 'FIXED');
0452 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0453 
0454 t = '[Pd, Qd] = total_load(b, g, ''all'', ''FIXED'') : ';
0455 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'FIXED');
0456 t_is(Pd, total.fixed.p, 12, [t 'Pd']);
0457 t_is(Qd, total.fixed.q, 12, [t 'Qd']);
0458 
0459 t = '      Pd = total_load(b, g, ''all'', ''DISPATCHABLE'') : ';
0460 Pd = total_load(mpc.bus, mpc.gen, 'all', 'DISPATCHABLE');
0461 t_is(Pd, total.disp.pnom, 12, [t 'Pd']);
0462 
0463 t = '[Pd, Qd] = total_load(b, g, ''all'', ''DISPATCHABLE'') : ';
0464 [Pd, Qd] = total_load(mpc.bus, mpc.gen, 'all', 'DISPATCHABLE');
0465 t_is(Pd, total.disp.pnom, 12, [t 'Pd']);
0466 t_is(Qd, total.disp.qnom, 12, [t 'Qd']);
0467 
0468 t = '      Pd = total_load(b, g, [], ''BOTH'') : ';
0469 Pd = total_load(mpc.bus, mpc.gen, [], 'BOTH');
0470 t_is(Pd, [area(1).both.pnom; area(2).both.pnom; area(3).both.pnom], 12, [t 'Pd']);
0471 
0472 t = '[Pd, Qd] = total_load(b, g, [], ''BOTH'') : ';
0473 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'BOTH');
0474 t_is(Pd, [area(1).both.pnom; area(2).both.pnom; area(3).both.pnom], 12, [t 'Pd']);
0475 t_is(Qd, [area(1).both.qnom; area(2).both.qnom; area(3).both.qnom], 12, [t 'Qd']);
0476 
0477 t = '      Pd = total_load(b, g, [], ''FIXED'') : ';
0478 Pd = total_load(mpc.bus, mpc.gen, [], 'FIXED');
0479 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0480 
0481 t = '[Pd, Qd] = total_load(b, g, [], ''FIXED'') : ';
0482 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'FIXED');
0483 t_is(Pd, [area(1).fixed.p; area(2).fixed.p; area(3).fixed.p], 12, [t 'Pd']);
0484 t_is(Qd, [area(1).fixed.q; area(2).fixed.q; area(3).fixed.q], 12, [t 'Qd']);
0485 
0486 t = '      Pd = total_load(b, g, [], ''DISPATCHABLE'') : ';
0487 Pd = total_load(mpc.bus, mpc.gen, [], 'DISPATCHABLE');
0488 t_is(Pd, [area(1).disp.pnom; area(2).disp.pnom; area(3).disp.pnom], 12, [t 'Pd']);
0489 
0490 t = '[Pd, Qd] = total_load(b, g, [], ''DISPATCHABLE'') : ';
0491 [Pd, Qd] = total_load(mpc.bus, mpc.gen, [], 'DISPATCHABLE');
0492 t_is(Pd, [area(1).disp.pnom; area(2).disp.pnom; area(3).disp.pnom], 12, [t 'Pd']);
0493 t_is(Qd, [area(1).disp.qnom; area(2).disp.qnom; area(3).disp.qnom], 12, [t 'Qd']);
0494 
0495 %%-----  explicit single load zone  -----
0496 nb = size(mpc.bus, 1);
0497 load_zone = zeros(nb, 1);
0498 k = find(mpc.bus(:, BUS_AREA) == 1);    %% area 1
0499 load_zone(k) = 1;
0500 t = '      Pd = total_load(b, g, ld_zone1, ''BOTH'') : ';
0501 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0502 t_is(Pd, area(1).both.pnom, 12, [t 'Pd']);
0503 
0504 t = '[Pd, Qd] = total_load(b, g, ld_zone1, ''BOTH'') : ';
0505 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0506 t_is(Pd, area(1).both.pnom, 12, [t 'Pd']);
0507 t_is(Qd, area(1).both.qnom, 12, [t 'Qd']);
0508 
0509 t = '      Pd = total_load(b, g, ld_zone1, ''FIXED'') : ';
0510 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0511 t_is(Pd, area(1).fixed.p, 12, [t 'Pd']);
0512 
0513 t = '[Pd, Qd] = total_load(b, g, ld_zone1, ''FIXED'') : ';
0514 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0515 t_is(Pd, area(1).fixed.p, 12, [t 'Pd']);
0516 t_is(Qd, area(1).fixed.q, 12, [t 'Qd']);
0517 
0518 t = '      Pd = total_load(b, g, ld_zone1, ''DISPATCHABLE'') : ';
0519 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0520 t_is(Pd, area(1).disp.pnom, 12, [t 'Pd']);
0521 
0522 t = '[Pd, Qd] = total_load(b, g, ld_zone1, ''DISPATCHABLE'') : ';
0523 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0524 t_is(Pd, area(1).disp.pnom, 12, [t 'Pd']);
0525 t_is(Qd, area(1).disp.qnom, 12, [t 'Qd']);
0526 
0527 %%-----  explicit multiple load zone  -----
0528 load_zone = zeros(nb, 1);
0529 k = find(mpc.bus(:, BUS_AREA) == 3);    %% area 3
0530 load_zone(k) = 1;
0531 k = find(mpc.bus(:, BUS_AREA) == 1);    %% area 1
0532 load_zone(k) = 2;
0533 t = '      Pd = total_load(b, g, ld_zone2, ''BOTH'') : ';
0534 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0535 t_is(Pd, [area(3).both.pnom; area(1).both.pnom], 12, [t 'Pd']);
0536 
0537 t = '[Pd, Qd] = total_load(b, g, ld_zone2, ''BOTH'') : ';
0538 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'BOTH');
0539 t_is(Pd, [area(3).both.pnom; area(1).both.pnom], 12, [t 'Pd']);
0540 t_is(Qd, [area(3).both.qnom; area(1).both.qnom], 12, [t 'Qd']);
0541 
0542 t = '      Pd = total_load(b, g, ld_zone2, ''FIXED'') : ';
0543 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0544 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0545 
0546 t = '[Pd, Qd] = total_load(b, g, ld_zone2, ''FIXED'') : ';
0547 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'FIXED');
0548 t_is(Pd, [area(3).fixed.p; area(1).fixed.p], 12, [t 'Pd']);
0549 t_is(Qd, [area(3).fixed.q; area(1).fixed.q], 12, [t 'Qd']);
0550 
0551 t = '      Pd = total_load(b, g, ld_zone2, ''DISPATCHABLE'') : ';
0552 Pd = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0553 t_is(Pd, [area(3).disp.pnom; area(1).disp.pnom], 12, [t 'Pd']);
0554 
0555 t = '[Pd, Qd] = total_load(b, g, ld_zone2, ''DISPATCHABLE'') : ';
0556 [Pd, Qd] = total_load(mpc.bus, mpc.gen, load_zone, 'DISPATCHABLE');
0557 t_is(Pd, [area(3).disp.pnom; area(1).disp.pnom], 12, [t 'Pd']);
0558 t_is(Qd, [area(3).disp.qnom; area(1).disp.qnom], 12, [t 'Qd']);
0559 
0560 t_end;

Generated on Mon 26-Jan-2015 15:21:31 by m2html © 2005