Está en la página 1de 15

% Date valori de baza

N=5;

Sb=100;

Ub1=110;

Ub2=20;

Zb1=Ub1^2/Sb;

Zb2=Ub2^2/Sb;

C1=1+((-1)^N)*0.01*N;

C2=1-((-1)^N)*0.01*N;

Nr_nod=4;

Eps=0.0001;

% Date linii electrice

% ik R X G B Imax UM Stare

Date_linii = [2 4 0.12*round(60*C1) 0.396*round(60*C1) 0 2.872*10^(-6)*round(60*C1) 420 1 1;

2 4 0.12*round(60*C1) 0.396*round(60*C1) 0 2.872*10^(-6)*round(60*C1) 420 1 1;

2 3 0.16*round(50*C2) 0.410*round(50*C2) 0 2.728*10^(-6)*round(50*C2) 420 1 1;

3 4 0.12*round(55*C2) 0.396*round(55*C2) 0 2.872*10^(-6)*round(55*C2) 420 1 1;

3 4 0.12*round(55*C2) 0.396*round(55*C2) 0 2.872*10^(-6)*round(55*C2) 420 1 1];

% Date transformatoare

% i k Snt Unf Unr0 DP0 I0 DPsc Usc Plot Dup Tip Stare

Date_Trafo = [1 3 63 22 110 60 0.9 260 12 0 1.78 2 1;

1 3 63 22 110 60 0.9 260 12 0 1.78 2 1];

% Generare Tabel Cuadripoli

[Nr_linii, col] = size(Date_linii);

[Nr_trafo, col] = size(Date_Trafo);


Nr_lat = Nr_linii + Nr_trafo;

Tab_Cuad = zeros(Nr_lat, 7);

% Completare Tab_Cuad linii

for l=1:Nr_linii

Tab_Cuad(l,1) = Date_linii(l,1);

Tab_Cuad(l,2) = Date_linii(l,2);

yik = 1/(Date_linii(l,3)+j*Date_linii(l,4));

yik0 = (Date_linii(l,5)+Date_linii(l,6))/2;

yki0 = yik0;

if Date_linii(l,8)==1

yik = yik*Zb1;

yik0 = yik0*Zb1;

yki0 = yki0*Zb1;

end

Tab_Cuad(l,3) = yik;

Tab_Cuad(l,4) = yik0;

Tab_Cuad(l,5) = yki0;

Tab_Cuad(l,6) = 1;

Tab_Cuad(l,7) = Date_linii(l,9);

end

% Completare Tab_Cuad Trafo

for t=1:Nr_trafo

RT = Date_Trafo(t,8)*(Date_Trafo(t,4)^2)/(Date_Trafo(t,3)^2)*10^(-3);

ZT = Date_Trafo(t,9)/100*(Date_Trafo(t,4)^2)/Date_Trafo(t,3);

XT = sqrt(ZT^2-RT^2);
GT0 = Date_Trafo(t,6)/(Date_Trafo(t,4)^2)*10^(-3);

YT0 = (Date_Trafo(t,7)/100)*Date_Trafo(t,3)/(Date_Trafo(t,4)^2);

BT0 = sqrt(YT0^2-GT0^2);

if Date_Trafo(t,12) == 1

yik = 1/(RT+j*XT)*Zb2;

yik0 = (GT0-j*BT0)*Zb2;

yki0 = 0;

Nik = Date_Trafo(t,4)/(Date_Trafo(t,5)*(1+Date_Trafo(t,10)*Date_Trafo(t,11)/100))*Ub1/Ub2;

end

if Date_Trafo(t,12) == 2

yik = 1/(RT+j*XT)*Zb2;

yik0 = 0;

yki0 = (GT0-j*BT0)*Zb2;

Nik = Date_Trafo(t,4)/(Date_Trafo(t,5)*(1+Date_Trafo(t,10)*Date_Trafo(t,11)/100))*Ub1/Ub2;

end

if Date_Trafo(t,12) == 3

yik = 1/(RT+j*XT)*Zb2;

yik0 = (GT0-j*BT0)*Zb2/2;

yki0 = yik0;

Nik = Date_Trafo(t,4)/(Date_Trafo(t,5)*(1+Date_Trafo(t,10)*Date_Trafo(t,11)/100))*Ub1/Ub2;

