ClearAll["Global`*"]

Ymatice[uzel1_,uzel2_,Z_,Y_,T_]:=(
(*tělo metody bylo odstraněno*)
);
redukce[m_,vekt_]:=Module[{proudy,poziceProudu,iterator,napeti,vekYU,poziceUg,poziceUz,rovnice,
vysledky,koef,matice},
(*vektor proudu*)
proudy=ConstantArray[0,Length@vekt];
poziceProudu=Position[vekt,Select[vekt,#≠0&][[1]]]/.{x_}->x;
iterator={ii,poziceProudu};
Table[proudy[[ii]]=(Subscript[Ig, ii]),Evaluate[iterator]];
(*vektor napeti*)
napeti=Table[(Subscript[Uz, ii]),{ii,1,Length@vekt}];
Table[napeti[[ii]]=(Subscript[Ug, ii]),Evaluate[iterator]];
(*vypocet*)
vekYU=m.napeti;
poziceUg=Position[Map[FreeQ[#,Uz]&,napeti],True]/.{x_}->x;
poziceUz=Position[Map[FreeQ[#,Ug]&,napeti],True]/.{x_}->x;
rovnice=Table[proudy[[i]]==vekYU[[i]],{i,1,Length@proudy}]/.List->And;
vysledky=Solve[rovnice,proudy[[poziceProudu]],napeti[[poziceUz]]]/.Rule->Equal;
koef=CoefficientArrays[vysledky[[1]],napeti[[poziceUg]]];
matice=-Normal[koef];
matice[[2]]//FullSimplify
];
napetiAproudy[indexy_,m_]:=Module[{proudy=indexy,vysledkyI,napeti},
vysledkyI=redukce[m,proudy].ConstantArray[U,proudy/.List->Plus]//FullSimplify;
pozice=Position[proudy,1]/.{x_}->x;
proudy[[pozice]]=vysledkyI;
napeti=Inverse[m].proudy//FullSimplify;
{proudy,napeti}
]

;

Ymat=Ymatice[
{1,2,3,4,4,7,8,9,5},
{2,3,4,7,5,8,9,10,6},
{Z12,Z23,Z34,Z47,Z45,Z78,Z89,Z910,Z56},
{0,0,0,0,0,0,(1/Zp),0,0,0},
{1,1,1,1,1,1,1,1,1}];
%//MatrixForm

indexy={1,0,0,0,0,1,0,0,0,1};
red=redukce[Ymat,indexy]//FullSimplify;

proudy=napetiAproudy[indexy,Ymat][[1]];
napeti=napetiAproudy[indexy,Ymat][[2]];

napeti/.{Zp->0}//MatrixForm

MVA=(10.^6);
kV=kVA=km=(10.^3);
(*vstupni data*)
Uv=22kV;
sit={Us->115kV,Sks->1000MVA};
gen={Sgn->5MVA,Ug->10.5kV,xd->0.15,CosFi->0.8};
trafo1={Ut1->115kV,Ut2->22kV,uk->0.1,St->10MVA,Pk->400kVA};
trafo23={Ut1->6.3kV,Ut2->22kV,uk->0.1,St->5MVA,Pk->200kVA};
vedeni123={lv->0.5(*km*),Rv->0.125,Xv->0.407};
motor={Sn->3MVA,Un->6.3kV,iz->7,ucin->0.85,RX->0.15};

(*vypocet*)
(*sit*)
Z12=Zs=((Us^2)/Sks)*((((Uv/Us)))^2)/.sit
(*G1*)
Z56=Zg=xd*((Ugn^2)/(Sgn*CosFi+I*Sgn*Sin[ArcCos[CosFi]]))*((((Uv/Ugn)))^2)/.gen
(*trafa*)
Z23=Zt1=(Pk/St)*((Ut2^2)/St)+I*(Sqrt[(((uk*((Ut2^2)/St)))^2)-((((Pk/St)*((Ut2^2)/St)))^2)])/.trafo1
Z45=Z89=Zt2=Zt3=(Pk/St)*((Ut2^2)/St)+I*(Sqrt[(((uk*((Ut2^2)/St)))^2)-((((Pk/St)*((Ut2^2)/St)))^2)])/.trafo23
(*vedeni*)
Z34=Z47=Z78=Zv1=Zv2=Zv3=lv*(Rv+I*Xv)/.vedeni123
(*motor*)
Z910=Zm=(1/iz)*((Un^2)/Sn)*ucin*((1/(Sqrt[1+(1/(RX^2))]))+I*(1/(Sqrt[1+(RX^2)])))*((((Uv/Un)))^2)/.motor

napeti/.{Zp->0,U->22kV}//MatrixForm

I47=((napeti[[4]]-napeti[[7]])/Z47)/.{Zp->0,U->22kV}//Abs

I37=((napeti[[7]]-napeti[[8]])/Z78)/.{Zp->0,U->22kV}//Abs

((napeti[[4]]-napeti[[7]])/Z47)-((napeti[[7]]-napeti[[8]])/Z78)/.{Zp->0,U->22kV}//Abs