Quiet@Remove["Global`*"];
$HistoryLength=2;
SetDirectory[NotebookDirectory[]];

cm=0.01;
d=5cm;
To=20;
Ts=60;
v=20;
Pr=0.7;
(*forced convection across cylinder correlations*)
Nu[re_]:=0.93*(re^0.4)*(Pr^0.4)/;5<re≤80;
Nu[re_]:=0.715*(re^0.46)*(Pr^0.4)/;80<re≤500;
Nu[re_]:=0.226*(re^0.6)*(Pr^0.4)/;500<re;
(*LogLogPlot[Nu[re],{re,5,50000}]*)

Dchar=d;
Tdef=((Ts+To)/2);
Print["Tdef= ",Tdef," °C"]

ν=16.92*(10^(-6));
Rey=v*(Dchar/ν);
Print["Re= ",Rey," -"]

nuOld=Nu[Rey];
Print["Nu po staru= ",nuOld]

NuNew[re_]:=0.3+((0.62*(re^0.5)*(Pr^(1/3)))/(((1+((((0.4/Pr)))^(2/3))))^(1/4)))*(((1+((((re/282000)))^(5/8))))^(4/5));
LogLogPlot[{Nu[re],NuNew[re]},{re,5,50000},PlotStyle->{Red,Blue}];

nunew=NuNew[Rey];
Print["Nu po novu= ",nunew," -"]

λ=27.35*(10^(-3));
α=nuOld*(λ/Dchar);
Print["α= ",α," W.(m^(-1)).(K^(-1))"]

SJedenM=Pi*d;
Pconv1m=SJedenM*α*(Ts-To);
Print["Pc= ",Pconv1m," W"]

ϵ=0.9;
σ=5.67*(10^(-8));
Prad=SJedenM*ϵ*σ*((((Ts+273))^4)-(((To+273))^4));
Print["Pr= ",Prad," W"]

Skolmy=((Pi*(d^2))/4);
γ=37*(10^6);
R1m=(1/(γ*Skolmy));
Solve[R1m*(proud^2)==Pconv1m][[2]]

(*samovolna konvekce, v=0*)
nuVolne[grpr_]:=1.18*(grpr^(1/8))/;0.001<grpr≤500;
nuVolne[grpr_]:=0.54*(grpr^(1/4))/;500<grpr≤2*(10^7);
nuVolne[grpr_]:=0.135*(grpr^(1/3))/;2*(10^7)<grpr;
LogLogPlot[nuVolne[grpr],{grpr,0.001,3*(10^10)}];
β=(1/(Tdef+273.));
g=9.81;
Gr=((β*g*(Ts-To)*(Dchar^3))/(ν^2));
Print["Gr*Pr= ",grpr=Gr*Pr," -"]
Print["Nu= ",nuu=nuVolne[grpr]," -"]
αVolne=nuu*(λ/Dchar);
Print["αVolne= ",αVolne," W.(m^(-1)).(K^(-1))"]

Pconv1mVolne=SJedenM*αVolne*(Ts-To);
Print["PcVolne= ",Pconv1mVolne," W"]
Solve[R1m*(proud^2)==Pconv1mVolne+Prad][[2]]

(*prepocet vymeniku*)
Quiet@Remove["Global`*"];
Twin=90;
Twout=70.;
cw=4186;
P=50000;
Tain=15;
ca=1000;
Vasteckou=1.;
ρain=(349./(273+Tain));
ma=Vasteckou*ρain;
dos1=Solve[{P==cw*mw*(Twin-Twout),P==ca*ma*(Taout-Tain)}][[1]];
Δ1=Twin-Taout/.dos1;
Δ2=Twout-Tain;
dos2=Solve[P==kS*((Δ1-Δ2)/(Log[((Δ1)/(Δ2))]))][[1]];
Print["kS= ",kS/.dos2," W/K"]

(*novy stav*)
TainN=20;
TwinN=45;
Δ1N=TwinN-TaoutN;
Δ2N=TwoutN-TainN;
rce={PN==kS*((Δ1N-Δ2N)/(Log[((Δ1N)/(Δ2N))])),PN==cw*mw*(TwinN-TwoutN),PN==ca*ma*(TaoutN-TainN)}/.Union[dos1,dos2];
FindRoot[rce,{{TaoutN,40},{TwoutN,24},{PN,15000}}]

rceLin={PN==kS*((Δ1N+Δ2N)/2),PN==cw*mw*(TwinN-TwoutN),PN==ca*ma*(TaoutN-TainN)}/.Union[dos1,dos2];
solLin=Solve[rceLin][[1]]
solLin/.Rule->List
(*solLin/.(name_->val_):>{name,val}*)
FindRoot[rce,solLin/.Rule->List]

Rule[a,b]
List[a,b]

60*0.75*((1/0.3)-1)

(*dva vymeniky s vodnim meziobvodem*)