1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
43 Va = copy(Va0)
44
45
46 Va[pvpq] = spsolve(B[pvpq.T, pvpq], Pbus[pvpq] - B[pvpq.T, ref] * Va0[ref])
47
48 return Va
49