Add auto_open parameter for plotly plotting functions
1 
# * coding: utf8 *


2  
3 
# Copyright 19962015 PSERC. All rights reserved.


4 
# Use of this source code is governed by a BSDstyle


5 
# license that can be found in the LICENSE file.


6  
7 
# Copyright (c) 20162021 by University of Kassel and Fraunhofer Institute for Energy Economics


8 
# and Energy System Technology (IEE), Kassel. All rights reserved.


9  
10  
11  1 
"""Solves a DC power flow.

12 
"""


13  
14  1 
from numpy import copy, r_, transpose, real, array 
15  1 
from scipy.sparse.linalg import spsolve 
16  
17  1 
def dcpf(B, Pbus, Va0, ref, pv, pq): 
18 
"""Solves a DC power flow.


19  
20 
Solves for the bus voltage angles at all but the reference bus, given the


21 
full system C{B} matrix and the vector of bus real power injections, the


22 
initial vector of bus voltage angles (in radians), and column vectors with


23 
the lists of bus indices for the swing bus, PV buses, and PQ buses,


24 
respectively. Returns a vector of bus voltage angles in radians.


25  
26 
@see: L{rundcpf}, L{runpf}


27  
28 
@author: Carlos E. MurilloSanchez (PSERC Cornell & Universidad


29 
Autonoma de Manizales)


30 
@author: Ray Zimmerman (PSERC Cornell)


31  
32 
# Version from pypower github (bugfix 'transpose')


33 
"""


34  1 
pvpq = r_[pv, pq] 
35  
36 
## initialize result vector


37  1 
Va = copy(Va0) 
38  
39 
## update angles for nonreference buses


40  1 
if pvpq.shape == (1, 1): #workaround for bug in scipy <0.19 
41 
pvpq = array(pvpq).flatten() 

42  1 
pvpq_matrix = B[pvpq.T,:].tocsc()[:,pvpq] 
43  1 
ref_matrix = transpose(Pbus[pvpq]  B[pvpq.T,:].tocsc()[:,ref] * Va0[ref]) 
44  1 
Va[pvpq] = real(spsolve(pvpq_matrix, ref_matrix)) 
45  
46  1 
return Va 
Read our documentation on viewing source code .