Home > matpower5.0 > extras > misc > loss2bus.m

loss2bus

PURPOSE ^

LOSS2BUS Accumulates branch real power losses at downstream buses.

SYNOPSIS ^

function bus_loss = loss2bus(mpc)

DESCRIPTION ^

LOSS2BUS   Accumulates branch real power losses at downstream buses.

   BUS_LOSS = LOSS2BUS(MPC)

   Takes a solved AC power flow case as input and returns an
   NB x 1 vector containing all branch active power losses
   accumulated to the bus at the downstream end of the branch.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function bus_loss = loss2bus(mpc)
0002 %LOSS2BUS   Accumulates branch real power losses at downstream buses.
0003 %
0004 %   BUS_LOSS = LOSS2BUS(MPC)
0005 %
0006 %   Takes a solved AC power flow case as input and returns an
0007 %   NB x 1 vector containing all branch active power losses
0008 %   accumulated to the bus at the downstream end of the branch.
0009 
0010 %   MATPOWER
0011 %   $Id: loss2bus.m 2471 2014-12-16 15:32:35Z ray $
0012 %   by Ray Zimmerman
0013 %   Copyright (c) 2014 by Ray Zimmerman
0014 %
0015 %   This file is part of MATPOWER.
0016 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0017 %
0018 %   MATPOWER is free software: you can redistribute it and/or modify
0019 %   it under the terms of the GNU General Public License as published
0020 %   by the Free Software Foundation, either version 3 of the License,
0021 %   or (at your option) any later version.
0022 %
0023 %   MATPOWER is distributed in the hope that it will be useful,
0024 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0026 %   GNU General Public License for more details.
0027 %
0028 %   You should have received a copy of the GNU General Public License
0029 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0030 %
0031 %   Additional permission under GNU GPL version 3 section 7
0032 %
0033 %   If you modify MATPOWER, or any covered work, to interface with
0034 %   other modules (such as MATLAB code and MEX-files) available in a
0035 %   MATLAB(R) or comparable environment containing parts covered
0036 %   under other licensing terms, the licensors of MATPOWER grant
0037 %   you additional permission to convey the resulting work.
0038 
0039 define_constants;
0040     
0041 %% create external to internal bus map
0042 nb  = size(mpc.bus, 1);     %% number of buses
0043 nl  = size(mpc.branch, 1);  %% number of branches
0044 mb  = max(abs([mpc.bus(:, BUS_I); mpc.gen(:, GEN_BUS); ...
0045             mpc.branch(:, F_BUS); mpc.branch(:, T_BUS)]));
0046 e2i = sparse(mpc.bus(:, BUS_I), ones(nb, 1), 1:nb, mb, 1);
0047 
0048 %% assign losses to downstream buses
0049 loss = mpc.branch(:, PF) + mpc.branch(:, PT);
0050 bus_loss = zeros(nb, 1);
0051 for j = 1:nl    %% need to use loop to accumulate for multiple lines per bus
0052     if mpc.branch(j, PF) >= mpc.branch(j, PT)
0053         b = T_BUS;
0054     else
0055         b = F_BUS;
0056     end
0057     ib = e2i(mpc.branch(j, b));
0058     bus_loss(ib) = bus_loss(ib) + loss(j);
0059 end

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