Home > matpower4.1 > makeJac.m

makeJac

PURPOSE ^

MAKEJAC Forms the power flow Jacobian.

SYNOPSIS ^

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

DESCRIPTION ^

MAKEJAC  Forms the power flow Jacobian.
   J = MAKEJAC(MPC)
   J = MAKEJAC(BASEMVA, BUS, BRANCH, GEN)
   [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).

   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)
0002 %MAKEJAC  Forms the power flow Jacobian.
0003 %   J = MAKEJAC(MPC)
0004 %   J = MAKEJAC(BASEMVA, BUS, BRANCH, GEN)
0005 %   [J, YBUS, YF, YT] = MAKEJAC(MPC)
0006 %
0007 %   Returns the power flow Jacobian and, optionally, the system admittance
0008 %   matrices. Inputs can be a MATPOWER case struct or individual BASEMVA,
0009 %   BUS, BRANCH and GEN values. Bus numbers must be consecutive beginning
0010 %   at 1 (internal ordering).
0011 %
0012 %   Note: This function builds the Jacobian from scratch, rebuilding the
0013 %         YBUS matrix in the process. You probably don't want to use this
0014 %         in performance critical code.
0015 %
0016 %   See also MAKEYBUS, EXT2INT
0017 
0018 %   MATPOWER
0019 %   $Id: makeJac.m,v 1.1 2010/06/25 17:37:40 ray Exp $
0020 %   by Ray Zimmerman, PSERC Cornell
0021 %   Copyright (c) 1996-2010 by Power System Engineering Research Center (PSERC)
0022 %
0023 %   This file is part of MATPOWER.
0024 %   See http://www.pserc.cornell.edu/matpower/ for more info.
0025 %
0026 %   MATPOWER is free software: you can redistribute it and/or modify
0027 %   it under the terms of the GNU General Public License as published
0028 %   by the Free Software Foundation, either version 3 of the License,
0029 %   or (at your option) any later version.
0030 %
0031 %   MATPOWER is distributed in the hope that it will be useful,
0032 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0033 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0034 %   GNU General Public License for more details.
0035 %
0036 %   You should have received a copy of the GNU General Public License
0037 %   along with MATPOWER. If not, see <http://www.gnu.org/licenses/>.
0038 %
0039 %   Additional permission under GNU GPL version 3 section 7
0040 %
0041 %   If you modify MATPOWER, or any covered work, to interface with
0042 %   other modules (such as MATLAB code and MEX-files) available in a
0043 %   MATLAB(R) or comparable environment containing parts covered
0044 %   under other licensing terms, the licensors of MATPOWER grant
0045 %   you additional permission to convey the resulting work.
0046 
0047 if nargin < 4
0048     mpc     = baseMVA;
0049     baseMVA = mpc.baseMVA;
0050     bus     = mpc.bus;
0051     branch  = mpc.branch;
0052     gen     = mpc.gen;
0053 end
0054 
0055 %% define named indices into bus, gen, branch matrices
0056 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0057     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0058 [GEN_BUS, PG, QG, QMAX, QMIN, VG, MBASE, GEN_STATUS, PMAX, PMIN, ...
0059     MU_PMAX, MU_PMIN, MU_QMAX, MU_QMIN, PC1, PC2, QC1MIN, QC1MAX, ...
0060     QC2MIN, QC2MAX, RAMP_AGC, RAMP_10, RAMP_30, RAMP_Q, APF] = idx_gen;
0061 
0062 %% get bus index lists of each type of bus
0063 [ref, pv, pq] = bustypes(bus, gen);
0064 
0065 %% build Ybus
0066 [Ybus, Yf, Yt] = makeYbus(baseMVA, bus, branch);
0067 
0068 %% extract voltage
0069 V = bus(:, VM) .* exp(sqrt(-1) * pi/180 * bus(:, VA));
0070 on = find(gen(:, GEN_STATUS) > 0);      %% which generators are on?
0071 gbus = gen(on, GEN_BUS);                %% what buses are they at?
0072 V(gbus) = gen(on, VG) ./ abs(V(gbus)).* V(gbus);
0073 
0074 %% build Jacobian
0075 [dSbus_dVm, dSbus_dVa] = dSbus_dV(Ybus, V);
0076 j11 = real(dSbus_dVa([pv; pq], [pv; pq]));
0077 j12 = real(dSbus_dVm([pv; pq], pq));
0078 j21 = imag(dSbus_dVa(pq, [pv; pq]));
0079 j22 = imag(dSbus_dVm(pq, pq));
0080 
0081 J = [   j11 j12;
0082         j21 j22;    ];

Generated on Mon 26-Jan-2015 15:00:13 by m2html © 2005