% Definice transformace
i=sqrt(-1)
Un=22
Unf=Un/sqrt(3)

% Generator
Png=20
CosFi=0.9
Sng=Png/CosFi
Xd=(200/100)*(Un^2/Sng)*i
pause 

% Transformator T1
Snt1=30
Ukt1=12
Xt1=(Ukt1/100)*(Un^2/Snt1)*i
pause 

% Vedeni
delka=20
Xv1=delka*0.3*i
Xv=Xv1/2

% Transformator T2
Snt2=30
Ukt2=10
Xt2=(Ukt2/100)*(Un^2/Snt2)*i
pause 

% Sit
Sk=10000
KoefC=1.05
Xs=KoefC*(Un^2/Sk)*i
pause

% Vypocet predporuchoveho stavu, zatizeni 90%
% Zvolit bud' velikost E, nebo CosFiS aktualni
% Zde voleno E
Ps=0.9*Png
E=2*Unf
Xsuma=Xd+Xt1+Xv+Xt2+Xs
Theta=asin(Ps/(3*E*Unf/abs(Xsuma)))
pause

% Zkrat v polovine vedeni Xv1

% Nahrada trojuhelnika hvezdou
Xa=Xv1*Xv1/2/(Xv1+Xv1/2+Xv1/2)
Xb=Xv1*Xv1/2/(Xv1+Xv1/2+Xv1/2)
Xc=Xv1/2*Xv1/2/(Xv1+Xv1/2+Xv1/2)

Xl=Xd+Xt1+Xa
Xr=Xb+Xt2+Xs
Xsumazkrat=Xl+Xr+Xl*Xr/Xc

% Odpojeni poruchy
Xsumaodpojeno=Xsuma -Xv + Xv1
pause

Pmax1=3*E*Unf/abs(Xsuma)
Pmax2=3*E*Unf/abs(Xsumazkrat)
Pmax3=3*E*Unf/abs(Xsumaodpojeno)
