Home > matpower7.0 > lib > dcpf.m

dcpf

PURPOSE ^

DCPF Solves a DC power flow.

SYNOPSIS ^

function [Va, success] = dcpf(B, Pbus, Va0, ref, pv, pq)

DESCRIPTION ^

DCPF  Solves a DC power flow.
   [VA, SUCCESS] = DCPF(B, PBUS, VA0, REF, PV, PQ) solves for the bus
   voltage angles at all but the reference bus, given the full system
   B matrix and the vector of bus real power injections, the initial
   vector of bus voltage angles (in radians), and column vectors with
   the lists of bus indices for the swing bus, PV buses, and PQ buses,
   respectively. Returns a vector of bus voltage angles in radians.

   See also RUNDCPF, RUNPF.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Va, success] = dcpf(B, Pbus, Va0, ref, pv, pq)
0002 %DCPF  Solves a DC power flow.
0003 %   [VA, SUCCESS] = DCPF(B, PBUS, VA0, REF, PV, PQ) solves for the bus
0004 %   voltage angles at all but the reference bus, given the full system
0005 %   B matrix and the vector of bus real power injections, the initial
0006 %   vector of bus voltage angles (in radians), and column vectors with
0007 %   the lists of bus indices for the swing bus, PV buses, and PQ buses,
0008 %   respectively. Returns a vector of bus voltage angles in radians.
0009 %
0010 %   See also RUNDCPF, RUNPF.
0011 
0012 %   MATPOWER
0013 %   Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC)
0014 %   by Carlos E. Murillo-Sanchez, PSERC Cornell & Universidad Nacional de Colombia
0015 %   and Ray Zimmerman, PSERC Cornell
0016 %
0017 %   This file is part of MATPOWER.
0018 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0019 %   See https://matpower.org for more info.
0020 
0021 %% constant
0022 Va_threshold = 1e5;     %% arbitrary threshold on |Va| for declaring failure
0023 
0024 %% initialize result vector
0025 Va = Va0;
0026 success = 1;    %% successful by default
0027 
0028 %% set up to trap non-singular matrix warnings
0029 [lastmsg, lastid] = lastwarn;
0030 lastwarn('');
0031 
0032 %% update angles for non-reference buses
0033 Va([pv; pq]) = B([pv; pq], [pv; pq]) \ ...
0034                 (Pbus([pv; pq]) - B([pv; pq], ref) * Va0(ref));
0035 
0036 [msg, id] = lastwarn;
0037 %% Octave is not consistent in assigning proper warning id, so we'll just
0038 %% check for presence of *any* warning
0039 if ~isempty(msg) || max(abs(Va)) > Va_threshold
0040     success = 0;
0041 end
0042 
0043 %% restore warning state
0044 lastwarn(lastmsg, lastid);

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005