Home > matpower7.1 > lib > opf_vref_fcn.m

opf_vref_fcn

PURPOSE ^

OPF_VREF_FCN Evaluates voltage angle reference and their gradients.

SYNOPSIS ^

function [Vref, dVref] = opf_vref_fcn(x, mpc, refs, mpopt)

DESCRIPTION ^

OPF_VREF_FCN  Evaluates voltage angle reference and their gradients.
   [Vref, dVref] = OPF_VREF_FCN(X, mpc, ref, MPOPT)

   Computes the voltage angle reference 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
     REFS : reference vector
     MPOPT : MATPOWER options struct

   Outputs:
     VREF  : vector of voltage angle reference
     DVREF : (optional) angle reference gradients

   Examples:
       Vref = opf_vref_fcn(x, mpc, refs, mpopt);
       [Vref, dVref] = opf_vref_fcn(x, mpc, refs, mpopt);

   See also OPF_VREF_HESS

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [Vref, dVref] = opf_vref_fcn(x, mpc, refs, mpopt)
0002 %OPF_VREF_FCN  Evaluates voltage angle reference and their gradients.
0003 %   [Vref, dVref] = OPF_VREF_FCN(X, mpc, ref, MPOPT)
0004 %
0005 %   Computes the voltage angle reference 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 %     REFS : reference vector
0012 %     MPOPT : MATPOWER options struct
0013 %
0014 %   Outputs:
0015 %     VREF  : vector of voltage angle reference
0016 %     DVREF : (optional) angle reference gradients
0017 %
0018 %   Examples:
0019 %       Vref = opf_vref_fcn(x, mpc, refs, mpopt);
0020 %       [Vref, dVref] = opf_vref_fcn(x, mpc, refs, mpopt);
0021 %
0022 %   See also OPF_VREF_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 n = length(refs);
0040 nb = length(Vr);
0041 
0042 %% compute voltage angle reference
0043 Vref = angle(Vr(refs) + 1j* Vi(refs)) - mpc.bus(refs, VA) * pi/180;
0044 
0045 if nargout > 1
0046     %% compute partials of voltage angle reference w.r.t Vr and Vi
0047     Vm2 = Vr(refs).^2 + Vi(refs).^2;
0048     dVa_dVr = sparse(1:n, refs, -Vi(refs) ./ Vm2, n, nb);
0049     dVa_dVi = sparse(1:n, refs,  Vr(refs) ./ Vm2, n, nb);
0050     dVref = [dVa_dVr dVa_dVi];          %% Vref w.r.t Vr, Vi
0051 end

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