ClearAll["Global`*"]

(*Vypocet kapacity vedeni vuci zemi*)

(*vypocet jednoducheho pretahu k odbockovemu trafu z R6*)
δkk[hk_,rk_]:=(1/0.0242)*Log10[((2*hk*(10^3))/rk)];
δkm[hk_,hm_,dkm_]:=(1/0.0242)*Log10[((Sqrt[4*hk*hm+(dkm^2)])/dkm)];
m=1;
mm=1;
V={r-> 8.74mm,d12-> 3m,d23-> 3m,d13-> 6m, h-> 9m};(*pretah tri vodici ve stejne vysce*)
δmat={{δkk[h,r],δkm[h,h,d12],δkm[h,h,d13]},{δkm[h,h,d12],δkk[h,r],δkm[h,h,d23]},{δkm[h,h,d13],δkm[h,h,d23],δkk[h,r]}}/.V;
δmat//MatrixForm;
cmat=Inverse[δmat];
k10=cmat[[1,1]]+cmat[[1,2]]+cmat[[1,3]];
k20=cmat[[2,1]]+cmat[[2,2]]+cmat[[2,3]];
k30=cmat[[3,1]]+cmat[[3,2]]+cmat[[3,3]];
k12=-cmat[[1,2]];
k13=-cmat[[1,3]];
k23=-cmat[[2,3]];
(*kapacita vedeni v µF/km*)
k0=k10+k20+k30

(*vedeni z odbočkového na blokove trafo, jednoduchy*)
V={r-> 3.98mm,d12-> 1m,d23-> 1m,d13-> 2m, h-> 5m};(*pretah tri vodici ve stejne vysce*)
δmat={{δkk[h,r],δkm[h,h,d12],δkm[h,h,d13]},{δkm[h,h,d12],δkk[h,r],δkm[h,h,d23]},{δkm[h,h,d13],δkm[h,h,d23],δkk[h,r]}}/.V;
δmat//MatrixForm;
cmat=Inverse[δmat];
k10=cmat[[1,1]]+cmat[[1,2]]+cmat[[1,3]];
k20=cmat[[2,1]]+cmat[[2,2]]+cmat[[2,3]];
k30=cmat[[3,1]]+cmat[[3,2]]+cmat[[3,3]];
(*kapacita vedeni vuci zemi v µF/km*)
k0=k10+k20+k30

(*jednoduché vedeni od blokoveho trafa k R110*)
V={r-> 3.98mm,d12-> 3m,d23-> 3m,d31-> 6m,h-> 10m};(*pretah deviti vodici ve stejne vysce*)
δmat={{δkk[h,r],δkm[h,h,d12],δkm[h,h,d31]},{δkm[h,h,d12],δkk[h,r],δkm[h,h,d23]},{δkm[h,h,d31],δkm[h,h,d23],δkk[h,r]}}/.V;
δmat//MatrixForm;
cmat=Inverse[δmat];
k10=cmat[[1,1]]+cmat[[1,2]]+cmat[[1,3]];
k20=cmat[[2,1]]+cmat[[2,2]]+cmat[[2,3]];
k30=cmat[[3,1]]+cmat[[3,2]]+cmat[[3,3]];
(*kapacita vedeni vuci zemi v µF/km*)
k0=k10+k20+k30

