% Axiomy
i=sqrt(-1)
A=-0.5+sqrt(3)/2*i
F=[ 1   1   1
    A*A A   1
    A   A*A 1 ]
pause

% Vstupni udaje
Un=110

% Alternator
Png=200
CosFi=0.9
Xd=2*(CosFi/Png)*Un^2*i
pause

% Transformator 1
Snt1=250
Uk1=10
Xt1=Uk1/100*Un^2/Snt1*i
% Transformator 2
Snt2=250
Uk2=8
Xt2=Uk2/100*Un^2/Snt2*i
pause

% Vedeni
delka=50
Xv=delka*0.3*i
% Sit'
Sks=1000
Xs=Un^2/Sks*i
pause

% Prepocet trojuhelnik hvezda
Xa1=Xv*(Xv/2)/(Xv+Xv/2+Xv/2)
Xb1=Xv*(Xv/2)/(Xv+Xv/2+Xv/2)
Xc1=(Xv/2)*(Xv/2)/(Xv+Xv/2+Xv/2)
pause

Xa2=Xv*(Xv/2)/(Xv+Xv/2+Xv/2)
Xb2=Xv*(Xv/2)/(Xv+Xv/2+Xv/2)
Xc2=(Xv/2)*(Xv/2)/(Xv+Xv/2+Xv/2)
pause

Xa0=3*Xv*(Xv/2)/(Xv+Xv/2+Xv/2)
Xb0=3*Xv*(Xv/2)/(Xv+Xv/2+Xv/2)
Xc0=3*(Xv/2)*(Xv/2)/(Xv+Xv/2+Xv/2)
pause

% Zpetna, netociva a ekvivalentni impedance
Z2=Xc2+1/(1/(Xd+Xt1+Xa2)+1/(Xb2+Xt2+Xs))
Z0=Xc0+1/(1/(Xt1+Xa0)+1/(Xb0+Xt2+Xs))
Zekv=1/(1/Z2+1/Z0)
pause

% Sousledna impedance a proud
Z1=Xc1+1/(1/(Xd+Xt1+Xa1)+1/(Xb1+Xt2+Xs))+Zekv
I1=1.1*Un/(sqrt(3)*Z1)

% Napeti v miste poruchy
U1=I1*Zekv
U2=U1
U0=U1
pause

% Proudy zpetne a netocive slozky
I2=-U2/Z2
I0=-U0/Z0

% Proudy generatoru a site
Ig1=I1*(Z1-Zekv-Xc1)/(Xd+Xt1+Xa1)
Is1=I1*(Z1-Zekv-Xc1)/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