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

📄 fm_base.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
字号:
function fm_base
%FM_BASE report component parameters to system bases
%
%FM_BASE
%
%see also FM_SPF
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Version:   1.0.0
%
%E-mail:    fmilano@thunderbox.uwaterloo.ca
%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano
%
% Copyright (C) 2002-2006 Federico Milano

fm_var

if Area.n
  Area.con(:,4) = Area.con(:,3).*Area.con(:,4)/Settings.mva;
  Area.con(:,5) = Area.con(:,3).*Area.con(:,5)/Settings.mva;
end

if Line.n

  % take into account that open breakers have varied line parameters!!
  if Breaker.n
    idx = find(~Breaker.con(:,6));
    Line.con(Breaker.line(idx),[8 9 10 11 12]) = ...
        Breaker.con(idx,[9 10 11 12 13]);
  end

  % look for transformers (kt ~= 0)
  idx = find(Line.con(:,7));
  kt = Line.con(idx,7);
  VL1 = Line.con(:,4);
  % set zero length for transformers
  Line.con(idx,6) = zeros(length(idx),1);
  V1 = Bus.con(Line.from,2);
  V2 = Bus.con(Line.to,2);
  KT = V1(idx)./V2(idx);

  % check consistency of voltage bases
  if ~isempty(kt)
    corr = abs(kt-KT)./KT;
    idx1 = find(corr > 0.1);
    for i = 1:length(idx1)
      k1 = Varname.bus{Line.from(idx(idx1(i)))};
      k2 = Varname.bus{Line.to(idx(idx1(i)))};
      fm_disp(['Tap ratio of transformer #',num2str(idx(idx1(i))), ...
	       ' from bus <', k1, '> to bus <', k2, ...
	       '> differs more than 10% from the bases defined at', ...
	       ' connected buses.'])
    end
    % adjust tap ratio if voltage bases do not match
    idx_m = find(Line.con(idx,11) == 0);
    Line.con(idx(idx_m),11) = 1;
    Line.con(idx,11) = Line.con(idx,11).*kt./KT;
  end
  idx2 = find(abs(VL1-V1)./V1 > 0.1);
  for i = 1:length(idx2)
    k1 = Varname.bus{Line.from(idx2(i))};
    k2 = Varname.bus{Line.to(idx2(i))};
    fm_disp(['Voltage of Line #',num2str(idx2(i)), ...
	       ' from bus <', k1,'> to bus <', k2, ...
	     '> differs more than 10% from the base defined at', ...
	     ' the connected bus <', k1,'>'])
  end

  % Voltage rates
  Vb2new = V1.*V1;
  Vb2old = VL1.*VL1;

  % report line parameters to system base [Sb]
  Line.con(:,8)  = Vb2old.*Line.con(:,8)./Line.con(:,3)./Vb2new*Settings.mva;
  Line.con(:,9)  = Vb2old.*Line.con(:,9)./Line.con(:,3)./Vb2new*Settings.mva;
  Line.con(:,10) = Vb2new.*Line.con(:,10).*Line.con(:,3)./Vb2old/Settings.mva;

  % report line limits to system bases
  Line.con(:,13) = Line.con(:,13).*Line.con(:,3).*V1./VL1/Settings.mva;
  Line.con(:,14) = Line.con(:,14).*Line.con(:,3)/Settings.mva;
  Line.con(:,15) = Line.con(:,15).*Line.con(:,3)/Settings.mva;

end

SW = base(SW);
PV = base(PV);
PQ = base(PQ);
Demand = base(Demand);
Supply = base(Supply);
Tg   = base(Tg);
Svc  = base(Svc);
Statcom = base(Statcom);
Tcsc = base(Tcsc);
Sssc = base(Sssc);
Upfc = base(Upfc);

