D2IBR_DV2 Computes 2nd derivatives of complex branch current w.r.t. voltage. [HAA, HAV, HVA, HVV] = D2IBR_DV2(CBR, YBR, V, LAM) returns 4 matrices containing the partial derivatives w.r.t. voltage angle and magnitude of the product of a vector LAM with the 1st partial derivatives of the complex branch currents. Takes sparse branch admittance matrix YBR, voltage vector V and nl x 1 vector of multipliers LAM. Output matrices are sparse. Example: [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch); Ybr = Yf; [Haa, Hav, Hva, Hvv] = d2Ibr_dV2(Ybr, V, lam); Here the output matrices correspond to: Haa = (d/dVa (dIbr_dVa.')) * lam Hav = (d/dVm (dIbr_dVa.')) * lam Hva = (d/dVa (dIbr_dVm.')) * lam Hvv = (d/dVm (dIbr_dVm.')) * lam For more details on the derivations behind the derivative code used in MATPOWER information, see: [TN2] R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and their Derivatives using Complex Matrix Notation", MATPOWER Technical Note 2, February 2010. http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf
0001 function [Haa, Hav, Hva, Hvv] = d2Ibr_dV2(Ybr, V, lam) 0002 %D2IBR_DV2 Computes 2nd derivatives of complex branch current w.r.t. voltage. 0003 % [HAA, HAV, HVA, HVV] = D2IBR_DV2(CBR, YBR, V, LAM) returns 4 matrices 0004 % containing the partial derivatives w.r.t. voltage angle and magnitude 0005 % of the product of a vector LAM with the 1st partial derivatives of the 0006 % complex branch currents. Takes sparse branch admittance matrix YBR, 0007 % voltage vector V and nl x 1 vector of multipliers LAM. Output matrices 0008 % are sparse. 0009 % 0010 % Example: 0011 % [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch); 0012 % Ybr = Yf; 0013 % [Haa, Hav, Hva, Hvv] = d2Ibr_dV2(Ybr, V, lam); 0014 % 0015 % Here the output matrices correspond to: 0016 % Haa = (d/dVa (dIbr_dVa.')) * lam 0017 % Hav = (d/dVm (dIbr_dVa.')) * lam 0018 % Hva = (d/dVa (dIbr_dVm.')) * lam 0019 % Hvv = (d/dVm (dIbr_dVm.')) * lam 0020 % 0021 % For more details on the derivations behind the derivative code used 0022 % in MATPOWER information, see: 0023 % 0024 % [TN2] R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and 0025 % their Derivatives using Complex Matrix Notation", MATPOWER 0026 % Technical Note 2, February 2010. 0027 % http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf 0028 0029 % MATPOWER 0030 % Copyright (c) 2008-2015 by Power System Engineering Research Center (PSERC) 0031 % by Ray Zimmerman, PSERC Cornell 0032 % 0033 % $Id: d2Ibr_dV2.m 2644 2015-03-11 19:34:22Z ray $ 0034 % 0035 % This file is part of MATPOWER. 0036 % Covered by the 3-clause BSD License (see LICENSE file for details). 0037 % See http://www.pserc.cornell.edu/matpower/ for more info. 0038 0039 %% define 0040 nb = length(V); 0041 0042 diaginvVm = sparse(1:nb, 1:nb, ones(nb, 1)./abs(V), nb, nb); 0043 0044 Haa = sparse(1:nb, 1:nb, -(Ybr.' * lam) .* V, nb, nb); 0045 Hva = -1j * Haa * diaginvVm; 0046 Hav = Hva; 0047 Hvv = sparse(nb, nb);