(*pretah od generatoru k blokovemu tafu, kazda faze tremi vodici*)
V={r->15.45mm,d12-> 0.01m,d23-> 0.01m,d31-> 0.02m,d14->3m,d45->0.01m,d56->0.01,d46->0.02,d47->3m,d78->0.01,d89->0.01,d79->0.02,h-> 9m};(*pretah deviti vodici ve stejne vysce*)
δmat={{δkk[h,r],δkm[h,h,d12],δkm[h,h,d31],δkm[h,h,d14],δkm[h,h,d14+d45],δkm[h,h,d14+d46],δkm[h,h,d14+d47],δkm[h,h,d14+d47+d78],δkm[h,h,d14+d47+d79]},
{δkm[h,h,d12],δkk[h,r],δkm[h,h,d23],δkm[h,h,d14-d12],δkm[h,h,d14],δkm[h,h,d14+d45],δkm[h,h,d14+d47-d78],δkm[h,h,d14+d47],δkm[h,h,d14+d47+d78]},
{δkm[h,h,d31],δkm[h,h,d23],δkk[h,r],δkm[h,h,d14-d31],δkm[h,h,d14-d12],δkm[h,h,d14],δkm[h,h,d14+d47-d79],δkm[h,h,d14+d47-d89],δkm[h,h,d14+d47]},
{δkm[h,h,d14],δkm[h,h,d14-d12],δkm[h,h,d14-d31],δkk[h,r],δkm[h,h,d45],δkm[h,h,d46],δkm[h,h,d47],δkm[h,h,d47+d78],δkm[h,h,d47+d79]},
{δkm[h,h,d14+d12],δkm[h,h,d14],δkm[h,h,d14-d23],δkm[h,h,d45],δkk[h,r],δkm[h,h,d56],δkm[h,h,d47-d45],δkm[h,h,d47],δkm[h,h,d47+d89]},
{δkm[h,h,d14+d31],δkm[h,h,d14+d23],δkm[h,h,d14],δkm[h,h,d46],δkm[h,h,d56],δkk[h,r],δkm[h,h,d47-d46],δkm[h,h,d47-d56],δkm[h,h,d47]},
{δkm[h,h,d14+d47],δkm[h,h,d14+d47+d12],δkm[h,h,d14+d47-d31],δkm[h,h,d47],δkm[h,h,d47-d45],δkm[h,h,d47-d46],δkk[h,r],δkm[h,h,d78],δkm[h,h,d79]},
{δkm[h,h,d14+d47+d78],δkm[h,h,d14+d47],δkm[h,h,d14+d47-d23],δkm[h,h,d47+d78],δkm[h,h,d47],δkm[h,h,d47-d56],δkm[h,h,d78],δkk[h,r],δkm[h,h,d89]},
{δkm[h,h,d14+d47+d79],δkm[h,h,d14+d47+d89],δkm[h,h,d14+d47],δkm[h,h,d47+d79],δkm[h,h,d47+d89],δkm[h,h,d47],δkm[h,h,d79],δkm[h,h,d89],δkk[h,r]}
}/.V;
δmat//MatrixForm;
cmat=Inverse[δmat];
k10=cmat[[1,1]]+cmat[[1,2]]+cmat[[1,3]]+cmat[[1,4]]+cmat[[1,5]]+cmat[[1,6]]+cmat[[1,7]]+cmat[[1,8]]+cmat[[1,9]];
k20=cmat[[2,1]]+cmat[[2,2]]+cmat[[2,3]]+cmat[[2,4]]+cmat[[2,5]]+cmat[[2,6]]+cmat[[2,7]]+cmat[[2,8]]+cmat[[2,9]];
k30=cmat[[3,1]]+cmat[[3,2]]+cmat[[3,3]]+cmat[[3,4]]+cmat[[3,5]]+cmat[[3,6]]+cmat[[3,7]]+cmat[[3,8]]+cmat[[3,9]];
k40=cmat[[4,1]]+cmat[[4,2]]+cmat[[4,3]]+cmat[[4,4]]+cmat[[4,5]]+cmat[[4,6]]+cmat[[4,7]]+cmat[[4,8]]+cmat[[4,9]];
k50=cmat[[5,1]]+cmat[[5,2]]+cmat[[5,3]]+cmat[[5,4]]+cmat[[5,5]]+cmat[[5,6]]+cmat[[5,7]]+cmat[[5,8]]+cmat[[5,9]];
k60=cmat[[6,1]]+cmat[[6,2]]+cmat[[6,3]]+cmat[[6,4]]+cmat[[6,5]]+cmat[[6,6]]+cmat[[6,7]]+cmat[[6,8]]+cmat[[6,9]];
k70=cmat[[7,1]]+cmat[[7,2]]+cmat[[7,3]]+cmat[[7,4]]+cmat[[7,5]]+cmat[[7,6]]+cmat[[7,7]]+cmat[[7,8]]+cmat[[7,9]];
k80=cmat[[8,1]]+cmat[[8,2]]+cmat[[8,3]]+cmat[[8,4]]+cmat[[8,5]]+cmat[[8,6]]+cmat[[8,7]]+cmat[[8,8]]+cmat[[8,9]];
k90=cmat[[9,1]]+cmat[[9,2]]+cmat[[9,3]]+cmat[[9,4]]+cmat[[9,5]]+cmat[[9,6]]+cmat[[9,7]]+cmat[[9,8]]+cmat[[9,9]];
(*kapacita vedeni vuci zemi v µF/km*)
k0=k10+k20+k30+k40+k50+k60+k70+k80+k90