if ~isempty(Shunt.con)
  fm_errv(Shunt.con(:,3),'Shunt',Shunt.bus);
  Vb2new = Bus.con(Shunt.bus,2).*Bus.con(Shunt.bus,2);
  Vb2old = Shunt.con(:,3).*Shunt.con(:,3);
  Shunt.con(:,5) = Shunt.con(:,2).*Vb2new.*Shunt.con(:,5)./Vb2old/Settings.mva;
  Shunt.con(:,6) = Shunt.con(:,2).*Vb2new.*Shunt.con(:,6)./Vb2old/Settings.mva;
  % update shunt values
  Shunt.g = sparse(Shunt.bus,1,Shunt.con(:,5),Bus.n,1);
  Shunt.b = sparse(Shunt.bus,1,Shunt.con(:,6),Bus.n,1);
end

if Breaker.n
  % update line data which are stored in the Breaker data
  Breaker.con(:,[9 10 11 12 13]) = Line.con(Breaker.line,[8 9 10 11 12]);
  idx = find(~Breaker.con(:,6));
  % change status of the line in case breakers are open
  if ~isempty(idx) & ~isempty(Line.con)
    Line.con(Breaker.line(idx),[8 9 10 11 12]) = ...
        [zeros(length(idx),1), 1e6*ones(length(idx),1), ...
         zeros(length(idx),1), ones(length(idx),1), ...
         zeros(length(idx),1)];
  end
end

if Pl.n
  Pl.con(:,5) = Pl.con(:,5).*Pl.con(:,2)/Settings.mva;
  Pl.con(:,6) = Pl.con(:,6).*Pl.con(:,2)/Settings.mva;
  Pl.con(:,7) = Pl.con(:,7).*Pl.con(:,2)/Settings.mva;
  Pl.con(:,8) = Pl.con(:,8).*Pl.con(:,2)/Settings.mva;
  Pl.con(:,9) = Pl.con(:,9).*Pl.con(:,2)/Settings.mva;
  Pl.con(:,10) = Pl.con(:,10).*Pl.con(:,2)/Settings.mva;
end

if Mn.n
  Mn.con(:,4) = Mn.con(:,4).*Mn.con(:,2)/Settings.mva;
  Mn.con(:,5) = Mn.con(:,5).*Mn.con(:,2)/Settings.mva;
end

if Mot.n
  errV(Mot.con(:,3),'Induction Motor',Mot.bus);
  Vb2new = Bus.con(Mot.bus,2).*Bus.con(Mot.bus,2);
  Vb2old = Mot.con(:,3).*Mot.con(:,3);
  Mot.con(:,[7 8 9 10 11 12 13]) = Mot.con(:,[7 8 9 10 11 12 13])*Settings.mva;
  Mot.con(:,7)  = Vb2old.*Mot.con(:,7)./Mot.con(:,2)./Vb2new;
  Mot.con(:,8)  = Vb2old.*Mot.con(:,8)./Mot.con(:,2)./Vb2new;
  Mot.con(:,9)  = Vb2old.*Mot.con(:,9)./Mot.con(:,2)./Vb2new;
  Mot.con(:,10) = Vb2old.*Mot.con(:,10)./Mot.con(:,2)./Vb2new;
  Mot.con(:,11) = Vb2old.*Mot.con(:,11)./Mot.con(:,2)./Vb2new;
  Mot.con(:,12) = Vb2old.*Mot.con(:,12)./Mot.con(:,2)./Vb2new;
  Mot.con(:,13) = Vb2old.*Mot.con(:,13)./Mot.con(:,2)./Vb2new;
  Mot.con(:,14) = Mot.con(:,14).*Mot.con(:,2)/Settings.mva;
  Mot.con(:,15) = Mot.con(:,15).*Mot.con(:,2)/Settings.mva;
  Mot.con(:,16) = Mot.con(:,16).*Mot.con(:,2)/Settings.mva;
  Mot.con(:,17) = Mot.con(:,17).*Mot.con(:,2)/Settings.mva;
  % update Mot.dat matrix.
  fm_mot(0);
end

if Tap.n
  Tap.con(:,9) = Tap.con(:,9)./Tap.con(:,2)*Settings.mva;
  Tap.con(:,10) = Tap.con(:,10)./Tap.con(:,2)*Settings.mva;
end

if Syn.n
  errV(Syn.con(:,3),'Synchronous Machine',Syn.bus);
  Vb2new = Bus.con(Syn.bus,2).*Bus.con(Syn.bus,2);
  Vb2old = Syn.con(:,3).*Syn.con(:,3);
  i = [6:10, 13:15];
  for h = 1:length(i)
    Syn.con(:,i(h))= (Vb2old.*Syn.con(:,i(h))./Syn.con(:,2)./Vb2new) ...
        *Settings.mva;
  end
  Syn.con(:,18) = Syn.con(:,18).*Syn.con(:,2)/Settings.mva;
  Syn.con(:,19) = Settings.freq*Settings.freq*Syn.con(:,2).* ...
      Syn.con(:,19)./Syn.con(:,4)./Syn.con(:,4)/Settings.mva;
end

if Cswt.n
  Cswt.con(:,6) = Cswt.con(:,6)./Cswt.con(:,3)*Settings.mva;
  Cswt.con(:,7) = Cswt.con(:,7)./Cswt.con(:,3)*Settings.mva;
  Cswt.con(:,8) = Cswt.con(:,8)./Cswt.con(:,3)*Settings.mva;
  Cswt.con(:,9) = Cswt.con(:,9)./Cswt.con(:,3)*Settings.mva;
  Cswt.con(:,10) = Cswt.con(:,10)./Cswt.con(:,3)*Settings.mva;
  Cswt.con(:,11) = Cswt.con(:,11).*Cswt.con(:,3)/Settings.mva;
  Cswt.con(:,12) = Cswt.con(:,12).*Cswt.con(:,3)/Settings.mva;
  Cswt.con(:,13) = Cswt.con(:,13).*Cswt.con(:,3)/Settings.mva;
end

if Dfig.n
  Dfig.con(:,6) = Dfig.con(:,6)./Dfig.con(:,3)*Settings.mva;
  Dfig.con(:,7) = Dfig.con(:,7)./Dfig.con(:,3)*Settings.mva;
  Dfig.con(:,8) = Dfig.con(:,8)./Dfig.con(:,3)*Settings.mva;
  Dfig.con(:,9) = Dfig.con(:,9)./Dfig.con(:,3)*Settings.mva;
  Dfig.con(:,10) = Dfig.con(:,10)./Dfig.con(:,3)*Settings.mva;
  Dfig.con(:,11) = Dfig.con(:,11).*Dfig.con(:,3)/Settings.mva;
  Dfig.con(:,20) = Dfig.con(:,20).*Dfig.con(:,3)/Settings.mva;
  Dfig.con(:,21) = Dfig.con(:,21).*Dfig.con(:,3)/Settings.mva;
  Dfig.con(:,22) = Dfig.con(:,22).*Dfig.con(:,3)/Settings.mva;
  Dfig.con(:,23) = Dfig.con(:,23).*Dfig.con(:,3)/Settings.mva;
end

if Fault.n
  Fault.con(:,7) = Fault.con(:,7)./Fault.con(:,2)*Settings.mva;
  Fault.con(:,8) = Fault.con(:,8)./Fault.con(:,2)*Settings.mva;
end

if Rmpg.n
  Rmpg.con(:,3) = Rmpg.con(:,3).*Rmpg.con(:,2)/Settings.mva;
  Rmpg.con(:,4) = Rmpg.con(:,4).*Rmpg.con(:,2)/Settings.mva;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function errV(Vold,msg,busidx)

global Varname Bus

Vbus = Bus.con(busidx,2);
Verr = abs((Vbus-Vold)./Vbus);
idx = find(Verr > 0.1);
for iii = 1:length(idx)
  kkk = idx(iii);
  fm_disp(['Voltage rate of ',msg,' #', num2str(kkk), ...
           ' at Bus ',Varname.bus{busidx(kkk)}, ...
           ' differs more than 10% from Bus voltage rate'],2)
end

⌨️ 快捷键说明

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