Off[General::"newpkg",General::"obspkg"]

<<Calculus`VectorAnalysis`;
Off[General::"spell1"];
<<Miscellaneous`PhysicalConstants`
<<Miscellaneous`ChemicalElements`

SetCoordinates[Cartesian[x,y,z]];

VacuumPermittivity

EVektor={Ex[y],0,0}
Curl[EVektor]
HVektor={0,0,Hz[y]};
Curl[HVektor]

Thread[Curl[EVektor]==-I*ω*μ*HVektor]
rce1=%[[3]]

Thread[Curl[HVektor]==γ*EVektor]
rce2=%[[1]]

FullSimplify[DSolve[{rce1,rce2,Hz[0]==H0,Ex[0]==E0},{Ex[y],Hz[y]},y][[1]],{μ>0,γ>0,ω>0}]

{rce1,rce2}

rceH=rce1/.D[Solve[rce2,Ex[y]][[1]],y]

dosres=Simplify[DSolve[rceH,Hz[y],y][[1]],{μ>0,γ>0,ω>0}]

(((-1))^(1/4))//N
((1+I)/(Sqrt[2]))//N

dosres/.C[1]->0
%/.y->0

hacko=Hz[y]/.(defres=dosres/.{C[1]->0,C[2]->H0})
ecko=(1/γ)Curl[{0,0,hacko}][[1]]

cm=0.01;
D1=15cm;
T1=20;
T2=500;
delka=0.5;
minuta=60;
tmax=5minuta;
c=400;
m=ρ*V;
ρ=8400;
V=((D1^2)/4)*Pi*delka;
P=Pt/.Solve[Pt*tmax==m*c*(T2-T1)][[1]];
Print["cisty tepelny vykon = ",P," W"]

γCu=57*(10^6);
γBrass=0.28γCu;
ω=2*Pi*f0;
μ0=N[VacuumPermeability][[1]];
aBrass=(Sqrt[(2/(ω*γBrass*μ0))]);
Solve[aBrass==0.12*D1];
f=50;
aBrass=(Sqrt[(2/(ω*γBrass*μ0))])/.f0->f;
Dingot=D1-aBrass;
Singot=((Dingot^2)/4)*Pi;
Lingot=α*μ0*(1^2)*(Singot/delka)/.α->0.91;
Print["D ku el= ",(Dingot/delka),"  -"]
Print["L2= ",Lingot,"  H"]
aCu=(Sqrt[(2/(ω*γCu*μ0))])/.f0->f;
Print["aCu= ",(aCu/cm),"  cm"]

D2=D1+3cm;
Dinduktor=D2+aCu;
Sinduktor=((Dinduktor^2)/4)*Pi;
Print["D ku el= ",(Dinduktor/delka),"  -"]
Linduktor=α*μ0*(n1^2)*(Sinduktor/delka)/.α->0.856;
Print["L1= ",Linduktor,"  H"]

(*{d1/l1,d2/l2,F}*)
dataF={{0.3,0.2,0.93},{0.3,0.3,0.931},{0.4,0.2,0.885},{0.4,0.3,0.886}};
Fit[dataF,{1,dkul1,dkul2},{dkul1,dkul2}]
naseF=%/.{dkul1->(Dinduktor/delka),dkul2->(Dingot/delka)}

Interpolation[dataF,InterpolationOrder->1][(Dinduktor/delka),(Dingot/delka)];

M=naseF*μ0*n1*1*(Singot/delka);
Print["M= ",M,"  H"]

R2=((Dingot*Pi)/(γBrass*delka*aBrass));
Print["R2= ",R2,"  Ω"]

R1=1.2((Dinduktor*Pi)/(γCu*delka*aCu))*(n1^2);
Print["R1= ",R1,"  Ω"]
L1=Linduktor;
L2=Lingot;

u1=24;
rceprimar=u1==(R1+I*ω*L1)*i1+I*ω*M*i2/.f0->f;
rcesekundar=0==(R2+I*ω*L2)*i2+I*ω*M*i1/.f0->f;
rcevykon=P==R2*((Abs[i2])^2);

resi1Ai2=Solve[{rceprimar,rcesekundar},{i1,i2}][[1]]//Chop

vyslrce=rcevykon/.Solve[{rceprimar,rcesekundar},{i1,i2}]/.resi1Ai2;
FindRoot[vyslrce,{n1,10}]
(delka/(n1/.%))

Plot[{R2*((Abs[i2])^2)/.resi1Ai2,P},{n1,10,20},PlotRange->All]

