import math
# Variables
# given
K_drywall = 0.28; #[Btu/ft*degF] - thermal conductivity of dry wall
K_fibreglass = 0.024; #[Btu/ft*degF] - thermal conductivity of fibre glass
K_concrete = 0.5; #[Btu/ft*degF] - thermal conductivity of concrete
T4 = 0.; #[degF]
T1 = 65.; #[degF]
deltaT = T4-T1; #[degF]
a = 1.; #[ft**2] - assuming area of 1 ft**2
deltax1 = 0.5/12; #[ft]
deltax2 = 3.625/12; #[ft]
deltax3 = 6./12; #[ft]
# Calculations
R1 = deltax1/(K_drywall*a); #[h*degF/Btu]
R2 = deltax2/(K_fibreglass*a); #[h*degF/Btu]
R3 = deltax3/(K_concrete*a); #[h*degF/Btu]
qx = deltaT/(R1+R2+R3);
q12 = -qx;
q23 = -qx;
q34 = -qx;
deltaT1 = (-q12)*deltax1*(1./(K_drywall*a));
T2 = T1+deltaT1;
deltaT2 = (-q23)*deltax2*(1./(K_fibreglass*a));
T3 = T2+deltaT2;
deltaT3 = (-q34)*deltax3*(1./(K_concrete*a));
T4 = T3+deltaT3;
# Results
print " T1 = %.0f F \
\n T2 = %.1f F \
\n delta T2 = %.2f deg F \
\n T3 = %.2f F \
\n delta T3 = %.2f deg F \
\n T4 = %.0f F"%(T1,T2,deltaT2,T3,deltaT3,T4);
# Variables
r1 = (2.067/2.)/(12); #[ft]
r2 = r1+0.154/12; #[ft]
r3 = r2+3/12.; #[ft]
L = 1.; #[ft]
Ka = 26.; #[Btu/h*ft*degF]
Kb = 0.04; #[Btu/h*ft*degF]
T1 = 50.; #[degF]
# Calculations
Ra = (math.log(r2/r1))/(2*math.pi*L*Ka);
Rb = (math.log(r3/r2))/(2*math.pi*L*Kb);
R = Ra+Rb;
deltaT = -18; #[degF] - driving force
Qr = -(deltaT/(R));
deltaT1 = (-Qr)*(Ra);
T2 = T1+deltaT1;
# Results
print " Qr = %.3f"%Qr;
print " The interface temperature is T2 = %.3f degF"%(T2);
# Variables
Ra = 8.502*10**-4; #[h*degF*Btu**-1]
Rb = 5.014; #[h*degF*Btu**-1]
r1 = (2.067/2)/(12.); #[ft]
r2 = r1+0.154/12.; #[ft]
r3 = r2+3/12.; #[ft]
d1 = 2.*r1;
d0 = 2.*r3;
h0 = 25.; #[Btu/h*ft**2*degF]
h1 = 840.; #[Btu/h*ft**2*degF]
L = 1.; #[ft] - considering 1 feet length
# Calculations
R0 = 1./(h0*math.pi*d0*L);
R1 = 1./(h1*math.pi*d1*L);
R = R0+R1+Ra+Rb;
deltaT = -400; #[degF]
Qr = -(deltaT)/R;
# the heat loss calculated above is the heat loss per foot.therefore for 500 ft
L = 500.;
Qr = Qr*L;
# Results
print " the heat loss for a 500 feet pipe is qr = %.2e Btu/h"%(Qr);
# Variables
Nre = 50000.;
d = 0.04; #[m] - diameter of pipe
# physical properties of water
T1 = 293.15; #[K]
T2 = 303.15; #[K]
T3 = 313.15; #[K]
p1 = 999.; #[kg/m**3] - density of water at temperature T1
p2 = 996.0; #[kg/m**3] - density of water at temperature T2
p3 = 992.1; #[kg/m**3] - density of water at temperature T3
mu1 = 1.001; #[cP] - viscosity of water at temperature T1
mu2 = 0.800; #[cP] - viscosity of water at temperature T2
mu3 = 0.654; #[cP] - viscosity of water at temperature T3
k1 = 0.63; #[W/m*K] - thermal conductivity of water at temperature T1
k2 = 0.618; #[W/m*K] - thermal conductivity of water at temperature T2
k3 = 0.632; #[W/m*K] - thermal conductivity of water at temperature T3
cp1 = 4182.; #[J/kg*K] - heat capacity of water at temperature T1
cp2 = 4178.; #[J/kg*K] - heat capacity of water at temperature T2
cp3 = 4179.; #[J/kg*K] - heat capacity of water at temperature T3
Npr1 = 6.94; # prandtl no. at temperature T1
Npr2 = 5.41; # prandtl no. at temperature T2
Npr3 = 4.32; # prandtl no. at temperature T3
# Calculations
# (a) Dittus -Boelter-this correction evalutes all properties at the mean bulk temperature,which is T1
kmb = 0.603
h = (kmb/d)*0.023*((Nre)**(0.8))*((Npr1)**0.4);
# Results
print " a) Dittus -Boelter the heat transfer coefficient is \nh = %.0f W/m**2*K \
= %.0f Btu/ft**2*h**-1*degF"%(h,h*0.17611);
# (b) Seid_er Tate-this correlation evaluates all the properties save muw at the mean bulk temperature
h = (kmb/d)*(0.027)*((Nre)**0.8)*((Npr1)**(1./3))*((mu1/mu3)**0.14);
print " b) Seid_er Tate the heat transfer coefficient is \nh = %.0f W/m**2*K \
= %.0f Btu/ft**2*h**-1*degF"%(h,h*0.17611);
# (c) Sleicher-Rouse equation
a = 0.88-(0.24/(4+Npr3));
b = (1./3)+0.5*math.exp((-0.6)*Npr3);
Nref = Nre*(mu1/mu2)*(p2/p1);
Nnu = 5+0.015*((Nref)**a)*((Npr3)**b);
h = Nnu*(kmb/d);
print " c) Sleicher-Rouse equation the heat transfer coefficient is \nh = %.0f W/m**2*K \
= %.0f Btu/ft**2*h**-1*degF"%(h,h*0.17611);
# (d) Colbum Analogy- the j factor for heat transfer is calculated
jh = 0.023*((Nref)**(-0.2));
Nst = jh*((Npr2)**(-2./3));
U = (Nre*mu1*10**-3)/(d*p1);
h = Nst*(p1*cp1*U);
print " d) Colbum Analogy the heat transfer coefficient is \nh \
= %.0f W/m**2*K = %.0f Btu/ft**2*h**-1*degF"%(h,h*0.17611);
# (e) Friend-Metzner
f = 0.005227;
Nnu = ((Nre)*(Npr1)*(f/2.)*((mu1/mu3)**0.14))/(1.20+((11.8)*((f/2)**(1./2))*(Npr1-1)*((Npr1)**(-1./3))));
h = Nnu*(kmb/d);
print " e) Friend-Metzner the heat transfer coefficient is \nh = %.0f W/m**2*K \
= %.0f Btu/ft**2*h**-1*degF"%(h,h*0.17611);
# (f) Numerical analysis
Nnu = 320.;
h = Nnu*(kmb/d);
print " f) Numerical analysis the heat transfer coefficient is \nh = %.0f W/m**2*K \
= %.0f Btu/ft**2*h**-1*degF"%(h,h*0.17611);
# Variables
# given
Tw = 680.; #[K] - temperature at the wall
Tb = 640.; #[K] - temperature at the bulk
Tf = (Tw+Tb)/2; #[K]
Nre = 50000.;
vmb = 2.88*10.**-7;
vf = 2.84*10.**-7;
Nref = Nre*(vmb/vf);
k = 27.48;
d = 0.04;
# Calculation and Results
# from table 11.3 the prandtl no. is
Npr = 8.74*10**-3
# consmath.tant heat flow
Nnu = 6.3+(0.0167)*((Nref)**0.85)*((Npr)**0.93);
h = Nnu*(k/d);
print " constant heat flow h = %.0f W/m**2*K = %.0f Btu/ft**2*h*degF"%(h,round(h*0.17611,-1));
# constant wall temperature
Nnu = 4.8+0.0156*((Nref)**0.85)*((Npr)**0.93);
h = Nnu*(k/d);
print " constant wall temperature h = %d W/m**2*K = %d Btu/ft**2*h*degF"%(h,h*0.17611);
# Variables
di = 0.620; #[inch] - internal diameter
d0 = 0.750; #[inch] - outer diameter
Ai = 0.1623; #[ft**2/ft]
Ao = 0.1963; #[ft**2/ft]
wc = 12*(471.3/0.9425); #[lb/h]
cp = 1.; #[Btu/lbm*degF] - heat capacity of water
Tco = 110.;
Tci = 50.;
# Calculations
qtotal = wc*cp*(Tco-Tci);
deltaH_coldwater = 3.6*10**5;
deltaH_vapourization = 1179.7-269.59;
wh = deltaH_coldwater/deltaH_vapourization;
hi = 80.; #[Btu/h*ft**2*degF]
ho = 500.; #[Btu/h*ft**2*degF]
km = 26.; #[Btu/h*ft*degF]
Ui = 1./((1./hi)+((Ai*math.log(d0/di))/(2*math.pi*km))+(Ai/(Ao*ho)));
deltaT1 = 300-50.;
deltaT2 = 300-110.;
LMTD = (deltaT1-deltaT2)/(math.log(deltaT1/deltaT2));
A = qtotal/(Ui*LMTD);
L = A/Ai;
# Results
print "the length of the heat exchanger is L = %.2f ft"%(L);
# Answer is slightly different becasue of rounding error.
# Variables
L = 30.; #[ft] - length
Ai = 0.1623*L;
di = 0.620; #[inch] - internal diameter
d0 = 0.750; #[inch] - outer diameter
Ao = 0.1963*L; #[ft**2/ft]
wc = 12.*(471.3/0.9425);
cp = 1.; #[Btu/lbm*degF] - heat capacity of water
# Calculations
deltaH_coldwater = 3.6*10**5;
deltaH_vapourization = 1179.7-269.59;
wh = deltaH_coldwater/deltaH_vapourization;
hi = 80.; #[Btu/h*ft**2*degF]
ho = 500.; #[Btu/h*ft**2*degF]
km = 26.; #[Btu/h*ft*degF]
Ui = 1./((1./hi)+(((Ai/L)*math.log(d0/di))/(2*math.pi*km))+(Ai/(Ao*ho)));
deltaT1 = 300-50.;
deltaT = deltaT1/(math.exp((Ui*Ai)/(wc*cp)));
Tsat = 300.;
Tc2 = Tsat-deltaT;
# Results
print " Therefore, the outlet temperature of the cold fluid_ is Tc2 = %.2f degF"%(Tc2);
# Variables
Ai = 4.869;
wc = 6000.;
cp = 1.;
Rf = 0.002;
Uclean = 69.685;
# Calculations
Udirty = 1./(Rf+(1./Uclean));
deltaT1 = 300.-50;
deltaT2 = deltaT1/(math.exp((Udirty*Ai)/(wc*cp)));
Th2 = 300.;
Tc2 = Th2-deltaT2;
# Results
print " the outlet temperature is Tc2 = %.1f degF"%(Tc2);
# Variables
Ui = 325.; #[W/m**2*K] - overall heat transfer coefficient
Thi = 120.; #[degC] - inlet temperature of hydrocarbon
Tho = 65.; #[degC] - outlet temperature of hydrocarbon
Tci = 15.; #[degC] - inlet temperature of water
Tco = 50.; #[degC] - outlet temperture of water
cp = 4184.; #[J/kg*K] - heat capacity of water
ch = 4184.*0.45 #[J/kg*K] - heat capacity of hydrocarbon
wc = 1.2; #[kg/sec] - mass flow rate of water
# Calculation and Results
wh = ((wc*cp)*(Tco-Tci))/((ch)*(Thi-Tho));
qtotal = wc*cp*(Tco-Tci);
# (a) - parallel double pipe
F = 1.;
Thi = 120.; #[degC] - inlet temperature of hydrocarbon
Tho = 65.; #[degC] - outlet temperature of hydrocarbon
Tci = 15.; #[degC] - inlet temperature of water
Tco = 50.; #[degC] - outlet temperture of water
deltaT1 = Thi-Tci;
deltaT2 = Tho-Tco;
LMTD = (deltaT2-deltaT1)/(math.log(deltaT2/deltaT1));
Ai = qtotal/((Ui*LMTD));
print " a) parallel double pipe Ai = %.2f m**2"%(Ai);
# (b) - counter flow
F = 1.;
Thi = 120.; #[degC] - inlet temperature of hydrocarbon
Tho = 65.; #[degC] - outlet temperature of hydrocarbon
Tco = 15.; #[degC] - inlet temperature of water
Tci = 50.; #[degC] - outlet temperture of water
deltaT1 = Thi-Tci;
deltaT2 = Tho-Tco;
LMTD = (deltaT2-deltaT1)/(math.log(deltaT2/deltaT1));
Ai = qtotal/((Ui*LMTD));
print " b) counter flow Ai = %.2f m**2"%(Ai);
# (c) - 1-2 shell and tube
Thi = 120.; #[degC] - inlet temperature of hydrocarbon
Tho = 65.; #[degC] - outlet temperature of hydrocarbon
Tci = 15.; #[degC] - inlet temperature of water
Tco = 50.; #[degC] - outlet temperture of water
Z = (Thi-Tho)/(Tco-Tci);
nh = (Tco-Tci)/(Thi-Tci);
deltaT1 = Thi-Tco;
deltaT2 = Tho-Tci;
F = 0.92;
LMTD = (F*(deltaT2-deltaT1))/(math.log(deltaT2/deltaT1));
Ai = qtotal/((Ui*LMTD));
print " c) 1-2 shell and tube Ai = %.2f m**2"%(Ai);
# (d) - 2-4 shell and tube
Thi = 120.; #[degC] - inlet temperature of hydrocarbon
Tho = 65.; #[degC] - outlet temperature of hydrocarbon
Tci = 15.; #[degC] - inlet temperature of water
Tco = 50.; #[degC] - outlet temperture of water
Z = (Thi-Tho)/(Tco-Tci);
nh = (Tco-Tci)/(Thi-Tci);
F = 0.975;
LMTD = (F*(deltaT2-deltaT1))/(math.log(deltaT2/deltaT1));
Ai = qtotal/((Ui*LMTD));
print " d) 2-4 shell and tube Ai = %.2f m**2"%(Ai);