end

Tab_Cuad(Nr_linii+t,1) = Date_Trafo(t,1);

Tab_Cuad(Nr_linii+t,2) = Date_Trafo(t,2);

Tab_Cuad(Nr_linii+t,3) = yik;

Tab_Cuad(Nr_linii+t,4) = yik0;
Tab_Cuad(Nr_linii+t,5) = yki0;

Tab_Cuad(Nr_linii+t,6) = Nik;

Tab_Cuad(Nr_linii+t,7) = Date_Trafo(t,13);

end

% Formare Ynn

Ynn = zeros(Nr_nod,Nr_nod);

for p=1:Nr_lat

if Tab_Cuad(p,7) == 1

i = Tab_Cuad(p,1);

k = Tab_Cuad(p,2);

yik = Tab_Cuad(p,3);

yik0 = Tab_Cuad(p,4);

yki0 = Tab_Cuad(p,5);

Nik = Tab_Cuad(p,6);

Ynn(i,i)=Ynn(i,i)+yik+yik0;

Ynn(i,k)=Ynn(i,k)-Nik*yik;

Ynn(k,i)=Ynn(k,i)-Nik*yik;

Ynn(k,k)=Ynn(k,k)+Nik^2*(yik+yki0);

end

end

Ynn

% Tratarea regimului permanent cu metoda NR

% Completarea tabelei Nod

% Nodul 1 CON_MT: Nod PQ

Tip_Nod(1,1)=0;
U(1,1)=1.000;

Teta(1,1)=0;

Un(1,1)=U(1,1);

Pg(1,1)=0;

Qg(1,1)=0;

Pc(1,1)=round(100*C1)/Sb;

Qc(1,1)=round(55*C1)/Sb;

Pimp(1,1)=Pg(1,1)-Pc(1,1);

Qimp(1,1)=Qg(1,1)-Qc(1,1);

Pcalc(1,1)=0;

Qcalc(1,1)=0;

Uimp(1,1)=0;

Qmin(1,1)=0;

Qmax(1,1)=0;

Stare_C(1,1)=0;

Index_PQ(1,1)=1;

% Nodul 2 CET_IT: Nod PU

Tip_Nod(2,1)=1;

U(2,1)=1.020;

Teta(2,1)=0;

Un(2,1)=U(1,1);

Pg(2,1)=round(90*C1)/Sb;

Qg(2,1)=0;

Pc(2,1)=round(15*C1)/Sb;

Qc(2,1)=round(8*C1)/Sb;
Pimp(2,1)=Pg(2,1)-Pc(2,1);

Qimp(2,1)=0;

Pcalc(2,1)=0;

Qcalc(2,1)=0;

Uimp(2,1)=1.020;

Qmin(2,1)=0;

Qmax(2,1)=90/Sb;

Stare_C(2,1)=0;

Index_PQ(2,1)=0;

% Nodul 3 CON_IT: Nod PQ

Tip_Nod(3,1)=0;

U(3,1)=1.000;

Teta(3,1)=0;

Un(3,1)=U(1,1);

Pg(3,1)=0;

Qg(3,1)=0;

Pc(3,1)=0;

Qc(3,1)=0;

Pimp(3,1)=Pg(3,1)-Pc(3,1);

Qimp(3,1)=Qg(3,1)-Qc(3,1);

Pcalc(3,1)=0;

Qcalc(3,1)=0;

Uimp(3,1)=0;

Qmin(3,1)=0;

Qmax(3,1)=0;
Stare_C(3,1)=0;

Index_PQ(3,1)=2;

% Nodul 4 SEN: Nod echilibru

Tip_Nod(4,1)=0;

U(4,1)=1.000;

Teta(4,1)=0;

Un(4,1)=U(1,1);

Pg(4,1)=0;

Qg(4,1)=0;

Pc(4,1)=0;

Qc(4,1)=0;

Pimp(4,1)=0;

Qimp(4,1)=0;

Pcalc(4,1)=0;

Qcalc(4,1)=0;

Uimp(4,1)=1.000;

Qmin(4,1)=0;

Qmax(4,1)=0;

Stare_C(4,1)=0;

Index_PQ(4,1)=0;

% Stabileste valorile initiale pentru indexul iteratiei si dimensiunea Jac

