Home > matpower6.0 > makeJac.m

makeJac

PURPOSE ^

MAKEJAC Forms the power flow Jacobian.

SYNOPSIS ^

function [J, Ybus, Yf, Yt] = makeJac(baseMVA, bus, branch, gen, fullJac)

DESCRIPTION ^

MAKEJAC  Forms the power flow Jacobian.
   J = MAKEJAC(MPC)
   J = MAKEJAC(MPC, FULLJAC)
   J = MAKEJAC(BASEMVA, BUS, BRANCH, GEN)
   J = MAKEJAC(BASEMVA, BUS, BRANCH, GEN, FULLJAC)
   [J, YBUS, YF, YT] = MAKEJAC(MPC)

   Returns the power flow Jacobian and, optionally, the system admittance
   matrices. Inputs can be a MATPOWER case struct or individual BASEMVA,
   BUS, BRANCH and GEN values. Bus numbers must be consecutive beginning
   at 1 (i.e. internal ordering). If the FULLJAC argument is present and
   true, it returns the full Jacobian (sensitivities of all bus injections
   w.r.t all voltage angles/magnitudes) as opposed to the reduced version
   used in the Newton power flow updates.

   Note: This function builds the Jacobian from scratch, rebuilding the
         YBUS matrix in the process. You probably don't want to use this
         in performance critical code.

   See also MAKEYBUS, EXT2INT

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [J, Ybus, Yf, Yt] = makeJac(baseMVA, bus, branch, gen, fullJac)
0002 %MAKEJAC  Forms the power flow Jacobian.
0003 %   J = MAKEJAC(MPC)
0004 %   J = MAKEJAC(MPC, FULLJAC)
0005 %   J = MAKEJAC(BASEMVA, BUS, BRANCH, GEN)
0006 %   J = MAKEJAC(BASEMVA, BUS, BRANCH, GEN, FULLJAC)
0007 %   [J, YBUS, YF, YT] = MAKEJAC(MPC)
0008 %
0009 %   Returns the power flow Jacobian and, optionally, the system admittance
0010 %   matrices. Inputs can be a MATPOWER case struct or individual BASEMVA,
0011 %   BUS, BRANCH and GEN values. Bus numbers must be consecutive beginning
0012 %   at 1 (i.e. internal ordering). If the FULLJAC argument is present and
0013 %   true, it returns the full Jacobian (sensitivities of all bus injections
0014 %   w.r.t all voltage angles/magnitudes) as opposed to the reduced version
0015 %   used in the Newton power flow updates.
0016 %
0017 %   Note: This function builds the Jacobian from scratch, rebuilding the
0018 %         YBUS matrix in the process. You probably don't want to use this
0019 %         in performance critical code.
0020 %
0021 %   See also MAKEYBUS, EXT2INT
0022 
0023 %   MATPOWER
0024 %   Copyright (c) 1996-2016, Power Systems Engineering Research Center (PSERC)
0025 %   by Ray Zimmerman, PSERC Cornell
0026 %
0027 %   This file is part of MATPOWER.
0028 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0029 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0030 
0031 if nargin < 4
0032     mpc     = baseMVA;
0033     if nargin > 1
0034         fullJac = bus;
0035     else
0036         fullJac = 0;
0037     end
0038     baseMVA = mpc.baseMVA;
0039     bus     = mpc.bus;
0040     branch  = mpc.branch;
0041     gen     = mpc.gen;
0042 elseif nargin < 5
0043     fullJac = 0;
0044 end
0045 
0046 %% define named indices into bus, gen, branch matrices
0047 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0048     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0049 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0050     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0051     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0052 
0053 %% build Ybus
0054 [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0055 
0056 %% extract voltage
0057 V = bus(:, VM) .* exp(sqrt(-1) * pi/180 * bus(:, VA));
0058 on = find(gen(:, GEN_STATUS) > 0);      %% which generators are on?
0059 gbus = gen(on, GEN_BUS);                %% what buses are they at?
0060 V(gbus) = gen(on, VG) ./ abs(V(gbus)).* V(gbus);
0061 
0062 %% build Jacobian
0063 [dSbus_dVm, dSbus_dVa] = dSbus_dV(Ybus, V);
0064 if fullJac
0065     j11 = real(dSbus_dVa);
0066     j12 = real(dSbus_dVm);
0067     j21 = imag(dSbus_dVa);
0068     j22 = imag(dSbus_dVm);
0069 else
0070     %% get bus index lists of each type of bus
0071     [ref, pv, pq] = bustypes(bus, gen);
0072 
0073     j11 = real(dSbus_dVa([pv; pq], [pv; pq]));
0074     j12 = real(dSbus_dVm([pv; pq], pq));
0075     j21 = imag(dSbus_dVa(pq, [pv; pq]));
0076     j22 = imag(dSbus_dVm(pq, pq));
0077 end
0078 
0079 J = [   j11 j12;
0080         j21 j22;    ];

Generated on Fri 16-Dec-2016 12:45:37 by m2html © 2005