Home > matpower4.0 > LPeqslvr.m

LPeqslvr

PURPOSE ^

------------------------------ deprecated ------------------------------

SYNOPSIS ^

function [x, success] = LPeqslvr(x, om, Ybus, Yf, Yt, Afeq, bfeq, Af, bf, mpopt, il)

DESCRIPTION ^

------------------------------  deprecated  ------------------------------
   OPF solvers based on LPCONSTR to be removed in a future version.
--------------------------------------------------------------------------
LPEQSLVR
   [X, SUCCESS] = LPEQSLVR(X, OM, YBUS, YF, YT, AFEQ, BFEQ, AF, BF, MPOPT, IL)

   See also LPOPF_SOLVER.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [x, success] = LPeqslvr(x, om, Ybus, Yf, Yt, Afeq, bfeq, Af, bf, mpopt, il)
0002 %------------------------------  deprecated  ------------------------------
0003 %   OPF solvers based on LPCONSTR to be removed in a future version.
0004 %--------------------------------------------------------------------------
0005 %LPEQSLVR
0006 %   [X, SUCCESS] = LPEQSLVR(X, OM, YBUS, YF, YT, AFEQ, BFEQ, AF, BF, MPOPT, IL)
0007 %
0008 %   See also LPOPF_SOLVER.
0009 
0010 %   MATPOWER
0011 %   $Id: LPeqslvr.m,v 1.22 2010/04/26 19:45:25 ray Exp $
0012 %   by Deqiang (David) Gan, PSERC Cornell & Zhejiang University
0013 %   and Ray Zimmerman, PSERC Cornell
0014 %   Copyright (c) 1996-2010 by Power System Engineering Research Center (PSERC)
0015 %
0016 %   This file is part of MATPOWER.
0017 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0018 %
0019 %   MATPOWER is free software: you can redistribute it and/or modify
0020 %   it under the terms of the GNU General Public License as published
0021 %   by the Free Software Foundation, either version 3 of the License,
0022 %   or (at your option) any later version.
0023 %
0024 %   MATPOWER is distributed in the hope that it will be useful,
0025 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0026 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0027 %   GNU General Public License for more details.
0028 %
0029 %   You should have received a copy of the GNU General Public License
0030 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0031 %
0032 %   Additional permission under GNU GPL version 3 section 7
0033 %
0034 %   If you modify MATPOWER, or any covered work, to interface with
0035 %   other modules (such as MATLAB code and MEX-files) available in a
0036 %   MATLAB(R) or comparable environment containing parts covered
0037 %   under other licensing terms, the licensors of MATPOWER grant
0038 %   you additional permission to convey the resulting work.
0039 
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 [PW_LINEAR, POLYNOMIAL, MODEL, STARTUP, SHUTDOWN, NCOST, COST] = idx_cost;
0048 
0049 %% options
0050 verbose = mpopt(31);            %% verbose
0051 
0052 %% default args
0053 if nargin < 11
0054     il = [];
0055 end
0056 
0057 %% unpack data
0058 mpc = get_mpc(om);
0059 [baseMVA, bus, gen, branch, gencost] = ...
0060     deal(mpc.baseMVA, mpc.bus, mpc.gen, mpc.branch, mpc.gencost);
0061 vv = get_idx(om);
0062 
0063 %% problem dimensions
0064 ny = getN(om, 'var', 'y');  %% number of piece-wise linear costs
0065 
0066 %% set default constrained lines
0067 if isempty(il)
0068     nl = size(branch, 1);   %% number of branches
0069     il = (1:nl);            %% all lines have limits by default
0070 end
0071 
0072 %% parse x, update bus, gen
0073 bus(:, VA) = x(vv.i1.Va:vv.iN.Va) * 180/pi;
0074 bus(:, VM) = x(vv.i1.Vm:vv.iN.Vm);
0075 gen(:, PG) = x(vv.i1.Pg:vv.iN.Pg) * baseMVA;
0076 gen(:, QG) = x(vv.i1.Qg:vv.iN.Qg) * baseMVA;
0077 
0078 %% turn down verbosity one level for call to power flow
0079 if verbose
0080     mpopt = mpoption(mpopt, 'VERBOSE', verbose-1);
0081 end
0082 
0083 %% get bus index lists of each type of bus
0084 [ref, pv, pq] = bustypes(bus, gen);
0085 
0086 %% run the power flow
0087 V = bus(:, VM) .* exp(1j * bus(:, VA) * pi/180);
0088 Sbus = makeSbus(baseMVA, bus, gen);
0089 [V, success, iterations] = newtonpf(Ybus, Sbus, V, ref, pv, pq, mpopt);   %% do NR iteration
0090 [bus, gen, branch] = pfsoln(baseMVA, bus, gen, branch(il,:), Ybus, Yf, Yt, V, ref, pv, pq);   %% post-processing
0091 % printpf(baseMVA, bus, gen, branch, [], success, 0, 1, mpopt);
0092 
0093 
0094 %% update x
0095 x(vv.i1.Va:vv.iN.Va) = bus(:, VA) * pi/180;
0096 x(vv.i1.Vm:vv.iN.Vm) = bus(:, VM);
0097 x(vv.i1.Pg:vv.iN.Pg) = gen(:, PG) / baseMVA;
0098 x(vv.i1.Qg:vv.iN.Qg) = gen(:, QG) / baseMVA;
0099 if ny > 0
0100     PgQg = [gen(:, PG); gen(:, QG)];
0101     ipwl = find(gencost(:, MODEL) == PW_LINEAR);  %% piece-wise linear costs
0102     x(vv.i1.y:vv.iN.y) = totcost(gencost(ipwl, :), PgQg(ipwl));
0103 end

Generated on Mon 26-Jan-2015 14:56:45 by m2html © 2005