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

📄 fm_block.m

📁 基于PSAT 软件的多目标最优潮流计算用于中小型电力系统的分析和管理
💻 M
字号:
function fm_block% FM_BLOCK change the mask properties of the current%          selected Simulink block%%see also FM_LIB, FM_SIM, FM_SIMDATA, FM_SIMSETT%%Author:    Federico Milano%Date:      11-Nov-2002%Update:    01-Aug-2003%Version:   1.0.1%%E-mail:    fmilano@thunderbox.uwaterloo.ca%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano%% Copyright (C) 2002-2006 Federico Milanosys    = get_param(0,'CurrentSystem');block  = get_param(sys,'CurrentBlock');gg     = get_param([sys,'/',block],'Selected');mask   = get_param([sys,'/',block],'MaskType');object = [sys,'/',block];Values = get_param(object,'MaskValues');set_param(object,'LinkStatus','none')a = get_param(object,'MaskEnables');b = get_param(object,'MaskPrompts');switch mask case 'Bus'  colors = {'black','blue','green','red','yellow', ...            'cyan','orange','darkgreen','lightblue','gray'};  set_param(object,'BackgroundColor', ...                   colors{rem(round(str2num(Values{5}))-1,10)+1}); case 'Syn'  tipo = str2num(Values{2});  idx = [10,11];  %                   Ko,Kp  Taa  switch tipo   case 2,   a(idx) = {'off'; 'off'};   case 3,   a(idx) = {'on';  'off'};   case 4,   a(idx) = {'on';  'off'};   case 5.1, a(idx) = {'on';  'off'};   case 5.2, a(idx) = {'on';  'on'};   case 5.3, a(idx) = {'off'; 'off'};   case 6,   a(idx) = {'on';  'on'};   case 8,   a(idx) = {'off'; 'on'};  end case 'Mot'  tipo = str2num(Values{2});  idx = [4, 7];  switch tipo   case 1, a(idx) = {'off'; 'off'};   case 3, a(idx) = {'on';  'off'};   case 5, a(idx) = {'on';  'on'};  end case 'Mn'  tipo = Values{4};  switch tipo   case 'on',  b{2} = 'Percentage of active && reactive powers [%, %]';   case 'off', b{2} = 'Active && reactive powers [p.u., p.u.]';  end case 'Pl'  tipo = Values{4};  switch tipo   case 'on'    b{2} = 'Percentage of resistance, active current and active power [%, %, %]';    b{3} = 'Percentage of reactance, reactive current and reactive power [%, %, %]';   case 'off'    b{2} = 'Resistance, active current and active power [p.u., p.u., p.u.]';    b{3} = 'Reactance, reactive current and reactive power [p.u., p.u., p.u.]';  end case 'Breaker'  display1 = ['plot([1 2 2 1 1],[-1 -1 1 1 -1]),color(''red''),', ...              'plot([1 2],[-1 1],[2 1],[-1 1])'];  display2 = ['plot([1 2 2 1 1],[-1 -1 1 1 -1])'];  tipo = Values{2};  switch tipo   case 'on',  set_param(object,'MaskDisplay',display1);   case 'off', set_param(object,'MaskDisplay',display2);  end case 'Oxl'  tipo = Values{2};  switch tipo   case 'on',  a([3, 4]) = {'off','off'};   case 'off', a([3, 4]) = {'on' ,'on'};  end case 'Pss'  tipo = str2num(Values{1});  switch tipo   case 1, a([2 5 6 7 8 9 10]) = {'off','on', 'off','off','off','off','off'};   case 2, a([2 5 6 7 8 9 10]) = {'on' ,'off','on', 'off','off','off','off'};   case 3, a([2 5 6 7 8 9 10]) = {'on' ,'off','on', 'off','off','off','off'};   case 4, a([2 5 6 7 8 9 10]) = {'on' ,'off','on', 'on', 'on', 'on' ,'on'};   case 5, a([2 5 6 7 8 9 10]) = {'on' ,'off','on', 'on', 'on', 'on' ,'on'};  end case 'Svc'  display1 = ['plot([0.5 0.5],[1 0.8],[0.5 0.5],[0 0.2],[0 1 1 0 0],[0.8 0.8 0.2 0.2 0.8]),', ...              ' plot([-0.1 1.1],[0 0],[0.1 0.9],[-0.05 -0.05],[0.3 0.7],[-0.1 -0.1]), color(''green'')', ...              ' plot([-0.4 -0.4 1.4 1.4],[0.1 0.3 0.7 0.9])'];  display2 = ['plot([0.5 0.5],[0 0.2],[-0.5 1.5],[0 0],[3 5],[-0.9 -0.9],', ...              '[0.5 0.5],[-1.6 -1.8],[4 4],[0.2 -0.8],[1.9 1.9],[0.2 0.4],[1.9 1.9],[-1.8 -2],', ...              '[0.5 4],[0.2 0.2],[0.5 0.5],[-0.65 -0.85],[4 4],[-1.8 -0.9],[0.5 4],[-1.8 -1.8],', ...              '[1.3 2.5],[-2 -2],[1.5 2.3],[-2.05 -2.05],[1.7 2.1],[-2.1 -2.1]), ', ...                'plot(4+yc,-0.7+0.1*xc,', ...              '0.5-0.5*xi,-1.15+0.175+0.125*yi,', ...              '0.5-0.5*xi,-1.15-0.325+0.125*yi,', ...              '0.5-0.5*xi,-1.15-0.075+0.125*yi), ', ...              'color(''magenta''), plot([-0.5 1.5 1.5 -0.5 -0.5],[-0.65 -0.65 0 0 -0.65],', ...              '[0 -0.5 -1 0],[-0.2 -0.45 -0.2 -0.2],[-0.7 -1.2],[-0.35 -0.35],[-1 0],[-0.45 -0.45],', ...              '[1 1.5 2 1],[-0.45 -0.2 -0.45 -0.45],[2 1],[-0.2 -0.2],[1.7 2.2],[-0.3 -0.3])'];  tipo   = str2num(Values{2});  idx1 = [3 4 6];  idx2 = [7 8 9];  switch tipo   case 1    b(idx1) = {'Regulator Time Constant Tr [s]'; ...               'Regulator Gain Kr [p.u./p.u.]'; ...               'B_max and B_min [p.u.  p.u.]'};    a(idx2) = {'off'; 'off'; 'off'};    set_param(object,'MaskDisplay',display1);   case 2    b(idx1) = {'Regulator Time Constant T2 [s]'; ...               'Regulator Gain K [p.u./p.u.]'; ...               'Alpha_max and Alpha_min [rad rad]'};    a(idx2) = {'on';  'on';  'on'};    set_param(object,'MaskDisplay',display2);  end case 'Tcsc'  display1 = ['plot([1 0.8],[0.5 0.5],[0 0.2],[0.5 0.5],[0.8 0.8 0.2 0.2 0.8],[0 1 1 0 0]), ' ...              'color(''green''), plot([0.1 0.3 0.7 0.9],[-0.4 -0.4 1.4 1.4])'];  display2 = ['plot([-1.6 -1.8 -1.8],[0.5 0.5 4],[0.2 0.2],[0.5 4],[-0.9 -0.9],[3 5],', ...              '[0 0.2],[0.5 0.5],[-0.65 -0.85],[0.5 0.5],[-1.8 -0.9],[4 4],', ...              '[0.2 -0.8],[4 4],[0.2 0.4],[1.9 1.9],[-1.8 -2],[1.9 1.9]), ', ...              'plot(-0.7+0.1*xc,4+yc,', ...              '-1.15+0.175+0.125*yi,0.5+0.5*xi,', ...              '-1.15-0.325+0.125*yi,0.5+0.5*xi,', ...              '-1.15-0.075+0.125*yi,0.5+0.5*xi), ', ...              'color(''magenta''), plot([-0.65 -0.65 0 0 -0.65],[-0.5 1.5 1.5 -0.5 -0.5],', ...              '[-0.2 -0.45 -0.2 -0.2],[0 -0.5 -1 0],[-0.35 -0.35],[-0.7 -1.2],[-0.45 -0.45],[-1 0],', ...              '[-0.45 -0.2 -0.45 -0.45],[1 1.5 2 1],[-0.2 -0.2],[2 1],[-0.3 -0.3],[1.7 2.2])'];  tipo = Values{2};  switch tipo   case 'Xc'    b{7} = 'Xc_max and Xc_min [p.u.  p.u.]';    a{9} = 'off';    set_param(object,'MaskDisplay',display1);   case 'Alpha'    b{7} = 'Alpha_max and Alpha_min [rad  rad]';    a{9} = 'on';    set_param(object,'MaskDisplay',display2);  end  tipo = Values{3};  switch tipo   case 'constant_power_flow'    a{8} = 'on';   otherwise    a{8} = 'off';  end  case 'Exc'  tipo   = str2num(Values{1});  idx1 = [4 5 6 7];  idx2 = [7 8 9 11];  switch tipo   case 1    b(idx1) = {'Regulator Gain m0 [p.u./p.u.]'; ....               'First Regulator Pole T1 [s]'; ...               'First Regulator Zero T2 [s]'; ...               'Second Regulator Pole T3 [s]'};    a(idx2) = {'on'; 'on'; 'on'; 'on'};   case 2    b(idx1) = {'Amplifier Gain Ka [p.u./p.u.]'; ...               'Amplifier Time Constant Ta [s]'; ...               'Stabilizer Gain Kf [p.u./p.u.]'; ...               'Stabilizer Time Tf [s]'};    a(idx2) = {'on'; 'off'; 'on'; 'on'};   case 3    b(idx1) = {'Regulator Gain [p.u./p.u.]'; ...               'Regulator Pole T2 [s]'; ...               'Regulator Zero T1 [s]'; ...               'Second Regulator Pole T3 [s]'};        a(idx2) = {'off'; 'off'; 'off'; 'off'};  end case 'Tg'  tipo = str2num(Values{1});  idx1 = [6 7];  idx2 = [8 9 10];  switch tipo   case 1,    b(idx1) = {'Governor Time Constant Ts [s]'; ...               'Servo Time Constant Ts [s]'};    a(idx2) = {'on';  'on';  'on'};   case 2,    b(idx1) = {'Pole Time Constant Ts [s]'; ...               'Zero Time Constant Ts [s]'};    a(idx2) = {'off'; 'off'; 'off'};  end case 'PQ'  tipo = Values{4};  switch tipo   case 'on', a{3} = 'on';   case 'off', a{3} = 'off';  end case 'PQgen'  tipo = Values{4};  switch tipo   case 'on', a{3} = 'on';   case 'off', a{3} = 'off';  end case 'Ltc'  display1 = ['plot(x,y,x+1.4,y,[2.4 2.8],[0 0],[3.1 3.5],[0 0],[-1 -2],[0 0],0,2), color(''green''), plot([2.95 2.95],', ...              '[-0.15 -2],[2.95 -0.8],[-2 -2],[-0.8 -0.8],[-2 -1.2], [-0.8 0.7],[-1.2 1.2],', ...              '[0.5 0.7],[1.1 1.2],[0.7 0.7], [1.0 1.2],[2.8 3.1 3.1 2.8 2.8],[-0.15 -0.15 0.15 0.15 -0.15]);'];    display2 = ['plot(x,y,x+1.4,y,[2.4 3.5],[0 0],[-1 -2],[0 0],0,2-4*rot), color(''green''), plot([0.8 0.8],3*rot-[1.3 1.7],', ...              '[0.65 0.95 0.95 0.65 0.65],[3.4*rot-1.7 3.4*rot-1.7 4*rot-2 4*rot-2 3.4*rot-1.7],', ...              '[0.8 -0.8],[2.4*rot-1.2 1.3-2.6*rot],[-0.6 -0.8],[1.1-2.2*rot 1.2-2.4*rot],[-0.8 -0.8], [1-2*rot 1.2-2.4*rot]);'];  inputs = get_param(object,'Ports');  inputs = inputs(3);  tipo = str2num(Values{3});  switch tipo   case 1    b{7} = 'Reference Voltage Vref [p.u.]';    set_param(object,'MaskDisplay',display1);    if inputs, delete_block([object,'/in_2']); end   case 2    b{7} = 'Reference Reactive Power Qref [p.u.]';    set_param(object,'MaskDisplay',display1);    if inputs, delete_block([object,'/in_2']); end   case 3    b{7} = 'Remote Reference Voltage Vref [p.u.]';    set_param(object,'MaskDisplay',display2);    if ~inputs      add_block('built-in/EnablePort',[object,'/in_2'])      set_param([object,'/in_2'],'position',[65, 155, 85, 175])    end  end   case 'Sssc'    tipo = Values{2};  switch tipo   case 'constant_power'     a([3 7]) = {'on'; 'on'};   otherwise     a([3 7]) = {'off'; 'off'};      end  case 'Shunt'  values = str2num(Values{2});  names = get_param(object,'MaskNames');  if strcmp(names{2},'p6q')    tipo = values;  else    return  end  if tipo == 0    fm_choice('Shunt reactance should not be zero!',2)    return  end  ground = ['[0 0],[-0.4 0.4],[0.075 0.075],[-0.25 0.25],[0.15' ...	    ' 0.15],[-0.1 0.1]'];  if tipo < 0 % inductance    lx  = ['-[0 23 23 24 28 34 40 47 52 55 56 54 51 51 47 46 ', ...	   '48 51 57 64 70 75 79 79 77 74 74 70 69 71 75 80 87 ', ...	   '93 99 102 103 101 97 97 94 93 94 98 104 110 117 ', ...	   '122 125 126 126 150]/150'];    ly  = ['[0 0 1 11 19 24 25 23 17 8 -2 -12 -18 -18 -9 1 11 ', ...	   '19 24 25 23 17 8 -2 -12 -18 -18 -9 1 11 19 24 25 ', ...	   '23 17 8 -2 -12 -18 -18 -9 1 11 19 24 25 23 17 8 0 0 0]/45'];    display1 = ['plot(',lx,',',ly,',',ground,',0,-0.5)'];  elseif tipo > 0 % conductance    cx1 = '-[0 60 60 55 53 55 60 60 55 53]/150';    cy1 = '[0 0 8 16 25 16 8 -8 -16 -25]/50';    cx2 = '-[80 80 80 150]/150';    cy2 = '[25 -25 0 0]/50';    display1 = ['plot(',cx1,',',cy1,',',cx2,',',cy2,',',ground,')'];  end  set_param(object,'MaskDisplay',display1);endset_param(object,'MaskEnables',a);set_param(object,'MaskPrompts',b);

⌨️ 快捷键说明

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