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

📄 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 == 0   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; endxa    = DAE.x;anga  = DAE.a;Va    = DAE.V;ffn   = DAE.f;ga    = DAE.g;Pg0   = Syn.Pg;Vrif0 = Exc.vrif0;SvcVref0 = Svc.Vref;SvcBe = Svc.Be;Tgcon0 = Tg.con;% 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.  % --------------------------------------------------------------------  fex_nrloop(Settings.lftol,Settings.lfmit)      % Differential equations & state matrix calculation      fm_call('1r');  fm_call('3');    ff=DAE.f;  NLA.a_sys(:,j)=ff./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;   NLA.c_Pg(:,j)=(Syn.Pg-Pg0)/deltaX;    DAE.x  = xa;  DAE.a  = anga;  DAE.V  = Va;     Syn.Pg = Pg0;end% -----------------------------------------------------------------------% Computation of input matrices B% -----------------------------------------------------------------------% B matrix for Exciters reference voltages % -----------------------------------------------------------------------fex_nrloop(Settings.lftol,Settings.lfmit)    fm_call('1r');fm_call('3');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    fex_nrloop(Settings.lftol,Settings.lfmit)        % Differential equations & state matrix formation        fm_call('1r');    fm_call('3');    ff=DAE.f;    NLA.b_Vr(:,j)=ff./deltaU;    DAE.x = xa;    DAE.a = anga;    DAE.V = Va;       Exc.vrif0 = Vrif0;  endend% B matrix for Governor reference  % -----------------------------------------------------------------------fex_nrloop(Settings.lftol,Settings.lfmit)    fm_call('1r');fm_call('3');if Tg.n  incY=0;   ntg=Tg.n;  for j=1:ntg;    deltaU = max(tol,abs(tol*Tg.con(j,3)));    Tg.con(j,3) = Tg.con(j,3)+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    fex_nrloop(Settings.lftol,Settings.lfmit)        % Differential equations & state matrix formation        fm_call('1r');    fm_call('3');    ff=DAE.f;    NLA.b_Tr(:,j)=ff./deltaU;    DAE.x  = xa;    DAE.a  = anga;    DAE.V  = Va;       Tg.con = Tgcon0;  endend% B matrix SVC voltage reference  % -----------------------------------------------------------------------fex_nrloop(Settings.lftol,Settings.lfmit)    fm_call('1r');fm_call('3');if Svc.n  incY=0;   nsvc=Svc.n;  for j=1:nsvc;    deltaU = max(tol,abs(tol*Svc.Vref));    Svc.Vref = Svc.Vref+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    fex_nrloop(Settings.lftol,Settings.lfmit)        % differential equations & state matrix formation        fm_call('1r');    fm_call('3');    ff=DAE.f;    NLA.b_svc(:,j)=ff./deltaU;    DAE.x = xa;    DAE.a = anga;    DAE.V = Va;       Svc.Vref = SvcVref0;  endend

⌨️ 快捷键说明

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