Iter=0;

Nr_Nod=4;

Nr_Nod_PQ=2;

Dim_Jac=Nr_Nod+Nr_Nod_PQ-1;
Jac=zeros(Dim_Jac, Dim_Jac);

% Calcularea puterilor nodale

while 1

In=conj(Ynn*Un);

Sn=Un.*In;

Pcalc=real(Sn);

Qcalc=imag(Sn);

% Tratarea nodurilor generatoare

if Iter > 2

for i=1:Nr_nod-1

if ((Tip_Nod(i,1)==1)&&(Stare_C(i,1)==0))

Qi=Qcalc(i,1);

if Qi < Qmin(i)

Qimp(i,1)=Qmin(i);

Stare_C(i,1)=-1;

end

if Qi > Qmax(i)

Qimp(i,1)=Qmax(i);

Stare_C(i,1)=1;

end

end

end

end

% Calcularea abaterilor DP si DQ

Dpq(1:Nr_Nod-1,1)=Pimp(1:Nr_nod-1,1)-Pcalc(1:Nr_nod-1,1);
Nr_Nod_PQ=0;

for i=1:Nr_nod-1

if (Tip_Nod(i,1)==0)

Nr_Nod_PQ=Nr_Nod_PQ+1;

Dpq(Nr_Nod-1+Nr_Nod_PQ,1)=Qimp(i,1)-Qcalc(i,1);

Index_PQ(i,1)=Nr_Nod_PQ;

end

if (Tip_Nod(i,1)==1)&&(Stare_C(i,1)~=0)

Nr_Nod_PQ=Nr_Nod_PQ+1;

Dpq(Nr_Nod-1+Nr_Nod_PQ,1)=Qimp(i,1)-Qcalc(i,1);

Index_PQ(i,1)=Nr_Nod_PQ;

end

if (Tip_Nod(i,1)==1)&&(Stare_C(i,1)==0)

Index_PQ(i,1)=0;

end

end

Dpq_Max=max(abs(Dpq));

% Test de convergenta

if Iter > 2

if (Dpq_Max<=Eps)

Temp=sprintf('Regimul a convers in %i iteratii', Iter);

disp(Temp);

break;

end

if Iter > 10
disp('Regim divergent');

break;

end

end

Iter=Iter+1;

% Formarea matricei Jac

% Initializarea matricei Jac

clear Jac;

Jac=zeros(Nr_Nod-1+Nr_Nod_PQ,Nr_Nod-1+Nr_Nod_PQ);

for i=1:Nr_Nod-1

for k=1:Nr_Nod-1

if i==k

Gii=real(Ynn(i,1));

Bii=imag(Ynn(i,1));

Ui=U(i,1);

Pi=Pcalc(i,1);

Qi=Qcalc(i,1);

Index_Pi=i;

Index_Ti=Index_Pi;

if Index_PQ(i)~=0

Index_Qi=Nr_Nod-1+Index_PQ(i);

Index_Ui=Index_Qi;

Jac(Index_Pi,Index_Ti)=-Bii*Ui^2-Qi;

Jac(Index_Pi,Index_Ui)= Gii*Ui^2+Qi;

Jac(Index_Qi,Index_Ti)=-Gii*Ui^2+Qi;
Jac(Index_Qi,Index_Ui)=-Bii*Ui^2+Qi;

else

Jac(Index_Pi,Index_Pi)=-Bii*Ui^2-Qi;

end

else

if Index_PQ(i)~=0

if Index_PQ(k)~=0

Index_Pi=i;

Index_Qi=Nr_Nod-1+Index_PQ(i);

Index_Tk=k;

Index_Uk=Nr_Nod-1+Index_PQ(k);

Gik=real(Ynn(i,k));

Bik=imag(Ynn(i,k));

Ui=U(i,1);

Uk=U(k,1);

Tik=Teta(i,1)-Teta(k,1);

Jac(Index_Pi,Index_Tk)=Ui*Uk*(Gik*sin(Tik)-Bik*cos(Tik));

Jac(Index_Pi,Index_Uk)=Ui*Uk*(Gik*cos(Tik)+Bik*sin(Tik));

Jac(Index_Qi,Index_Tk)=-(Ui*Uk*(Gik*cos(Tik)+Bik*sin(Tik)));