rd1=Jz''[x]==I*ω*γCu*μ0*Jz[x]/.f0->f;
resJz=DSolve[{rd1,Jz'[0]==0},Jz[x],x][[1]];
pomvys=Jz[x]/.resJz;
dosC2=Solve[Integrate[m*pomvys,{x,-d,d}]==I0,C[2]][[1]];
hustota=FullSimplify[pomvys/.dosC2]/.{I0->1};
ClearAll[vykonztraty];
vykonztraty[dd_]:=Module[{nasehustota,xx,dmin,dmax},nasehustota=((Abs[hustota/.{d->dd,x->xx}])^2);dmin=-1.*dd;dmax=1.*dd;NIntegrate[nasehustota,{xx,dmin,dmax}]//Chop;xx];
(*Plot[vykonztraty[d],{d,(Pi/2)*aCu-0.4cm,(Pi/2)*aCu+0.2cm},AxesOrigin->{0,0}];
*)

resn1=n1->15;
resishodnotami=resi1Ai2/.resn1;
Print["i1= ",i1/.resishodnotami,"  A"]
Solve[(u1/(1/(ω*cap)))==-Im[i1/.resishodnotami],cap]/.f0->f;
Print["kompenzacni kapacita= ",cap/.%[[1]],"  F"]

ztratyinduktor=R1*((Abs[i1])^2)/.resishodnotami/.resn1;
Print["ztraty v induktoru= ",ztratyinduktor,"  W"];
ucinnost=(P/(P+ztratyinduktor));
Print["ucinnost ohrevu= ",ucinnost*100,"  %"];

z1=(u1/(i1/.resishodnotami));
Print["z1= ",z1,"  Ω"]

Snom=60*(10^3);
Unom=400.;
p=(Unom/u1);
z1prim=z1*(p^2);
Znom=znom/.Solve[Snom==((Unom^2)/znom)][[1]];
Zσ=I*0.08*Znom;
Zcelk=z1prim+Zσ;
FindRoot[Im[((Zcelk*(1/(I*ω*cap)))/(Zcelk+(1/(I*ω*cap))))/.f0->f]==0,{cap,0.001,0.005}]

Plot[Im[((Zcelk*(1/(I*ω*cap)))/(Zcelk+(1/(I*ω*cap))))/.f0->f],{cap,0.001,0.005},PlotRange->All]

Tinduktor=90;
Tingot=T2;
ϵ1=1;
ϵ2=1;
ϵφ=(1/((1/(ϵ1))+(S1/S2)*((1/(ϵ2))-1)));
σ=StefanConstant[[1]];
S1=D1*Pi*delka;
Qsal=S1*σ*ϵφ*((((Tingot+273))^4)-(((Tpovrch+273))^4));
λiz=1;
Rth=(1/(λiz*2Pi*delka))*Log[(D2/(D2-2cm))];
Qizolaci=((Tpovrch-Tinduktor)/Rth);
dosPovrch=Solve[Qizolaci==Qsal]//Last;
vykonIzolaci=Qizolaci/.dosPovrch;
Print["ztraty izolaci cini ",vykonIzolaci," W"]
Print["ztraty v induktoru= ",ztratyinduktor,"  W"];
Pchlazeni=ztratyinduktor+vykonIzolaci;
Print["ztraty celkem= ",Pchlazeni,"  W"];

pocetSekci=3;
Tw1=35;
Tw2=70;
c=4186;
prutokmin=msteckou/.Solve[msteckou*c*(Tw2-Tw1)==(Pchlazeni/pocetSekci)][[1]];
Print["minimalni prutok vody= ",prutokmin," kg.(s^(-1))"]
prutok=1*prutokmin;

najedenzavit=(delka/(1.2n1/.resn1));
Print["sirka dratu= ",(najedenzavit/cm)," cm"];
mm=0.1cm;
tl=5mm;
adira=najedenzavit-2*tl;
Print["adira= ",(adira/cm)," cm"];
minpomer=(1/3);
bdira=bd/.Solve[minpomer==((12mm+tl+bd)/(D1/2))][[1]];
Print["bdira= ",(bdira/cm)," cm"];
ro=1000;
Vsteckou=(prutok/ro);
rychlost=(Vsteckou/(adira*bdira));
Print["rychlost vody v induktoru= ",rychlost," m.(s^(-1))"]

ν=0.365*(10^(-6));
Dchar=((4*adira*bdira)/(2*(adira+bdira)));
Rey=((rychlost*Dchar)/ν);
Print["Re= ",Rey," -"];
λ=0.67;
a=(λ/(ro*c));
Print["teplotni vodivost a= ",a," (m^2).(s^(-1))"]
Pr=(ν/a);
Print["Pr= ",Pr," -"];

Nu=0.023*(Rey^0.8)*(Pr^0.4);
Print["Nu= ",Nu," -"];
α=((Nu*λ)/Dchar);
Print["a= ",α," W.(m^(-2)).(K^(-1))"];

(*Pozor, objemovy a hmotnostni prutok*)

rT=0.5*D2+12mm+0.5*bdira;
Steplo=2*Pi*rT*2*(adira+bdira)*n1/.resn1;
Print["povrch kterym jde teplo do vody= ",Steplo," (m^2)"];
q=(Pchlazeni/Steplo);
Print["q= ",q," W.(m^(-2))"];
Solve[q==α*ΔT][[1]]

dynTlak=(1/2)ro*(rychlost^2);
Print["pdyn= ",dynTlak," Pa"];
Print["Re= ",Rey," -"];
Print["prutok= ",prutok," (kg/s)"];

ksiAltsul[re_,drsnost_]:=0.11*((((68/re)+drsnost))^0.25);
ksiIsajev[re_,drsnost_]:=(((1.8*Log[10,(6.81/re)+(((0.27drsnost))^1.11)]))^(-2));
ksi=0.5(ksiAltsul[Rey,(10^(-3))]+ksiIsajev[Rey,(10^(-3))]);
Print["ξ= ",ksi," -"];

delkaDratu=((2*Pi*rT*n1)/pocetSekci)/.resn1;
ΔpInduktor=dynTlak*(delkaDratu/Dchar)*ksi;
Print["ΔpInduktor= ",ΔpInduktor," Pa"];
vykonCerpadla=pocetSekci*ΔpInduktor*prutok;
Print["Pcerp= ",vykonCerpadla," W"];

prutokSprcha=1.5*prutok*pocetSekci;
nDer=100;
Dder=2mm;
Sder=nDer*((Pi*(Dder^2))/4);
vder=(prutokSprcha/(Sder*ro));
Print["rychlost vody v dirce sprchy= ",vder," m.(s^(-1))"]
pdynSprcha=(1/2)*ro*(vder^2);
Print["pdyn= ",pdynSprcha," Pa"];
ΔpDirasprchy=pdynSprcha*(0.5+1);
Print["vykon= ",ΔpDirasprchy*prutokSprcha,"W"]