Package pypower :: Module dcpf
[hide private]
[frames] | no frames]

Source Code for Module pypower.dcpf

 1  # Copyright (C) 1996-2011 Power System Engineering Research Center (PSERC) 
 2  # Copyright (C) 2011 Richard Lincoln 
 3  # 
 4  # PYPOWER is free software: you can redistribute it and/or modify 
 5  # it under the terms of the GNU General Public License as published 
 6  # by the Free Software Foundation, either version 3 of the License, 
 7  # or (at your option) any later version. 
 8  # 
 9  # PYPOWER is distributed in the hope that it will be useful, 
10  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
11  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
12  # GNU General Public License for more details. 
13  # 
14  # You should have received a copy of the GNU General Public License 
15  # along with PYPOWER. If not, see <http://www.gnu.org/licenses/>. 
16   
17  """Solves a DC power flow. 
18  """ 
19   
20  from numpy import copy, r_, matrix 
21  from scipy.sparse.linalg import spsolve 
22   
23   
24 -def dcpf(B, Pbus, Va0, ref, pv, pq):
25 """Solves a DC power flow. 26 27 Solves for the bus voltage angles at all but the reference bus, given the 28 full system C{B} matrix and the vector of bus real power injections, the 29 initial vector of bus voltage angles (in radians), and column vectors with 30 the lists of bus indices for the swing bus, PV buses, and PQ buses, 31 respectively. Returns a vector of bus voltage angles in radians. 32 33 @see: L{rundcpf}, L{runpf} 34 35 @author: Carlos E. Murillo-Sanchez (PSERC Cornell & Universidad 36 Autonoma de Manizales) 37 @author: Ray Zimmerman (PSERC Cornell) 38 @author: Richard Lincoln 39 """ 40 pvpq = matrix(r_[pv, pq]) 41 42 ## initialize result vector 43 Va = copy(Va0) 44 45 ## update angles for non-reference buses 46 Va[pvpq] = spsolve(B[pvpq.T, pvpq], Pbus[pvpq] - B[pvpq.T, ref] * Va0[ref]) 47 48 return Va
49