In [2]:

```
#Variable declaration:
Q = 12000.0 #Heat transfer rate (Btu/h)
U = 48.0 #Overall heat coefficient (Btu/ft^2.h.°F)
DTlm = 50.0 #Log mean temperature difference (°F)
#Calculation:
A = Q/(U*DTlm) #Area of exchanger (ft^2)
#Result:
print "The area of the exchanger is :",round(A)," ft^2 ."
```

In [26]:

```
from sympy import symbols,solve,log
#Variable declaration:
Q = 56760 #Heat transfer rate (Btu/h)
U = 35.35 #Overall heat coefficient (Btu/ft.h.°F)
A = 32.1 #Area of exachanger (ft^2)
t1 = 63.0 #Outlet cold water temperature (°F)
T1 = 164 #Outlet hot water temperature (°F)
T2 = 99 #Inlet hot water temperature (°F)
t2 = symbols('t2') #Inlet cold water temperature (°F)
#Calculation:
DTlm = Q/(U*A) #Log mean temperature difference (°F)
dT1 = T1-t1 #Temperature approach at pipe outlet (°F)
dT2 = T2-t2 #Temperature approach at pipe inlet (°F)
Eq = (dT2-dT1)/log(dT2/dT1)-DTlm
R = solve(Eq,t2) #Inlet cold water temperature (°F)
#Result:
print "The inlet cold water temperature is : ",round(R[0])," °F."
```

In [8]:

```
#Variable declaration:
m = 14.6 #Flow rate of water inside the tube (lb/min)
Cp = 1 #Heat capacity of water (Btu/lb.°F)
t2 = 79 #Initial temperature of water (°F)
t1 = 63 #Final temperature of water (°F)
#From example 15.3:
Q1 = 56760 #Old heat transfer rate (Btu/h)
#Calculation:
Q2 = m*Cp*(t2-t1) #New heat transfer rate (Btu/min)
#Result:
print "The new heat transfer rate is :",round(Q2)," Btu/min."
print "Or, the new heat transfer rate is :",round(Q2*60)," Btu/h."
if (Q1==Q2) :
print "This result agree with the Q˙ provided in the problem statement. Shakespeare is wrong, nothing is rotten there."
else :
print "This result does not agree with the Q˙ provided in the problem statement. Shakespeare is right, something is indeed rotten."
```

In [5]:

```
from math import log
#Variable declaration:
T1 = 210.0 #Initial temperature of oil (°F)
T2 = 170.0 #Final temperature of oil (°F)
T3 = 60.0 #Surface temperature of oil (°F)
m = 8000.0 #Flow rate of oil inside tube (lb/h)
cp = 0.55 #Heat capacity of oil (Btu/lb.°F)
U = 63.0 #Overall heat teansfer coefficient (Btu.h.ft^2.°F)
#Calculation:
DT1 = T1-T3 #Temperature difference 1 (°F)
DT2 = T2-T3 #Temperature difference 2 (°F)
DTlm = (DT1-DT2)/log(DT1/DT2) #Log mean temerature difference (°F)
Q = m*cp*(T1-T2) #Heat transferred (Btu/h)
A = Q/(U*DTlm) #Heat transfer area (ft^2)
#Result:
print "The required heat transfer area is :",round(A,2)," ft^2 ."
```

In [6]:

```
from math import log
#Variable declaration:
T1 = 140.0 #Initial temperature of hot water (°F)
T2 = 110.0 #Final temperature of hot water (°F)
T3 = 60.0 #Initial temperature of cold water (°F)
T4 = 90.0 #Initial temperature of cold water (°F)
DTlm2 = 50.0 #Log mean temerature difference for countercurrent flow, a constant (°F) (part 2)
m = 100.0*60 #Water flow rate (lb/h)
cp = 1.0 ##Heat capacity of water (Btu/lb.°F)
U = 750.0 #Overall heat teansfer coefficient (Btu.h.ft^2.°F)
#Calculation:
DT1 = T1-T3 #Temperature difference 1 (°F) (part 1)
DT2 = T2-T4 #Temperature difference 2 (°F)
DTlm1 = (DT1-DT2)/log(DT1/DT2) #Log mean temerature difference (°F)
Q = m*cp*(T1-T2) #Heat transferred (Btu/h)
Ap = Q/(U*DTlm1) #Heat transfer area for parallel flow (ft^2)
Ac = Q/(U*DTlm2) #Heat transfer area for counter flow (ft^2)
#Result:
print "1. The double pipe co-current flow is :",round(Ap,2)," ft^2 ."
print "1. The double pipe countercurrent flow is :",round(Ac,2)," ft^2 ."
```

