Home > matpower4.1 > t > t_loadcase.m

t_loadcase

PURPOSE ^

T_LOADCASE Test that LOADCASE works with a struct as well as case file.

SYNOPSIS ^

function t_loadcase(quiet)

DESCRIPTION ^

T_LOADCASE  Test that LOADCASE works with a struct as well as case file.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_loadcase(quiet)
0002 %T_LOADCASE  Test that LOADCASE works with a struct as well as case file.
0003 
0004 %   MATPOWER
0005 %   $Id: t_loadcase.m,v 1.12 2010/04/26 19:45:26 ray Exp $
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %   Copyright (c) 2004-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 t_begin(240, quiet);
0038 
0039 %% compare result of loading from M-file file to result of using data matrices
0040 casefile = 't_case9_opf';
0041 matfile  = 't_mat9_opf';
0042 pfcasefile = 't_case9_pf';
0043 pfmatfile  = 't_mat9_pf';
0044 casefilev2 = 't_case9_opfv2';
0045 matfilev2  = 't_mat9_opfv2';
0046 pfcasefilev2 = 't_case9_pfv2';
0047 pfmatfilev2  = 't_mat9_pfv2';
0048 
0049 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0050     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0051     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
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 
0056 %% read version 1 OPF data matrices
0057 [baseMVA, bus, gen, branch, areas, gencost] = feval(casefile);
0058 %% save as .mat file
0059 eval(['save ' matfile '.mat baseMVA bus gen branch areas gencost']);
0060 
0061 %% read version 2 OPF data matrices
0062 mpc = feval(casefilev2);
0063 %% save as .mat file
0064 eval(['save ' matfilev2 '.mat mpc']);
0065 
0066 %% prepare expected matrices for v1 load
0067 %% (missing gen cap curve & branch ang diff lims)
0068 tmp1 = {mpc.baseMVA, mpc.bus, mpc.gen, mpc.branch, mpc.areas, mpc.gencost};
0069 tmp2 = {mpc.baseMVA, mpc.bus, mpc.gen, mpc.branch, mpc.areas, mpc.gencost};
0070 %% remove capability curves, angle difference limits
0071 tmp1{3}(2:3, [PC1, PC2, QC1MIN, QC1MAX, QC2MIN, QC2MAX]) = zeros(2,6);
0072 tmp1{4}(1, ANGMAX) = 360;
0073 tmp1{4}(9, ANGMIN) = -360;
0074 [baseMVA, bus, gen, branch, areas, gencost] = deal(tmp1{:});
0075 
0076 %%-----  load OPF data into individual matrices  -----
0077 t = 'loadcase(opf_M_file_v1) without .m extension : ';
0078 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = loadcase(casefile);
0079 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0080 t_is(bus1,      bus,        12, [t 'bus']);
0081 t_is(gen1,      gen,        12, [t 'gen']);
0082 t_is(branch1,   branch,     12, [t 'branch']);
0083 t_is(areas1,    areas,      12, [t 'areas']);
0084 t_is(gencost1,  gencost,    12, [t 'gencost']);
0085 
0086 t = 'loadcase(opf_M_file_v1) with .m extension : ';
0087 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = loadcase([casefile '.m']);
0088 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0089 t_is(bus1,      bus,        12, [t 'bus']);
0090 t_is(gen1,      gen,        12, [t 'gen']);
0091 t_is(branch1,   branch,     12, [t 'branch']);
0092 t_is(areas1,    areas,      12, [t 'areas']);
0093 t_is(gencost1,  gencost,    12, [t 'gencost']);
0094 
0095 t = 'loadcase(opf_MAT_file_v1) without .mat extension : ';
0096 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = loadcase(matfile);
0097 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0098 t_is(bus1,      bus,        12, [t 'bus']);
0099 t_is(gen1,      gen,        12, [t 'gen']);
0100 t_is(branch1,   branch,     12, [t 'branch']);
0101 t_is(areas1,    areas,      12, [t 'areas']);
0102 t_is(gencost1,  gencost,    12, [t 'gencost']);
0103 
0104 t = 'loadcase(opf_MAT_file_v1) with .mat extension : ';
0105 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = loadcase([matfile '.mat']);
0106 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0107 t_is(bus1,      bus,        12, [t 'bus']);
0108 t_is(gen1,      gen,        12, [t 'gen']);
0109 t_is(branch1,   branch,     12, [t 'branch']);
0110 t_is(areas1,    areas,      12, [t 'areas']);
0111 t_is(gencost1,  gencost,    12, [t 'gencost']);
0112 
0113 %% prepare expected matrices for v2 load
0114 [baseMVA, bus, gen, branch, areas, gencost] = deal(tmp2{:});
0115 
0116 t = 'loadcase(opf_M_file_v2) without .m extension : ';
0117 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = loadcase(casefilev2);
0118 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0119 t_is(bus1,      bus,        12, [t 'bus']);
0120 t_is(gen1,      gen,        12, [t 'gen']);
0121 t_is(branch1,   branch,     12, [t 'branch']);
0122 t_is(areas1,    areas,      12, [t 'areas']);
0123 t_is(gencost1,  gencost,    12, [t 'gencost']);
0124 
0125 t = 'loadcase(opf_M_file_v2) with .m extension : ';
0126 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = loadcase([casefilev2 '.m']);
0127 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0128 t_is(bus1,      bus,        12, [t 'bus']);
0129 t_is(gen1,      gen,        12, [t 'gen']);
0130 t_is(branch1,   branch,     12, [t 'branch']);
0131 t_is(areas1,    areas,      12, [t 'areas']);
0132 t_is(gencost1,  gencost,    12, [t 'gencost']);
0133 
0134 t = 'loadcase(opf_MAT_file_v2) without .mat extension : ';
0135 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = loadcase(matfilev2);
0136 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0137 t_is(bus1,      bus,        12, [t 'bus']);
0138 t_is(gen1,      gen,        12, [t 'gen']);
0139 t_is(branch1,   branch,     12, [t 'branch']);
0140 t_is(areas1,    areas,      12, [t 'areas']);
0141 t_is(gencost1,  gencost,    12, [t 'gencost']);
0142 
0143 t = 'loadcase(opf_MAT_file_v2) with .mat extension : ';
0144 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = loadcase([matfilev2 '.mat']);
0145 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0146 t_is(bus1,      bus,        12, [t 'bus']);
0147 t_is(gen1,      gen,        12, [t 'gen']);
0148 t_is(branch1,   branch,     12, [t 'branch']);
0149 t_is(areas1,    areas,      12, [t 'areas']);
0150 t_is(gencost1,  gencost,    12, [t 'gencost']);
0151 
0152 %% prepare expected matrices for v1 load
0153 [baseMVA, bus, gen, branch, areas, gencost] = deal(tmp1{:});
0154 
0155 t = 'loadcase(opf_struct_v1) (no version): ';
0156 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = feval(casefile);
0157 clear c;
0158 c.baseMVA   = baseMVA1;
0159 c.bus       = bus1;
0160 c.gen       = gen1;
0161 c.branch    = branch1;
0162 c.areas     = areas1;
0163 c.gencost   = gencost1;
0164 [baseMVA2, bus2, gen2, branch2, areas2, gencost2] = loadcase(c);
0165 t_is(baseMVA2,  baseMVA,    12, [t 'baseMVA']);
0166 t_is(bus2,      bus,        12, [t 'bus']);
0167 t_is(gen2,      gen,        12, [t 'gen']);
0168 t_is(branch2,   branch,     12, [t 'branch']);
0169 t_is(areas2,    areas,      12, [t 'areas']);
0170 t_is(gencost2,  gencost,    12, [t 'gencost']);
0171 
0172 t = 'loadcase(opf_struct_v1) (version=''1''): ';
0173 c.version   = '1';
0174 [baseMVA2, bus2, gen2, branch2, areas2, gencost2] = loadcase(c);
0175 t_is(baseMVA2,  baseMVA,    12, [t 'baseMVA']);
0176 t_is(bus2,      bus,        12, [t 'bus']);
0177 t_is(gen2,      gen,        12, [t 'gen']);
0178 t_is(branch2,   branch,     12, [t 'branch']);
0179 t_is(areas2,    areas,      12, [t 'areas']);
0180 t_is(gencost2,  gencost,    12, [t 'gencost']);
0181 
0182 %% prepare expected matrices for v2 load
0183 [baseMVA, bus, gen, branch, areas, gencost] = deal(tmp2{:});
0184 
0185 t = 'loadcase(opf_struct_v2) (no version): ';
0186 clear c;
0187 c.baseMVA   = baseMVA;
0188 c.bus       = bus;
0189 c.gen       = gen;
0190 c.branch    = branch;
0191 c.areas     = areas;
0192 c.gencost   = gencost;
0193 [baseMVA2, bus2, gen2, branch2, areas2, gencost2] = loadcase(c);
0194 t_is(baseMVA2,  baseMVA,    12, [t 'baseMVA']);
0195 t_is(bus2,      bus,        12, [t 'bus']);
0196 t_is(gen2,      gen,        12, [t 'gen']);
0197 t_is(branch2,   branch,     12, [t 'branch']);
0198 t_is(areas2,    areas,      12, [t 'areas']);
0199 t_is(gencost2,  gencost,    12, [t 'gencost']);
0200 
0201 t = 'loadcase(opf_struct_v2) (version=''2''): ';
0202 clear c;
0203 c.baseMVA   = baseMVA;
0204 c.bus       = bus;
0205 c.gen       = gen;
0206 c.branch    = branch;
0207 c.areas     = areas;
0208 c.gencost   = gencost;
0209 c.version   = '2';
0210 [baseMVA2, bus2, gen2, branch2, areas2, gencost2] = loadcase(c);
0211 t_is(baseMVA2,  baseMVA,    12, [t 'baseMVA']);
0212 t_is(bus2,      bus,        12, [t 'bus']);
0213 t_is(gen2,      gen,        12, [t 'gen']);
0214 t_is(branch2,   branch,     12, [t 'branch']);
0215 t_is(areas2,    areas,      12, [t 'areas']);
0216 t_is(gencost2,  gencost,    12, [t 'gencost']);
0217 
0218 %%-----  load OPF data into struct  -----
0219 %% prepare expected matrices for v1 load
0220 [baseMVA, bus, gen, branch, areas, gencost] = deal(tmp1{:});
0221 
0222 t = 'mpc = loadcase(opf_M_file_v1) without .m extension : ';
0223 mpc1 = loadcase(casefile);
0224 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0225 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0226 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0227 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0228 t_is(mpc1.areas,    areas,      12, [t 'areas']);
0229 t_is(mpc1.gencost,  gencost,    12, [t 'gencost']);
0230 
0231 t = 'mpc = loadcase(opf_M_file_v1) with .m extension : ';
0232 mpc1 = loadcase([casefile '.m']);
0233 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0234 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0235 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0236 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0237 t_is(mpc1.areas,    areas,      12, [t 'areas']);
0238 t_is(mpc1.gencost,  gencost,    12, [t 'gencost']);
0239 
0240 t = 'mpc = loadcase(opf_MAT_file_v1) without .mat extension : ';
0241 mpc1 = loadcase(matfile);
0242 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0243 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0244 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0245 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0246 t_is(mpc1.areas,    areas,      12, [t 'areas']);
0247 t_is(mpc1.gencost,  gencost,    12, [t 'gencost']);
0248 
0249 t = 'mpc = loadcase(opf_MAT_file_v1) with .mat extension : ';
0250 mpc1 = loadcase([matfile '.mat']);
0251 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0252 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0253 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0254 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0255 t_is(mpc1.areas,    areas,      12, [t 'areas']);
0256 t_is(mpc1.gencost,  gencost,    12, [t 'gencost']);
0257 
0258 %% prepare expected matrices for v2 load
0259 [baseMVA, bus, gen, branch, areas, gencost] = deal(tmp2{:});
0260 
0261 t = 'mpc = loadcase(opf_M_file_v2) without .m extension : ';
0262 mpc1 = loadcase(casefilev2);
0263 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0264 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0265 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0266 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0267 t_is(mpc1.areas,    areas,      12, [t 'areas']);
0268 t_is(mpc1.gencost,  gencost,    12, [t 'gencost']);
0269 
0270 t = 'mpc = loadcase(opf_M_file_v2) with .m extension : ';
0271 mpc1 = loadcase([casefilev2 '.m']);
0272 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0273 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0274 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0275 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0276 t_is(mpc1.areas,    areas,      12, [t 'areas']);
0277 t_is(mpc1.gencost,  gencost,    12, [t 'gencost']);
0278 
0279 t = 'mpc = loadcase(opf_MAT_file_v2) without .mat extension : ';
0280 mpc1 = loadcase(matfilev2);
0281 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0282 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0283 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0284 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0285 t_is(mpc1.areas,    areas,      12, [t 'areas']);
0286 t_is(mpc1.gencost,  gencost,    12, [t 'gencost']);
0287 
0288 t = 'mpc = loadcase(opf_MAT_file_v2) with .mat extension : ';
0289 mpc1 = loadcase([matfilev2 '.mat']);
0290 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0291 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0292 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0293 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0294 t_is(mpc1.areas,    areas,      12, [t 'areas']);
0295 t_is(mpc1.gencost,  gencost,    12, [t 'gencost']);
0296 
0297 %% prepare expected matrices for v1 load
0298 [baseMVA, bus, gen, branch, areas, gencost] = deal(tmp1{:});
0299 
0300 t = 'mpc = loadcase(opf_struct_v1) (no version): ';
0301 [baseMVA1, bus1, gen1, branch1, areas1, gencost1] = feval(casefile);
0302 clear c;
0303 c.baseMVA   = baseMVA1;
0304 c.bus       = bus1;
0305 c.gen       = gen1;
0306 c.branch    = branch1;
0307 c.areas     = areas1;
0308 c.gencost   = gencost1;
0309 mpc2 = loadcase(c);
0310 t_is(mpc2.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0311 t_is(mpc2.bus,      bus,        12, [t 'bus']);
0312 t_is(mpc2.gen,      gen,        12, [t 'gen']);
0313 t_is(mpc2.branch,   branch,     12, [t 'branch']);
0314 t_is(mpc2.areas,    areas,      12, [t 'areas']);
0315 t_is(mpc2.gencost,  gencost,    12, [t 'gencost']);
0316 
0317 t = 'mpc = loadcase(opf_struct_v1) (version=''1''): ';
0318 c.version   = '1';
0319 mpc2 = loadcase(c);
0320 t_is(mpc2.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0321 t_is(mpc2.bus,      bus,        12, [t 'bus']);
0322 t_is(mpc2.gen,      gen,        12, [t 'gen']);
0323 t_is(mpc2.branch,   branch,     12, [t 'branch']);
0324 t_is(mpc2.areas,    areas,      12, [t 'areas']);
0325 t_is(mpc2.gencost,  gencost,    12, [t 'gencost']);
0326 
0327 %% prepare expected matrices for v2 load
0328 [baseMVA, bus, gen, branch, areas, gencost] = deal(tmp2{:});
0329 
0330 t = 'mpc = loadcase(opf_struct_v2) (no version): ';
0331 clear c;
0332 c.baseMVA   = baseMVA;
0333 c.bus       = bus;
0334 c.gen       = gen;
0335 c.branch    = branch;
0336 c.areas     = areas;
0337 c.gencost   = gencost;
0338 mpc2 = loadcase(c);
0339 t_is(mpc2.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0340 t_is(mpc2.bus,      bus,        12, [t 'bus']);
0341 t_is(mpc2.gen,      gen,        12, [t 'gen']);
0342 t_is(mpc2.branch,   branch,     12, [t 'branch']);
0343 t_is(mpc2.areas,    areas,      12, [t 'areas']);
0344 t_is(mpc2.gencost,  gencost,    12, [t 'gencost']);
0345 t_ok(strcmp(mpc2.version, '2'), [t 'version']);  
0346 
0347 t = 'mpc = loadcase(opf_struct_v2) (version=''2''): ';
0348 clear c;
0349 c.baseMVA   = baseMVA;
0350 c.bus       = bus;
0351 c.gen       = gen;
0352 c.branch    = branch;
0353 c.areas     = areas;
0354 c.gencost   = gencost;
0355 c.version   = '2';
0356 mpc2 = loadcase(c);
0357 t_is(mpc2.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0358 t_is(mpc2.bus,      bus,        12, [t 'bus']);
0359 t_is(mpc2.gen,      gen,        12, [t 'gen']);
0360 t_is(mpc2.branch,   branch,     12, [t 'branch']);
0361 t_is(mpc2.areas,    areas,      12, [t 'areas']);
0362 t_is(mpc2.gencost,  gencost,    12, [t 'gencost']);
0363 
0364 
0365 %% read version 1 PF data matrices
0366 [baseMVA, bus, gen, branch] = feval(pfcasefile);
0367 eval(['save ' pfmatfile '.mat baseMVA bus gen branch']);
0368 
0369 %% read version 2 PF data matrices
0370 mpc = feval(pfcasefilev2);
0371 tmp = {mpc.baseMVA, mpc.bus, mpc.gen, mpc.branch};
0372 [baseMVA, bus, gen, branch] = deal(tmp{:});
0373 %% save as .mat file
0374 eval(['save ' pfmatfilev2 '.mat mpc']);
0375 
0376 %%-----  load PF data into individual matrices  -----
0377 t = 'loadcase(pf_M_file_v1) without .m extension : ';
0378 [baseMVA1, bus1, gen1, branch1] = loadcase(pfcasefile);
0379 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0380 t_is(bus1,      bus,        12, [t 'bus']);
0381 t_is(gen1,      gen,        12, [t 'gen']);
0382 t_is(branch1,   branch,     12, [t 'branch']);
0383 
0384 t = 'loadcase(pf_M_file_v1) with .m extension : ';
0385 [baseMVA1, bus1, gen1, branch1] = loadcase([pfcasefile '.m']);
0386 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0387 t_is(bus1,      bus,        12, [t 'bus']);
0388 t_is(gen1,      gen,        12, [t 'gen']);
0389 t_is(branch1,   branch,     12, [t 'branch']);
0390 
0391 t = 'loadcase(pf_MAT_file_v1) without .mat extension : ';
0392 [baseMVA1, bus1, gen1, branch1] = loadcase(pfmatfile);
0393 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0394 t_is(bus1,      bus,        12, [t 'bus']);
0395 t_is(gen1,      gen,        12, [t 'gen']);
0396 t_is(branch1,   branch,     12, [t 'branch']);
0397 
0398 t = 'loadcase(pf_MAT_file_v1) with .mat extension : ';
0399 [baseMVA1, bus1, gen1, branch1] = loadcase([pfmatfile '.mat']);
0400 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0401 t_is(bus1,      bus,        12, [t 'bus']);
0402 t_is(gen1,      gen,        12, [t 'gen']);
0403 t_is(branch1,   branch,     12, [t 'branch']);
0404 
0405 t = 'loadcase(pf_M_file_v2) without .m extension : ';
0406 [baseMVA1, bus1, gen1, branch1] = loadcase(pfcasefilev2);
0407 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0408 t_is(bus1,      bus,        12, [t 'bus']);
0409 t_is(gen1,      gen,        12, [t 'gen']);
0410 t_is(branch1,   branch,     12, [t 'branch']);
0411 
0412 t = 'loadcase(pf_M_file_v2) with .m extension : ';
0413 [baseMVA1, bus1, gen1, branch1] = loadcase([pfcasefilev2 '.m']);
0414 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0415 t_is(bus1,      bus,        12, [t 'bus']);
0416 t_is(gen1,      gen,        12, [t 'gen']);
0417 t_is(branch1,   branch,     12, [t 'branch']);
0418 
0419 t = 'loadcase(pf_MAT_file_v2) without .mat extension : ';
0420 [baseMVA1, bus1, gen1, branch1] = loadcase(pfmatfilev2);
0421 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0422 t_is(bus1,      bus,        12, [t 'bus']);
0423 t_is(gen1,      gen,        12, [t 'gen']);
0424 t_is(branch1,   branch,     12, [t 'branch']);
0425 
0426 t = 'loadcase(pf_MAT_file_v2) with .mat extension : ';
0427 [baseMVA1, bus1, gen1, branch1] = loadcase([pfmatfilev2 '.mat']);
0428 t_is(baseMVA1,  baseMVA,    12, [t 'baseMVA']);
0429 t_is(bus1,      bus,        12, [t 'bus']);
0430 t_is(gen1,      gen,        12, [t 'gen']);
0431 t_is(branch1,   branch,     12, [t 'branch']);
0432 
0433 t = 'loadcase(pf_struct_v1) (no version): ';
0434 [baseMVA1, bus1, gen1, branch1] = feval(pfcasefile);
0435 clear c;
0436 c.baseMVA   = baseMVA1;
0437 c.bus       = bus1;
0438 c.gen       = gen1;
0439 c.branch    = branch1;
0440 [baseMVA2, bus2, gen2, branch2] = loadcase(c);
0441 t_is(baseMVA2,  baseMVA,    12, [t 'baseMVA']);
0442 t_is(bus2,      bus,        12, [t 'bus']);
0443 t_is(gen2,      gen,        12, [t 'gen']);
0444 t_is(branch2,   branch,     12, [t 'branch']);
0445 
0446 t = 'loadcase(pf_struct_v1) (version=''1''): ';
0447 c.version   = '1';
0448 [baseMVA2, bus2, gen2, branch2] = loadcase(c);
0449 t_is(baseMVA2,  baseMVA,    12, [t 'baseMVA']);
0450 t_is(bus2,      bus,        12, [t 'bus']);
0451 t_is(gen2,      gen,        12, [t 'gen']);
0452 t_is(branch2,   branch,     12, [t 'branch']);
0453 
0454 t = 'loadcase(pf_struct_v2) : ';
0455 clear c;
0456 c.baseMVA   = baseMVA;
0457 c.bus       = bus;
0458 c.gen       = gen;
0459 c.branch    = branch;
0460 c.version   = '2';
0461 [baseMVA2, bus2, gen2, branch2] = loadcase(c);
0462 t_is(baseMVA2,  baseMVA,    12, [t 'baseMVA']);
0463 t_is(bus2,      bus,        12, [t 'bus']);
0464 t_is(gen2,      gen,        12, [t 'gen']);
0465 t_is(branch2,   branch,     12, [t 'branch']);
0466 
0467 
0468 
0469 
0470 
0471 
0472 
0473 
0474 
0475 
0476 
0477 
0478 %%-----  load PF data into struct  -----
0479 t = 'mpc = loadcase(pf_M_file_v1) without .m extension : ';
0480 mpc1 = loadcase(pfcasefile);
0481 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0482 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0483 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0484 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0485 
0486 t = 'mpc = loadcase(pf_M_file_v1) with .m extension : ';
0487 mpc1 = loadcase([pfcasefile '.m']);
0488 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0489 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0490 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0491 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0492 
0493 t = 'mpc = loadcase(pf_MAT_file_v1) without .mat extension : ';
0494 mpc1 = loadcase(pfmatfile);
0495 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0496 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0497 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0498 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0499 
0500 t = 'mpc = loadcase(pf_MAT_file_v1) with .mat extension : ';
0501 mpc1 = loadcase([pfmatfile '.mat']);
0502 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0503 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0504 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0505 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0506 
0507 t = 'mpc = loadcase(pf_M_file_v2) without .m extension : ';
0508 mpc1 = loadcase(pfcasefilev2);
0509 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0510 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0511 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0512 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0513 
0514 t = 'mpc = loadcase(pf_M_file_v2) with .m extension : ';
0515 mpc1 = loadcase([pfcasefilev2 '.m']);
0516 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0517 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0518 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0519 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0520 
0521 t = 'mpc = loadcase(pf_MAT_file_v2) without .mat extension : ';
0522 mpc1 = loadcase(pfmatfilev2);
0523 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0524 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0525 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0526 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0527 
0528 t = 'mpc = loadcase(pf_MAT_file_v2) with .mat extension : ';
0529 mpc1 = loadcase([pfmatfilev2 '.mat']);
0530 t_is(mpc1.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0531 t_is(mpc1.bus,      bus,        12, [t 'bus']);
0532 t_is(mpc1.gen,      gen,        12, [t 'gen']);
0533 t_is(mpc1.branch,   branch,     12, [t 'branch']);
0534 
0535 t = 'mpc = loadcase(pf_struct_v1) (no version): ';
0536 [baseMVA1, bus1, gen1, branch1] = feval(pfcasefile);
0537 clear c;
0538 c.baseMVA   = baseMVA1;
0539 c.bus       = bus1;
0540 c.gen       = gen1;
0541 c.branch    = branch1;
0542 mpc2 = loadcase(c);
0543 t_is(mpc2.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0544 t_is(mpc2.bus,      bus,        12, [t 'bus']);
0545 t_is(mpc2.gen,      gen,        12, [t 'gen']);
0546 t_is(mpc2.branch,   branch,     12, [t 'branch']);
0547 
0548 t = 'mpc = loadcase(pf_struct_v1) (version=''1''): ';
0549 c.version   = '1';
0550 mpc2 = loadcase(c);
0551 t_is(mpc2.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0552 t_is(mpc2.bus,      bus,        12, [t 'bus']);
0553 t_is(mpc2.gen,      gen,        12, [t 'gen']);
0554 t_is(mpc2.branch,   branch,     12, [t 'branch']);
0555 
0556 t = 'mpc = loadcase(pf_struct_v2) : ';
0557 clear c;
0558 c.baseMVA   = baseMVA;
0559 c.bus       = bus;
0560 c.gen       = gen;
0561 c.branch    = branch;
0562 c.version   = '2';
0563 mpc2 = loadcase(c);
0564 t_is(mpc2.baseMVA,  baseMVA,    12, [t 'baseMVA']);
0565 t_is(mpc2.bus,      bus,        12, [t 'bus']);
0566 t_is(mpc2.gen,      gen,        12, [t 'gen']);
0567 t_is(mpc2.branch,   branch,     12, [t 'branch']);
0568 
0569 %% cleanup
0570 delete([ matfile '.mat' ]);
0571 delete([ pfmatfile '.mat' ]);
0572 delete([ matfilev2 '.mat' ]);
0573 delete([ pfmatfilev2 '.mat' ]);
0574 
0575 t = 'runpf(my_M_file)';
0576 opt = mpoption('VERBOSE', 0, 'OUT_ALL', 0);
0577 [baseMVA3, bus3, gen3, branch3, success, et] = runpf(pfcasefile, opt);
0578 t_ok( success, t );
0579 
0580 t = 'runpf(my_struct)';
0581 [baseMVA4, bus4, gen4, branch4, success, et] = runpf(c, opt);
0582 t_ok( success, t );
0583 
0584 t = 'runpf result comparison : ';
0585 t_is(baseMVA3,  baseMVA4,   12, [t 'baseMVA']);
0586 t_is(bus3,      bus4,       12, [t 'bus']);
0587 t_is(gen3,      gen4,       12, [t 'gen']);
0588 t_is(branch3,   branch4,    12, [t 'branch']);
0589 
0590 t = 'runpf(modified_struct)';
0591 c.gen(3,2) = c.gen(3,2) + 1;            %% increase gen 3 output by 1
0592 [baseMVA5, bus5, gen5, branch5, success, et] = runpf(c, opt);
0593 t_is(gen5(1,2), gen4(1,2) - 1, 1, t);   %% slack bus output should decrease by 1
0594 
0595 t_end;

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005