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
%%% Forma��o da matriz de Admit�ncia da Rede (Y_bus) %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OBS.: fazer uma rotina que monte a matriz Y_bus de modo geral para
% qualquer sistema el�trico a partir dos dados contidos em DBAR e DLIN
Y_bus = zeros(Num_Barras, Num_Barras)
for (k=1:Num_Linhas)
Y_bus( DLIN(k,1) , DLIN(k,2) ) = - 1/ ( (DLIN(k,3))/100 + i * (DLIN(k,4))/100 ) ;
Y_bus( DLIN(k,2) , DLIN(k,1) ) = - 1/ ( (DLIN(k,3))/100 + i * (DLIN(k,4))/100 ) ;
Y_bus( DLIN(k,1) , DLIN(k,1) ) = Y_bus( DLIN(k,1) , DLIN(k,1) ) + 1/ ( (DLIN(k,3))/100 + i * (DLIN(k,4))/100 ) + (0+ i * ( DLIN(k,5)/200 ) ) ;
Y_bus( DLIN(k,2) , DLIN(k,2) ) = Y_bus( DLIN(k,2) , DLIN(k,2) ) + 1/ ( (DLIN(k,3))/100 + i * (DLIN(k,4))/100 ) + (0+ i * ( DLIN(k,5)/200 ) ) ;
end
Y_bus = Y_bus
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%% Solucao Gauss-Seidel %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
E = zeros(Num_Barras, 1);
%%%%%%%%%%%% Inicia vetor de Tensoes Complexas %%%%%%%%%%%%%%%%%%%%%%
for (k=1:Num_Barras)
E(k,1) = DBAR(k,3) + i * (DBAR(k,4));
end
max_erro = 1.00
somatorio = 0.0;
iteracao = 0;
while abs(max_erro) > 0.01
iteracao = iteracao + 1
E_temp = E;
for (k=1:Num_Barras)
if k ~= 1
for (n=1: Num_Barras)
if n~= k
somatorio = somatorio + Y_bus(k,n) * E(n,1);
end
end
E(k,1) = ( 1/Y_bus(k,k) )*(( -(DBAR(k,7)/100) + i*(DBAR(k,8)/100) ) / ( conj( E(k,1) ) ) - somatorio ) ;
end
somatorio = 0;
end
delta_E = E - E_temp
delta_E_abs = abs(delta_E)
max_erro = max(delta_E_abs)
end
E= E