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

Source Code for Module pypower.d2ASbr_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 power flow|**2 w.r.t. V. 
18  """ 
19   
20  from scipy.sparse import csr_matrix 
21   
22  from d2Sbr_dV2 import d2Sbr_dV2 
23   
24   
25 -def d2ASbr_dV2(dSbr_dVa, dSbr_dVm, Sbr, Cbr, Ybr, V, lam):
26 """Computes 2nd derivatives of |complex power flow|**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 branch complex power flows. 31 Takes sparse first derivative matrices of complex flow, complex flow 32 vector, sparse connection matrix C{Cbr}, sparse branch admittance matrix 33 C{Ybr}, voltage vector C{V} and C{nl x 1} vector of multipliers C{lam}. 34 Output matrices are sparse. 35 36 For more details on the derivations behind the derivative code used 37 in PYPOWER information, see: 38 39 [TN2] R. D. Zimmerman, I{"AC Power Flows, Generalized OPF Costs and 40 their Derivatives using Complex Matrix Notation"}, MATPOWER 41 Technical Note 2, February 2010. 42 U{http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf} 43 44 @see: L{dSbr_dV} 45 46 @author: Ray Zimmerman (PSERC Cornell) 47 @author: Richard Lincoln 48 """ 49 il = range(len(lam)) 50 51 diaglam = csr_matrix((lam, (il, il))) 52 diagSbr_conj = csr_matrix((Sbr.conj(), (il, il))) 53 54 Saa, Sav, Sva, Svv = d2Sbr_dV2(Cbr, Ybr, V, diagSbr_conj * lam) 55 56 Haa = 2 * ( Saa + dSbr_dVa.T * diaglam * dSbr_dVa.conj() ).real 57 Hva = 2 * ( Sva + dSbr_dVm.T * diaglam * dSbr_dVa.conj() ).real 58 Hav = 2 * ( Sav + dSbr_dVa.T * diaglam * dSbr_dVm.conj() ).real 59 Hvv = 2 * ( Svv + dSbr_dVm.T * diaglam * dSbr_dVm.conj() ).real 60 61 return Haa, Hav, Hva, Hvv
62