In [5]:

```
from math import log
#Variable declaration:
#From figure 16.13, for ideal countercurrent heat exchanger:
T1 = 150.0 #Inlet temperature of hot fluid (°F)
T2 = 100.0 #Outet temperature of hot fluid (°F)
t1 = 50.0 #Inlet temperature of cold fluid (°F)
t2 = 80.0 #Outet temperature of hot fluid (°F)
#From figure 16.14, for shell and tube exchanger:
T_1 = 50.0 #Inlet temperature of cold fluid (°F)
T_2 = 80.0 #Outet temperature of hot fluid (°F)
t_1 = 150.0 #Inlet temperature of hot fluid (°F)
t_2 = 100.0 #Outet temperature of hot fluid (°F)
#Calculation:
DT1 = T1 - t2 #Temperature driving force 1 (°F)
DT2 = T2 - t1 #Temperature driving force 1 (°F)
DTlm1 = ((DT1-DT2)/log(DT1/DT2)) #Log mean temperature driving force for ideal countercurrent heat exchanger (°F)
P = (t2-t1)/(T1 - t1) #Dimensionless ratio P
R = (T1-T2)/(t2-t1) #Dimensionless ratio R
#From figure 16.7:
F = 0.925 #Correction Factor
DTlm2 = F*DTlm1 #Log mean temperature driving force for shell and tube exchanger (°F)
#Result:
print "The log mean temperature difference for ideal system is :",round(DTlm1,1)," °F ."
print "The log mean temperature difference for real system is :",round(DTlm2,2)," °F ."
```

In [6]:

```
from math import log
5
#Variable declaration:
T1 = 400.0 #Temperature of fluid entering the shell (°F)
T2 = 250.0 #Temperature of fluid leaving the shell (°F)
t1 = 100.0 #Temperature of fluid entering the tube (°F)
t2 = 175.0 #Temperature of fluid leaving the tube (°F)
#Calculation:
DT1 = T1 - T2 #Temperature driving force 1 (°F)
DT2 = t2 - t1 #Temperature driving force 1 (°F)
DTlm1 = ((DT1-DT2)/log(DT1/DT2)) #Log mean temperature driving force for ideal countercurrent heat exchanger (°F)
P = (t2-t1)/(T1 - t1) #Dimensionless ratio P
R = (T1-T2)/(t2-t1) #Dimensionless ratio R
#From figure 16.8:
F = 0.985 #Correction factor
DTlm2 = F*DTlm1 #Log mean temperature driving force for shell and tube exchanger (°F)
#Result:
print "The log mean temperature difference between the hot fluid and the cold fluid is :",round(DTlm2,1)," °F ."
```

In [7]:

```
#Variable declaration:
#From example 16.5:
P1 = 0.30 #Dimensionless ratio P
R1 = 1.67 #Dimensionless ratio R
#From example 16.6:
P2 = 0.30 #Dimensionless ratio P
R2 = 1.67 #Dimensionless ratio R
#Calculation:
#Applying Equation 16.27:
F1 = 0.92 #Correction Factor
#Applying Equation 16.33:
F2 = 0.985 #Correction Factor
#From example 16.6:
LMTD1 = 59.4 #Log mean temperature driving force 1 for ideal countercurrent heat exchanger (°F)
LMTD2 = 108.0 #Log mean temperature driving force 2 for ideal countercurrent heat exchanger (°F)
DTlm1 = F1*LMTD1 #Log mean temperature driving force 1 for shell and tube exchanger (°F)
DTlm2 = F2*LMTD2 #Log mean temperature driving force 2 for shell and tube exchanger (°F)
#Result:
print "The log mean temperature difference for real system (in example 16.5) is :",round(DTlm1,2)," °F ."
print "The log mean temperature difference for real system (in example 16.6) is :",round(DTlm2,1)," °F ."
```

In [8]:

```
from math import log
#Variable declaration:
t2 = 75.0 #Temperature of water leaving the shell (°C)
t1 = 35.0 #Temperature of water enteringing the shell (°C)
T2 = 75.0 #Temperature of oil leaving the tube (°C)
T1 = 110.0 #Temperature of oil entering the tube (°C)
m = 1.133 #Mass flowrate of water (kg/s)
cp = 4180.0 #Heat capacity of water (J/kg.K)
F = 0.965 #Correction factor
U = 350.0 #Overall heat transfer coefficient (W/m^2.K)
#Calculation:
Q = m*cp*(t2-t1) #Heat load (W)
DT1 = T1-t2 #Temperature driving force 1 (°C)
DT2 = T2-t1 #Temperature driving force 2 (°C)
DTlm1 = (DT1-DT2)/log(DT1/DT2)+273.0 #Countercurrent log-mean temperature difference (K)
DTlm2 = F*DTlm1 #Corrected log-mean temperature difference (K)
A = Q/(U*DTlm2) #Required heat transfer area (m^2)
#Result:
print "The required heat-transfer area is :",round(A,3)," m^2 ."
```

In [10]:

