D2ASBR_DV2 Computes 2nd derivatives of |power flow|^2 w.r.t. V. ----- DEPRECATED - Please use D2ABR_DV2 instead ----- ----- See wrapper code in D2ASBR_DV2 for example. ----- % The derivatives can be take with respect to polar or cartesian coordinates of voltage, depending on the 8th argument. [HAA, HAV, HVA, HVV] = D2ASBR_DV2(DSBR_DV1, DSBR_DV2, SBR, CBR, YBR, V, MU) [HAA, HAV, HVA, HVV] = D2ASBR_DV2(DSBR_DV1, DSBR_DV2, SBR, CBR, YBR, V, MU, 0) Returns 4 matrices containing the partial derivatives w.r.t. voltage angle and magnitude of the product of a vector MU with the 1st partial derivatives of the square of the magnitude of branch power flows. [HRR, HRI, HIR, HII] = D2ASBR_DV2(DSBR_DV1, DSBR_DV2, SBR, CBR, YBR, V, MU, 1) Returns 4 matrices containing the partial derivatives w.r.t. real and imaginary part of complex voltage of the product of a vector MU with the 1st partial derivatives of the square of the magnitude of branch power flows. Takes as inputs sparse first derivative matrices of complex flow, complex flow vector, sparse connection matrix CBR, sparse branch admittance matrix YBR, voltage vector V and nl x 1 vector of multipliers MU. Output matrices are sparse. Example: f = branch(:, F_BUS); Cf = sparse(1:nl, f, ones(nl, 1), nl, nb); [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch); [dSf_dV1, dSf_dV2, dSt_dV1, dSt_dV2, Sf, St] = ... dSbr_dV(branch, Yf, Yt, V, vcart); Cbr = Cf; Ybr = Yf; dSbr_dV1 = dSf_dV1; dSbr_dV2 = dSf_dV2; Sbr = Sf; [H11, H12, H21, H22] = ... d2ASbr_dV2(dSbr_dV1, dSbr_dV2, Sbr, Cbr, Ybr, V, mu, vcart); Here the output matrices correspond to: H11 = d/dV1 (dASbr_dV1.' * mu) H12 = d/dV2 (dASbr_dV1.' * mu) H21 = d/dV1 (dASbr_dV2.' * mu) H22 = d/dV2 (dASbr_dV2.' * mu) See also DSBR_DV, DABR_DV. 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. [Online]. Available: https://matpower.org/docs/TN2-OPF-Derivatives.pdf doi: 10.5281/zenodo.3237866
0001 function [H11, H12, H21, H22] = ... 0002 d2ASbr_dV2(dSbr_dV1, dSbr_dV2, Sbr, Cbr, Ybr, V, mu, vcart) 0003 %D2ASBR_DV2 Computes 2nd derivatives of |power flow|^2 w.r.t. V. 0004 % 0005 % ----- DEPRECATED - Please use D2ABR_DV2 instead ----- 0006 % ----- See wrapper code in D2ASBR_DV2 for example. ----- 0007 %% 0008 % The derivatives can be take with respect to polar or cartesian coordinates 0009 % of voltage, depending on the 8th argument. 0010 % 0011 % [HAA, HAV, HVA, HVV] = D2ASBR_DV2(DSBR_DV1, DSBR_DV2, SBR, CBR, YBR, V, MU) 0012 % [HAA, HAV, HVA, HVV] = D2ASBR_DV2(DSBR_DV1, DSBR_DV2, SBR, CBR, YBR, V, MU, 0) 0013 % 0014 % Returns 4 matrices containing the partial derivatives w.r.t. voltage 0015 % angle and magnitude of the product of a vector MU with the 1st partial 0016 % derivatives of the square of the magnitude of branch power flows. 0017 % 0018 % [HRR, HRI, HIR, HII] = D2ASBR_DV2(DSBR_DV1, DSBR_DV2, SBR, CBR, YBR, V, MU, 1) 0019 % 0020 % Returns 4 matrices containing the partial derivatives w.r.t. real and 0021 % imaginary part of complex voltage of the product of a vector MU with the 0022 % 1st partial derivatives of the square of the magnitude of branch power 0023 % flows. 0024 % 0025 % Takes as inputs sparse first derivative matrices of complex flow, complex 0026 % flow vector, sparse connection matrix CBR, sparse branch admittance matrix 0027 % YBR, voltage vector V and nl x 1 vector of multipliers MU. Output matrices 0028 % are sparse. 0029 % 0030 % Example: 0031 % f = branch(:, F_BUS); 0032 % Cf = sparse(1:nl, f, ones(nl, 1), nl, nb); 0033 % [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch); 0034 % [dSf_dV1, dSf_dV2, dSt_dV1, dSt_dV2, Sf, St] = ... 0035 % dSbr_dV(branch, Yf, Yt, V, vcart); 0036 % Cbr = Cf; 0037 % Ybr = Yf; 0038 % dSbr_dV1 = dSf_dV1; 0039 % dSbr_dV2 = dSf_dV2; 0040 % Sbr = Sf; 0041 % [H11, H12, H21, H22] = ... 0042 % d2ASbr_dV2(dSbr_dV1, dSbr_dV2, Sbr, Cbr, Ybr, V, mu, vcart); 0043 % 0044 % Here the output matrices correspond to: 0045 % H11 = d/dV1 (dASbr_dV1.' * mu) 0046 % H12 = d/dV2 (dASbr_dV1.' * mu) 0047 % H21 = d/dV1 (dASbr_dV2.' * mu) 0048 % H22 = d/dV2 (dASbr_dV2.' * mu) 0049 % 0050 % See also DSBR_DV, DABR_DV. 0051 % 0052 % For more details on the derivations behind the derivative code used 0053 % in MATPOWER information, see: 0054 % 0055 % [TN2] R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and 0056 % their Derivatives using Complex Matrix Notation", MATPOWER 0057 % Technical Note 2, February 2010. [Online]. Available: 0058 % https://matpower.org/docs/TN2-OPF-Derivatives.pdf 0059 % doi: 10.5281/zenodo.3237866 0060 0061 % MATPOWER 0062 % Copyright (c) 2008-2019, Power Systems Engineering Research Center (PSERC) 0063 % by Ray Zimmerman, PSERC Cornell 0064 % 0065 % This file is part of MATPOWER. 0066 % Covered by the 3-clause BSD License (see LICENSE file for details). 0067 % See https://matpower.org for more info. 0068 0069 %% default input args 0070 if nargin < 8 0071 vcart = 0; %% default to polar coordinates 0072 end 0073 0074 d2F_dV2 = @(V, mu)d2Sbr_dV2(Cbr, Ybr, V, mu, vcart); 0075 [H11, H12, H21, H22] = d2Abr_dV2(d2F_dV2, dSbr_dV1, dSbr_dV2, Sbr, V, mu);