Home > matpower5.1 > t > t_margcost.m

t_margcost

PURPOSE ^

T_MARGCOST Tests for code in MARGCOST.

SYNOPSIS ^

function t_margcost(quiet)

DESCRIPTION ^

T_MARGCOST  Tests for code in MARGCOST.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function t_margcost(quiet)
0002 %T_MARGCOST  Tests for code in MARGCOST.
0003 
0004 %   MATPOWER
0005 %   Copyright (c) 2010-2015 by Power System Engineering Research Center (PSERC)
0006 %   by Ray Zimmerman, PSERC Cornell
0007 %
0008 %   $Id: t_margcost.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 = 22;
0019 
0020 t_begin(n_tests, quiet);
0021 
0022 %% define named indices into data matrices
0023 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0024     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0025     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0026 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0027 
0028 %% generator cost data
0029 %    1    startup    shutdown    n    x1    y1    ...    xn    yn
0030 %    2    startup    shutdown    n    c(n-1)    ...    c0
0031 gencost = [
0032     2    0    0    3    0.01    0.1    1    0    0    0    0    0;
0033     2    0    0    5    0.0006    0.005    0.04    0.3    2    0    0    0;
0034     1    0    0    4    0    0    10    200    20    600    30    1200;
0035     1    0    0    4    -30    -2400    -20    -1800    -10    -1000    0    0;
0036 ];
0037 
0038 t = 'margcost - quadratic';
0039 t_is(margcost(gencost, [0;0;0;0]), [0.1;0.3;20;100], 8, t);
0040 t_is(margcost(gencost, [1;0;0;0]), [0.12;0.3;20;100], 8, t);
0041 t_is(margcost(gencost, [2;0;0;0]), [0.14;0.3;20;100], 8, t);
0042 
0043 t = 'margcost - 4th order polynomial';
0044 t_is(margcost(gencost, [0;0;0;0]), [0.1;0.3;20;100], 8, t);
0045 t_is(margcost(gencost, [0;1;0;0]), [0.1;0.3974;20;100], 8, t);
0046 t_is(margcost(gencost, [0;2;0;0]), [0.1;0.5392;20;100], 8, t);
0047 
0048 t = 'margcost - pwl (gen)';
0049 t_is(margcost(gencost, [0;0;-10;0 ]), [0.1;0.3;20;100], 8, t);
0050 t_is(margcost(gencost, [0;0;5;0 ]),   [0.1;0.3;20;100], 8, t);
0051 t_is(margcost(gencost, [0;0;10;0]),   [0.1;0.3;20;100], 8, t);
0052 t_is(margcost(gencost, [0;0;15;0]),   [0.1;0.3;40;100], 8, t);
0053 t_is(margcost(gencost, [0;0;20;0]),   [0.1;0.3;40;100], 8, t);
0054 t_is(margcost(gencost, [0;0;25;0]),   [0.1;0.3;60;100], 8, t);
0055 t_is(margcost(gencost, [0;0;30;0]),   [0.1;0.3;60;100], 8, t);
0056 t_is(margcost(gencost, [0;0;35;0]),   [0.1;0.3;60;100], 8, t);
0057 
0058 t = 'margcost - pwl (load)';
0059 t_is(margcost(gencost, [0;0;0;10 ]), [0.1;0.3;20;100], 8, t);
0060 t_is(margcost(gencost, [0;0;0;-5 ]), [0.1;0.3;20;100], 8, t);
0061 t_is(margcost(gencost, [0;0;0;-10]), [0.1;0.3;20;80], 8, t);
0062 t_is(margcost(gencost, [0;0;0;-15]), [0.1;0.3;20;80], 8, t);
0063 t_is(margcost(gencost, [0;0;0;-20]), [0.1;0.3;20;60], 8, t);
0064 t_is(margcost(gencost, [0;0;0;-25]), [0.1;0.3;20;60], 8, t);
0065 t_is(margcost(gencost, [0;0;0;-30]), [0.1;0.3;20;60], 8, t);
0066 t_is(margcost(gencost, [0;0;0;-35]), [0.1;0.3;20;60], 8, t);
0067 
0068 t_end;

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