```
from math import log
#Variable declaration:
t2 = 84.0 #Temperature of water leaving the tube (°C)
t1 = 16.0 #Temperature of water entering the tube (°C)
m1 = 10000.0/3600.0 #Mass flowrate of water (kg/s)
T2 = 94.0 #Temperature of oil leaving the shell (°C)
T1 = 160.0 #Temperature of oil entering the shell (°C)
#Calculation:
Tw = (t1+t2)/2.0 #Average bulk temperature of water (°C)
To = (T1+T2)/2.0 #Average bulk temperature of oil (°C)
#From table 16.1:
p1 = 987.0 #Density of water (kg/m^3)
cp1 = 4176.0 #Heat capacity of water (J/kg.°C)
p2 = 822.0 #Density of oil (kg/m^3)
Q = m1*cp1*(t2-t1) #Heat load (W)
cp2 = 4820.0 #Heat capacity of oil (J/kg.°C)
m2 = Q/(cp2*(T1-T2)) #Mass flowrate of oil (kg/s)
DT1 = T2-t1 #Temperature driving force 1 (°C)
DT2 = T1-t2 #Temperature driving force 2 (°C)
DTlm1 = ((DT1-DT2)/log(DT1/DT2)) #Log mean temperature driving force for ideal countercurrent heat exchanger (°C)
P = (t2-t1)/(T1 - t1) #Dimensionless ratio P
R = (T1-T2)/(t2-t1) #Dimensionless ratio R
#From figure 16.7:
F = 0.965 #Correction factor
DTlm2 = F*DTlm1 #Log mean temperature driving force for 1-4 shell and tube exchanger (°C)
#Result:
print "1. The heat load is :",round(Q/10**6,3)," MW ."
print "2. The countercurrent flow log mean temperature difference is :",round(DTlm1)," °C ."
print "3. The F correction factor and the corrected log mean temperature difference is :",round(DTlm2,1)," °C ."
```

In [11]:

```
from math import pi
#Variable declaration:
#From example 16.10:
U = 350.0 #Over all heat transfer coefficient (W/m^2.°C)
DTlm = 74.3 #Log mean temperature driving force for 1-4 shell and tube exchanger (°C)
Q = 788800.0 #Heat load (W)
Nt = 11.0 #Number of tubes per pass
Np = 4.0 #Number of passes
Di = 0.0229 #Inside diameter of tube (m)
#Calculation:
A = Q/(U*DTlm) #Heat transfer area required for heat exchanger (m^2)
N = Nt*Np #Total number of tubes
L = A/(pi*Di*N) #Tube length (m)
#Result:
print "The heat transfer area required for the heat exchanger is :",round(A,2)," m^2 ."
print "The length of the tubes required for the heat exchanger is :",round(L*3.28,1)," ft ."
```

In [18]:

```
#Variable declaration:
#From example 16.10:
m1 = 2.778 #Mass flowrate of water (kg/s)
cp1 = 4176.0 #Heat capacity of water (J/kg.°C)
cp2 = 4820.0 #Heat capacity of oil (J/kg.°C)
m2 = 2.48 #Mass flowrate of oil (kg/s)
t2 = 84.0 #Temperature of water leaving the tube (°C)
t1 = 16.0 #Temperature of water entering the tube (°C)
T2 = 94.0 #Temperature of oil leaving the shell (°C)
T1 = 160.0 #Temperature of oil entering the shell (°C)
U = 350.0 #Over all heat transfer coefficient (W/m^2.°C)
A = 30.33 #Heat transfer area required for heat exchanger (m^2)
#Calculation:
C1 = m1*cp1 #Capacitance rate of water (W/°C)
C2 = m2*cp2 #Capacitance rate of oil (W/°C)
Q = C1*(t2-t1) #Heat load of water (W)
Qmax = C1*(T1-t1) #Maximum heat load of water (W)
E = Q/Qmax #Effectiveness
if (C1<C2):
Cmin = C1 #Minimum capacitance rate (W/°C)
Cmax = C2 #Maximum capacitance rate (W/°C)
else:
Cmin = C2 #Minimum capacitance rate (W/°C)
Cmax = C1 #Maximum capacitance rate (W/°C)
NTU = U*A/Cmin #Number of transfer units
C = Cmin/Cmax #Capacitance rate ratio
#Result:
print "The effectiveness is :",round(E,3),"."
print "The number of transfer units is :",round(NTU,3),"."
print "The capacitance rate ratio is :",round(C,3),"."
```

In [19]:

