ClearAll["Global`*"]

(*funkce sestaveni admitancni matice*)
Ymatice[uzel1_,uzel2_,Z_,Y_,T_]:=Module[{YT,Ykm,Ymk,Yk0,Ym0,u1,u2,m},
YT=(1/Z);
Ykm=Ymk=(YT/T);
Yk0=(1-(1/T))*YT;
Ym0=((1-T)/(T^2))*YT;
m=DiagonalMatrix[Y];
For[i=1,i<Length[uzel1]+1,i++,
u1=uzel1[[i]];
u2=uzel2[[i]];
(*přidáme admitance všech okolních větví na diagonálu admitanční matice*)
m[[u1,u1]]=m[[u1,u1]]+Ykm[[i]]+Yk0[[i]];
m[[u2,u2]]=m[[u2,u2]]+Ymk[[i]]+Ym0[[i]];
(*nediagonalni prvky*)
m[[u1,u2]]=m[[u1,u2]]-Ykm[[i]];
m[[u2,u1]]=m[[u2,u1]]-Ymk[[i]];
];
m
];
(*funkce pro vypocet razoveho 3f zkratoveho proudu*)
Ikcc3f[Unuz_,zmat_]:=Module[{Ikv,Ik},
Ikv=ConstantArray[0,Length[Unuz]]; (*vektor zkratovych proudu uzlu*)
For[z=1,z<Length[Unuz]+1,z++,
Ik=((-Unuz[[z]])/((Sqrt[3])*zmat[[z,z]])); (*zkratový proud*)
Ikv[[z]]=Ikv[[z]]+Ik;
];
Ikv
];
(*funkce pro vypocet razoveho 2f zkratoveho proudu*)
Ikcc2f[Unuz_,zmt1_,zmt2_]:=Module[{Ikv,Ik},
Ikv=ConstantArray[0,Length[Unuz]]; (*vektor zkratovych proudu uzlu*)
For[z=1,z<Length[Unuz]+1,z++,
Ik=((-(Sqrt[3])Unuz[[z]])/((Sqrt[3])*(zmt1[[z,z]]+zmt2[[z,z]]))); (*zkratový proud*)
Ikv[[z]]=Ikv[[z]]+Ik;
];
Ikv
];
(*funkce pro vypocet razoveho 2f zemniho zkratoveho proudu*)
Ikcc2fz[Unuz_,zmt1_,zmt2_,zmt0_]:=Module[{Ikv,Ik},
Ikv=ConstantArray[0,Length[Unuz]]; (*vektor zkratovych proudu uzlu*)
For[z=1,z<Length[Unuz]+1,z++,
Ik=((-(Sqrt[3])*(Sqrt[1-((Im[zmt2[[z,z]]]*Im[zmt0[[z,z]]])/(((Im[zmt2[[z,z]]]+Im[zmt0[[z,z]]]))^2))])*Unuz[[z]])/((Sqrt[3])*(zmt1[[z,z]]+(1/((1/(zmt2[[z,z]]))+(1/(zmt0[[z,z]]))))))); (*zkratový proud*)
Ikv[[z]]=Ikv[[z]]+Ik;
];
Ikv
];
(*funkce pro vypocet zkratoveho proudu zemniho spojeni*)
Ikcc1fz[Unuz_,C0_,zmt1_,zmt2_,zmt0_]:=Module[{Ikv,Ik,Z},
Ikv=ConstantArray[0,Length[Unuz]]; (*vektor zkratovych proudu uzlu*)
For[z=1,z<Length[Unuz]+1,z++,
Z=zmt1[[z,z]]+(1/(I*2*Pi*f*C0[[z]]+(1/((1/((1/(zmt2[[z,z]]))+I*2*Pi*f*C0[[z]]))+(1/(I*2*Pi*f*C0[[z]]+(1/(zmt0[[z,z]]))))))));
Ik=((-3*Unuz[[z]])/((Sqrt[3])*Z)); (*zkratový proud*)
Ikv[[z]]=Ikv[[z]]+Ik;
];
Ikv
];
(*funkce pro vypocet narazoveho zkratoveho proudu*)
Ip[zmat_,Ikcc_]:=Module[{Inar,κ,ip},
Inar=ConstantArray[0,Length[Ikcc]]; (*vektor zkratovych proudu uzlu*)
For[z=1,z<Length[Ikcc]+1,z++,
κ=1.02+0.98*(E^(-3*((Re[zmat[[z,z]]])/(Im[zmat[[z,z]]]))));
ip=κ*(Sqrt[2])*Ikcc[[z]];
Inar[[z]]=Inar[[z]]+ip;
];
Inar
];
(*Zadané hodnoty, pro pripad 1 blok 1 pri standartnim provozu*)
MVA=1000000;
kV=kW=1000;
A=1;
(*Pro výpočet maximálníxh zkratový proudů zadej c=1,10 a ujisti se že nejsou zakomentované korekční součinitele traf a motory v Y matici. Pro minimální zkratové proudy zadej c=1,00 pro vn a 0,9 pro nn, ujisti se že jsou zakomentované korekční součinitele traf a motory v Y matici s vyjímkou odsíření a výměníkové stanice v případech 3 a 9. !po zakomentování motorů doplnit 0!*)
c=1.10;
f=50;
R110={Sks-> 2400 MVA,Un-> 110kV};
T1={St-> 63 MVA,U1-> 110 kV,U2-> 10.5 kV,p->(U1/U2), uk-> 0.105,Pk-> 285kW,Int-> 301A}; (*zapojeni YNd1*)
G1={Un-> 10.5 kV, Sn-> 75 MVA,xdraz-> 0.145};
T11={St-> 10 MVA,U1-> 10.5 kV,U2-> 6 kV,p->(U1/U2), uk-> 0.076,Pk-> 50kW,Int-> 550A}; (*zapojeni Dd0*)
Mmlyn={Un-> 6 kV,Inm-> 46.8A,iz(*Iz/In*)-> 5}; (*Mlyn Vykon P=400kW a n= 980 ot/min*)
Mkv={Un-> 6 kV,Inm-> 153A,iz(*Iz/In*)-> 6};(*kourovy ventilator P= 1350 kW a n= 1490 ot/min*)
Mvzv={Un-> 6 kV,Inm-> 46.4A,iz(*Iz/In*)-> 5.4};(*vzduchovy ventilator P= 400 kW a n= 1485 ot/min*)
Mnap={Un-> 6 kV,Inm-> 190A,iz(*Iz/In*)-> 4};(*napajecka 1 P= 1700 kW a n= 2960 ot/min*)
Mnapm={Un-> 6 kV,Inm-> 152A,iz(*Iz/In*)-> 3};(*napajecka 2 s statickým měničem a transformátorem 1,6 MVA*)
T31={St-> 2 MVA,U1-> 6 kV,U2-> 0.4 kV,p->(U1/U2), uk-> 0.062,Pk-> 16kW,Int-> 192.45A};(*zapojeni Dyn*)
Meq={Un-> 0.4 kV,Inm-> 727 A,iz(*Iz/In*)-> 5};
(*Vypocet impedanci*)
Zr110=I*((c*(Un^2))/Sks)/.R110;
Zt1n=uk*((U1^2)/St)/.T1;
Rt1=(Pk/(3*(Int^2)))/.T1;
Xt1=(Sqrt[(Zt1n^2)+(Rt1^2)]);
Zt1=Rt1+I*Xt1;
Xg1=xdraz*((Un^2)/Sn)/.G1;
Rg1=0.07*Xg1;
Zg1=Rg1+I*Xg1;
Zt11n=uk*((U1^2)/St)/.T11;
Rt11=(Pk/(3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u*)
T={1/p//.T1,1/p//.T11,1/p//.T31};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/Zr110),(1/Zg1),(1/Zvs63f),(1/Zeq)};
Y={(1/Zr110),(1/Zg1),(1/Zvs6),(1/Zeq)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={(1/((1/Zr110)+(1/Zt1))),1*(10^50),1*(10^50),Zt31};(*v uzlu 2 a 3 vyjde jako u nezemniho*)
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,10.5kV,6kV,0.4kV};
(*kapacita proti zemi uzlu*)
C0={0,0.0010919*(10^(-6)),(0.6126+0.10149)*(10^(-6)),0}; (*ma smysl pocitat zemni spojeni pouze v uzlech 2 a 3, v 2. uzlu není výpočet přesný kvůli zanedbání pásoviny k generátoru*)
(*admitancni a impedancni matice*)
ymat3f=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3f//MatrixForm;
ymat1=ymat2=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3f=Inverse[ymat3f];
zmat1=zmat2=Inverse[ymat1];
(*3f zkrat*)
Ik3fcc=Ikcc3f[Unuzel,zmat3f]
Abs[Ik3fcc]

(*2f zkrat*)
Ik2fcc=Ikcc2f[Unuzel,zmat1,zmat2]
Abs[Ik2fcc]

(*2f zemni zkrat*)
zmat0=DiagonalMatrix[Zvid0];
Ik2fzcc=Ikcc2fz[Unuzel,zmat1,zmat2,zmat0]
Abs[Ik2fzcc]

(*zemni spojeni /1f zkrat*)
Ik1fzcc=Ikcc1fz[Unuzel,C0,zmat1,zmat2,zmat0]
Abs[Ik1fzcc]

(*narazovy zkratovy proud*)
ip3f=Ip[zmat3f,Ik3fcc]
Abs[ip3f]
ip2f=Ip[zmat1,Ik2fcc]
Abs[ip2f]
ip2fz=Ip[zmat1,Ik2fzcc]
Abs[ip2fz]
ip1fz=Ip[zmat1,Ik1fzcc]
Abs[ip1fz]

(*Blok 1 napájeny z rozvodny r6-0 a zaskokoveho trafa Aue21*)
(*Zadané hodnoty k případu dva, pokud se liší*)
T21={St-> 16 MVA,U1-> 110 kV,U2-> 6 kV,p->(U1/U2), uk-> 0.114,Pk-> 110kW,Int-> 84A};
T50={St-> 1 MVA,U1-> 6 kV,U2-> 0.4 kV,p->(U1/U2), uk-> 0.0612,Pk-> 8 kW,Int-> 96A};
T44={St-> 1 MVA,U1-> 6 kV,U2-> 0.4 kV,p->(U1/U2), uk-> 0.0612,Pk-> 8kW,Int-> 96A};
Mbg={Un-> 6 kV,Inm-> 48.5A,iz(*Iz/In*)-> 6};(*1480 ot*)
Mspl={Un-> 6 kV,Inm-> 26.6A,iz(*Iz/In*)-> 6};(*990 ot*)
(*čerpací stanice*)
Mfm={Un-> 6 kV,Inm-> 108A,iz(*Iz/In*)-> 3};
Mbfm={Un-> 6 kV,Inm-> 84.2A,iz(*Iz/In*)-> 5};
T52={St-> 0.63 MVA,U1-> 6 kV,U2-> 0.4 kV,p->(U1/U2), uk-> 0.06,Pk-> 5kW,Int-> 60.6A}; (*Dyn*)
Meqcs={Un-> 0.4 kV,Inm-> 317.5 A,iz(*Iz/In*)-> 5};

Meq040={Un-> 0.4 kV,Inm-> 764 A,iz(*Iz/In*)-> 5};
Meqzu={Un-> 0.4 kV,Inm-> 936.4 A,iz(*Iz/In*)-> 5};
(*Vypocet impedanci*)
Zt21n=uk*((U1^2)/St)/.T21;
Rt21=(Pk/(3*(Int^2)))/.T21;
Xt21=(Sqrt[(Zt21n^2)+(Rt21^2)]);
Zt21=Rt21+I*Xt21;
Zt44n=uk*((U1^2)/St)/.T44;
Rt44=(Pk/(3*(Int^2)))/.T44;
Xt44=(Sqrt[(Zt44n^2)+(Rt44^2)]);
xt44=(Xt44/((U1^2)/St))/.T44;
Kt44=0.95*(c/(1+0.6*xt44));
Zt44=Kt44*(Rt44+I*Xt44);
Zt50n=uk*((U1^2)/St)/.T50;
Rt50=(Pk/(3*(Int^2)))/.T50;
Xt50=(Sqrt[(Zt50n^2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/Zbg)+(1/Zcs)));
Z203f=(1/((1/Zvs63f)+(2/Zspl)+(2/Zbg)+(1/Zcs3f)));
(*Zapojeni soustavy*)
uzel1={1,2,2,2};
uzel2={2,3,4,5};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt21,Zt31,Zt50,Zt44};
(*Vektor prevodu*)
T={1/p//.T21,1/p//.T31,1/p//.T50,1/p//.T44};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/Zr110),(1/Z203f),(1/Zeq),(1/Zeq040),(1/Zeqzu)};
Y={(1/Zr110),(1/Z20),(1/Zeq),(1/Zeq040),(1/Zeqzu)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={Zr110,1*(10^50),Zt31,Zt50,Zt44};(*v uzlu 2 vyjde jako u nezemniho*)
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,6kV,0.4kV,0.4kV,0.4kV};
(*kapacita proti zemi uzlu*)
C0={0,(2.272+0.1548)*(10^(-6)),0,0,0}; (*ma smysl pocitat zemni spojeni pouze v uzlech 2 *)
(*admitancni a impedancni matice*)
ymat3fp2=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp2//MatrixForm;
ymat1p2=ymat2p2=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp2=Inverse[ymat3fp2];
zmat1p2=zmat2p2=Inverse[ymat1p2];
(*3f zkrat*)
Ik3fccp2=Ikcc3f[Unuzel,zmat3fp2]
Abs[Ik3fccp2]

(*2f zkrat*)
Ik2fccp2=Ikcc2f[Unuzel,zmat1p2,zmat2p2]
Abs[Ik2fccp2]

(*2f zemni zkrat*)
zmat0p2=DiagonalMatrix[Zvid0];
Ik2fzccp2=Ikcc2fz[Unuzel,zmat1p2,zmat2p2,zmat0p2]
Abs[Ik2fzccp2]

(*zemni spojeni /1f zkrat*)
Ik1fzccp2=Ikcc1fz[Unuzel,C0,zmat1p2,zmat2p2,zmat0p2]
Abs[Ik1fzccp2]

(*narazovy zkratovy proud*)
ip3fp2=Ip[zmat3fp2,Ik3fccp2]
Abs[ip3fp2]
ip2fp2=Ip[zmat1p2,Ik2fccp2]
Abs[ip2fp2]
ip2fzp2=Ip[zmat1p2,Ik2fzccp2]
Abs[ip2fzp2]
ip1fzp2=Ip[zmat1p2,Ik1fzccp2]
Abs[ip1fzp2]

(*Blok 3 v standartnim provozu*)
(*Zadané hodnoty k případu t5i, pokud se liší od predchozich*)
T3={StAB-> 63 MVA,StAC-> 40 MVA,StBC-> 40 MVA,U1-> 110 kV,U2-> 10.5 kV,U3-> 6 kV, ukAB-> 0.1164, ukAC-> 0.1732, ukBC-> 0.0925,PkAB-> 285kW,PkAC-> 175kW,PkBC-> 110kW,Int-> 331A};
T33={St-> 2 MVA,U1-> 6 kV,U2-> 0.4 kV,p->(U1/U2), uk-> 0.062,Pk-> 16kW,Int-> 192.45A};
Meq043={Un-> 0.4 kV,Inm-> 1889 A,iz(*Iz/In*)-> 5};
Reaktor={Un-> 6 kV,Inr-> 1000 A,uk-> 0.06};
G3=G1;
(*cerpadla na VS Praha*)
Mvsp={Un-> 6 kV,Inm-> 141.5 A,iz(*Iz/In*)-> 6};
(*motory na odsíření*)
Mvyv={Un-> 6 kV,Inm-> 30 A,iz(*Iz/In*)-> 5};
Moxidmych1={Un-> 6 kV,Inm-> 30 A,iz(*Iz/In*)-> 5};
Moxidmych2={Un-> 6 kV,Inm-> 42.7 A,iz(*Iz/In*)-> 5};
Mcabs1={Un-> 6 kV,Inm-> 108.3 A,iz(*Iz/In*)-> 5};
Mcabs2={Un-> 6 kV,Inm-> 96.2 A,iz(*Iz/In*)-> 5};
(*Vypocet impedanci*)
urt3AB=((StAB*PkAB)/((U1^2)*3*Int))/.T3; (*cinne slozky napeni na prazdno*)
urt3AC=((StAC*PkAC)/((U1^2)*3*Int))/.T3;
urt3BC=((StBC*PkBC)/((U1^2)*3*Int))/.T3;
uxt3AB=(Sqrt[(ukAB^2)-(urt3AB^2)])/.T3;(*reaktancni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abs1=Rcabs1+I*Xcabs1;
Zcabs21=(1/iz)*(Un/((Sqrt[3])*Inm))/.Mcabs2;
Xcabs2=0.922*Zcabs21;
Rcabs2=0.42*Xcabs2;
Zcabs2=Rcabs2+I*Xcabs2;
Zods=(1/((1/Zvyv)+(1/Zoxidmych1)+(2/Zoxidmych2)+(1/Zcabs1)+(2/Zcabs2)));
Zvsp1=(1/iz)*(Un/((Sqrt[3])*Inm))/.Mvsp;
Xvsp=0.922*Zvsp1;
Rvsp=0.42*Xvsp;
Zvsp=Rvsp+I*Xvsp;
(*Zapojeni soustavy*)
uzel1={1,8,8,3,4,4,4};
uzel2={8,2,3,4,5,6,7};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt3A,Zt3B,Zt3C,Zreak,Zt33,Zt50,Zt44};
(*Vektor prevodu*)
T={(U1/U2)/.T3,1,(U2/U3)/.T3,1,1/p//.T33,1/p//.T50,1/p//.T44};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/Zr110),(1/Zg3),(1/Zods)+(5/Zvsp),(1/Z203f),(1/Zeq043),(1/Zeq040),(1/Zeqzu),0};
Y={(1/Zr110),(1/Zg3),(1/Zods)+(5/Zvsp),(1/Z20),(1/Zeq043),(1/Zeq040),(1/Zeqzu),0};
(*vektor videnych impedanci netocive slozky*)
Zvid0={(1/((1/Zr110)+(1/Zt3A))),1*(10^50),1*(10^50),1*(10^50),Zt33,Zt50,Zt44,Zt3A+Zr110};
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,10.5kV,6kV,6kV,0.4kV,0.4kV,0.4kV,10.5kV};
(*vektor kapacit vuci zemi*)
C0={0,0,2.2172*(10^(-6)),(2.272+0.129)*(10^(-6)),0,0,0,0}; (*ma smysl pocitat zemni spojeni pouze v uzlech 2, 3 a 4, s toho v uzlu 2 nemuzeme pocitat z duvodu zanedbani pretahu *)
(*admitancni a impedancni matice*)
ymat3fp3=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp3//MatrixForm;
ymat1p3=ymat2p3=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp3=Inverse[ymat3fp3];
zmat1p3=zmat2p3=Inverse[ymat1p3];
(*3f zkrat*)
Ik3fccp3=Ikcc3f[Unuzel,zmat3fp3]
Abs[Ik3fccp3]

(*2f zkrat*)
Ik2fccp3=Ikcc2f[Unuzel,zmat1p3,zmat2p3]
Abs[Ik2fccp3]

(*2f zemni zkrat*)
zmat0p3=DiagonalMatrix[Zvid0];
Ik2fzccp3=Ikcc2fz[Unuzel,zmat1p3,zmat2p3,zmat0p3]
Abs[Ik2fzccp3]

(*zemni spojeni /1f zkrat*)
Ik1fzccp3=Ikcc1fz[Unuzel,C0,zmat1p3,zmat2p3,zmat0p3]
Abs[Ik1fzccp3]

(*narazovy zkratovy proud*)
ip3fp3=Ip[zmat3fp3,Ik3fccp3]
Abs[ip3fp3]
ip2fp3=Ip[zmat1p3,Ik2fccp3]
Abs[ip2fp3]
ip2fzp3=Ip[zmat1p3,Ik2fzccp3]
Abs[ip2fzp3]
ip1fzp3=Ip[zmat1p3,Ik1fzccp3]
Abs[ip1fzp3]

(*Blok 3 napajeny z zaskokoveho trafa*)
(*Zapojeni soustavy*)
uzel1={1,2,2,2};
uzel2={2,3,4,5};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt21,Zt33,Zt50,Zt44};
(*Vektor prevodu*)
T={1/p//.T21,1/p//.T33,1/p//.T50,1/p//.T44};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/Zr110),(1/Z203f),(1/Zeq043),(1/Zeq040),(1/Zeqzu)};
Y={(1/Zr110),(1/Z20),(1/Zeq043),(1/Zeq040),(1/Zeqzu)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={Zr110,1*(10^50),Zt33,Zt50,Zt44};(*v uzlu 2 vyjde jako u nezemniho*)
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,6kV,0.4kV,0.4kV,0.4kV};
(*vektor kapacit vuci zemi*)
C0={0,(2.272+0.1548)*(10^(-6)),0,0,0}; (*ma smysl pocitat zemni spojeni pouze v uzlech 2 *)
(*admitancni a impedancni matice*)
ymat3fp4=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp4//MatrixForm;
ymat1p4=ymat2p4=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp4=Inverse[ymat3fp4];
zmat1p4=zmat2p4=Inverse[ymat1p4];
(*3f zkrat*)
Ik3fccp4=Ikcc3f[Unuzel,zmat3fp4]
Abs[Ik3fccp4]

(*2f zkrat*)
Ik2fccp4=Ikcc2f[Unuzel,zmat1p4,zmat2p4]
Abs[Ik2fccp4]

(*2f zemni zkrat*)
zmat0p4=DiagonalMatrix[Zvid0];
Ik2fzccp4=Ikcc2fz[Unuzel,zmat1p4,zmat2p4,zmat0p4]
Abs[Ik2fzccp4]

(*zemni spojeni /1f zkrat*)
Ik1fzccp4=Ikcc1fz[Unuzel,C0,zmat1p4,zmat2p4,zmat0p4]
Abs[Ik1fzccp4]

(*narazovy zkratovy proud*)
ip3fp4=Ip[zmat3fp4,Ik3fccp4]
Abs[ip3fp4]
ip2fp4=Ip[zmat1p4,Ik2fccp4]
Abs[ip2fp4]
ip2fzp4=Ip[zmat1p4,Ik2fzccp4]
Abs[ip2fzp4]
ip1fzp4=Ip[zmat1p4,Ik1fzccp4]
Abs[ip1fzp4]

(*pripad 5 blok 6 v normalnim provozu*)
(*Zadané hodnoty*)
T6={St-> 63 MVA,U1-> 110 kV,U2-> 10.5 kV,p->(U1/U2), uk-> 0.1058,Pk-> 188kW,Int-> 301A}; (*zapojeni YNd1*)
T16={St-> 10 MVA,U1-> 10.5 kV,U2-> 6 kV,p->(U1/U2), uk-> 0.072,Pk-> 50kW,Int-> 550A}; (*zapojeni Dd0*)
T36=T31;(*zapojeni Dyn*)
Meq046={Un-> 0.4 kV,Inm-> 1329 A,iz(*Iz/In*)-> 5};
(*Vypocet impedanci*)
Zt6n=uk*((U1^2)/St)/.T6;
Rt6=(Pk/(3*(Int^2)))/.T6;
Xt6=(Sqrt[(Zt6n^2)+(Rt6^2)]);
Zt6=Rt6+I*Xt6;
Zt16n=uk*((U1^2)/St)/.T16;
Rt16=(Pk/(3*(Int^2)))/.T16;
Xt16=(Sqrt[(Zt16n^2)+(Rt16^2)]);
xt16=(Xt16/((U1^2)/St))/.T16;
Kt16=0.95*(c/(1+0.6*xt16));
Zt16=Kt16*(Rt16+I*Xt16);
Zt36=Zt31;
Zeq0461=(1/iz)*(Un/((Sqrt[3])*Inm))/.Meq046;
Xeq046=0.922*Zeq0461;
Req046=0.42*Xeq046;
Zeq046=Req+I*Xeq046;
(*Zapojeni soustavy*)
uzel1={1,2,3};
uzel2={2,3,4};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt6,Zt16,Zt36};
(*Vektor prevodu*)
T={1/p//.T6,1/p//.T16,1/p//.T36};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/Zr110),0,(1/Zvs63f),(1/Zeq046)};
Y={(1/Zr110),0,(1/Zvs6),(1/Zeq046)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={(1/((1/Zr110)+(1/Zt6))),1*(10^50),1*(10^50),Zt36};(*v uzlu 2 a 4 vyjde jako u nezemniho*)
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,10.5kV,6kV,0.4kV};
(*vektor kapacit vuci zemi*)
C0={0,0.000288798*(10^(-6)),(0.6126+0.10149)*(10^(-6)),0}; (*ma smysl pocitat zemni spojeni pouze v uzlech 2 a 3*)
(*admitancni a impedancni matice*)
ymat3fp5=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp5//MatrixForm;
ymat1p5=ymat2p5=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp5=Inverse[ymat3fp5];
zmat1p5=zmat2p5=Inverse[ymat1p5];
(*3f zkrat*)
Ik3fccp5=Ikcc3f[Unuzel,zmat3fp5]
Abs[Ik3fccp5]

(*2f zkrat*)
Ik2fccp5=Ikcc2f[Unuzel,zmat1p5,zmat2p5]
Abs[Ik2fccp5]

(*2f zemni zkrat*)
zmat0p5=DiagonalMatrix[Zvid0];
Ik2fzccp5=Ikcc2fz[Unuzel,zmat1p5,zmat2p5,zmat0p5]
Abs[Ik2fzccp5]

(*zemni spojeni /1f zkrat*)
Ik1fzccp5=Ikcc1fz[Unuzel,C0,zmat1p5,zmat2p5,zmat0p5]
Abs[Ik1fzccp5]

(*narazovy zkratovy proud*)
ip3fp5=Ip[zmat3fp5,Ik3fccp5]
Abs[ip3fp5]
ip2fp5=Ip[zmat1p5,Ik2fccp5]
Abs[ip2fp5]
ip2fzp5=Ip[zmat1p5,Ik2fzccp5]
Abs[ip2fzp5]
ip1fzp5=Ip[zmat1p5,Ik1fzccp5]
Abs[ip1fzp5]

(*Blok 6 napajeny z zaskokoveho trafa*)
(*Zapojeni soustavy*)
uzel1={1,2,2,2};
uzel2={2,3,4,5};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt21,Zt36,Zt50,Zt44};
(*Vektor prevodu*)
T={1/p//.T21,1/p//.T36,1/p//.T50,1/p//.T44};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/Zr110),(1/Z203f),(1/Zeq046),(1/Zeq040),(1/Zeqzu)};
Y={(1/Zr110),(1/Z20),(1/Zeq046),(1/Zeq040),(1/Zeqzu)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={Zr110,1*(10^50),Zt36,Zt50,Zt44};(*v uzlu 2 vyjde jako u nezemniho*)
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,6kV,0.4kV,0.4kV,0.4kV};
(*vektor kapacit vuci zemi*)
C0={0,(2.272+0.1548)*(10^(-6)),0,0,0}; (*ma smysl pocitat zemni spojeni pouze v uzlech 2 *)
(*admitancni a impedancni matice*)
ymat3fp6=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp6//MatrixForm;
ymat1p6=ymat2p6=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp6=Inverse[ymat3fp6];
zmat1p6=zmat2p6=Inverse[ymat1p6];
(*3f zkrat*)
Ik3fccp6=Ikcc3f[Unuzel,zmat3fp6]
Abs[Ik3fccp6]

(*2f zkrat*)
Ik2fccp6=Ikcc2f[Unuzel,zmat1p6,zmat2p6]
Abs[Ik2fccp6]

(*2f zemni zkrat*)
zmat0p6=DiagonalMatrix[Zvid0];
Ik2fzccp6=Ikcc2fz[Unuzel,zmat1p6,zmat2p6,zmat0p6]
Abs[Ik2fzccp6]

(*zemni spojeni /1f zkrat*)
Ik1fzccp6=Ikcc1fz[Unuzel,C0,zmat1p6,zmat2p6,zmat0p6]
Abs[Ik1fzccp6]

(*narazovy zkratovy proud*)
ip3fp6=Ip[zmat3fp6,Ik3fccp6]
Abs[ip3fp6]
ip2fp6=Ip[zmat1p6,Ik2fccp6]
Abs[ip2fp6]
ip2fzp6=Ip[zmat1p6,Ik2fzccp6]
Abs[ip2fzp6]
ip1fzp6=Ip[zmat1p6,Ik1fzccp6]
Abs[ip1fzp6]

(*Dale nasleduji priklady s branim v uvahu kabelovych propoju*)
(*pripad 7 blok 1 v normalnim chodu*)
(*pamaretry kabelu a vedeni*)
mm=(10^(-3));
m=(10^(-3));
mH=(10^(-3));
µ0=4*Pi*(10^(-7));
V12={n-> 1,r-> 3.98mm,dl12-> 3,dl23-> 3,dl31-> 6,l-> 40m}; 
V34={n-> 3,r-> 15.45mm,dl12-> 3,dl23-> 3,dl31-> 6,l-> 50m};
V35={n-> 1,r-> 3.98mm,dl12-> 1,dl23-> 1,dl31-> 2,l-> 20m};
V67={n-> 1,r-> 8.74mm,dl12-> 3,dl23-> 3,dl31-> 6,l-> 50m};
K67={rl-> 0.125,ll-> 0.28mH,l-> 100m};(*240 (mm^2)*)
K7m1={rl-> 0.253,ll-> 0.3mH,l-> 47m};(*120 (mm^2)*)
K7m2={rl-> 0.253,ll-> 0.3mH,l-> 35m};(*120 (mm^2)*)
K7m3={rl-> 0.253,ll-> 0.3mH,l-> 67m};(*120 (mm^2)*)
K7m4={rl-> 0.253,ll-> 0.3mH,l-> 56m};(*120 (mm^2)*)
K7vv1={rl-> 0.253,ll-> 0.3mH,l-> 82m};(*120 (mm^2)*)
K7vv2={rl-> 0.253,ll-> 0.3mH,l-> 75m};(*120 (mm^2)*)
K7kv={rl-> 0.164,ll-> 0.29mH,l-> 185m};(*185 (mm^2)*)
K7np={rl-> 0.164,ll-> 0.29mH,l-> 185m};(*185 (mm^2)*)
K7npm={rl-> 0.164,ll-> 0.29mH,l-> 20m};(*185 (mm^2)*)
K78={rl-> 0.164,ll-> 0.29mH,l-> 50m};(*185 (mm^2)*)
K910={rl-> 0.320,ll->0.280 mH,l-> 20m};(* 95 (mm^2)*)
(*vypocet impedanci*)
d12=((dl12*dl23*dl31)^(1/3))/.V12;
X12=l*f*µ0*((1/(4*n))+Log[(d12/r)])*(10^(-3))/.V12;
X120=3*X12;
Z12p7=I*X12;
Z120p7=I*X120;
d34=((dl12*dl23*dl31)^(1/3))/.V34;
X34=l*f*µ0*((1/(4*n))+Log[(d34/r)])*(10^(-3))/.V34;
Z34p7=I*X34;
X340=3*X34;
Z340p7=I*X340;
d35=((dl12*dl23*dl31)^(1/3))/.V35;
X35=l*f*µ0*((1/(4*n))+Log[(d35/r)])*(10^(-3))/.V35;
Z35p7=I*X35;
X350=3*X35;
Z350p7=I*X350;
d67=((dl12*dl23*dl31)^(1/3))/.V67;
X67=l*f*µ0*((1/(4*n))+Log[(d35/r)])*(10^(-3))/.V67;
ZV67=I*X67;
RK67=rl*l/.K67;
XK67=2*Pi*f*ll*l/.K67;
ZK67=RK67+I*XK67;
Z67p7=ZV67+ZK67;
(*VS*)
RK7m1=rl*l/.K7m1;
XK7m1=2*Pi*f*ll*l/.K7m1;
ZK7m1=RK7m1+I*XK7m1;
RK7m2=rl*l/.K7m2;
XK7m2=2*Pi*f*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7,8,9,10};
(*Vektor meziuzlovych impedanci*)
Zkm={Z12p7,Zt1,Z34p7,Z35p7,Zt11,Z67p7,Z78p7,Zt31,Z910p7};
(*Vektor prevodu*)
T={1,1/p//.T1,1,1,1/p//.T11,1,1,1/p//.T31,1};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/Zr110),0,0,(1/Zg1),0,0,(1/Zvs63f),0,0,(1/Zeq)};
Y={(1/Zr110),0,0,(1/Zg1),0,0,(1/Zvs6),0,0,(1/Zeq)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={(1/((1/Zr110)+(1/(Zt1+Z120p7)))),(1/((1/(Zr110+Z120p7))+(1/Zt1))),1*(10^50),1*(10^50),1*(10^50),1*(10^50),1*(10^50),1*(10^50),Zt31,Zt31+Z9100p7};
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,110kV,10.5kV,10.5kV,10.5kV,6kV,6kV,6kV,0.4kV,0.4kV};
(*vektor kapacit vuci zemi*)
C0={0,0,0.0010919*(10^(-6)),0.0008032*(10^(-6)),0.000288798*(10^(-6)),0.1548*(10^(-6)),(0.6126+0.1548)*(10^(-6)),0.04*(10^(-6)),0,0}; (*ma smysl pocitat zemni spojeni pouze v uzlech 3, 4, 5, 6, 7 a 8, v uzlech 3 , 4 a 5 nevychází presný výsledek z důvodu nebrání v úvahu přetahu*)
(*admitancni a impedancni matice*)
ymat3fp7=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp7//MatrixForm;
ymat1p7=ymat2p7=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp7=Inverse[ymat3fp7];
zmat1p7=zmat2p7=Inverse[ymat1p7];
(*3f zkrat*)
Ik3fccp7=Ikcc3f[Unuzel,zmat3fp7]
Abs[Ik3fccp7]

(*2f zkrat*)
Ik2fccp7=Ikcc2f[Unuzel,zmat1p7,zmat2p7]
Abs[Ik2fccp7]

(*2f zemni zkrat*)
zmat0p7=DiagonalMatrix[Zvid0];
Ik2fzccp7=Ikcc2fz[Unuzel,zmat1p7,zmat2p7,zmat0p7]
Abs[Ik2fzccp7]

(*zemni spojeni /1f zkrat*)
Ik1fzccp7=Ikcc1fz[Unuzel,C0,zmat1p7,zmat2p7,zmat0p7]
Abs[Ik1fzccp7]

(*narazovy zkratovy proud*)
ip3fp7=Ip[zmat3fp7,Ik3fccp7]
Abs[ip3fp7]
ip2fp7=Ip[zmat1p7,Ik2fccp7]
Abs[ip2fp7]
ip2fzp7=Ip[zmat1p7,Ik2fzccp7]
Abs[ip2fzp7]
ip1fzp7=Ip[zmat1p7,Ik1fzccp7]
Abs[ip1fzp7]

(*pripad 8 blok 1 napajeny zaskokove*)
(*pamaretry kabelu a vedeni, ktere nejsou vyse*)
K34={rl-> 0.125,ll-> 0.28mH,l-> 180m};(*240 (mm^2)*)
K45=K78;
K67=K910;
K3bc={rl-> 0.253,ll-> 0.3mH,l-> 250m};(*120 (mm^2)*)
K3sp={rl-> 0.253,ll-> 0.3mH,l-> 250m};(*120 (mm^2)*)
K38={rl-> 0.164,ll-> 0.29mH,l-> 170m};(*185 (mm^2)*)
K311={rl-> 0.164,ll-> 0.29mH,l-> 170m};(*185 (mm^2)*)
K910={rl-> 0.32,ll->0.31 mH,l-> 20m};(*95 (mm^2)*)
K1213={rl-> 0.32,ll->0.31 mH,l-> 1000m};(*95 (mm^2)*)
(*doplnit cerpaci stanici a kabel k ni*)
K314={rl-> 0.164,ll-> 0.29mH,l-> 800m};(*185 (mm^2)*)
Kcscbfm={rl-> 0.206,ll->0.29 mH,l-> 120m};(*150 (mm^2)*)
Kcst52={rl-> 0.206,ll->0.29 mH,l-> 50m};(*150 (mm^2)*)
Kcs04={rl-> 0.32,ll->0.31 mH,l-> 100m};(*95 (mm^2)*)
Kcscfm={rl-> 0.197,ll-> 0.933mH,l-> 30m};(*120 (mm^2) kabel N2XSEY*)

K23={rl-> 0.125,ll-> 0.28mH,l-> 180m};(*240 (mm^2)*)
V1r110={n-> 1,r-> 3.98mm,dl12-> 3,dl23-> 3,dl31-> 6,l-> 40m};(*50 (mm^2)*)
(*vypocet impedanci*)
RK34=rl*l/.K34;
XK34=2*Pi*f*ll*l/.K34;
Z34p8=RK34+I*XK34;
Z45p8=Z78p7;
Z67p8=Z910p7;
Z670p8=Z9100p7;
RK3bc=rl*l/.K3bc;
XK3bc=2*Pi*f*ll*l/.K3bc;
Z3bc=RK3bc+I*XK3bc;
RK3sp=rl*l/.K3sp;
XK3sp=2*Pi*f*ll*l/.K3sp;
Z3sp=RK3sp+I*XK3sp;
RK38=rl*l/.K38;
XK38=2*Pi*f*ll*l/.K38;
Z38p8=RK38+I*XK38;
Z311p8=Z38p8;
RK910=rl*l/.K910;
XK910=2*Pi*f*ll*l/.K910;
Z910p8=RK910+I*XK910;
XK9100=3*XK910;
Z9100p8=RK910+I*XK9100;
RK1213=rl*l/.K1213;
XK1213=2*Pi*f*ll*l/.K1213;
Z1213p8=RK1213+I*XK1213;
XK12130=3*XK1213;
Z12130p8=RK1213+I*XK12130;
(*cerpaci stanici a kabel k ni*)
RK314=rl*l/.K314;
XK314=2*Pi*f*ll*l/.K314;
Z314p8=(1/2)(RK314+I*XK314);
RKcscbfm=rl*l/.Kcscbfm;
XKcscbfm=2*Pi*f*ll*l/.Kcscbfm;
Zcscbfm=RKcscbfm+I*XKcscbfm;
RKcscfm=rl*l/.Kcscfm;
XKcscfm=2*Pi*f*ll*l/.Kcscfm;
Zcscfm=RKcscfm+I*XKcscfm;
RKcst52=rl*l/.Kcst52;
XKcst52=2*Pi*f*ll*l/.Kcst52;
Zcst52=RKcst52+I*XKcst52;
RKcs04=rl*l/.Kcs04;
XKcs04=2*Pi*f*ll*l/.Kcs04;
Zcs04=RKcs04+I*XKcs04;

Zcs3f=(1/((1/(Zeqcs+Zt52+Zcs04+Zcst52))+(1/(Zfm+Zcscfm))+(1/(Zbfm+Zcscbfm))));
Zcs=(1/((1/(Zeqcs+Zt52+Zcs04+Zcst52))+(1/(Zfm+Zcscfm))));
RK23=rl*l/.K23;
XK23=2*Pi*f*ll*l/.K23;
Z23p8=RK23+I*XK23;

d1r110=((dl12*dl23*dl31)^(1/3))/.V1r110;
XV1r110=l*(10^(-3))*f*µ0*((1/(4*n))+Log[(dl23/r)])/.V1r110;
Z1r110p8=I*XV1r110;
X1r1100=3*XV1r110;
Z1r1100p8=I*X1r1100;
Zr60=(1/((2/(Zspl+Z3bc))+(2/(Zbg+Z3sp))));
(*Zapojeni soustavy*)
uzel1={1,2,3,3,3,3,4,5,6,8,9,11,12};
uzel2={2,3,4,8,11,14,5,6,7,9,10,12,13};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt21,Z23p8,Z34p8,Z38p8,Z311p8,Z314p8,Z45p8,Zt31,Z67p8,Zt50,Z910p8,Zt44,Z1213p8};
(*Vektor prevodu*)
T={1/p//.T21,1,1,1,1,1,1,1/p//.T31,1,1/p//.T50,1,1/p//.T44,1};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/(Zr110+Z1r110p8)),0,(1/Zr60),(1/Zvs63f),0,0,(1/Zeq),0,0,(1/Zeq040),0,0,(1/Zeqzu),(1/Zcs3f)};
Y={(1/(Zr110+Z1r110p8)),0,(1/Zr60),(1/Zvs6),0,0,(1/Zeq),0,0,(1/Zeq040),0,0,(1/Zeqzu),(1/Zcs)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={Zr110+Z1r1100p8,1*(10^50),1*(10^50),1*(10^50),1*(10^50),Zt31,Zt31+Z670p8,1*(10^50),Zt50,Zt50+Z9100p8,1*(10^50),Zt44,Zt44+Z12130p8,1*(10^50)};
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,6kV,6kV,6kV,6kV,0.4kV,0.4kV,6kV,0.4kV,0.4kV,6kV,0.4kV,0.4kV,6kV};
(*vektor kapacit vuci zemi*)
C0={0,0.1548*(10^(-6)),(2.272+0.1548+0.1548)*(10^(-6)),(0.6126+0.1548)*(10^(-6)),0.04*(10^(-6)),0,0,0.04*(10^(-6)),0,0,0.04*(10^(-6)),0,0,1.41955*(10^(-6))}; (*ma smysl pocitat v uzlech 2,3,4,5,8,11,14*)
(*admitancni a impedancni matice*)
ymat3fp8=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp8//MatrixForm;
ymat1p8=ymat2p8=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp8=Inverse[ymat3fp8];
zmat1p8=zmat2p8=Inverse[ymat1p8];
(*3f zkrat*)
Ik3fccp8=Ikcc3f[Unuzel,zmat3fp8]
Abs[Ik3fccp8]

(*2f zkrat*)
Ik2fccp8=Ikcc2f[Unuzel,zmat1p8,zmat2p8]
Abs[Ik2fccp8]

(*2f zemni zkrat*)
zmat0p8=DiagonalMatrix[Zvid0];
Ik2fzccp8=Ikcc2fz[Unuzel,zmat1p8,zmat2p8,zmat0p8]
Abs[Ik2fzccp8]

(*zemni spojeni /1f zkrat*)
Ik1fzccp8=Ikcc1fz[Unuzel,C0,zmat1p8,zmat2p8,zmat0p8]
Abs[Ik1fzccp8]

(*narazovy zkratovy proud*)
ip3fp8=Ip[zmat3fp8,Ik3fccp8]
Abs[ip3fp8]
ip2fp8=Ip[zmat1p8,Ik2fccp8]
Abs[ip2fp8]
ip2fzp8=Ip[zmat1p8,Ik2fzccp8]
Abs[ip2fzp8]
ip1fzp8=Ip[zmat1p8,Ik1fzccp8]
Abs[ip1fzp8]

(*pripad 9 blok 3 v normalnim stavu*)
(*pamaretry kabelu a vedeni, ktere nejsou vyse !POZOR! očíslování v názvech kabelů a vedení není přesné, aby platilo musí se od každého čísla většího nebo rovnému 4 odečíst 1. Doporučuji kontrolovat s schematem*)
K4vsp={rl-> 0.125,ll-> 0.28mH,l-> 600m};(*240 (mm^2)*)
K45={rl-> 0.125,ll-> 0.28mH,l-> 520m};(*4 kabely 3x240 (mm^2)*)
K4reak={rl-> 0.125,ll-> 0.28mH,l-> 30m};(*240 (mm^2)*)
K67={rl-> 0.125,ll-> 0.28mH,l-> 150m};(*240 (mm^2)*)
Kvspm={rl-> 0.164,ll-> 0.29mH,l-> 170m};(*185 (mm^2)*)
(*odsireni*)
Kodvyv={rl-> 0.206,ll-> 0.29mH,l-> 120m};(*150 (mm^2)*)
Kodoxd={rl-> 0.206,ll-> 0.29mH,l-> 120m};(*150 (mm^2)*)
Kodcabs={rl-> 0.206,ll-> 0.29mH,l-> 170m};(*150 (mm^2)*)
Kod12={rl-> 0.125,ll-> 0.28mH,l-> 10m};(*240 (mm^2)*)
(*impedance*)
RK4vsp=rl*l/.K4vsp;
XK4vsp=2*Pi*f*ll*l/.K4vsp;
Z4vsp=RK4vsp+I*XK4vsp;
RK45=rl*l/.K45;
XK45=2*Pi*f*ll*l/.K45;
Z45=(1/4)*(RK45+I*XK45);
RK4reak=rl*l/.K4reak;
XK4reak=2*Pi*f*ll*l/.K4reak;
Z4reak=RK4reak+I*XK4reak;
RK67=rl*l/.K67;
XK67=2*Pi*f*ll*l/.K67;
Z67=Z611=RK67+I*XK67;
RKvspm=rl*l/.Kvspm;
XKvspm=2*Pi*f*ll*l/.Kvspm;
Zvspm=RKvspm+I*XKvspm;
(*odsireni*)
RKodvyv=rl*l/.Kodvyv;
XKodvyv=2*Pi*f*ll*l/.Kodvyv;
Zodvyv=RKodvyv+I*XKodvyv;
RKodoxd=rl*l/.Kodoxd;
XKodoxd=2*Pi*f*ll*l/.Kodoxd;
Zodoxd=RKodoxd+I*XKodoxd;
RKodcabs=rl*l/.Kodcabs;
XKodcabs=2*Pi*f*ll*l/.Kodcabs;
Zodcabs=RKodcabs+I*XKodcabs;
RKod12=rl*l/.Kod12;
XKod12=2*Pi*f*ll*l/.Kod12;
Zod12=RKod12+I*XKod12;
Zods=(1/((1/(Zvyv+Zodvyv))+(1/(Zoxidmych1+Zodoxd))+(2/(Zoxidmych2+Zodoxd))+(1/(Zcabs1+Zodcabs))+(1/(Zod12 +(1/(2/(Zcabs2+Zodcabs)))))));
(*Zapojeni soustavy*)
uzel1={1,18,18,3,3,5,6,7,8,5,10,10,10,11,12,14,15};
uzel2={18,2,3,4,5,6,7,8,9,10,11,14,17,12,13,15,16};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt3A,Zt3B,Zt3C,Z45,Zreak+Z4reak,Z67,Z78p7,Zt33,Z910p7,Z611,Z38p8,Z311p8,Z314p8,Zt50,Z910p8,Zt44,Z1213p8};
(*Vektor prevodu*)
T={(U1/U2)/.T3,1,(U2/U3)/.T3,1,1,1,1,1/p//.T33,1,1,1,1,1,1/p//.T50,1,1/p//.T44,1};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/(Zr110+Z12p7)),(1/Zg3),(1/((1/(5/(Zvsp+Zvspm)))+Z4vsp)),(1/Zods),0,(1/Zvs63f),0,0,(1/Zeq043),(1/Zr60),0,0,(1/Zeq040),0,0,(1/Zeqzu),(1/Zcs3f),0};
Y={(1/(Zr110+Z12p7)),(1/Zg3),(1/((1/(5/(Zvsp+Zvspm)))+Z4vsp)),(1/Zods),0,(1/Zvs6),0,0,(1/Zeq043),(1/Zr60),0,0,(1/Zeq040),0,0,(1/Zeqzu),(1/Zcs),0};
(*vektor videnych impedanci netocive slozky*)
Zvid0={(1/((1/(Zr110+Z120p7))+(1/Zt3A))),1*(10^50),1*(10^50),1*(10^50),1*(10^50),1*(10^50),1*(10^50),Zt33,Zt33+Z9100p7,1*(10^50),1*(10^50),Zt50,Zt50+Z9100p8,1*(10^50),Zt44,Zt44+Z12130p8,1*(10^50),Z12p7+Zt3A+Zr110};
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,10.5kV,6kV,6kV,6kV,6kV,6kV,0.4kV,0.4kV,6kV,6kV,0.4kV,0.4kV,6kV,0.4kV,0.4kV,6kV,10.5kV};
(*vektor kapacit vuci zemi*)
C0={0,0,2.2172*(10^(-6)),1.7888*(10^(-6)),2*0.129*(10^(-6)),(0.6126+0.129)*(10^(-6)),0.04*(10^(-6)),0,0,(2.272+0.129)*(10^(-6)),0.04*(10^(-6)),0,0,0.04*(10^(-6)),0,0,1.28*(10^(-6)),0}; (*ma smysl pocitat v uzlech 2,3,4,5,6,7,10,11,14,17 z toho v uzlu 2 nemuzeme pocitat z duvodu zanedbani pretahu*)
(*admitancni a impedancni matice*)
ymat3fp9=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp9//MatrixForm;
ymat1p9=ymat2p9=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp9=Inverse[ymat3fp9];
zmat1p9=zmat2p9=Inverse[ymat1p9];
(*3f zkrat*)
Ik3fccp9=Ikcc3f[Unuzel,zmat3fp9]
Abs[Ik3fccp9]

(*2f zkrat*)
Ik2fccp9=Ikcc2f[Unuzel,zmat1p9,zmat2p9]
Abs[Ik2fccp9]

(*2f zemni zkrat*)
zmat0p9=DiagonalMatrix[Zvid0];
Ik2fzccp9=Ikcc2fz[Unuzel,zmat1p9,zmat2p9,zmat0p9]
Abs[Ik2fzccp9]

(*zemni spojeni /1f zkrat*)
Ik1fzccp9=Ikcc1fz[Unuzel,C0,zmat1p9,zmat2p9,zmat0p9]
Abs[Ik1fzccp9]

(*narazovy zkratovy proud*)
ip3fp9=Ip[zmat3fp9,Ik3fccp9]
Abs[ip3fp9]
ip2fp9=Ip[zmat1p9,Ik2fccp9]
Abs[ip2fp9]
ip2fzp9=Ip[zmat1p9,Ik2fzccp9]
Abs[ip2fzp9]
ip1fzp9=Ip[zmat1p9,Ik1fzccp9]
Abs[ip1fzp9]

(*pripad 10 blok 3 v zaskokovem stavu*)
(*pamaretry kabelu a vedeni, ktere nejsou vyse*)
(*vypocet impedanci*)
(*Zapojeni soustavy*)
uzel1={1,2,3,3,3,3,4,5,6,8,9,11,12};
uzel2={2,3,4,8,11,14,5,6,7,9,10,12,13};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt21,Z23p8,Z34p8,Z38p8,Z311p8,Z314p8,Z45p8,Zt33,Z67p8,Zt50,Z910p8,Zt44,Z1213p8};
(*Vektor prevodu*)
T={1/p//.T21,1,1,1,1,1,1,1/p//.T33,1,1/p//.T50,1,1/p//.T44,1};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/(Zr110+Z1r110p8)),0,(1/Zr60),(1/Zvs63f),0,0,(1/Zeq043),0,0,(1/Zeq040),0,0,(1/Zeqzu),(1/Zcs3f)};
Y={(1/(Zr110+Z1r110p8)),0,(1/Zr60),(1/Zvs6),0,0,(1/Zeq043),0,0,(1/Zeq040),0,0,(1/Zeqzu),(1/Zcs)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={Zr110+Z1r1100p8,1*(10^50),1*(10^50),1*(10^50),1*(10^50),Zt33,Zt33+Z670p8,1*(10^50),Zt50,Zt50+Z9100p8,1*(10^50),Zt44,Zt44+Z12130p8,1*(10^50)};
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,6kV,6kV,6kV,6kV,0.4kV,0.4kV,6kV,0.4kV,0.4kV,6kV,0.4kV,0.4kV,6kV};
(*vektor kapacit vuci zemi*)
C0={0,0.1548*(10^(-6)),(2.272+0.1548+0.1548)*(10^(-6)),(0.6126+0.1548)*(10^(-6)),0.04*(10^(-6)),0,0,0.04*(10^(-6)),0,0,0.04*(10^(-6)),0,0,1.28*(10^(-6))}; (*ma smysl pocitat v uzlech 2,3,4,5,8,11,14*)
(*admitancni a impedancni matice*)
ymat3fp10=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp10//MatrixForm;
ymat1p10=ymat2p10=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp10=Inverse[ymat3fp10];
zmat1p10=zmat2p10=Inverse[ymat1p10];
(*3f zkrat*)
Ik3fccp10=Ikcc3f[Unuzel,zmat3fp10]
Abs[Ik3fccp10]

(*2f zkrat*)
Ik2fccp10=Ikcc2f[Unuzel,zmat1p10,zmat2p10]
Abs[Ik2fccp10]

(*2f zemni zkrat*)
zmat0p10=DiagonalMatrix[Zvid0];
Ik2fzccp10=Ikcc2fz[Unuzel,zmat1p10,zmat2p10,zmat0p10]
Abs[Ik2fzccp10]

(*zemni spojeni /1f zkrat*)
Ik1fzccp10=Ikcc1fz[Unuzel,C0,zmat1p10,zmat2p10,zmat0p10]
Abs[Ik1fzccp10]

(*narazovy zkratovy proud*)
ip3fp10=Ip[zmat3fp10,Ik3fccp10]
Abs[ip3fp10]
ip2fp10=Ip[zmat1p10,Ik2fccp10]
Abs[ip2fp10]
ip2fzp10=Ip[zmat1p10,Ik2fzccp10]
Abs[ip2fzp10]
ip1fzp10=Ip[zmat1p10,Ik1fzccp10]
Abs[ip1fzp10]

(*pripad 11 blok 6 v normalnim stavu*)
(*pamaretry kabelu a vedeni, ktere nejsou vyse*)
(*vypocet impedanci*)
(*Zapojeni soustavy*)
uzel1={1,2,3,4,5,6,7};
uzel2={2,3,4,5,6,7,8};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt6,Z35p7,Zt16,Z67p7,Z78p7,Zt36,Z910p7};
(*Vektor prevodu*)
T={1/p//.T6,1,1/p//.T16,1,1,1/p//.T36,1};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/(Zr110+Z12p7)),0,0,0,(1/Zvs63f),0,0,(1/Zeq046)};
Y={(1/(Zr110+Z12p7)),0,0,0,(1/Zvs6),0,0,(1/Zeq046)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={(1/((1/(Zr110+Z120p7))+(1/Zt6))),1*(10^50),1*(10^50),1*(10^50),1*(10^50),1*(10^50),Zt36,Zt33+Z910p7};
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,10.5kV,10.5kV,6kV,6kV,6kV,0.4kV,0.4kV};
(*vektor kapacit vuci zemi*)
C0={0,0.000288798*(10^(-6)),0.000288798*(10^(-6)),0.10149*(10^(-6)),(0.6126+0.10149)*(10^(-6)),0.04*(10^(-6)),0,0}; (*ma smysl pocitat zemni spojeni pouze v uzlech 2,3, 4, 5, 6*)
(*admitancni a impedancni matice*)
ymat3fp11=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp11//MatrixForm;
ymat1p11=ymat2p11=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp11=Inverse[ymat3fp11];
zmat1p11=zmat2p11=Inverse[ymat1p11];
(*3f zkrat*)
Ik3fccp11=Ikcc3f[Unuzel,zmat3fp11]
Abs[Ik3fccp11]

(*2f zkrat*)
Ik2fccp11=Ikcc2f[Unuzel,zmat1p11,zmat2p11]
Abs[Ik2fccp11]

(*2f zemni zkrat*)
zmat0p11=DiagonalMatrix[Zvid0];
Ik2fzccp11=Ikcc2fz[Unuzel,zmat1p11,zmat2p11,zmat0p11]
Abs[Ik2fzccp11]

(*zemni spojeni /1f zkrat*)
Ik1fzccp11=Ikcc1fz[Unuzel,C0,zmat1p11,zmat2p11,zmat0p11]
Abs[Ik1fzccp11]

(*narazovy zkratovy proud*)
ip3fp11=Ip[zmat3fp11,Ik3fccp11]
Abs[ip3fp11]
ip2fp11=Ip[zmat1p11,Ik2fccp11]
Abs[ip2fp11]
ip2fzp11=Ip[zmat1p11,Ik2fzccp11]
Abs[ip2fzp11]
ip1fzp11=Ip[zmat1p11,Ik1fzccp11]
Abs[ip1fzp11]

(*pripad 12 blok 6 napajeny zaskokove*)
(*pamaretry kabelu a vedeni, ktere nejsou vyse*)
(*vypocet impedanci*)
(*Zapojeni soustavy*)
uzel1={1,2,3,3,3,3,4,5,6,8,9,11,12};
uzel2={2,3,4,8,11,14,5,6,7,9,10,12,13};
(*Vektor meziuzlovych impedanci*)
Zkm={Zt21,Z23p8,Z34p8,Z38p8,Z311p8,Z314p8,Z45p8,Zt36,Z67p8,Zt50,Z910p8,Zt44,Z1213p8};
(*Vektor prevodu*)
T={1/p//.T21,1,1,1,1,1,1,1/p//.T36,1,1/p//.T50,1,1/p//.T44,1};
(*vektor uzlových admitancí (admitance proti zemi)*)
Y3f={(1/(Zr110+Z1r110p8)),0,(1/Zr60),(1/Zvs63f),0,0,(1/Zeq046),0,0,(1/Zeq040),0,0,(1/Zeqzu),(1/Zcs3f)};
Y={(1/(Zr110+Z1r110p8)),0,(1/Zr60),(1/Zvs6),0,0,(1/Zeq046),0,0,(1/Zeq040),0,0,(1/Zeqzu),(1/Zcs)};
(*vektor videnych impedanci netocive slozky*)
Zvid0={Zr110+Z1r1100p8,1*(10^50),1*(10^50),1*(10^50),1*(10^50),Zt33,Zt33+Z670p8,1*(10^50),Zt50,Zt50+Z9100p8,1*(10^50),Zt44,Zt44+Z12130p8,1*(10^50)};
(*vektor jmenovitych napeti uzlu*)
Unuzel={110kV,6kV,6kV,6kV,6kV,0.4kV,0.4kV,6kV,0.4kV,0.4kV,6kV,0.4kV,0.4kV,6kV};
(*vektor kapacit vuci zemi*)
C0={0,0.1548*(10^(-6)),(2.272+0.1548+0.1548)*(10^(-6)),(0.6126+0.1548)*(10^(-6)),0.04*(10^(-6)),0,0,0.04*(10^(-6)),0,0,0.04*(10^(-6)),0,0,1.28*(10^(-6))}; (*ma smysl pocitat v uzlech 2,3,4,5,8,11,14*)
(*admitancni a impedancni matice*)
ymat3fp12=Ymatice[uzel1,uzel2,Zkm,Y3f,T]; (*pro trojfazovy zkrat*)
ymat3fp12//MatrixForm;
ymat1p12=ymat2p12=Ymatice[uzel1,uzel2,Zkm,Y,T];
zmat3fp12=Inverse[ymat3fp12];
zmat1p12=zmat2p12=Inverse[ymat1p12];
(*3f zkrat*)
Ik3fccp12=Ikcc3f[Unuzel,zmat3fp12]
Abs[Ik3fccp12]

(*2f zkrat*)
Ik2fccp12=Ikcc2f[Unuzel,zmat1p12,zmat2p12]
Abs[Ik2fccp12]

(*2f zemni zkrat*)
zmat0p12=DiagonalMatrix[Zvid0];
Ik2fzccp12=Ikcc2fz[Unuzel,zmat1p12,zmat2p12,zmat0p12]
Abs[Ik2fzccp12]

(*zemni spojeni /1f zkrat*)
Ik1fzccp12=Ikcc1fz[Unuzel,C0,zmat1p12,zmat2p12,zmat0p12]
Abs[Ik1fzccp12]

ip3fp12=Ip[zmat3fp12,Ik3fccp12]
Abs[ip3fp12]
ip2fp12=Ip[zmat1p12,Ik2fccp12]
Abs[ip2fp12]
ip2fzp12=Ip[zmat1p12,Ik2fzccp12]
Abs[ip2fzp12]
ip1fzp12=Ip[zmat1p12,Ik1fzccp12]
Abs[ip1fzp12]

ymat3f//MatrixForm
ymat1//MatrixForm
zmat0//MatrixForm
zmat1//MatrixForm
zmat3f//MatrixForm

ymat3fp2//MatrixForm
ymat1p2//MatrixForm
zmat0p2//MatrixForm
zmat1p2//MatrixForm
zmat3fp2//MatrixForm

ymat3fp3//MatrixForm
ymat1p3//MatrixForm
zmat0p3//MatrixForm
zmat1p3//MatrixForm
zmat3fp3//MatrixForm

ymat3fp4//MatrixForm
ymat1p4//MatrixForm
zmat0p4//MatrixForm
zmat3fp4//MatrixForm
zmat1p4//MatrixForm

ymat3fp5//MatrixForm
ymat1p5//MatrixForm
zmat0p5//MatrixForm
zmat3fp5//MatrixForm
zmat1p5//MatrixForm

ymat3fp6//MatrixForm
ymat1p6//MatrixForm
zmat0p6//MatrixForm
zmat3fp6//MatrixForm
zmat1p6//MatrixForm

(*vypocet rozdilu velikosti zkratoveho proudu pro pripad s a bez zanedbani spoju*)
(*Pripad 1 a 7*)
{Abs[((Ik3fcc[[1]])/(Ik3fccp7[[2]]))]*100,Abs[((Ik3fcc[[2]])/(Ik3fccp7[[3]]))]*100,Abs[((Ik3fcc[[3]])/(Ik3fccp7[[7]]))]*100,Abs[((Ik3fcc[[4]])/(Ik3fccp7[[9]]))]*100}
{Abs[((Ik2fcc[[1]])/(Ik2fccp7[[2]]))]*100,Abs[((Ik2fcc[[2]])/(Ik2fccp7[[3]]))]*100,Abs[((Ik2fcc[[3]])/(Ik2fccp7[[7]]))]*100,Abs[((Ik2fcc[[4]])/(Ik2fccp7[[9]]))]*100}
{Abs[((Ik2fzcc[[1]])/(Ik2fzccp7[[2]]))]*100,Abs[((Ik2fzcc[[2]])/(Ik2fzccp7[[3]]))]*100,Abs[((Ik2fzcc[[3]])/(Ik2fzccp7[[7]]))]*100,Abs[((Ik2fzcc[[4]])/(Ik2fzccp7[[9]]))]*100}
{Abs[((Ik1fzcc[[1]])/(Ik1fzccp7[[2]]))]*100,Abs[((Ik1fzcc[[2]])/(Ik1fzccp7[[3]]))]*100,Abs[((Ik1fzcc[[3]])/(Ik1fzccp7[[7]]))]*100,Abs[((Ik1fzcc[[4]])/(Ik1fzccp7[[9]]))]*100}

(*Pripad 2 a 8*)
{Abs[((Ik3fccp2[[1]])/(Ik3fccp8[[1]]))]*100,Abs[((Ik3fccp2[[2]])/(Ik3fccp8[[3]]))]*100,Abs[((Ik3fccp2[[2]])/(Ik3fccp8[[4]]))]*100,Abs[((Ik3fccp2[[3]])/(Ik3fccp8[[6]]))]*100,Abs[((Ik3fccp2[[4]])/(Ik3fccp8[[9]]))]*100,Abs[((Ik3fccp2[[5]])/(Ik3fccp8[[12]]))]*100}
{Abs[((Ik2fccp2[[1]])/(Ik2fccp8[[1]]))]*100,Abs[((Ik2fccp2[[2]])/(Ik2fccp8[[3]]))]*100,Abs[((Ik2fccp2[[2]])/(Ik2fccp8[[4]]))]*100,Abs[((Ik2fccp2[[3]])/(Ik2fccp8[[6]]))]*100,Abs[((Ik2fccp2[[4]])/(Ik2fccp8[[9]]))]*100,Abs[((Ik2fccp2[[5]])/(Ik2fccp8[[12]]))]*100}
{Abs[((Ik2fzccp2[[1]])/(Ik2fzccp8[[1]]))]*100,Abs[((Ik2fzccp2[[2]])/(Ik2fzccp8[[3]]))]*100,Abs[((Ik2fzccp2[[2]])/(Ik2fzccp8[[4]]))]*100,Abs[((Ik2fzccp2[[3]])/(Ik2fzccp8[[6]]))]*100,Abs[((Ik2fzccp2[[4]])/(Ik2fzccp8[[9]]))]*100,Abs[((Ik2fzccp2[[5]])/(Ik2fzccp8[[12]]))]*100}
{Abs[((Ik1fzccp2[[1]])/(Ik1fzccp8[[1]]))]*100,Abs[((Ik1fzccp2[[2]])/(Ik1fzccp8[[3]]))]*100,Abs[((Ik1fzccp2[[2]])/(Ik1fzccp8[[4]]))]*100,Abs[((Ik1fzccp2[[3]])/(Ik1fzccp8[[6]]))]*100,Abs[((Ik1fzccp2[[4]])/(Ik1fzccp8[[9]]))]*100,Abs[((Ik1fzccp2[[5]])/(Ik1fzccp8[[12]]))]*100}(*v uzlu 2/4 neni pomer presny, kapacita k zemi je brana k jako v uzlu 3 pripadu 8*)

(*Pripad 3 a 9*)
{Abs[((Ik3fccp3[[1]])/(Ik3fccp9[[1]]))]*100,Abs[((Ik3fccp3[[2]])/(Ik3fccp9[[2]]))]*100,Abs[((Ik3fccp3[[3]])/(Ik3fccp9[[3]]))]*100,Abs[((Ik3fccp3[[4]])/(Ik3fccp9[[6]]))]*100,Abs[((Ik3fccp3[[4]])/(Ik3fccp9[[10]]))]*100,Abs[((Ik3fccp3[[5]])/(Ik3fccp9[[8]]))]*100,Abs[((Ik3fccp3[[6]])/(Ik3fccp9[[12]]))]*100,Abs[((Ik3fccp3[[7]])/(Ik3fccp9[[15]]))]*100}
{Abs[((Ik2fccp3[[1]])/(Ik2fccp9[[1]]))]*100,Abs[((Ik2fccp3[[2]])/(Ik2fccp9[[2]]))]*100,Abs[((Ik2fccp3[[3]])/(Ik2fccp9[[3]]))]*100,Abs[((Ik2fccp3[[4]])/(Ik2fccp9[[6]]))]*100,Abs[((Ik2fccp3[[4]])/(Ik2fccp9[[10]]))]*100,Abs[((Ik2fccp3[[5]])/(Ik2fccp9[[8]]))]*100,Abs[((Ik2fccp3[[6]])/(Ik2fccp9[[12]]))]*100,Abs[((Ik2fccp3[[7]])/(Ik2fccp9[[15]]))]*100}
{Abs[((Ik2fzccp3[[1]])/(Ik2fzccp9[[1]]))]*100,Abs[((Ik2fzccp3[[2]])/(Ik2fzccp9[[2]]))]*100,Abs[((Ik2fzccp3[[3]])/(Ik2fzccp9[[3]]))]*100,Abs[((Ik2fzccp3[[4]])/(Ik2fzccp9[[6]]))]*100,Abs[((Ik2fzccp3[[4]])/(Ik2fzccp9[[10]]))]*100,Abs[((Ik2fzccp3[[5]])/(Ik2fzccp9[[8]]))]*100,Abs[((Ik2fzccp3[[6]])/(Ik2fzccp9[[12]]))]*100,Abs[((Ik2fzccp3[[7]])/(Ik2fzccp9[[15]]))]*100}
{Abs[((Ik1fzccp3[[1]])/(Ik1fzccp9[[1]]))]*100,Abs[((Ik1fzccp3[[2]])/(Ik1fzccp9[[2]]))]*100,Abs[((Ik1fzccp3[[3]])/(Ik1fzccp9[[3]]))]*100,Abs[((Ik1fzccp3[[4]])/(Ik1fzccp9[[6]]))]*100,Abs[((Ik1fzccp3[[4]])/(Ik1fzccp9[[10]]))]*100,Abs[((Ik1fzccp3[[5]])/(Ik1fzccp9[[8]]))]*100,Abs[((Ik1fzccp3[[6]])/(Ik1fzccp9[[12]]))]*100,Abs[((Ik1fzccp3[[7]])/(Ik1fzccp9[[15]]))]*100}(*v uzlu 4/6 neni pomer presny, kapacita k zemi je brana k jako v uzlu 10 pripadu 9*)

(*Pripad 4 a 10*)
{Abs[((Ik3fccp4[[1]])/(Ik3fccp10[[1]]))]*100,Abs[((Ik3fccp4[[2]])/(Ik3fccp10[[3]]))]*100,Abs[((Ik3fccp4[[2]])/(Ik3fccp10[[4]]))]*100,Abs[((Ik3fccp4[[3]])/(Ik3fccp10[[6]]))]*100,Abs[((Ik3fccp4[[4]])/(Ik3fccp10[[9]]))]*100,Abs[((Ik3fccp4[[5]])/(Ik3fccp10[[12]]))]*100}
{Abs[((Ik2fccp4[[1]])/(Ik2fccp10[[1]]))]*100,Abs[((Ik2fccp4[[2]])/(Ik2fccp10[[3]]))]*100,Abs[((Ik2fccp4[[2]])/(Ik2fccp10[[4]]))]*100,Abs[((Ik2fccp4[[3]])/(Ik2fccp10[[6]]))]*100,Abs[((Ik2fccp4[[4]])/(Ik2fccp10[[9]]))]*100,Abs[((Ik2fccp4[[5]])/(Ik2fccp10[[12]]))]*100}
{Abs[((Ik2fzccp4[[1]])/(Ik2fzccp10[[1]]))]*100,Abs[((Ik2fzccp4[[2]])/(Ik2fzccp10[[3]]))]*100,Abs[((Ik2fzccp4[[2]])/(Ik2fzccp10[[4]]))]*100,Abs[((Ik2fzccp4[[3]])/(Ik2fzccp10[[6]]))]*100,Abs[((Ik2fzccp4[[4]])/(Ik2fzccp10[[9]]))]*100,Abs[((Ik2fzccp4[[5]])/(Ik2fzccp10[[12]]))]*100}
{Abs[((Ik1fzccp4[[1]])/(Ik1fzccp10[[1]]))]*100,Abs[((Ik1fzccp4[[2]])/(Ik1fzccp10[[3]]))]*100,Abs[((Ik1fzccp4[[2]])/(Ik1fzccp10[[4]]))]*100,Abs[((Ik1fzccp4[[3]])/(Ik1fzccp10[[6]]))]*100,Abs[((Ik1fzccp4[[4]])/(Ik1fzccp10[[9]]))]*100,Abs[((Ik1fzccp4[[5]])/(Ik1fzccp10[[12]]))]*100}(*v uzlu 2/4 neni pomer presny, kapacita k zemi je brana k jako v uzlu 3 pripadu 10*)

(*Pripad 5 a 11*)
{Abs[((Ik3fccp5[[1]])/(Ik3fccp11[[1]]))]*100,Abs[((Ik3fccp5[[2]])/(Ik3fccp11[[2]]))]*100,Abs[((Ik3fccp5[[3]])/(Ik3fccp11[[5]]))]*100,Abs[((Ik3fccp5[[4]])/(Ik3fccp11[[7]]))]*100}
{Abs[((Ik2fccp5[[1]])/(Ik2fccp11[[1]]))]*100,Abs[((Ik2fccp5[[2]])/(Ik2fccp11[[2]]))]*100,Abs[((Ik2fccp5[[3]])/(Ik2fccp11[[5]]))]*100,Abs[((Ik2fccp5[[4]])/(Ik2fccp11[[7]]))]*100}
{Abs[((Ik2fzccp5[[1]])/(Ik2fzccp11[[1]]))]*100,Abs[((Ik2fzccp5[[2]])/(Ik2fzccp11[[2]]))]*100,Abs[((Ik2fzccp5[[3]])/(Ik2fzccp11[[5]]))]*100,Abs[((Ik2fzccp5[[4]])/(Ik2fzccp11[[7]]))]*100}
{Abs[((Ik1fzccp5[[1]])/(Ik1fzccp11[[1]]))]*100,Abs[((Ik1fzccp5[[2]])/(Ik1fzccp11[[2]]))]*100,Abs[((Ik1fzccp5[[3]])/(Ik1fzccp11[[5]]))]*100,Abs[((Ik1fzccp5[[4]])/(Ik1fzccp11[[7]]))]*100}

(*Pripad 6 a 12*)
{Abs[((Ik3fccp6[[1]])/(Ik3fccp12[[1]]))]*100,Abs[((Ik3fccp6[[2]])/(Ik3fccp12[[3]]))]*100,Abs[((Ik3fccp6[[2]])/(Ik3fccp12[[4]]))]*100,Abs[((Ik3fccp6[[3]])/(Ik3fccp12[[6]]))]*100,Abs[((Ik3fccp6[[4]])/(Ik3fccp12[[9]]))]*100,Abs[((Ik3fccp6[[5]])/(Ik3fccp12[[12]]))]*100}
{Abs[((Ik2fccp6[[1]])/(Ik2fccp12[[1]]))]*100,Abs[((Ik2fccp6[[2]])/(Ik2fccp12[[3]]))]*100,Abs[((Ik2fccp6[[2]])/(Ik2fccp12[[4]]))]*100,Abs[((Ik2fccp6[[3]])/(Ik2fccp12[[6]]))]*100,Abs[((Ik2fccp6[[4]])/(Ik2fccp12[[9]]))]*100,Abs[((Ik2fccp6[[5]])/(Ik2fccp12[[12]]))]*100}
{Abs[((Ik2fzccp6[[1]])/(Ik2fzccp12[[1]]))]*100,Abs[((Ik2fzccp6[[2]])/(Ik2fzccp12[[3]]))]*100,Abs[((Ik2fzccp6[[2]])/(Ik2fzccp12[[4]]))]*100,Abs[((Ik2fzccp6[[3]])/(Ik2fzccp12[[6]]))]*100,Abs[((Ik2fzccp6[[4]])/(Ik2fzccp12[[9]]))]*100,Abs[((Ik2fzccp6[[5]])/(Ik2fzccp12[[12]]))]*100}
{Abs[((Ik1fzccp6[[1]])/(Ik1fzccp12[[1]]))]*100,Abs[((Ik1fzccp6[[2]])/(Ik1fzccp12[[3]]))]*100,Abs[((Ik1fzccp6[[2]])/(Ik1fzccp12[[4]]))]*100,Abs[((Ik1fzccp6[[3]])/(Ik1fzccp12[[6]]))]*100,Abs[((Ik1fzccp6[[4]])/(Ik1fzccp12[[9]]))]*100,Abs[((Ik1fzccp6[[5]])/(Ik1fzccp12[[12]]))]*100}(*v uzlu 2/4 neni pomer presny, kapacita k zemi je brana k jako v uzlu 3 pripadu 12*)