Home > matpower7.1 > lib > d2Imis_dV2.m

d2Imis_dV2

PURPOSE ^

D2IMIS_DV2 Computes 2nd derivatives of current balance w.r.t. voltage.

SYNOPSIS ^

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

DESCRIPTION ^

D2IMIS_DV2   Computes 2nd derivatives of current balance w.r.t. voltage.

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

   [GAA, GAV, GVA, GVV] = D2IMIS_DV2(SBUS, YBUS, V, LAM)
   [GAA, GAV, GVA, GVV] = D2IMIS_DV2(SBUS, 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 current balance.

   [GRR, GIR, GIR, GII] = D2IMIS_DV2(SBUS, 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 current balance.

   Takes bus complex power injection (gen-load) vector, sparse bus admittance
   matrix YBUS, voltage vector V and nb x 1 vector of multipliers LAM. Output
   matrices are sparse.

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

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

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

       Here the output matrices correspond to:
           Grr = d/dVr (dImis_dVr.' * lam)
           Gri = d/dVi (dImis_dVr.' * lam)
           Gir = d/dVr (dImis_dVi.' * lam)
           Gii = d/dVi (dImis_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
   [TN3]  B. Sereeter and R. D. Zimmerman, "Addendum to AC Power Flows and
          their Derivatives using Complex Matrix Notation: Nodal Current
          Balance," MATPOWER Technical Note 3, April 2018. [Online].
          Available: https://matpower.org/docs/TN3-More-OPF-Derivatives.pdf
          doi: 10.5281/zenodo.3237900
   [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] = d2Imis_dV2(Sbus, Ybus, V, lam, vcart)
0002 %D2IMIS_DV2   Computes 2nd derivatives of current balance 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 %   [GAA, GAV, GVA, GVV] = D2IMIS_DV2(SBUS, YBUS, V, LAM)
0008 %   [GAA, GAV, GVA, GVV] = D2IMIS_DV2(SBUS, 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 current balance.
0013 %
0014 %   [GRR, GIR, GIR, GII] = D2IMIS_DV2(SBUS, 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 current balance.
0019 %
0020 %   Takes bus complex power injection (gen-load) vector, sparse bus admittance
0021 %   matrix YBUS, voltage vector V and nb x 1 vector of multipliers LAM. Output
0022 %   matrices are sparse.
0023 %
0024 %   Examples:
0025 %       Sbus = makeSbus(baseMVA, bus, gen);
0026 %       [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0027 %       [Gaa, Gav, Gva, Gvv] = d2Imis_dV2(Sbus, Ybus, V, lam);
0028 %
0029 %       Here the output matrices correspond to:
0030 %           Gaa = d/dVa (dImis_dVa.' * lam)
0031 %           Gav = d/dVm (dImis_dVa.' * lam)
0032 %           Gva = d/dVa (dImis_dVm.' * lam)
0033 %           Gvv = d/dVm (dImis_dVm.' * lam)
0034 %
0035 %       [Grr, Gri, Gir, Gii] = d2Imis_dV2(Sbus, Ybus, V, lam, 1);
0036 %
0037 %       Here the output matrices correspond to:
0038 %           Grr = d/dVr (dImis_dVr.' * lam)
0039 %           Gri = d/dVi (dImis_dVr.' * lam)
0040 %           Gir = d/dVr (dImis_dVi.' * lam)
0041 %           Gii = d/dVi (dImis_dVi.' * lam)
0042 %
0043 %   For more details on the derivations behind the derivative code used
0044 %   in MATPOWER, see:
0045 %
0046 %   [TN2]  R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and
0047 %          their Derivatives using Complex Matrix Notation", MATPOWER
0048 %          Technical Note 2, February 2010. [Online]. Available:
0049 %          https://matpower.org/docs/TN2-OPF-Derivatives.pdf
0050 %          doi: 10.5281/zenodo.3237866
0051 %   [TN3]  B. Sereeter and R. D. Zimmerman, "Addendum to AC Power Flows and
0052 %          their Derivatives using Complex Matrix Notation: Nodal Current
0053 %          Balance," MATPOWER Technical Note 3, April 2018. [Online].
0054 %          Available: https://matpower.org/docs/TN3-More-OPF-Derivatives.pdf
0055 %          doi: 10.5281/zenodo.3237900
0056 %   [TN4]  B. Sereeter and R. D. Zimmerman, "AC Power Flows and their
0057 %          Derivatives using Complex Matrix Notation and Cartesian
0058 %          Coordinate Voltages," MATPOWER Technical Note 4, April 2018.
0059 %          [Online]. Available: https://matpower.org/docs/TN4-OPF-Derivatives-Cartesian.pdf
0060 %          doi: 10.5281/zenodo.3237909
0061 
0062 %   MATPOWER
0063 %   Copyright (c) 2019, Power Systems Engineering Research Center (PSERC)
0064 %   by Baljinnyam Sereeter, Delft University of Technology
0065 %   and Ray Zimmerman, PSERC Cornell
0066 %
0067 %   This file is part of MATPOWER.
0068 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0069 %   See https://matpower.org for more info.
0070 
0071 %% default input args
0072 if nargin < 5
0073     vcart = 0;      %% default to polar coordinates
0074 end
0075 
0076 nb = length(V);
0077 
0078 if vcart
0079     C = 2 * lam .* conj(Sbus./(V.^3));
0080 
0081     G22 = sparse(1:nb, 1:nb, C, nb, nb);
0082     G11 = -G22;
0083     G12 = 1j*G22;
0084     G21 = G12;
0085 else
0086     absV = abs(V);
0087     diagV    = sparse(1:nb, 1:nb, V, nb, nb);
0088     diagV1   = sparse(1:nb, 1:nb, 1./V, nb, nb);
0089     diagVmV1 = sparse(1:nb, 1:nb, 1./(V.*absV), nb, nb);
0090     diagVmV2 = sparse(1:nb, 1:nb, 1./(V.*(absV.^2)), nb, nb);
0091     diagLamS = sparse(1:nb, 1:nb, lam.*Sbus, nb, nb);
0092     diagYlam = sparse(1:nb, 1:nb, Ybus.'*lam, nb, nb);
0093     diagE    = sparse(1:nb, 1:nb, V./absV, nb, nb);
0094 
0095     G11   = - diagYlam* diagV + conj(diagLamS*diagV1);
0096     G22   = - 2 * conj(diagLamS*diagVmV2);
0097     G21 = 1j * ( diagYlam* diagE + conj(diagLamS*diagVmV1)) ;
0098     G12 = G21.';
0099 end

Generated on Fri 09-Oct-2020 11:21:31 by m2html © 2005