Home > matpower7.0 > lib > dImis_dV.m

dImis_dV

PURPOSE ^

DIMIS_DV Computes partial derivatives of current balance w.r.t. voltage.

SYNOPSIS ^

function [dImis_dV1, dImis_dV2] = dImis_dV(Sbus, Ybus, V, vcart)

DESCRIPTION ^

DIMIS_DV   Computes partial 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 3rd argument.

   [DIMIS_DVM, DIMIS_DVA] = DIMIS_DV(SBUS, YBUS, V)
   [DIMIS_DVM, DIMIS_DVA] = DIMIS_DV(SBUS, YBUS, V, 0)

   Returns two matrices containing partial derivatives of the complex bus
   current balance w.r.t voltage magnitude and voltage angle, respectively
   (for all buses).

   [DIMIS_DVR, DIMIS_DVI] = DIMIS_DV(SBUS, YBUS, V, 1)

   Returns two matrices containing partial derivatives of the complex bus
   current balance w.r.t the real and imaginary parts of voltage,
   respectively (for all buses).

   If YBUS is a sparse matrix, the return values will be also. The following
   explains the expressions used to form the matrices:

   Imis = Ibus + Idg = Ybus * V - conj(Sbus./V)

   Polar coordinates:
     Partials of V & Ibus w.r.t. voltage angles
       dV/dVa = j * diag(V)
       dI/dVa = Ybus * dV/dVa = Ybus * j * diag(V)

     Partials of V & Ibus w.r.t. voltage magnitudes
       dV/dVm = diag(V./abs(V))
       dI/dVm = Ybus * dV/dVm = Ybus * diag(V./abs(V))

     Partials of Imis w.r.t. voltage angles
       dImis/dVa = j * (Ybus* diag(V) - diag(conj(Sbus./V)))

     Partials of Imis w.r.t. voltage magnitudes
       dImis/dVm = Ybus * diag(V./abs(V)) +  diag(conj(Sbus./(V*abs(V))))

   Cartesian coordinates:
     Partials of V & Ibus w.r.t. real part of complex voltage
       dV/dVr = diag(ones(n,1))
       dI/dVr = Ybus * dV/dVr = Ybus

     Partials of V & Ibus w.r.t. imaginary part of complex voltage
       dV/dVi = j * diag(ones(n,1))
       dI/dVi = Ybus * dV/dVi = Ybus * j

     Partials of Imis w.r.t. real part of complex voltage
       dImis/dVr = Ybus + conj(diag(Sbus./(V.^2)))

     Partials of S w.r.t. imaginary part of complex voltage
       dImis/dVi = j * (Ybus - diag(conj(Sbus./(V.^2))))

   Examples:
       Sbus = makeSbus(baseMVA, bus, gen);
       [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
       [dImis_dVm, dImis_dVa] = dImis_dV(Sbus, Ybus, V);
       [dImis_dVr, dImis_dVi] = dImis_dV(Sbus, Ybus, V, 1);

   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
   [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 [dImis_dV1, dImis_dV2] = dImis_dV(Sbus, Ybus, V, vcart)
0002 %DIMIS_DV   Computes partial 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 3rd argument.
0006 %
0007 %   [DIMIS_DVM, DIMIS_DVA] = DIMIS_DV(SBUS, YBUS, V)
0008 %   [DIMIS_DVM, DIMIS_DVA] = DIMIS_DV(SBUS, YBUS, V, 0)
0009 %
0010 %   Returns two matrices containing partial derivatives of the complex bus
0011 %   current balance w.r.t voltage magnitude and voltage angle, respectively
0012 %   (for all buses).
0013 %
0014 %   [DIMIS_DVR, DIMIS_DVI] = DIMIS_DV(SBUS, YBUS, V, 1)
0015 %
0016 %   Returns two matrices containing partial derivatives of the complex bus
0017 %   current balance w.r.t the real and imaginary parts of voltage,
0018 %   respectively (for all buses).
0019 %
0020 %   If YBUS is a sparse matrix, the return values will be also. The following
0021 %   explains the expressions used to form the matrices:
0022 %
0023 %   Imis = Ibus + Idg = Ybus * V - conj(Sbus./V)
0024 %
0025 %   Polar coordinates:
0026 %     Partials of V & Ibus w.r.t. voltage angles
0027 %       dV/dVa = j * diag(V)
0028 %       dI/dVa = Ybus * dV/dVa = Ybus * j * diag(V)
0029 %
0030 %     Partials of V & Ibus w.r.t. voltage magnitudes
0031 %       dV/dVm = diag(V./abs(V))
0032 %       dI/dVm = Ybus * dV/dVm = Ybus * diag(V./abs(V))
0033 %
0034 %     Partials of Imis w.r.t. voltage angles
0035 %       dImis/dVa = j * (Ybus* diag(V) - diag(conj(Sbus./V)))
0036 %
0037 %     Partials of Imis w.r.t. voltage magnitudes
0038 %       dImis/dVm = Ybus * diag(V./abs(V)) +  diag(conj(Sbus./(V*abs(V))))
0039 %
0040 %   Cartesian coordinates:
0041 %     Partials of V & Ibus w.r.t. real part of complex voltage
0042 %       dV/dVr = diag(ones(n,1))
0043 %       dI/dVr = Ybus * dV/dVr = Ybus
0044 %
0045 %     Partials of V & Ibus w.r.t. imaginary part of complex voltage
0046 %       dV/dVi = j * diag(ones(n,1))
0047 %       dI/dVi = Ybus * dV/dVi = Ybus * j
0048 %
0049 %     Partials of Imis w.r.t. real part of complex voltage
0050 %       dImis/dVr = Ybus + conj(diag(Sbus./(V.^2)))
0051 %
0052 %     Partials of S w.r.t. imaginary part of complex voltage
0053 %       dImis/dVi = j * (Ybus - diag(conj(Sbus./(V.^2))))
0054 %
0055 %   Examples:
0056 %       Sbus = makeSbus(baseMVA, bus, gen);
0057 %       [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0058 %       [dImis_dVm, dImis_dVa] = dImis_dV(Sbus, Ybus, V);
0059 %       [dImis_dVr, dImis_dVi] = dImis_dV(Sbus, Ybus, V, 1);
0060 %
0061 %   For more details on the derivations behind the derivative code used
0062 %   in MATPOWER information, see:
0063 %
0064 %   [TN2]  R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and
0065 %          their Derivatives using Complex Matrix Notation", MATPOWER
0066 %          Technical Note 2, February 2010. [Online]. Available:
0067 %          https://matpower.org/docs/TN2-OPF-Derivatives.pdf
0068 %          doi: 10.5281/zenodo.3237866
0069 %   [TN3]  B. Sereeter and R. D. Zimmerman, "Addendum to AC Power Flows and
0070 %          their Derivatives using Complex Matrix Notation: Nodal Current
0071 %          Balance," MATPOWER Technical Note 3, April 2018. [Online].
0072 %          Available: https://matpower.org/docs/TN3-More-OPF-Derivatives.pdf
0073 %          doi: 10.5281/zenodo.3237900
0074 %   [TN4]  B. Sereeter and R. D. Zimmerman, "AC Power Flows and their
0075 %          Derivatives using Complex Matrix Notation and Cartesian
0076 %          Coordinate Voltages," MATPOWER Technical Note 4, April 2018.
0077 %          [Online]. Available: https://matpower.org/docs/TN4-OPF-Derivatives-Cartesian.pdf
0078 %          doi: 10.5281/zenodo.3237909
0079 
0080 %   MATPOWER
0081 %   Copyright (c) 2019, Power Systems Engineering Research Center (PSERC)
0082 %   by Baljinnyam Sereeter, Delft University of Technology
0083 %   and Ray Zimmerman, PSERC Cornell
0084 %
0085 %   This file is part of MATPOWER.
0086 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0087 %   See https://matpower.org for more info.
0088 
0089 %% default input args
0090 if nargin < 4
0091     vcart = 0;      %% default to polar coordinates
0092 end
0093 
0094 n = length(V);
0095 
0096 if vcart
0097     if issparse(Ybus)
0098        diagSV2c = sparse(1:n, 1:n, conj(Sbus./(V.^2)), n, n);
0099     else
0100        diagSV2c = diag(conj(Sbus./(V.^2)));
0101     end
0102 
0103     dImis_dV1 = Ybus + diagSV2c;            %% dImis/dVr
0104     dImis_dV2 = 1j*(Ybus - diagSV2c);       %% dImis/dVi
0105 else
0106     Vm = abs(V);
0107     Vnorm = V./Vm;
0108     Ibus = conj(Sbus./V);
0109     if issparse(Ybus)
0110         diagV       = sparse(1:n, 1:n, V, n, n);
0111         diagIbus    = sparse(1:n, 1:n, Ibus, n, n);
0112         diagIbusVm  = sparse(1:n, 1:n, Ibus./Vm, n, n);
0113         diagVnorm   = sparse(1:n, 1:n, V./abs(V), n, n);
0114     else
0115         diagV       = diag(V);
0116         diagIbus    = diag(Ibus);
0117         diagIbusVm  = diag(Ibus./Vm);
0118         diagVnorm   = diag(V./abs(V));
0119     end
0120 
0121     dImis_dV1 = 1j*(Ybus*diagV - diagIbus);     %% dImis/dVa
0122     dImis_dV2 = Ybus*diagVnorm + diagIbusVm;    %% dImis/dVm
0123 end

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