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

Source Code for Module pypower.dAbr_dV

 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  """Partial derivatives of squared flow magnitudes w.r.t voltage. 
18  """ 
19   
20  from scipy.sparse import csr_matrix 
21   
22   
23 -def dAbr_dV(dSf_dVa, dSf_dVm, dSt_dVa, dSt_dVm, Sf, St):
24 """Partial derivatives of squared flow magnitudes w.r.t voltage. 25 26 Returns four matrices containing partial derivatives of the square of 27 the branch flow magnitudes at "from" & "to" ends of each branch w.r.t 28 voltage magnitude and voltage angle respectively (for all buses), given 29 the flows and flow sensitivities. Flows could be complex current or 30 complex or real power. Notation below is based on complex power. The 31 following explains the expressions used to form the matrices: 32 33 Let Af refer to the square of the apparent power at the "from" end of 34 each branch:: 35 36 Af = abs(Sf)**2 37 = Sf .* conj(Sf) 38 = Pf**2 + Qf**2 39 40 then ... 41 42 Partial w.r.t real power:: 43 dAf/dPf = 2 * diag(Pf) 44 45 Partial w.r.t reactive power:: 46 dAf/dQf = 2 * diag(Qf) 47 48 Partial w.r.t Vm & Va:: 49 dAf/dVm = dAf/dPf * dPf/dVm + dAf/dQf * dQf/dVm 50 dAf/dVa = dAf/dPf * dPf/dVa + dAf/dQf * dQf/dVa 51 52 Derivations for "to" bus are similar. 53 54 For more details on the derivations behind the derivative code used 55 in PYPOWER information, see: 56 57 [TN2] R. D. Zimmerman, I{"AC Power Flows, Generalized OPF Costs and 58 their Derivatives using Complex Matrix Notation"}, MATPOWER 59 Technical Note 2, February 2010. 60 U{http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf} 61 62 @return: The partial derivatives of the squared flow magnitudes w.r.t 63 voltage magnitude and voltage angle given the flows and flow 64 sensitivities. Flows could be complex current or complex or 65 real power. 66 @see: L{dIbr_dV}, L{dSbr_dV} 67 68 @author: Ray Zimmerman (PSERC Cornell) 69 @author: Richard Lincoln 70 """ 71 il = range(len(Sf)) 72 73 dAf_dPf = csr_matrix((2 * Sf.real, (il, il))) 74 dAf_dQf = csr_matrix((2 * Sf.imag, (il, il))) 75 dAt_dPt = csr_matrix((2 * St.real, (il, il))) 76 dAt_dQt = csr_matrix((2 * St.imag, (il, il))) 77 78 # Partial derivative of apparent power magnitude w.r.t voltage 79 # phase angle. 80 dAf_dVa = dAf_dPf * dSf_dVa.real + dAf_dQf * dSf_dVa.imag 81 dAt_dVa = dAt_dPt * dSt_dVa.real + dAt_dQt * dSt_dVa.imag 82 # Partial derivative of apparent power magnitude w.r.t. voltage 83 # amplitude. 84 dAf_dVm = dAf_dPf * dSf_dVm.real + dAf_dQf * dSf_dVm.imag 85 dAt_dVm = dAt_dPt * dSt_dVm.real + dAt_dQt * dSt_dVm.imag 86 87 return dAf_dVa, dAf_dVm, dAt_dVa, dAt_dVm
88