Home > matpower7.0 > lib > d2Sbus_dV2.m

d2Sbus_dV2

PURPOSE ^

D2SBUS_DV2 Computes 2nd derivatives of power injection w.r.t. voltage.

SYNOPSIS ^

function [G11, G12, G21, G22] = d2Sbus_dV2(Ybus, V, lam, vcart)

DESCRIPTION ^

D2SBUS_DV2   Computes 2nd derivatives of power injection w.r.t. voltage.

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

   [GAA, GAV, GVA, GVV] = D2SBUS_DV2(YBUS, V, LAM)
   [GAA, GAV, GVA, GVV] = D2SBUS_DV2(YBUS, V, LAM, 0)

   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 bus power injections.

   [GRR, GIR, GIR, GII] = D2SBUS_DV2(YBUS, V, LAM, 1)

   Returns 4 matrices containing the partial derivatives w.r.t. real and
   imaginary parts of voltage of the product of a vector LAM with the 1st
   partial derivatives of the complex bus power injections.

   Takes sparse bus admittance matrix YBUS, voltage vector V and nb x 1 vector
   of multipliers LAM. Output matrices are sparse.

   Examples:
       [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
       [Gaa, Gav, Gva, Gvv] = d2Sbus_dV2(Ybus, V, lam);

       Here the output matrices correspond to:
           Gaa = d/dVa (dSbus_dVa.' * lam)
           Gav = d/dVm (dSbus_dVa.' * lam)
           Gva = d/dVa (dSbus_dVm.' * lam)
           Gvv = d/dVm (dSbus_dVm.' * lam)

       [Grr, Gri, Gir, Gii] = d2Sbus_dV2(Ybus, V, lam, 1);

       Here the output matrices correspond to:
           Grr = d/dVr (dSbus_dVr.' * lam)
           Gri = d/dVi (dSbus_dVr.' * lam)
           Gir = d/dVr (dSbus_dVi.' * lam)
           Gii = d/dVi (dSbus_dVi.' * lam)

   For more details on the derivations behind the derivative code used
   in MATPOWER, 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 [G11, G12, G21, G22] = d2Sbus_dV2(Ybus, V, lam, vcart)
0002 %D2SBUS_DV2   Computes 2nd derivatives of power injection w.r.t. voltage.
0003 %
0004 %   The derivatives can be take with respect to polar or cartesian coordinates
0005 %   of voltage, depending on the 4th argument.
0006 %
0007 %   [GAA, GAV, GVA, GVV] = D2SBUS_DV2(YBUS, V, LAM)
0008 %   [GAA, GAV, GVA, GVV] = D2SBUS_DV2(YBUS, V, LAM, 0)
0009 %
0010 %   Returns 4 matrices containing the partial derivatives w.r.t. voltage angle
0011 %   and magnitude of the product of a vector LAM with the 1st partial
0012 %   derivatives of the complex bus power injections.
0013 %
0014 %   [GRR, GIR, GIR, GII] = D2SBUS_DV2(YBUS, V, LAM, 1)
0015 %
0016 %   Returns 4 matrices containing the partial derivatives w.r.t. real and
0017 %   imaginary parts of voltage of the product of a vector LAM with the 1st
0018 %   partial derivatives of the complex bus power injections.
0019 %
0020 %   Takes sparse bus admittance matrix YBUS, voltage vector V and nb x 1 vector
0021 %   of multipliers LAM. Output matrices are sparse.
0022 %
0023 %   Examples:
0024 %       [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0025 %       [Gaa, Gav, Gva, Gvv] = d2Sbus_dV2(Ybus, V, lam);
0026 %
0027 %       Here the output matrices correspond to:
0028 %           Gaa = d/dVa (dSbus_dVa.' * lam)
0029 %           Gav = d/dVm (dSbus_dVa.' * lam)
0030 %           Gva = d/dVa (dSbus_dVm.' * lam)
0031 %           Gvv = d/dVm (dSbus_dVm.' * lam)
0032 %
0033 %       [Grr, Gri, Gir, Gii] = d2Sbus_dV2(Ybus, V, lam, 1);
0034 %
0035 %       Here the output matrices correspond to:
0036 %           Grr = d/dVr (dSbus_dVr.' * lam)
0037 %           Gri = d/dVi (dSbus_dVr.' * lam)
0038 %           Gir = d/dVr (dSbus_dVi.' * lam)
0039 %           Gii = d/dVi (dSbus_dVi.' * lam)
0040 %
0041 %   For more details on the derivations behind the derivative code used
0042 %   in MATPOWER, see:
0043 %
0044 %   [TN2]  R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and
0045 %          their Derivatives using Complex Matrix Notation", MATPOWER
0046 %          Technical Note 2, February 2010. [Online]. Available:
0047 %          https://matpower.org/docs/TN2-OPF-Derivatives.pdf
0048 %          doi: 10.5281/zenodo.3237866
0049 %   [TN4]  B. Sereeter and R. D. Zimmerman, "AC Power Flows and their
0050 %          Derivatives using Complex Matrix Notation and Cartesian
0051 %          Coordinate Voltages," MATPOWER Technical Note 4, April 2018.
0052 %          [Online]. Available: https://matpower.org/docs/TN4-OPF-Derivatives-Cartesian.pdf
0053 %          doi: 10.5281/zenodo.3237909
0054 
0055 %   MATPOWER
0056 %   Copyright (c) 2008-2019, Power Systems Engineering Research Center (PSERC)
0057 %   by Ray Zimmerman, PSERC Cornell
0058 %   and Baljinnyam Sereeter, Delft University of Technology
0059 %
0060 %   This file is part of MATPOWER.
0061 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0062 %   See https://matpower.org for more info.
0063 
0064 %% default input args
0065 if nargin < 4
0066     vcart = 0;      %% default to polar coordinates
0067 end
0068 
0069 n = length(V);
0070 
0071 diaglam = sparse(1:n, 1:n, lam, n, n);
0072 if vcart
0073     E = diaglam * conj(Ybus);
0074     F = E + E.';
0075     G = 1j * (E - E.');
0076 
0077     G11 = F;        %% Grr
0078     G21 = G;        %% Gir
0079     G12 = G21.';    %% Gri
0080     G22 = G11;      %% Gii
0081 else
0082     Ibus    = Ybus * V;
0083     diagV   = sparse(1:n, 1:n, V, n, n);
0084 
0085     A = sparse(1:n, 1:n, lam .* V, n, n);
0086     B = Ybus * diagV;
0087     C = A * conj(B);
0088     D = Ybus' * diagV;
0089     E = conj(diagV) * (D * diaglam - sparse(1:n, 1:n, D*lam, n, n));
0090     F = C - A * sparse(1:n, 1:n, conj(Ibus), n, n);
0091     G = sparse(1:n, 1:n, ones(n, 1)./abs(V), n, n);
0092 
0093     G11 = E + F;
0094     G21 = 1j * G * (E - F);
0095     G12 = G21.';
0096     G22 = G * (C + C.') * G;
0097 end

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