📄 fm_wcall.m
字号:
function fm_wcall%FM_WCALL writes the function FM_CALL for the component calls.% and uses the information in Comp.prop for setting% the right calls. Comp.prop is organized as follows:% comp(i,:) = [x1 x2 x3 x4 x5 xi x0 xt]%% if x1 -> call for algebraic equations% if x2 -> call for algebraic Jacobians% if x3 -> call for state equations% if x4 -> call for state Jacobians% if x5 -> call for non-windup limits% if xi -> component used in power flow computations% if x0 -> call for initializations% if xt -> call for current simulation time% (-1 is used for static analysis)%% Comp.prop is stored in the "comp.ini" file.%%FM_WCALL%%Author: Federico Milano%Date: 11-Nov-2002%Update: 22-Aug-2003%Version: 1.1.0%%E-mail: fmilano@thunderbox.uwaterloo.ca%Web-site: http://thunderbox.uwaterloo.ca/~fmilano%% Copyright (C) 2002-2005 Federico Milano%% This toolbox is free software; you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation; either version 2.0 of the License, or% (at your option) any later version.%% This toolbox is distributed in the hope that it will be useful, but% WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU% General Public License for more details.%% You should have received a copy of the GNU General Public License% along with this toolbox; if not, write to the Free Software% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,% USA.fm_var% ------------------------------------------------------------------------% Opening file "fm_call.m" for writing% ------------------------------------------------------------------------if Settings.local fid = fopen([Path.local,'fm_call.m'], 'wt');else [fid,msg] = fopen([Path.psat,'fm_call.m'], 'wt'); if fid == -1 fm_disp(msg) fid = fopen([Path.local,'fm_call.m'], 'wt'); endendcount = fprintf(fid,'function fm_call(flag)\n\n');count = fprintf(fid,'\n%%FM_CALL calls component equations');count = fprintf(fid,'\n%%');count = fprintf(fid,'\n%%FM_CALL(CASE)');count = fprintf(fid,'\n%% CASE ''1'' algebraic equations');count = fprintf(fid,'\n%% CASE ''pq'' load algebraic equations');count = fprintf(fid,'\n%% CASE ''3'' differential equations');count = fprintf(fid,'\n%% CASE ''1r'' algebraic equations for Rosenbrock method');count = fprintf(fid,'\n%% CASE ''4'' state Jacobians');count = fprintf(fid,'\n%% CASE ''0'' initialization');count = fprintf(fid,'\n%% CASE ''l'' the complete set of equations and Jacobians');count = fprintf(fid,'\n%% CASE ''kg'' as "L" option but for distributed slack bus');count = fprintf(fid,'\n%% CASE ''n'' algebraic equations and Jacobians');count = fprintf(fid,'\n%% CASE ''i'' set initial point');count = fprintf(fid,'\n%% CASE ''5'' non-windup limits');count = fprintf(fid,'\n%%');count = fprintf(fid,'\n%%see also FM_WCALL\n\n');count = fprintf(fid,'global DAE Bus \n');count = fprintf(fid,'switch flag\n\n');space = ' ';% ------------------------------------------------------------------------% call algebraic equations% ------------------------------------------------------------------------count = fprintf(fid,'\n case ''1''\n\n');for i = 1:Comp.n-2 ncompi = eval(Comp.number{i}); flag1i = Comp.prop(i,1); lf = Comp.prop(i,6); if ncompi > 0 & flag1i & lf count = fprintf(fid,[' ',Comp.funct{i},'(1);\n']); endend% ------------------------------------------------------------------------% call algebraic equations of shunt components% ------------------------------------------------------------------------count = fprintf(fid,'\n case ''pq''\n\n');for i = 1:Comp.n-2 ncompi = eval(Comp.number{i}); flag1i = Comp.prop(i,1); lf = Comp.prop(i,6); sh = Comp.prop(i,8); if ncompi > 0 & flag1i & lf & sh count = fprintf(fid,[space,Comp.funct{i},'(1);\n']); endend% ------------------------------------------------------------------------% call differential equations% ------------------------------------------------------------------------count = fprintf(fid,'\n case ''3''\n\n');for i = 1:Comp.n-2 ncompi = eval(Comp.number{i}); flag3i = Comp.prop(i,3); if ncompi > 0 & flag3i count = fprintf(fid,[space,Comp.funct{i},'(3);\n']); endend% ------------------------------------------------------------------------% call algebraic equations for Rosenbrock method% ------------------------------------------------------------------------count = fprintf(fid,'\n case ''1r''\n\n');if Line.n > 0 count = fprintf(fid,[space,'fm_lf(1);\n']);endfor i = 1:Comp.n ncompi = eval(Comp.number{i}); flag1i = Comp.prop(i,1); if ncompi & flag1i == 1 count = fprintf(fid,[space,Comp.funct{i},'(1);\n']); endendcount = fprintf(fid,'\n DAE.g = [DAE.gp; DAE.gq];\n\n');% ------------------------------------------------------------------------% call DAE Jacobians% ------------------------------------------------------------------------count = fprintf(fid,'\n case ''4''\n');if Settings.octave count = fprintf(fid,'\n DAE.Fx = zeros(DAE.n,DAE.n);'); count = fprintf(fid,'\n DAE.Fy = zeros(DAE.n,2*Bus.n);'); count = fprintf(fid,'\n DAE.Gx = zeros(2*Bus.n,DAE.n);\n');else count = fprintf(fid,'\n DAE.Fx = sparse(DAE.n,DAE.n);'); count = fprintf(fid,'\n DAE.Fy = sparse(DAE.n,2*Bus.n);'); count = fprintf(fid,'\n DAE.Gx = sparse(2*Bus.n,DAE.n);\n');endfor i = 1:Comp.n-2 ncompi = eval(Comp.number{i}); flag4i = Comp.prop(i,4); if ncompi & flag4i count = fprintf(fid,[space,Comp.funct{i},'(4);\n']); endend% ------------------------------------------------------------------------% call initialization functions% ------------------------------------------------------------------------count = fprintf(fid,'\n case ''0''\n\n');for i = 1:Comp.n-2 ncompi = eval(Comp.number{i}); lf = Comp.prop(i,7); if ncompi & lf count = fprintf(fid,[space,Comp.funct{i},'(0);\n']); endend% ------------------------------------------------------------------------% call the complete set of equations and Jacobians% ------------------------------------------------------------------------count = fprintf(fid,'\n case ''fdpf''\n\n');if Line.n > 0 count = fprintf(fid,[' fm_lf(1);\n']);endfor i = 1:Comp.n ncompi = eval(Comp.number{i}); flag1i = Comp.prop(i,1); lf = Comp.prop(i,6); if ncompi > 0 & flag1i & lf count = fprintf(fid,[space,Comp.funct{i},'(1);\n']); endendcount = fprintf(fid,'\n DAE.g = [DAE.gp; DAE.gq];\n\n');% ------------------------------------------------------------------------% call the complete set of equations and Jacobians% ------------------------------------------------------------------------count = fprintf(fid,'\n case ''l''\n\n');if Line.n > 0 count = fprintf(fid,[' fm_lf(1);\n']);endfor i = 1:Comp.n ncompi = eval(Comp.number{i}); flag1i = Comp.prop(i,1); lf = Comp.prop(i,6); if ncompi > 0 & flag1i & lf count = fprintf(fid,[space,Comp.funct{i},'(1);\n']); endendcount = fprintf(fid,'\n DAE.g = [DAE.gp; DAE.gq];\n\n');if Line.n > 0 count = fprintf(fid,[space,'fm_lf(2);\n']);endcount = fprintf(fid,' DAE.Jlf = [DAE.J11, DAE.J12; DAE.J21, DAE.J22];\n');for i = 1:Comp.n ncompi = eval(Comp.number{i}); flag2i = Comp.prop(i,2); lf = Comp.prop(i,6); if ncompi > 0 & flag2i & lf count = fprintf(fid,[space,Comp.funct{i},'(2);\n']); endendcount = fprintf(fid,'\n DAE.Jlfv = [DAE.J11, DAE.J12; DAE.J21, DAE.J22];\n\n');for i = 1:Comp.n ncompi = eval(Comp.number{i}); flag3i = Comp.prop(i,3); lf = Comp.prop(i,6); if ncompi > 0 & flag3i & lf count = fprintf(fid,[space,Comp.funct{i},'(3);\n']); endendcount = fprintf(fid,'\n');if Settings.octave count = fprintf(fid,'\n DAE.Fx = zeros(DAE.n,DAE.n);'); count = fprintf(fid,'\n DAE.Fy = zeros(DAE.n,2*Bus.n);'); count = fprintf(fid,'\n DAE.Gx = zeros(2*Bus.n,DAE.n);\n');else count = fprintf(fid,'\n DAE.Fx = sparse(DAE.n,DAE.n);'); count = fprintf(fid,'\n DAE.Fy = sparse(DAE.n,2*Bus.n);'); count = fprintf(fid,'\n DAE.Gx = sparse(2*Bus.n,DAE.n);\n');endcount = fprintf(fid,'\n');for i = 1:Comp.n ncompi = eval(Comp.number{i}); flag4i = Comp.prop(i,4); lf = Comp.prop(i,6); if ncompi > 0 & flag4i & lf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -