📄 autorun.m
字号:
function check = autorun(msg)% AUTORUN properly launch PSAT routine checking for data% files and previous power flow solutions%% CHECK = AUTORUN(MSG)% MSG message to be displayed% CHECK 1 if everything goes fine, 0 otherwise%%Author: Federico Milano%Date: 29-Oct-2003%Version: 1.0.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.global Settings File Snapshot Line Busglobal DAE LIB SNB OPF CPF clpsatcheck = 0;% check for data fileif isempty(File.data), fm_disp(['Set a data file before running ',msg,'.'],2) returnend% check for initial power flow solutionif ~Settings.init solvepf if ~Settings.init return endend% check for previous CPF & ATC solutionsif strcmp(msg,'SNB Direct Method') one = 1;else one = 0;endif CPF.init & ~(one & CPF.init == 1) switch CPF.init case 1, met = 'CPF'; case 2, met = 'ATC'; case 3, met = 'N-1 Cont. An.'; case 4, met = 'Continuation OPF (PSAT-GAMS)'; end Settings.ok = 0; if clpsat.init Settings.ok = clpsat.refresh; else uiwait(fm_choice([met,' has been run last. Do you want to' ... ' restore initial PF solution?'],1)) end if Settings.ok Line.Y = Snapshot(1).Y; Bus.Pg = Snapshot(1).Pg; Bus.Qg = Snapshot(1).Qg; Bus.Pl = Snapshot(1).Pl; Bus.Ql = Snapshot(1).Ql; DAE.V = Snapshot(1).V; DAE.a = Snapshot(1).ang; DAE.x = Snapshot(1).x; DAE.Jlf = Snapshot(1).Jlf; DAE.Jlfv = Snapshot(1).Jlfv; DAE.Fx = Snapshot(1).Fx; DAE.Fy = Snapshot(1).Fy; DAE.Gx = Snapshot(1).Gx; fm_disp(['Initial PF solution will be used as ', ... 'base case solution.']) else fm_disp(['Last ',met,' solution will be used as ', ... 'base case solution.']) end CPF.init = 0;end% check for previous time domain simulationsif Settings.init == 2 Settings.ok = 0; if clpsat.init Settings.ok = clpsat.refresh; else uiwait(fm_choice(['TD has been run last. Do you want to' ... ' restore initial PF solution?'],1)) end if Settings.ok solvepf fm_disp(['Initial PF solution will be used as ', ... 'base case solution.']) else fm_disp(['Last TD point will be used as base case ', ... 'solution.']) end Settings.init = 1;end% check for SNB direct methodif SNB.init Settings.ok = 0; if clpsat.init Settings.ok = clpsat.refresh; else uiwait(fm_choice(['SNB direct method has been run last. Do you want to' ... ' restore initial PF solution?'],1)) end if Settings.ok solvepf fm_disp(['Initial PF solution will be used as ', ... 'base case solution.']) else fm_disp(['SNB solution will be used as base case ', ... 'solution.']) end SNB.init = 0;end% check for LIB direct methodif LIB.init Settings.ok = 0; if clpsat.init Settings.ok = clpsat.refresh; else uiwait(fm_choice(['LIB direct method has been run last. Do you want to' ... ' restore initial PF solution?'],1)) end if Settings.ok solvepf fm_disp(['Initial PF solution will be used as ', ... 'base case solution.']) else fm_disp(['LIB solution will be used as base case ', ... 'solution.']) end LIB.init = 0;end% check for OPF solutionif strcmp(msg,'Optimal Power Flow') one = 0;else one = 1;endif OPF.init & one Settings.ok = 0; if clpsat.init Settings.ok = clpsat.refresh; else uiwait(fm_choice(['OPF has been run last. Do you want to' ... ' restore initial PF solution?'],1)) end if Settings.ok solvepf fm_disp(['Initial PF solution will be used as ', ... 'base case solution.']) else fm_disp(['OPF solution will be used as base case ', ... 'solution.']) end OPF.init = 0;endcheck = 1;% ---------------------------------------------------function solvepfglobal Settingsfm_disp('Solve base case power flow...')Settings.show = 0;fm_set('lf')Settings.show = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -