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

📄 fm_nrlf.m

📁 这是一个很适合研究和学习用的电力系统仿真软件
💻 M
字号:
function    conv = fm_nrlf(iter_max, tol, Show)
% FM_NRLF solve power flow with locked ste variables
%
% CONV = FM_NRLF(ITERMAX,TOL)
%       ITERMAX = max number of iterations
%       TOL = convergence tolerance
%       CONV = 1 if convergence reached, 0 otherwise
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Update:    11-Sep-2003
%Version:   1.1.0
%
%E-mail:    fmilano@thunderbox.uwaterloo.ca
%Web-site:  http://thunderbox.uwaterloo.ca/~fmilano
%
% Copyright (C) 2002-2006 Federico Milano

global DAE Bus Line PV SW Settings

conv = 1;
iteration = 0;
inc = ones(2*Bus.n,1);
rbus = Settings.refbus;

% initialize bus voltages
DAE.V = 1.05*ones(Bus.n,1);
DAE.V(PV.bus) = getvg(PV,'all');
DAE.V(SW.bus) = getvg(SW,'all');
y2 = [DAE.a; DAE.V];

% Newton-Raphson routine with locked state variables
while max(abs(inc)) > tol & iteration < iter_max

  if isempty(Line.Y)
    DAE.gp = zeros(Bus.n,1);
    DAE.gq = zeros(Bus.n,1);
    DAE.J11 = sparse(Bus.n,Bus.n);
    DAE.J21 = sparse(Bus.n,Bus.n);
    DAE.J12 = sparse(Bus.n,Bus.n);
    DAE.J22 = sparse(Bus.n,Bus.n);
  end

  fm_call('n')  % call algebraic functions

  %DAE.Jlfv(rbus,:) = 0;
  %DAE.Jlfv(:,rbus) = 0;
  %DAE.Jlfv(rbus,rbus) = 1;
  %DAE.g(rbus) = 0;

  % check for islanded buses
  if ~isempty(Bus.island)
    k = Bus.island;
    DAE.Jlfv(k,:) = 0;
    DAE.Jlfv(:,k) = 0;
    DAE.Jlfv(:,k+Bus.n) = 0;
    DAE.Jlfv(k+Bus.n,:) = 0;
    DAE.Jlfv(k,k) = speye(length(k));
    DAE.Jlfv(k+Bus.n,k+Bus.n) = speye(length(k));
    DAE.g(k) = 0;
    DAE.g(k+Bus.n) = 0;
    DAE.V(k) = 1e-6;
    DAE.a(k) = 0;
  end

  inc = -DAE.Jlfv\DAE.g;
  y2 = y2 + inc;
  DAE.a = y2(1:Bus.n);
  DAE.V = y2(Bus.n+1:2*Bus.n);
  iteration = iteration + 1;
end

DAE.a(find(DAE.V <= 1e-6)) = 0;

% unwrap voltage phases for very low voltages
idx = find(DAE.V < 1e-4);
if ~isempty(idx), DAE.a = rem(DAE.a,2*pi); end

% message of end of operations
if iteration >= iter_max
  fm_disp('Solution of algebraic equations failed.')
  conv = 0;
elseif Show
  fm_disp(['Solution of algebraic equations completed in ', ...
	   num2str(iteration),' iterations.'])
end

% update time derivatives of state variables
fm_call('i');

⌨️ 快捷键说明

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