% Program pro vypocet cinnych a jalovych ztrat 
clear
clc

% Un [kV]
Un=220
% Pmax [MW]
Pmax=310
% cos Fi [-]
CosFi=0.9
% Sn [MVA]
Sn=200/CosFi
% Td [hod]
Td=6570/365
% T [hod]
T=6570
% Tp [hod]
Tp=8760
% Tz [hod]
% Tz=T*sqrt(T/Tp)
Tz=5329
% dP0 [%]
dP0p=0.5
% dPk [%]
dPkp=1.5
% Uk [%]
Ukp=10
% I0 [%]
I0p=1

dP0=dP0p/100*Sn
dPk=dPkp/100*Sn
dP0r=dP0*Tp
dPkr=dPk*Tz*((Pmax/CosFi)/Sn)^2
dPr=dP0r+dPkr
Ap=T*Pmax
dPp=dPr/Ap*100

Odm3=sqrt(3);
Inorm=Sn/(Odm3*Un)
I0=I0p/100*Inorm
Q0=Odm3*Un*I0
dQ0r=Q0*Tp
Urp=dPkp
Uxp=sqrt(Ukp*Ukp-Urp*Urp)
Qk=Uxp/100*Sn
dQkr=Qk*Tz*((Pmax/CosFi)/Sn)^2
dQr=dQ0r+dQkr

% Doplnek
frekv=50
omega=2*pi*frekv

% Vypocty parametru nahraniho schematu
Znt=Un^2/Sn

Rk=(dPkp/100)*(Un^2/Sn)
Rk1=Rk/2
Zk=(Ukp/100)*(Un^2/Sn)
Xs=sqrt(Zk^2-Rk^2)
Ls=Xs/omega
Ls1=Ls/2

Gfe=(dP0p/100)*(Sn/Un^2)
Rfe=1/Gfe
Y0=(I0p/100)*(Sn/Un^2)
Xh=1/sqrt(Y0^2-Gfe^2)
Lh=Xh/omega

In=Inorm*1000
Unf=Un/Odm3*1000

% Ztraty transformatoru okamzite naprazdno detailne
dP0alt1=3*Rk1*(I0*1000)^2
dP0alt2=3*Rfe*(Unf/Rfe)^2
dP0alt2=3*Unf^2/Rfe
dP0alt=dP0alt1+dP0alt2

% Ztraty transformatoru okamzite nakratko detailne
dPkalt1=3*Rk*In^2
dPkalt2=3*Rfe*((Unf*Ukp/100/2)/Rfe)^2
dPkalt2=3*(Unf*Ukp/100/2)^2/Rfe
dPkalt=dPkalt1+dPkalt2

% Vedeni
delka=1
Rp=delka*0.1
Cp=delka*10e-9
Gp=delka*50e-9

% Ztraty na vedeni okamzite naprazdno detailne
Ic=Unf*omega*Cp
dP0ved1=3*Rp*Ic^2
dP0ved1=3*Rp*(Unf*omega*Cp)^2
dP0ved2=3*(Unf*Gp)^2/Gp
dP0ved2=3*Unf^2*Gp
dP0ved=dP0ved1+dP0ved2

% Ztraty na vedeni okamzite nakratko detailne
dPkved1=3*Rp*In^2
dPkved2=3*((Unf*Ukp/100/2)*Gp)^2/Gp
dPkved2=3*(Unf*Ukp/100/2)^2*Gp
dPkved=dPkved1+dPkved2
