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

Source Code for Module pypower.pqcost

 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  """Splits the gencost variable into two pieces if costs are given for Qg. 
18  """ 
19   
20  from sys import stderr 
21   
22  from numpy import array, arange 
23   
24   
25 -def pqcost(gencost, ng, on=None):
26 """Splits the gencost variable into two pieces if costs are given for Qg. 27 28 Checks whether C{gencost} has cost information for reactive power 29 generation (rows C{ng+1} to C{2*ng}). If so, it returns the first C{ng} 30 rows in C{pcost} and the last C{ng} rows in C{qcost}. Otherwise, leaves 31 C{qcost} empty. Also does some error checking. 32 If C{on} is specified (list of indices of generators which are on line) 33 it only returns the rows corresponding to these generators. 34 35 @author: Ray Zimmerman (PSERC Cornell) 36 @author: Richard Lincoln 37 """ 38 if on is None: 39 on = arange(ng) 40 41 if gencost.shape[0] == ng: 42 pcost = gencost[on, :] 43 qcost = array([]) 44 elif gencost.shape[0] == 2 * ng: 45 pcost = gencost[on, :] 46 qcost = gencost[on + ng, :] 47 else: 48 stderr.write('pqcost: gencost has wrong number of rows\n') 49 50 return pcost, qcost
51