In [8]:

```
from __future__ import division
from math import pi,log
#Variable declaration:
uC = 3.7*10**-4 #Viscosity of benzene (lb/ft.s)
uH = 2.05*10**-4 #Viscosity of water @200 °F (lb/ft.s)
u2 = 2.16*10**-4 #Viscosity of water @192 °F (lb/ft.s)
pC = 54.8 #Density of benzene (lb/ft^3)
pH = 60.13 #Density of water (lb/ft^3)
cpC = 0.415 #Specific heat capacity of benzene (Btu/lb.°F)
cpH = 1 #Specific heat capacity of water (Btu/lb.°F)
sgC = 0.879
kC = 0.092 #Thermal conductivity of benzene (Btu/h.ft.°F)
kH = 0.392 #Thermal conductivity of water @200 °F (Btu/h.ft.°F)
k2 = 0.390 #Thermal conductivity of water @192 °F (Btu/h.ft.°F)
mC = 2500 #Flow rate of benzene (lb/s)
mH = 4000 #Flow rate of water (lb/s)
Re = 13000 #Reynolds number
dTc = 120-60 #Difference in temperature heating for benzene
Tw = 200 #Temperatperature of hot water (°F)
#For 2-inch schedule 40 pipe
Ai = 0.541 #Inside area of pipe (ft^2/ft)
Ao = 0.622 #Outside area of pipe (ft^2/ft)
Di = 2.067 #Inside diameter of pipe (inch)
Do = 2.375 #Outside diameter of pipe (inch)
Si = 0.0233 #Inside surface area of pipe (ft^2)
dXw = 0.128 #Width of pipe (ft)
#For 4-inch schedule 40 pipe
Dio = 4.026 #Inside diameter of pipe (inch)
Doi = Do #Outside diameter of pipe (inch)
kw = 26
#Calculations:
def St(Re,Pr): #Dittus Boelter equation
return 0.023*Re**-0.2*Pr**-0.667
#For inside tubes:
Dicalc = 4*mC/(Re*pi*uC)/3600 #Inside diameter (ft)
mHcalc = Re*pi*uH*(Doi+Dio)/4*3600/12 #Mass flow rate of water (lb/h)
Q = mC*cpC*dTc #Heat in water (Btu/h)
dTH = Q/mH #Temperature difference of water (°F)
THo = Tw - dTH #Outlet temperature of water (°F)
THav = (Tw+THo)/2 #Average temperature of water (°F)
#For benzene:
PrC = cpC*uC/kC*3600 #Prandtl number
StC = round(St(13000, PrC),5) #Stanton number
hi = StC*cpC*mC/Si #Heat transfer coefficient (Btu/h.ft^2.°F)
#For water:
ReH = 4*mH/3600/(pi*u2*(Doi+Dio)/12) #Reynolds number
PrH = round(cpH*(u2)/k2*3600 ,2) #Prandtl number
StH = round(St(ReH, PrH),5) #Stanton number
Sann = round(pi/4*(Dio**2-Doi**2)/144,4) #Surface area of annulus (ft^2)
ho = round(StH*cpH*mH/Sann) #Heat transfer coefficient (Btu/h.ft^2.°F)
#For pipe:
Dlm = round((Do-Di)/log(Do/Di)*12,3) #Log mean difference in diameter (ft)
Uo = 1/(Do/Di/hi + dXw*Do/kw/Dlm + 1/ho) #Overall heat transfer coefficient (Btu/h.ft^2.°F)
dTlm = (124.4-80)/log(124.4/80) #Log mean temperature difference (°F)
L = Q/(Uo*0.622*dTlm) #Length of pipe (ft)
#Result:
print 'The required length of pipe: ',round(L,1), 'ft'
```

In [10]:

```
from __future__ import division
from math import e
#Variable declaration:
MC = 2000.0
mc = 1000.0
U = 2000.0
A = 10.0
T1 = 300.0
t1 = 60.0
#Calculation:
B = 1.0/mc
b = 1.0/MC
x = B/b
y = U*(B-b)
T2 = ((x-y)*T1 + x*(e-y)*t1)/(2*e-1)
t2 = t1+(T1-T2)/x
#Result:
print "T2 = :",round(T2)," °F"
print "t2 = :",round(t2)," °F"
```

