Un1 =  13.5
Uv=Un1
frekv =  50
omega =  2*pi*frekv

% Transformatory
Snt1 = 200
Ukp1 = 10
Xt1 = Ukp1/100*Uv^2/Snt1

Snt2 = 250
Ukp2 =  10
Xt2 = Ukp2/100*Uv^2/Snt2

% Vedeni
Xv1=0.3*20/110^2*Uv^2
Xv=Xv1/2

% Nadrazena soustava
Xs=1.1*Uv^2/100

% Alternator
CosFi=0.9
Png=200
Sng=Png/CosFi
Xd=250/100*Uv^2/Sng
Xdc=50/100*Uv^2/Sng
Jmot=10E6

Pt=150
Fi=acos(CosFi)
Qg=Pt/CosFi*sin(Fi)
Qg=Pt*tan(Fi)
Ig=(Pt-i*Qg)/sqrt(3)/Uv
Unf=Uv/sqrt(3)
Xc=Xd+Xt1+Xv+Xt2+Xs
E=i*Ig*Xc+Unf
Xcc=Xdc+Xt1+Xv+Xt2+Xs
Ec=i*Ig*Xcc+Unf

Us=i*Ig*Xs+Unf
Ug=i*Ig*(Xs+Xt2+Xv+Xt1)+Unf

Theta0=angle(E)
Theta0c=angle(Ec)
abs(E)
abs(Ec)

Pg=3*abs(E)*Unf/Xc*sin(Theta0)
Pg=3*abs(Ec)*Unf/Xcc*sin(Theta0c)
Pmax=3*abs(E)*Unf/Xc
Pmaxc=3*abs(Ec)*Unf/Xcc

Pmax1=Pmaxc
Pmax2=0
Xccc=Xdc+Xt1+Xv1+Xt2+Xs
Pmax3=3*abs(Ec)*Unf/Xccc
