1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
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