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

Source Code for Module pypower.update_mupq

 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  """Updates values of generator limit shadow prices. 
18  """ 
19   
20  from pypower.idx_gen import MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN 
21   
22   
23 -def update_mupq(baseMVA, gen, mu_PQh, mu_PQl, data):
24 """Updates values of generator limit shadow prices. 25 26 Updates the values of C{MU_PMIN}, C{MU_PMAX}, C{MU_QMIN}, C{MU_QMAX} based 27 on any shadow prices on the sloped portions of the generator 28 capability curve constraints. 29 30 @param mu_PQh: shadow prices on upper sloped portion of capability curves 31 @param mu_PQl: shadow prices on lower sloped portion of capability curves 32 @param data: "data" dict returned by L{makeApq} 33 34 @see: C{makeApq}. 35 36 @author: Ray Zimmerman (PSERC Cornell) 37 @author: Carlos E. Murillo-Sanchez (PSERC Cornell & Universidad 38 Autonoma de Manizales) 39 @author: Richard Lincoln 40 """ 41 ipqh, ipql, Apqhdata, Apqldata = \ 42 data['ipqh'], data['ipql'], data['h'], data['l'] 43 44 # If we succeeded and there were generators with general PQ curve 45 # characteristics, this is the time to re-compute the multipliers, 46 # splitting any nonzero multiplier on one of the linear bounds among the 47 # Pmax, Pmin, Qmax or Qmin limits, producing one multiplier for a P limit and 48 # another for a Q limit. For upper Q limit, if we are neither at Pmin nor at 49 # Pmax, the limit is taken as Pmin if the Qmax line's normal has a negative P 50 # component, Pmax if it has a positive P component. Messy but there really 51 # are many cases. 52 muPmax = gen[:, MU_PMAX] 53 muPmin = gen[:, MU_PMIN] 54 if len(mu_PQh) > 0: 55 #gen[:, [MU_PMIN, MU_PMAX, MU_QMIN, MU_QMAX]] 56 k = 0 57 for i in ipqh: 58 if muPmax[i] > 0: 59 gen[i, MU_PMAX] = gen[i, MU_PMAX] - mu_PQh[k] * Apqhdata[k, 0] / baseMVA 60 elif muPmin[i] > 0: 61 gen[i, MU_PMIN] = gen[i, MU_PMIN] + mu_PQh[k] * Apqhdata[k, 0] / baseMVA 62 else: 63 if Apqhdata[k, 0] >= 0: 64 gen[i, MU_PMAX] = gen[i, MU_PMAX] - mu_PQh[k] * Apqhdata[k, 0] / baseMVA 65 else: 66 gen[i, MU_PMIN] = gen[i, MU_PMIN] + mu_PQh[k] * Apqhdata[k, 0] / baseMVA 67 68 gen[i, MU_QMAX] = gen[i, MU_QMAX] - mu_PQh[k] * Apqhdata[k, 1] / baseMVA 69 k = k + 1 70 71 72 if len(mu_PQl) > 0: 73 #gen[:, [MU_PMIN, MU_PMAX, MU_QMIN, MU_QMAX]] 74 k = 0 75 for i in ipql: 76 if muPmax[i] > 0: 77 gen[i, MU_PMAX] = gen[i, MU_PMAX] - mu_PQl[k] * Apqldata[k, 0] / baseMVA 78 elif muPmin[i] > 0: 79 gen[i, MU_PMIN] = gen[i, MU_PMIN] + mu_PQl[k] * Apqldata[k, 0] / baseMVA 80 else: 81 if Apqldata[k, 0] >= 0: 82 gen[i, MU_PMAX] = gen[i, MU_PMAX] - mu_PQl[k] * Apqldata[k, 0] / baseMVA 83 else: 84 gen[i, MU_PMIN] = gen[i, MU_PMIN] + mu_PQl[k] * Apqldata[k, 0] / baseMVA 85 86 gen[i, MU_QMIN] = gen[i, MU_QMIN] + mu_PQl[k] * Apqldata[k, 1] / baseMVA 87 k = k + 1 88 89 #gen[:, [MU_PMIN, MU_PMAX, MU_QMIN, MU_QMAX]] 90 #-[ mu_PQl[:2], mu_PQh[:2] ] / baseMVA 91 #-[ mu_PQl[:2] * Apqldata[:2, 0], mu_PQh[:2] * Apqhdata[:2, 0] ] / baseMVA 92 #-[ mu_PQl[:2] * Apqldata[:2, 1], mu_PQh[:2] * Apqhdata[:2, 1] ] / baseMVA 93 94 return gen
95