Jac(Index_Qi,Index_Uk)=Ui*Uk*(Gik*sin(Tik)-Bik*cos(Tik));

else

Index_Pi=i;

Index_Qi=Nr_Nod-1+Index_PQ(i);

Index_Tk=k;

Gik=real(Ynn(i,k));
Bik=imag(Ynn(i,k));

Ui=U(i,1);

Uk=U(k,1);

Tik=Teta(i,1)-Teta(k,1);

Jac(Index_Pi,Index_Tk)=Ui*Uk*(Gik*sin(Tik)-Bik*cos(Tik));

Jac(Index_Qi,Index_Tk)=-(Ui*Uk*(Gik*cos(Tik)+Bik*sin(Tik)));

end

else

if Index_PQ(k)~=0

Index_Pi=i;

Index_Tk=k;

Index_Uk=Nr_Nod-1+Index_PQ(k);

Gik=real(Ynn(i,k));

Bik=imag(Ynn(i,k));

Ui=U(i,1);

Uk=U(k,1);

Tik=Teta(i,1)-Teta(k,1);

Jac(Index_Pi,Index_Tk)=Ui*Uk*(Gik*sin(Tik)-Bik*cos(Tik));

Jac(Index_Pi,Index_Uk)=Ui*Uk*(Gik*cos(Tik)+Bik*sin(Tik));

else

Index_Pi=i;

Index_Tk=k;

Gik=real(Ynn(i,k));

Bik=imag(Ynn(i,k));

Ui=U(i,1);
Uk=U(k,1);

Tik=Teta(i,1)-Teta(k,1)

Jac(Index_Pi,Index_Tk)=Ui*Uk*(Gik*sin(Tik)-Bik*cos(Tik));

end

end

end

end

end

% Calcularea corectiilor DT si DU

D_TU=inv(Jac)*Dpq;

% Determinarea unei noi solutii

for i=1:Nr_Nod-1

Teta(i,1)=Teta(i,1)+D_TU(i,1);

if Tip_Nod(i,1)==1

Index_Ui=Nr_Nod-1+Index_PQ(i);

U(i,1)=U(i,1)*(1+D_TU(Index_Ui));

end

if (Tip_Nod(i,1)==0&&Index_PQ(i)~=0)

Index_Ui=Nr_Nod-1+Index_PQ(i);

U(i,1)=U(i,1)*(1+D_TU(Index_Ui));

if (Stare_C(i,1)==-1)&&(U(i,1)<Uimp(i,1))

Stare_C(i,1)=0;

U(i,1)=Uimp(i,1);

end

if (Stare_C(i,1)==1)&&(U(i,1)>Uimp(i,1))
Stare_C(i,1)=0;

U(i,1)=Uimp(i,1);

end

end

end

for i=1:Nr_Nod-1

Un(i,1)=U(i,1)*(cos(Teta(i,1))+j*sin(Teta(i,1)));

end

end

Rez=zeros(4,4);

for i=1:4

Rez(i,1)=U(i,1);

Rez(i,2)=Teta(i,1);

Rez(i,3)=Pcalc(i,1);

Rez(i,4)=Qcalc(i,1);

Rez(i,5)=Tip_Nod(i,1);

Rez(i,6)=Stare_C(i,1);

Rez(i,7)=Index_PQ(i,1);

end

Rez_NR=Rez

9.5398 0 -9.5398 0.2686 -0.3283

0 15.2450 -4.9291 0 -1.9235

-9.5398 -4.9291 24.0225 -0.3283 5.2041

-0.3283 0 0.3283 7.8053 -9.5398


0.3283 1.9235 -5.1384 -9.5398 25.9882

Columns 1 through 12

0 1.0000 0 1.0000 0 0 0.9500 0.5200 -0.9500 -0.5200 0 0

1.0000 1.0200 0 1.0200 0.8550 0 0.1400 0.0800 0.7150 -0.0800 0 0

0 1.0000 0 1.0000 0 0 0 0 0 0 0 0

-1.0000 1.0000 0 1.0000 0 0 0 0 0 0 0 0

Columns 13 through 17

0 0 0 0 1.0000

0 0.9000 1.1220 0 0

0 0 0 0 2.0000

0 0 1.1000 0 0