Home > matpower7.0 > lib > d2Sbr_dV2.m

d2Sbr_dV2

PURPOSE ^

D2SBR_DV2 Computes 2nd derivatives of complex brch power flow w.r.t. voltage.

SYNOPSIS ^

function [H11, H12, H21, H22] = d2Sbr_dV2(Cbr, Ybr, V, mu, vcart)

DESCRIPTION ^

D2SBR_DV2   Computes 2nd derivatives of complex brch power flow w.r.t. voltage.

   The derivatives can be take with respect to polar or cartesian coordinates
   of voltage, depending on the 5th argument.

   [HAA, HAV, HVA, HVV] = D2SBR_DV2(CBR, YBR, V, MU)
   [HAA, HAV, HVA, HVV] = D2SBR_DV2(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 complex branch power flows.

   [HRR, HRI, HIR, HII] = d2Sbr_dV2(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 complex branch power flows.

   Takes sparse connection matrix CBR, sparse branch admittance matrix YBR,
   voltage vector V and nl x 1 vector of multipliers MU. Output matrices are
   sparse.

   Examples:
       f = branch(:, F_BUS);
       Cf =  sparse(1:nl, f, ones(nl, 1), nl, nb);
       [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
       Cbr = Cf;
       Ybr = Yf;
       [Haa, Hav, Hva, Hvv] = d2Sbr_dV2(Cbr, Ybr, V, mu);

       Here the output matrices correspond to:
           Haa = d/dVa (dSbr_dVa.' * mu)
           Hav = d/dVm (dSbr_dVa.' * mu)
           Hva = d/dVa (dSbr_dVm.' * mu)
           Hvv = d/dVm (dSbr_dVm.' * mu)

       [Hrr, Hri, Hir, Hii] = d2Sbr_dV2(Cbr, Ybr, V, mu, 1);

       Here the output matrices correspond to:
           Hrr = d/dVr (dSbr_dVr.' * mu)
           Hri = d/dVi (dSbr_dVr.' * mu)
           Hir = d/dVr (dSbr_dVi.' * mu)
           Hii = d/dVi (dSbr_dVi.' * mu)

   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
   [TN4]  B. Sereeter and R. D. Zimmerman, "AC Power Flows and their
          Derivatives using Complex Matrix Notation and Cartesian
          Coordinate Voltages," MATPOWER Technical Note 4, April 2018.
          [Online]. Available: https://matpower.org/docs/TN4-OPF-Derivatives-Cartesian.pdf
          doi: 10.5281/zenodo.3237909

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [H11, H12, H21, H22] = d2Sbr_dV2(Cbr, Ybr, V, mu, vcart)
0002 %D2SBR_DV2   Computes 2nd derivatives of complex brch power flow w.r.t. voltage.
0003 %
0004 %   The derivatives can be take with respect to polar or cartesian coordinates
0005 %   of voltage, depending on the 5th argument.
0006 %
0007 %   [HAA, HAV, HVA, HVV] = D2SBR_DV2(CBR, YBR, V, MU)
0008 %   [HAA, HAV, HVA, HVV] = D2SBR_DV2(CBR, YBR, V, MU, 0)
0009 %
0010 %   Returns 4 matrices containing the partial derivatives w.r.t. voltage angle
0011 %   and magnitude of the product of a vector MU with the 1st partial
0012 %   derivatives of the complex branch power flows.
0013 %
0014 %   [HRR, HRI, HIR, HII] = d2Sbr_dV2(CBR, YBR, V, MU, 1)
0015 %
0016 %   Returns 4 matrices containing the partial derivatives w.r.t. real and
0017 %   imaginary part of complex voltage of the product of a vector MU with the
0018 %   1st partial derivatives of the complex branch power flows.
0019 %
0020 %   Takes sparse connection matrix CBR, sparse branch admittance matrix YBR,
0021 %   voltage vector V and nl x 1 vector of multipliers MU. Output matrices are
0022 %   sparse.
0023 %
0024 %   Examples:
0025 %       f = branch(:, F_BUS);
0026 %       Cf =  sparse(1:nl, f, ones(nl, 1), nl, nb);
0027 %       [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0028 %       Cbr = Cf;
0029 %       Ybr = Yf;
0030 %       [Haa, Hav, Hva, Hvv] = d2Sbr_dV2(Cbr, Ybr, V, mu);
0031 %
0032 %       Here the output matrices correspond to:
0033 %           Haa = d/dVa (dSbr_dVa.' * mu)
0034 %           Hav = d/dVm (dSbr_dVa.' * mu)
0035 %           Hva = d/dVa (dSbr_dVm.' * mu)
0036 %           Hvv = d/dVm (dSbr_dVm.' * mu)
0037 %
0038 %       [Hrr, Hri, Hir, Hii] = d2Sbr_dV2(Cbr, Ybr, V, mu, 1);
0039 %
0040 %       Here the output matrices correspond to:
0041 %           Hrr = d/dVr (dSbr_dVr.' * mu)
0042 %           Hri = d/dVi (dSbr_dVr.' * mu)
0043 %           Hir = d/dVr (dSbr_dVi.' * mu)
0044 %           Hii = d/dVi (dSbr_dVi.' * mu)
0045 %
0046 %   For more details on the derivations behind the derivative code used
0047 %   in MATPOWER information, see:
0048 %
0049 %   [TN2]  R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and
0050 %          their Derivatives using Complex Matrix Notation", MATPOWER
0051 %          Technical Note 2, February 2010. [Online]. Available:
0052 %          https://matpower.org/docs/TN2-OPF-Derivatives.pdf
0053 %          doi: 10.5281/zenodo.3237866
0054 %   [TN4]  B. Sereeter and R. D. Zimmerman, "AC Power Flows and their
0055 %          Derivatives using Complex Matrix Notation and Cartesian
0056 %          Coordinate Voltages," MATPOWER Technical Note 4, April 2018.
0057 %          [Online]. Available: https://matpower.org/docs/TN4-OPF-Derivatives-Cartesian.pdf
0058 %          doi: 10.5281/zenodo.3237909
0059 
0060 %   MATPOWER
0061 %   Copyright (c) 2008-2019, Power Systems Engineering Research Center (PSERC)
0062 %   by Ray Zimmerman, PSERC Cornell
0063 %   and Baljinnyam Sereeter, Delft University of Technology
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 < 5
0071     vcart = 0;      %% default to polar coordinates
0072 end
0073 
0074 nl = length(mu);
0075 nb = length(V);
0076 
0077 A = Ybr' * sparse(1:nl, 1:nl, mu, nl, nl) * Cbr;
0078 if vcart
0079     H11 = A + A.';
0080     H12 = 1j * (A - A.');
0081     H21 = -H12;
0082     H22 = H11;
0083 else
0084     diagV  = sparse(1:nb, 1:nb, V, nb, nb);
0085 
0086     B = conj(diagV) * A * diagV;
0087     D = sparse(1:nb, 1:nb, (A*V) .* conj(V), nb, nb);
0088     E = sparse(1:nb, 1:nb, (A.'*conj(V)) .* V, nb, nb);
0089     F = B + B.';
0090     G = sparse(1:nb, 1:nb, ones(nb, 1)./abs(V), nb, nb);
0091 
0092     H11 = F - D - E;
0093     H21 = 1j * G * (B - B.' - D + E);
0094     H12 = H21.';
0095     H22 = G * F * G;
0096 end

Generated on Mon 24-Jun-2019 15:58:45 by m2html © 2005