Home > matpower7.1 > lib > calc_branch_angle.m

calc_branch_angle

PURPOSE ^

CALC_BRANCH_ANGLE Calculate branch angle differences across active branches

SYNOPSIS ^

function delta = calc_branch_angle(mpc)

DESCRIPTION ^

CALC_BRANCH_ANGLE  Calculate branch angle differences across active branches
   DELTA = CALC_BRANCH_ANGLE(MPC)

   Calculates the angle difference (in degrees) across all active branches
   in the MATPOWER case. Angles are calculated as the difference between
   the FROM bus and the TO bus.

   Input:
       MPC   - MATPOWER case struct (can have external bus numbering)

   Output:
       DELTA - nl x 1 vector of branch angle differences Af - At, where
               Af and At are vectors of voltage angles at "from" and "to"
               ends of each line respectively. DELTA is 0 for out-of-service
               branches.

   See also TOGGLE_SOFTLIMS.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function delta = calc_branch_angle(mpc)
0002 %CALC_BRANCH_ANGLE  Calculate branch angle differences across active branches
0003 %   DELTA = CALC_BRANCH_ANGLE(MPC)
0004 %
0005 %   Calculates the angle difference (in degrees) across all active branches
0006 %   in the MATPOWER case. Angles are calculated as the difference between
0007 %   the FROM bus and the TO bus.
0008 %
0009 %   Input:
0010 %       MPC   - MATPOWER case struct (can have external bus numbering)
0011 %
0012 %   Output:
0013 %       DELTA - nl x 1 vector of branch angle differences Af - At, where
0014 %               Af and At are vectors of voltage angles at "from" and "to"
0015 %               ends of each line respectively. DELTA is 0 for out-of-service
0016 %               branches.
0017 %
0018 %   See also TOGGLE_SOFTLIMS.
0019 
0020 %   MATPOWER
0021 %   Copyright (c) 2018, Power Systems Engineering Research Center (PSERC)
0022 %   by Eran Schweitzer, Arizona State University
0023 %   and Ray Zimmerman, PSERC Cornell
0024 %
0025 %   This file is part of MATPOWER.
0026 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0027 %   See https://matpower.org for more info.
0028 
0029 %% define named indices into data matrices
0030 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0031     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0032 [F_BUS, T_BUS, BR_R, BR_X, BR_B, RATE_A, RATE_B, RATE_C, ...
0033     TAP, SHIFT, BR_STATUS, PF, QF, PT, QT, MU_SF, MU_ST, ...
0034     ANGMIN, ANGMAX, MU_ANGMIN, MU_ANGMAX] = idx_brch;
0035 
0036 status = mpc.branch(:, BR_STATUS);
0037 nl  = size(mpc.branch, 1);
0038 nb  = size(mpc.bus, 1);
0039 max_bus_num = max(mpc.bus(:, BUS_I));
0040 e2i = sparse(mpc.bus(:, BUS_I), 1, 1:nb, max_bus_num, 1);   %% ext to int bus number map
0041 bf  = full(e2i(mpc.branch(:, F_BUS)));              %% "from" bus indices
0042 bt  = full(e2i(mpc.branch(:, T_BUS)));              %% "to" bus indices
0043 
0044 A = sparse([1:nl,1:nl]', [bf; bt], [status; -status], nl, nb);
0045 delta = A * mpc.bus(:, VA);                         %% angle differences

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005