⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fex_abcd.m

📁 基于PSAT 软件的多目标最优潮流计算用于中小型电力系统的分析和管理
💻 M
字号:
function fex_abcd% This function computes matrices (A, B, C, D) for linear analysis by% means of numerical differentiation.  It has to be run after state% initialization performed by power flow PSAT functions in Command% Line mode.%% Structure NLA contains Jacobian matrices and settings for the% numeric linear analysis library.  NLA.a_sys is the state matrix, and% can be compared with the analytical state matrix calculated by PSAT% functions.%% Author:  Alberto Del Rosso% Date:    June 2004% Update:% Version: preliminary version% E-mail:  adelrosso@mercadosenergeticos.com% % I M P O R T A N T   N O T E % =========================== % This external function is not part of the original PSAT software% package although it uses many of PSAT functions. It has not been% approved yet by Dr. Federico Milano to be distributed along with% PSAT files.fm_varfm_disp% Check for dynamic componentsif ~DAE.n   fm_disp('No dynamic component is loaded.')  fm_disp('Computation of linear dynamic matrices aborted.')  returnendfm_disp('Computation of linear analysis matrices A,B,C,D:')fm_dispfm_disp('   [Delta dx/dt] = [A] [Delta x] + [B] [Delta u]')fm_disp('       [Delta y] = [C] [Delta x] + [D] [Delta u]')fm_dispfm_disp('Input and Output matrices are stored in structure NLA')% Excitation  systemsif ~Exc.n, fm_disp('No excitation systems found'), end% Turbine governorsif ~Tg.n, fm_disp('No turbine governor found'), end% Static var systemsif ~Svc.n, fm_disp('No Static Var Compensators found'), end% Define matrices NLA structure% State matrixnstates = DAE.n;NLA.a_sys = zeros(nstates);% -------------------------------------------------------------------% Output matrices  % -------------------------------------------------------------------% output matrix corresponding to bus voltage magnitudesNLA.c_V  = zeros(Bus.n, DAE.n);  % output matrix corresponding to generator active powersNLA.c_Pg = zeros(Syn.n, DAE.n);  % output matrix for the line power flow at the from buses PsNLA.c_ps = zeros(Line.n, DAE.n);  % output matrix for the line reactive power flow at the from buses% QsNLA.c_qs = zeros(Line.n, DAE.n);  % output matrix for the line power flow at the to buses PrNLA.c_pr = zeros(Line.n, DAE.n);  % output matrix for the line reactive power flow at the to buses QrNLA.c_qr = zeros(Line.n, DAE.n);  % output matrix for the line current magnitude at the from buses IsNLA.c_Is = zeros(Line.n, DAE.n);  % output matrix for the line current magnitude at the to buses IrNLA.c_Ir = zeros(Line.n, DAE.n);  % -------------------------------------------------------------------% Input matrices% -------------------------------------------------------------------% input matrix corresponding to the exciter reference Vrif0 NLA.b_Vr = zeros(DAE.n, Exc.n);  % input matrix corresponding to governor referenceNLA.b_Tr = zeros(DAE.n, Tg.n);% input matrix corresponding to the svc reference inputNLA.b_svc= zeros(DAE.n, Svc.n);  % Set tolerance for variable perturbation% ----------------------------------------------------------------------tol = NLA.tol;% Backup of actual variables% ----------------------------------------------------------------------if isempty(DAE.x), DAE.x = 0; endif isempty(DAE.f), DAE.f = 0; end% refresh equationsfm_call('i')fm_nrlf(Settings.lfmit,Settings.lftol,0);xa    = DAE.x;anga  = DAE.a;Va    = DAE.V;ffn   = DAE.f;ga    = DAE.g;Pg0   = Syn.Pg;Vrif0 = Exc.vrif0;% Initial line power flows[Ps0,Qs0,Pr0,Qr0,Is0,Ir0] = fex_lineflows;% Comuputation of state matrix "NLA.a_sys" and output matrices% Sequentially perturb differential and algebraic equations % A matrix% ----------------------------------------------------------------------for j=1:nstates;  deltaX = max(tol,abs(tol*DAE.x(j)));  DAE.x(j)=DAE.x(j)+deltaX;  % --------------------------------------------------------------------  % Solve algebraic equations  g(x0,y) for algebraic variables y,  % where x0 is the perturbed state vector which is  % kept constant during the NR loop.  % --------------------------------------------------------------------  fm_nrlf(Settings.lfmit,Settings.lftol,0);  % Differential equations & state matrix calculation  ff = DAE.f;  NLA.a_sys(:,j)=(ff-ffn)./deltaX;  % Power flows and current magnitude in  Lines   [Ps,Qs,Pr,Qr,Is,Ir] = fex_lineflows;  % Output matrices matrices calculation   NLA.c_V(:,j) =(DAE.V-Va)/deltaX;  NLA.c_ps(:,j)=(Ps-Ps0)/deltaX;   NLA.c_qs(:,j)=(Qs-Qs0)/deltaX;   NLA.c_pr(:,j)=(Pr-Pr0)/deltaX;   NLA.c_qr(:,j)=(Qr-Qr0)/deltaX;   NLA.c_Is(:,j)=(Is-Is0)/deltaX;   NLA.c_Ir(:,j)=(Ir-Ir0)/deltaX;   if Syn.n, NLA.c_Pg(:,j)=(Syn.Pg-Pg0)/deltaX; end  DAE.x  = xa;  DAE.a  = anga;  DAE.V  = Va;     Syn.Pg = Pg0;end% -----------------------------------------------------------------------% Computation of input matrices B% -----------------------------------------------------------------------% B matrix for Exciters reference voltages % -----------------------------------------------------------------------fm_nrlf(Settings.lfmit,Settings.lftol,0);if Exc.n  incY=0;   nexcs=Exc.n;  for j=1:nexcs;    deltaU = max(tol,abs(tol*Exc.vrif0(j)));    Exc.vrif0(j) = Exc.vrif0(j)+deltaU;    % --------------------------------------------------------------------    % Solve algebraic equations -- solve equations g(x,y,U0) for algebraic    % variables y, where U0 is the perturbed input vector which is    % kept constant during the NR loop.      % --------------------------------------------------------------------        % Initialize NR loop    fm_nrlf(Settings.lfmit,Settings.lftol,0);    % Differential equations & state matrix formation        ff=DAE.f;    NLA.b_Vr(:,j)=(ff-ffn)./deltaU;    DAE.x = xa;    DAE.a = anga;    DAE.V = Va;       Exc.vrif0 = Vrif0;  endend% B matrix for Governor reference  numdiff(Tg,ffn,xa,Va,anga);% B matrix SVC voltage reference  numdiff(Svc,ffn,xa,Va,anga);fm_disp('Numerical Linear Analysis completed.')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -