Home > matpower5.1 > 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 (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 (internal ordering). If the FULLJAC argument is present and true,
0013 %   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-2015 by Power System Engineering Research Center (PSERC)
0025 %   by Ray Zimmerman, PSERC Cornell
0026 %
0027 %   $Id: makeJac.m 2644 2015-03-11 19:34:22Z ray $
0028 %
0029 %   This file is part of MATPOWER.
0030 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0031 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0032 
0033 if nargin < 4
0034     mpc     = baseMVA;
0035     if nargin > 1
0036         fullJac = bus;
0037     else
0038         fullJac = 0;
0039     end
0040     baseMVA = mpc.baseMVA;
0041     bus     = mpc.bus;
0042     branch  = mpc.branch;
0043     gen     = mpc.gen;
0044 elseif nargin < 5
0045     fullJac = 0;
0046 end
0047 
0048 %% define named indices into bus, gen, branch matrices
0049 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0050     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0051 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0052     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0053     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0054 
0055 %% build Ybus
0056 [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0057 
0058 %% extract voltage
0059 V = bus(:, VM) .* exp(sqrt(-1) * pi/180 * bus(:, VA));
0060 on = find(gen(:, GEN_STATUS) > 0);      %% which generators are on?
0061 gbus = gen(on, GEN_BUS);                %% what buses are they at?
0062 V(gbus) = gen(on, VG) ./ abs(V(gbus)).* V(gbus);
0063 
0064 %% build Jacobian
0065 [dSbus_dVm, dSbus_dVa] = dSbus_dV(Ybus, V);
0066 if fullJac
0067     j11 = real(dSbus_dVa);
0068     j12 = real(dSbus_dVm);
0069     j21 = imag(dSbus_dVa);
0070     j22 = imag(dSbus_dVm);
0071 else
0072     %% get bus index lists of each type of bus
0073     [ref, pv, pq] = bustypes(bus, gen);
0074 
0075     j11 = real(dSbus_dVa([pv; pq], [pv; pq]));
0076     j12 = real(dSbus_dVm([pv; pq], pq));
0077     j21 = imag(dSbus_dVa(pq, [pv; pq]));
0078     j22 = imag(dSbus_dVm(pq, pq));
0079 end
0080 
0081 J = [   j11 j12;
0082         j21 j22;    ];

Generated on Fri 20-Mar-2015 18:23:34 by m2html © 2005