In [23]:

```
from sympy import symbols,solve,log
#Variable declaration:
h1 = 1200.0 #Hot film coefficient (Btu/h.ft^2.°F)
h2 = 1175.0 #Cold film coefficient (Btu/h.ft^2.°F)
L = 200.0 #Length of pipe (ft)
MC = 30000.0
mc = 22300.0
T1 = 300.0 #Inlet temperature of hot fluid in pipe (°F)
t1 = 60.0 #Inlet temperature of cold fluid in pipe (°F)
T2 = symbols('T2') #Outlet temperature of hot fluid °F
t2 = symbols('t2') #Outlet temperature of cold fluid °F
#From table 6.2:
ID = 2.067 #Inside diameter of pipe (in)
OD = 2.375 #Outside diameter of pipe (in)
Dx = 0.154 #Thickness of pipe (in)
Ai = 0.541 #Inside sectional area of pipe (ft^2/ft)
k = 25.0 #Thermal conductivity of pipe (Btu/h)
#Calculation:
Ui = 1.0/((1.0/h1) +(Dx/(k*12.0))+(1.0/(h2*(OD/ID)))) #Overall heat transfer coefficient (Btu/h.ft^2.°F)
Ai1 = Ai*L #Inside area of pipe (ft^3/ft)
QH = MC*(T1-T2) #Heat transfer rate of hot fluid (Btu/h)
QC = mc*(t2-t1) #Heat transfer rate of cold fluid (Btu/h)
t2ht = 195 #t2 by hit and trial
x = solve(QC-QH,T2)
T2 = x[0]
DTlm = (T1-t1-T2+t2)/log((T1-t1)/(T2-t2)) #Log mean temperature difference (°F)
Q = Ui*Ai1*DTlm.subs(t2,t2ht) #Total heat transfer rate (Btu/h)
#Result:
print "T2 :", round(T2.subs(t2,t2ht)),"(°F)"
print "t2 :", t2.subs(t2,t2ht),"(°F)"
print "Qdot :", round(Q/10**6) ,"x 10**6 Btu/h"
```

In [27]:

```
from __future__ import division
from math import log,e
#Variable declaration:
B = 3.33*10**-5
b = 4.48*10**-5
#From example 15.11:
A = 108.2 #Inside area of pipe (ft^3/ft)
U = 482 #Overall heat transfer coefficient (Btu/h.ft^2.°F)
MC = 30000.0
mc = 23000.0
T1 = 300.0 #Inlet temperature of hot fluid in pipe (°F)
t1 = 60.0 #Inlet temperature of cold fluid in pipe (°F)
#Calculation:
#From equation 15.28:
T2 = ((B/b)*(e**(U*A*(B-b))-1)*t1+T1*(B/b-1))/((B/b)*e**(U*A*(B-b))-1) #Outlet temperature of hot fluid (°F)
#From equation 15.32:
t2 = ((b/B)*(e**(U*A*(b-B))-1)*T1+t1*(b/B-1))/((b/B)*e**(U*A*(b-B))-1) #Outlet temperature of cold fluid (°F)
DT = ((T2-t1)-(T1-t2))/(log((T2-t1)/(T1-t2))) #Log mean difference temperature (°F)
Q1 = U*A*DT #Heat transfer rate of hot fluid (Btu/h)
Q2 = MC*(T1-T2) #Heat transfer rate of cold fluid (Btu/h)
#Result:
print "The heat load is :",round(Q2,-3)," Btu/h."
```

In [24]:

