Home > matpower7.1 > lib > d2Imis_dVdSg.m

d2Imis_dVdSg

PURPOSE ^

D2IMIS_DVDSG Computes 2nd derivatives of current balance w.r.t. V and Sg.

SYNOPSIS ^

function Gsv = d2Imis_dVdSg(Cg, V, lam, vcart)

DESCRIPTION ^

D2IMIS_DVDSG   Computes 2nd derivatives of current balance w.r.t. V and Sg.

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

   GSV = D2IMIS_DVDSG(CG, V, LAM)
   GSV = D2IMIS_DVDSG(CG, V, LAM, 0)

   Returns a matrix 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 real and reactive power generation.

   GSV = D2IMIS_DVDSG(CG, V, LAM, 1)

   Returns a matrix 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 real and reactive power generation.

   Takes the generator connection matrix, complex voltage vector V and
   nb x 1 vector of multipliers LAM. Output matrices are sparse.

   Examples:
       Cg = sparse(gen(:, GEN_BUS), 1:ng, -, nb, ng);
       Gsv = d2Imis_dVdSg(Cg, V, lam);

       Here the output matrix corresponds to:
           Gsv = [ Gpa Gpv;
                   Gqa Gqv ];
           Gpa = d/dVa (dImis_dPg.' * lam)
           Gpv = d/dVm (dImis_dPg.' * lam)
           Gqa = d/dVa (dImis_dQg.' * lam)
           Gqv = d/dVm (dImis_dQg.' * lam)

       [Grr, Gri, Gir, Gii] = d2Imis_dVdSg(Cg, V, lam, 1);

       Here the output matrices correspond to:
           Gsv = [ Gpr Gpi;
                   Gqr Gqi ];
           Gpr = d/dVr (dImis_dPg.' * lam)
           Gpi = d/dVi (dImis_dPg.' * lam)
           Gqr = d/dVr (dImis_dQg.' * lam)
           Gqi = d/dVi (dImis_dQg.' * 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 Gsv = d2Imis_dVdSg(Cg, V, lam, vcart)
0002 %D2IMIS_DVDSG   Computes 2nd derivatives of current balance w.r.t. V and Sg.
0003 %
0004 %   The derivatives can be take with respect to polar or cartesian coordinates
0005 %   of voltage, depending on the 4th argument.
0006 %
0007 %   GSV = D2IMIS_DVDSG(CG, V, LAM)
0008 %   GSV = D2IMIS_DVDSG(CG, V, LAM, 0)
0009 %
0010 %   Returns a matrix 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 real and reactive power generation.
0013 %
0014 %   GSV = D2IMIS_DVDSG(CG, V, LAM, 1)
0015 %
0016 %   Returns a matrix 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 real and reactive power generation.
0019 %
0020 %   Takes the generator connection matrix, complex voltage vector V and
0021 %   nb x 1 vector of multipliers LAM. Output matrices are sparse.
0022 %
0023 %   Examples:
0024 %       Cg = sparse(gen(:, GEN_BUS), 1:ng, -, nb, ng);
0025 %       Gsv = d2Imis_dVdSg(Cg, V, lam);
0026 %
0027 %       Here the output matrix corresponds to:
0028 %           Gsv = [ Gpa Gpv;
0029 %                   Gqa Gqv ];
0030 %           Gpa = d/dVa (dImis_dPg.' * lam)
0031 %           Gpv = d/dVm (dImis_dPg.' * lam)
0032 %           Gqa = d/dVa (dImis_dQg.' * lam)
0033 %           Gqv = d/dVm (dImis_dQg.' * lam)
0034 %
0035 %       [Grr, Gri, Gir, Gii] = d2Imis_dVdSg(Cg, V, lam, 1);
0036 %
0037 %       Here the output matrices correspond to:
0038 %           Gsv = [ Gpr Gpi;
0039 %                   Gqr Gqi ];
0040 %           Gpr = d/dVr (dImis_dPg.' * lam)
0041 %           Gpi = d/dVi (dImis_dPg.' * lam)
0042 %           Gqr = d/dVr (dImis_dQg.' * lam)
0043 %           Gqi = d/dVi (dImis_dQg.' * lam)
0044 %
0045 %   For more details on the derivations behind the derivative code used
0046 %   in MATPOWER, see:
0047 %
0048 %   [TN2]  R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and
0049 %          their Derivatives using Complex Matrix Notation", MATPOWER
0050 %          Technical Note 2, February 2010. [Online]. Available:
0051 %          https://matpower.org/docs/TN2-OPF-Derivatives.pdf
0052 %          doi: 10.5281/zenodo.3237866
0053 %   [TN3]  B. Sereeter and R. D. Zimmerman, "Addendum to AC Power Flows and
0054 %          their Derivatives using Complex Matrix Notation: Nodal Current
0055 %          Balance," MATPOWER Technical Note 3, April 2018. [Online].
0056 %          Available: https://matpower.org/docs/TN3-More-OPF-Derivatives.pdf
0057 %          doi: 10.5281/zenodo.3237900
0058 %   [TN4]  B. Sereeter and R. D. Zimmerman, "AC Power Flows and their
0059 %          Derivatives using Complex Matrix Notation and Cartesian
0060 %          Coordinate Voltages," MATPOWER Technical Note 4, April 2018.
0061 %          [Online]. Available: https://matpower.org/docs/TN4-OPF-Derivatives-Cartesian.pdf
0062 %          doi: 10.5281/zenodo.3237909
0063 
0064 %   MATPOWER
0065 %   Copyright (c) 2019, Power Systems Engineering Research Center (PSERC)
0066 %   by Baljinnyam Sereeter, Delft University of Technology
0067 %   and Ray Zimmerman, PSERC Cornell
0068 %
0069 %   This file is part of MATPOWER.
0070 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0071 %   See https://matpower.org for more info.
0072 
0073 %% default input args
0074 if nargin < 4
0075     vcart = 0;      %% default to polar coordinates
0076 end
0077 
0078 nb = length(V);
0079 
0080 if vcart
0081     D = Cg' * sparse(1:nb,1:nb, lam./conj(V.^2), nb, nb);
0082 
0083     G_Pg_Vr = D;
0084     G_Pg_Vi = -1j * D;
0085     G_Qg_Vr = G_Pg_Vi;
0086     G_Qg_Vi = -D;
0087 
0088     Gsv = [ G_Pg_Vr G_Pg_Vi;
0089             G_Qg_Vr G_Qg_Vi ];
0090 else
0091     D = sparse(1:nb, 1:nb, 1./abs(V), nb, nb);
0092     E = sparse(1:nb, 1:nb, lam./conj(V), nb, nb);
0093     K = Cg' * E;
0094     L = K * D;
0095 
0096     G_Pg_Va = -1j * K;
0097     G_Pg_Vm = L;
0098     G_Qg_Va = -K;
0099     G_Qg_Vm = -1j * L;
0100 
0101     Gsv = [ G_Pg_Va G_Pg_Vm;
0102             G_Qg_Va G_Qg_Vm ];
0103 end

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