clc
% Vstupni parametry
Sal=(3.3/2)^2*30*pi
Sfe=(3.3/2)^2*7*pi
l=100
t1=20
t2=50
RhoAl=0.02941
RhoFe=0.13000
AlfaAl=0.00387
AlfaFe=0.00480
r=23.1/2
mu0=4*pi*1E-7
frekv=50
omega=2*pi*frekv

% Provozni podelny cinny odpor
Rss1km=1/(Sal/RhoAl+Sfe/RhoFe)*1000

Ktal=1+AlfaAl*(t2-t1)
Ktfe=1+AlfaFe*(t2-t1)
Ral=RhoAl*l/Sal*Ktal*1000
Rfe=RhoFe*l/Sfe*Ktfe*1000
Rss=1/(1/Ral+1/Rfe)

m=r/2/1000*sqrt(mu0*omega/(RhoAl/1E6))
Ks=1+m^4/12-m^8/180+m^12/2442

Ke=1.0222

SigmaH=130E6
Gamma=0.038E6
Pretizeni=3
ParametrC=SigmaH/Gamma/Pretizeni
Rozpeti=100
DelkaLana=2*ParametrC*sinh(Rozpeti/(2*ParametrC))
Kp=DelkaLana/Rozpeti

Ralfe=Rss*Ks*Ke*Kp

% Provozni podelna indukcnost
A2=3300
A3=3300
C1=2600
C2=3400
C3=2600
E=1300
Ha=21300
Hb=18000
Hc=14700
Msvazek=400
Ksi=0.809
Ksi0=0.779

Dab=sqrt((C2-C1)^2+A2^2)
Dbc=sqrt((C2-C3)^2+A3^2)
Dac=sqrt((C3-C1)^2+(A2+A3)^2)
Ds=(Dab*Dbc*Dac)^(1/3)

% Zjednodusene vztahy
Lp=0.46*log10(Ds/r)+0.05
Lpksi=0.46*log10(Ds/(Ksi0*r))
Lpksi=0.46*log10(Ds/(Ksi*r))

% Korekce s uvazovanim svazkovych vodicu
Rn=(r*Msvazek^2)^(1/3)
Lpsvazek=0.46*log10(Ds/Rn)+0.05/3

% Presne vypocty pro dvojity potah
Dabc=sqrt((C1+C2)^2+A2^2)
Dbcc=sqrt((C2+C3)^2+A3^2)
Dacc=sqrt((C1+C3)^2+(A2+A3)^2)
Daac=2*C1
Dbbc=2*C2
Dccc=2*C3
Lpnetransp=0.46*log10(sqrt(Dab*Dabc*Dac*Dacc)/(r*Daac))-j*sqrt(3)*0.46*log10(sqrt(Dac*Dacc/(Dab*Dabc)))+0.05
LpnetranspAbs=abs(Lpnetransp)
Dsc=(Daac*Dbbc*Dccc)^(1/3)
Lptransp=0.46*log10((Dab*Dabc*Dbc*Dbcc*Dac*Dacc)^(1/3)/(r*Dsc))+0.05

% Provozni pricna kapacita
Hs=(Ha*Hb*Hc)^(1/3)
D=41.4E6*log10(2*Hs/r)
Dc=41.4E6*log10(sqrt((2*Hs)^2+Ds^2)/Ds)

% Zjednodusene vztahy
C0=1/(D+2*Dc)*1E9
Cc=Dc/((D+2*Dc)*(D-Dc))*1E9
Cp=C0+3*Cc
Cp=1/(D-Dc)*1E9

Cp=0.0242E-6/log10(2*Hs*Ds/r/sqrt(4*Hs^2+Ds^2))*1E9
Cp=0.0242E-6/log10(Ds/r)*1E9

% Presne vypocty nesymetrickych kapacit
D11=41.4E6*log10(2*Ha/r)
D22=41.4E6*log10(2*Hb/r)
D33=41.4E6*log10(2*Hc/r)

% Zapocitani delky izolatoru a pruhybu
Fmax=ParametrC*(cosh(Rozpeti/(2*ParametrC))-1)
dH=E+2/3*Fmax*1000

D12=41.4E6*log10(sqrt((Ha-dH+Hb-dH)^2+(C2-C1)^2)/Dab)
D23=41.4E6*log10(sqrt((Hb-dH+Hc-dH)^2+(C2-C3)^2)/Dbc)
D13=41.4E6*log10(sqrt((Ha-dH+Hc-dH)^2+(C3-C1)^2)/Dac)

Dij=[ D11 D12 D13
      D12 D22 D23
      D13 D23 D33 ]
% Kapacitni koeficienty v nF
Gij=inv(Dij)*1E9
C10=Gij(1,1)+Gij(1,2)+Gij(1,3)
C20=Gij(2,1)+Gij(2,2)+Gij(2,3)
C30=Gij(3,1)+Gij(3,2)+Gij(3,3)
% alternativne
% C10=sum(Gij(1,:))
% C10=sum(Gij)(1)
C12=-Gij(1,2)
C13=-Gij(1,3)
C23=-Gij(2,3)

U1=1
U2=-0.5+1j*sqrt(3)/2
U3=-0.5-1j*sqrt(3)/2
Q1=C10*U1+C12*(U1-U2)+C13*(U1-U3)
Q2=C20*U1+C23*(U1-U2)+C12*(U1-U3)
Q3=C30*U1+C13*(U1-U2)+C23*(U1-U3)
%alternaticne
Q2=C20*U2+C23*(U2-U3)+C12*(U2-U1)
Cp2=Q2/U2
Q3=C30*U3+C13*(U3-U1)+C23*(U3-U2)
Cp3=Q3/U3