```
from math import log
#Variable declaration:
#From table 16.4:
Cw = 11680.3 #Capacitance rate of water (W/°C)
t2 = 65.0 #Temperature of water leaving the tube (°C)
t1 = 20.0 #Temperature of water entering the tube (°C)
T2 = 107.3 #Temperature of steam leaving the shell (°C)
T1 = 107.3 #Temperature of steam entering the shell (°C)
hv = 2.238*10**6 #Latenet heat of condensation for steam (J/kg)
U = 2000.0 #Overall heat transfer coefficient (W/m^2.°C)
#Calculation:
Q = Cw*(t2-t1) #Heat load (W)
m2 = Q/hv #Steam condensation rate (kg/s)
DT1 = T2-t1 #Temperature driving force 1 (°C)
DT2 = T1-t2 #Temperature driving force 2 (°C)
DTlm1 = ((DT1-DT2)/log(DT1/DT2)) #Log mean temperature driving force for ideal countercurrent heat exchanger (°C)
F = 1.0 #Correction factor (since, T2 = T1)
DTlm2 = F*DTlm1 #Log mean temperature driving force for shell and tube exchanger (°C)
A1 = Q/(U*DTlm2) #Heat transfer area using LMTD method (m^2)
E = (t2-t1)/(T1-t1) #Effectiveness
#From figure 16.18:
NTU = 0.7 #Number of transfer units
A2 = (NTU*Cw)/U #Heat transfer area using E-NTU method (m^2)
#Result:
print "The heat transfr area for the exchanger (using LMTD method) is :",round(A1,2)," m^2 ."
print "The heat transfr area for the exchanger (using E-NTU method) is :",round(A2,1)," m^2 ."
```

In [21]:

```
from math import pi,log
#Variable declaration:
#From table 16.5:
t2 = 75.0 #Temperature of water leaving the shell (°C)
t1 = 35.0 #Temperature of water entering the shell (°C
T2 = 75.0 #Temperature of oil leaving the tube (°C)
T1 = 110.0 #Temperature of oil entering the tube (°C)
mw = 1.133 #Mass flowrtae of water (kg/s)
cpw = 4180.0 #Heat capacity of water (J/kg.K)
cpo = 1900.0 #Heat capacity of oil (J/kg.K)
p = 850.0 #Density of oil (kg/m^3)
Di = 0.01905 #Inside diameter of tube (m)
V = 0.3 #Average velocity of oil flow inside the tube (m/s)
Np = 2.0 #Number of passes
Uc = 350.0 #Overall heat transfer coefficient for clean heat exchanger (W/m^2)
Rf = 0.00027 #Fouling factor (m^2.K/w)
#Calculation:
Cw = mw*cpw #Water capacitance rate (W/K)
Q = Cw*(t2-t1) #Heat load (W)
Co = Q/(T1-T2) #Oil capacitance rate (W/K)
mo = Co/cpo #Total flowrate of oil (kg/s)
if (Cw<Co):
Cmin = Cw #Minimum capacitance rate (W/K)
Cmax = Co #Maximum capacitance rate (W/K)
else:
Cmin = Co #Minimum capacitance rate (W/K)
Cmax = Cw #Maximum capacitance rate (W/K)
m_ot = p*V*(pi/4.0)*Di**2 #Oil flowrate per tube (kg/s)
Nt = mo/m_ot #Number of tubes per pass
N = Nt*Np #Number of tubes
DT1 = T2-t1 #Temperature driving force 1 (°C)
DT2 = T1-t2 #Temperature driving force 2 (°C)
DTlm1 = ((DT1-DT2)/log(DT1/DT2)) #Log mean temperature driving force for ideal countercurrent heat exchanger (°C)
P = (t2-t1)/(T1 - t1) #Dimensionless parameter P
R = (T1-T2)/(t2-t1) #Dimensionless parameter R
#From figure 16.7:
F = 0.81 #Correction factor
DTlm2 = F*DTlm1 #Log mean temperature driving force for shell and tube exchanger (°C)
Ud = 1.0/(1.0/Uc+Rf) #Dirty overall heat transfer coefficient (W/m^2.K)
A = Q/(Ud*DTlm2) #Required heat transfer area (m^2)
L = A/(N*pi*Di) #Tube length (m)
#Result:
print "1. The mass flow rate of the oil is :",round(mo,2)," kg/s ."
print "2. The minimum and maximum heat capacity rate is :",round(Cmin)," and ",round(Cmax,1)," W/K ."
print "3. The heat load, Q is :",round(Q)," W ."
print "4. The total number of tubes is :",round(N,-1),"."
print "5. The tube length is :",round(L,1)," m ."
```

In [22]:

```
#Variable declaration:
#From example 16.22:
t2 = 75.0 #Temperature of water leaving the shell (°F)
t1 = 35.0 #Temperature of water entering the shell (°F)
T2 = 75.0 #Temperature of oil leaving the tube (°F)
T1 = 110.0 #Temperature of oil entering the tube (°F)
U = 320.0 #Overall heat transfer coefficient (W/m^2.K)
A = 19.5 #Required heat transfer area (m^2)
Cmin = 4736.0 #Minimum capacitance rate (W/K)
#Calculation:
DT1 = t2-t1 #Actual water temperature change (°F)
DT2 = T1 - t1 #Maximum water temperature change (°F)
E = DT1/DT2 #Effectiveness
NTU = (U*A)/Cmin #Number of transfer units
#Result:
print "The effectiveness is :",round(E,3),"."
print "The NTU is :",round(NTU,3),"."
```