Home > matpower7.1 > lib > opf_vlim_fcn.m

opf_vlim_fcn

PURPOSE ^

OPF_VLIM_FCN Evaluates voltage magnitudes and their gradients.

SYNOPSIS ^

function [Vlims, dVlims] = opf_vlim_fcn(x, mpc, idx, mpopt)

DESCRIPTION ^

OPF_VLIM_FCN  Evaluates voltage magnitudes and their gradients.
   [Vlims, dVlims] = OPF_VLIM_FCN(X, MPC, IDX, MPOPT)

   Computes the voltage magnitudes using real and imaginary part of complex voltage for
   AC optimal power flow. Computes constraint vectors and their gradients.

   Inputs:
     X : optimization vector
     MPC : MATPOWER case struct
     IDX : index of buses whose voltage magnitudes should be fixed
     MPOPT : MATPOWER options struct

   Outputs:
     VLIMS  : vector of voltage magnitudes
     DVLIMS : (optional) magnitude gradients

   Examples:
       Vlims = opf_vlim_fcn(x, mpc, mpopt);
       [Vlims, dVlims] = opf_vlim_fcn(x, mpc, idx, mpopt);

   See also OPF_VLIM_HESS

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Vlims, dVlims] = opf_vlim_fcn(x, mpc, idx, mpopt)
0002 %OPF_VLIM_FCN  Evaluates voltage magnitudes and their gradients.
0003 %   [Vlims, dVlims] = OPF_VLIM_FCN(X, MPC, IDX, MPOPT)
0004 %
0005 %   Computes the voltage magnitudes using real and imaginary part of complex voltage for
0006 %   AC optimal power flow. Computes constraint vectors and their gradients.
0007 %
0008 %   Inputs:
0009 %     X : optimization vector
0010 %     MPC : MATPOWER case struct
0011 %     IDX : index of buses whose voltage magnitudes should be fixed
0012 %     MPOPT : MATPOWER options struct
0013 %
0014 %   Outputs:
0015 %     VLIMS  : vector of voltage magnitudes
0016 %     DVLIMS : (optional) magnitude gradients
0017 %
0018 %   Examples:
0019 %       Vlims = opf_vlim_fcn(x, mpc, mpopt);
0020 %       [Vlims, dVlims] = opf_vlim_fcn(x, mpc, idx, mpopt);
0021 %
0022 %   See also OPF_VLIM_HESS
0023 
0024 %   MATPOWER
0025 %   Copyright (c) 2018, Power Systems Engineering Research Center (PSERC)
0026 %   by Baljinnyam Sereeter, Delft University of Technology
0027 %   and Ray Zimmerman, PSERC Cornell
0028 %
0029 %   This file is part of MATPOWER.
0030 %   Covered by the 3-clause BSD License (see LICENSE file for details).
0031 %   See https://matpower.org for more info.
0032 
0033 %% define named indices into data matrices
0034 [PQ, PV, REF, NONE, BUS_I, BUS_TYPE, PD, QD, GS, BS, BUS_AREA, VM, ...
0035     VA, BASE_KV, ZONE, VMAX, VMIN, LAM_P, LAM_Q, MU_VMAX, MU_VMIN] = idx_bus;
0036 
0037 %% unpack data
0038 [Vr, Vi] = deal(x{:});
0039 
0040 %% problem dimensions
0041 nb = length(Vi);            %% number of buses
0042 n = length(idx);            %% number of buses with voltage limits
0043 
0044 %% compute voltage magnitude
0045 Vm2 = Vr(idx).^2 + Vi(idx).^2;
0046 Vlims = [ mpc.bus(idx, VMIN).^2 - Vm2;
0047           Vm2 - mpc.bus(idx, VMAX).^2 ];
0048 
0049 if nargout > 1
0050     %% compute partials of voltage magnitude w.r.t Vr and Vi
0051     dVm_dVr = sparse(1:n, idx, 2 * Vr(idx), n, nb);
0052     dVm_dVi = sparse(1:n, idx, 2 * Vi(idx), n, nb);
0053     dVlims = [ -dVm_dVr -dVm_dVi;   %% Vlims w.r.t Vr, Vi
0054                 dVm_dVr  dVm_dVi  ];
0055 end

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