```
from __future__ import division
from math import log,pi
#Variable declaration:
Ts = 100.0 #Saturation temperature (°C)
t1 = 25.0 #Initial temperature of water (°C)
t2 = 73.0 #Final temperature of water (°C)
m = 228.0/3600.0 #Mass flow rate of water (kg/s)
cp = 4174.0 #Heat capacity of water (J/kg.K)
m_s = 55.0/3600.0 #Mass flow rate of steam (kg/s)
h_vap = 2.26*10**26 #Latent heat of condensation (J/kg)
k = 54.0 #Thermal conductivity for 0.5% carbon steel (W/m.K)
rii = 0.013 #Inner radius of inner pipe of the double pipe heat exchanger (m)
roi = 0.019 #Outer radius of inner pipe of the double pipe heat exchanger (m)
Rf = 0.0002 #Fouling factor (m^2.K/W)
Uc = 0.00045 #Clean overall heat transfer coefficient (W/m^2.K)
#Calculation:
DT1 = Ts-t1 #Temperature driving force at end 1 (K)
DT2 = Ts-t2 #Temperature driving force at end 2 (K)
DTlm = (DT1-DT2)/(log(DT1/DT2)) #Log mean difference temperature (°C)
Cw =m*cp #Capacitance rate of water (W/K)
Q = Cw*(t2-t1) #Heat transfer rate (W)
Qmax1 = Cw*(Ts-t1) #Maximum heat term from the water stream (W)
Qmax2 = m_s*h_vap #Maximum heat term from the steam (W)
E = Q/Qmax1 #Effectiveness
Lmin = (Q*(log(roi/rii)))/(2*pi*k*(Ts-t1)) #Minimum required length of heat exchanger (m)
Ud = 1.0/(1.0/Uc+Rf) #Dirty overall heat transfer coefficient (W/m^2.K)
#Result:
print "1. The temperature profile of the water and steam along the length of the exchanger is :",round(DTlm)," °C ."
print "2. Effectiveness of energy from steam to heat the water is :",round(E,3)," ."
print "3. The minimum length of the heat exchanger is :",round(Lmin,3)," m ."
print "4. The dirty overall heat transfer coefficient :",round(Ud,5)," W/m^2.K ."
print "5. U_dirty: ", round(1/Ud,-1)," W/m^2.K"
```

In [15]:

```
from math import pi
#Variable declaration:
Q = 12700.0 #Heat transfer rate (W)
Ud = 2220.0 #Dirty overall heat transfer coefficient (W/m^2.K)
DTlm = 47.0 #Log mean difference temperature (°C)
rii = 0.013 #Inner radius of inner pipe of the double pipe heat exchanger (m)
#Calculation:
A = Q/(Ud*DTlm) #Heat transfer area (m^2)
L = A/(2*pi*rii) #Tube length (m)
#Result:
print "The heat transfer area is :",round(A,4)," m^2 ."
print "The length of the heat exchanger is :",round(L,2)," m ."
```

In [16]:

```
#Variable declaration:
Ud = 2220.0 #Dirty overall heat transfer coefficient (W/m^2.K)
A = 0.1217 #Heat transfer area (m^2)
Cw = 264.0 #Capacitance rate of water (W/K)
#Calculation:
NTU = (Ud*A)/Cw #Number of transfer units of the exchanger
#Result:
print "The number of transfer units (NTU) of the exchanger is :",round(NTU,2)," ."
```

In [18]:

```
#Variable declaration:
Ao = 1.85 #Area of heat exchanger (ft^2)
#Calculation:
#From figure 15.6:
y = 0.560*10**-3 #Intercept 1/UoAo (°F.h/Btu)
ho = 1.0/(Ao*y) #Thermal conductivity for heat exchanger (Btu/h.ft^2.°F)
#Result:
print "Thermal conductivity for the heat exchanger is :",round(ho)," Btu/h.ft^2.°F ."
```

In [19]:

```
#Variable declaration:
#From figure 15.7:
a = 0.00126
b = 0.0276
#Calculation:
ho = 1.0/a #The value of ho (Btu/h.ft^2.°F)
#Result:
print "Thermal conductivity is :",round(ho)," Btu/h.ft^2.°F ."
```

In [20]:

```
#Variable declaration:
Di = 0.902/12.0 #Inside diameter of tube (ft)
Do = 1.0/12.0 #Outside diameter of tube (ft)
k = 60.0 #Thermal conductivity of tube (Btu/h.ft^2.°F)
#Calculation:
#From example 15.19:
a = 0.00126
Dr = (Do - Di)/2.0 #Radial thickness of tube wall (ft)
Rw = Dr/k #Resistance of wall (Btu/h.°F)
ho = 1.0/(a-Rw) #The revised ho (Btu/h.ft^2.°F)
#Result:
print "The revised ho is :",round(ho)," Btu/h.ft^2.°F ."
```

In [21]:

```
#Variable declaration:
a1 = 0.00044 #Term 'a' for U_clean
a2 = 0.00089 #Term 'a' for U_dirty
#Calculation:
Rs = a2 - a1 #Resistance associated with the scale
hs = 1.0/Rs #Scale film coefficient (Btu/h.ft^2.°F)
#Result:
print "The scale film coefficient neglecting the wall resistance is:",round(hs)," Btu/h.ft^2.°F ."
```