% Definice transformace
i=sqrt(-1)
Un=110
Unf=Un/sqrt(3)*1000

% Generator 40 MW
Png=40
CosFi=0.85
Sng=Png/CosFi
Xd=(200/100)*(Un^2/Sng)*i
Xdc=(70/100)*(Un^2/Sng)*i
Tm=13

pause 

% Transformator T1 6/110 kV
Snt1=63
Ukt1=10
Xt1=(Ukt1/100)*(Un^2/Snt1)*i
pause 

% Vedeni
delka=5
Xv1=delka*0.4*i
Xv2=Xv1/2

% Transformator T2 110/400 kV
Snt2=63
Ukt2=8
Xt2=(Ukt2/100)*(Un^2/Snt2)*i
pause 

% Sit
Sk=5000
Xs=(Un^2/Sk)*i
pause

% Vypocet predporuchoveho stavu
Ps=40
CosFiS=0.85
Is=Ps*1e6/(3*Unf*CosFiS)
Isc=Is*CosFiS
Isj=Is*sin(acos(CosFiS))
pause

Xsuma=abs(Xd+Xt1+Xv2+Xt2+Xs)
Ey=Isc*Xsuma
Ex=Unf+Isj*Xsuma
E=sqrt(Ex*Ex+Ey*Ey)
Ekomp=Unf+(Isc-i*Isj)*i*Xsuma
Theta=atan(Ey/Ex)
Pskontr=3*E*Unf/Xsuma*sin(Theta)
pause

% Nahrada trojuhelnika hvezdou
X1=Xv1*Xv1/2/(Xv1+Xv1/2+Xv1/2)
X2=Xv1*Xv1/2/(Xv1+Xv1/2+Xv1/2)
X3=Xv1/2*Xv1/2/(Xv1+Xv1/2+Xv1/2)
Xa=abs(Xdc+Xt1+X1)
Xb=abs(X2+Xt2+Xs)
X12=Xa+Xb+Xa*Xb/abs(X3)
X12odp=Xsuma+abs(-Xv2+Xv1)
pause

Pmax1=3*E*Unf/Xsuma
Pmax2=3*E*Unf/X12
Pmax3=3*E*Unf/X12odp
