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

Source Code for Module pypower.d2AIbr_dV2

 1  # Copyright (C) 2008-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  """Computes 2nd derivatives of |complex current|**2 w.r.t. V. 
18  """ 
19   
20  from scipy.sparse import csr_matrix as sparse 
21   
22  from d2Ibr_dV2 import d2Ibr_dV2 
23   
24   
25 -def d2AIbr_dV2(dIbr_dVa, dIbr_dVm, Ibr, Ybr, V, lam):
26 """Computes 2nd derivatives of |complex current|**2 w.r.t. V. 27 28 Returns 4 matrices containing the partial derivatives w.r.t. voltage 29 angle and magnitude of the product of a vector C{lam} with the 1st partial 30 derivatives of the square of the magnitude of the branch currents. 31 Takes sparse first derivative matrices of complex flow, complex flow 32 vector, sparse branch admittance matrix C{Ybr}, voltage vector C{V} and 33 C{nl x 1} vector of multipliers C{lam}. Output matrices are sparse. 34 35 For more details on the derivations behind the derivative code used 36 in PYPOWER information, see: 37 38 [TN2] R. D. Zimmerman, I{"AC Power Flows, Generalized OPF Costs and 39 their Derivatives using Complex Matrix Notation"}, MATPOWER 40 Technical Note 2, February 2010. 41 U{http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf} 42 43 @see: L{dIbr_dV}. 44 45 @author: Ray Zimmerman (PSERC Cornell) 46 @author: Richard Lincoln 47 """ 48 # define 49 il = range(len(lam)) 50 51 diaglam = sparse((lam, (il, il))) 52 diagIbr_conj = sparse((Ibr.conj(), (il, il))) 53 54 Iaa, Iav, Iva, Ivv = d2Ibr_dV2(Ybr, V, diagIbr_conj * lam) 55 56 Haa = 2 * ( Iaa + dIbr_dVa.T * diaglam * dIbr_dVa.conj() ).real 57 Hva = 2 * ( Iva + dIbr_dVm.T * diaglam * dIbr_dVa.conj() ).real 58 Hav = 2 * ( Iav + dIbr_dVa.T * diaglam * dIbr_dVm.conj() ).real 59 Hvv = 2 * ( Ivv + dIbr_dVm.T * diaglam * dIbr_dVm.conj() ).real 60 61 return Haa, Hav, Hva, Hvv
62