Home > matpower6.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 %   Copyright (c) 2014-2016, Power Systems Engineering Research Center (PSERC)
0012 %   by Ray Zimmerman, PSERC Cornell
0013 %
0014 %   This file is part of MATPOWER.
0015 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0016 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0017 
0018 define_constants;
0019     
0020 %% create external to internal bus map
0021 nb  = size(mpc.bus, 1);     %% number of buses
0022 nl  = size(mpc.branch, 1);  %% number of branches
0023 mb  = max(abs([mpc.bus(:, BUS_I); mpc.gen(:, GEN_BUS); ...
0024             mpc.branch(:, F_BUS); mpc.branch(:, T_BUS)]));
0025 e2i = sparse(mpc.bus(:, BUS_I), ones(nb, 1), 1:nb, mb, 1);
0026 
0027 %% assign losses to downstream buses
0028 loss = mpc.branch(:, PF) + mpc.branch(:, PT);
0029 bus_loss = zeros(nb, 1);
0030 for j = 1:nl    %% need to use loop to accumulate for multiple lines per bus
0031     if mpc.branch(j, PF) >= mpc.branch(j, PT)
0032         b = T_BUS;
0033     else
0034         b = F_BUS;
0035     end
0036     ib = e2i(mpc.branch(j, b));
0037     bus_loss(ib) = bus_loss(ib) + loss(j);
0038 end

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005