In [9]:

```
#Variable declaration:
D = 1.0 #Diamete of vessel (ft)
L = 1.5 #Length of vessel (ft)
T1 = 390.0 #Surface temperature of vessel (°F)
T2 = 50.0 #Surrounding temperature of vessel (°F)
h = 4.0 #Convective heat transfer coefficient (Btu/h.ft.°F)
#Calculation:
A = pi*D*L+2*pi*(D/2)**2 #Total heat transfer area (ft^2)
Q = h*A*(T1-T2) #Rate of heat transfer (Btu/h)
R = 1/(h*A) #Thermal resistance (°F.h/Btu)
#Result:
print "The thermal resistance of vessel wal is :",round(R,4)," °F.h/Btu ."
```

In [2]:

```
'''Referring to the previous example, convert the resistance to K/W and °C/W.
'''
#Variable declaration:
#From example 9.1:
R = 0.0398 #Theral resistance (°F.h/Btu)
Btu = 3.412 #Btu/h in a watt
C = 1.8 #Change in degree fahrenheit for a degree change in celsius
K = 1 #Change in degree celsius for a unit change in Kelvin
#Calculation:
Rc = R*Btu/C #Thermal resistance in degree cesius per watt (°C/W)
Rk = Rc/K #Thermal resistance in Kelvin per watt (K/W)
#Result:
print "The thermal resistance in °C/W is :",round(Rc,3)," °C/W."
print "The thermal resistance in K/W is :",round(Rk,3)," K/W."
```

In [3]:

```
#Variable declaration:
h = 48.0 #Convective heat transfer coefficient (Btu/h.ft.°F)
A = 2*1.5 #Total heat transfer area (ft^2)
Ts = 530.0 #Surface temperature of plate (°F)
Tm = 105.0 #Maintained temperature of opposite side of plate (°F)
kW = 3.4123*10**3 #Units kW in a Btu/h
#Calculation:
Q = h*A*(Ts-Tm) #Heat transfer rate in Btu/h (Btu/h)
Q1 = Q/kW #Heat transfer rate in kW (kW)
#Result:
print "The heat transfer rate in Btu/h is :",round(Q)," Btu/h."
print "The heat transfer rate in kW is :",round(Q1,2)," kW."
```

In [22]:

```
#Variable declaration:
TS = 10+273 #Outer surface temperature of wall (K)
Q = 3000.0 #Heat transfer rate (W)
h = 100.0 #Convection coefficient of air (W/m^2)
A = 3.0 #Area of glass window (m^2)
#Calculation:
TM = TS-Q/(h*A) #Bulk temperature of fluid (K)
#Result:
print "The bulk temperature of fluid is :",round(TM)," K."
print "The bulk temperature of fluid is :",round(TM-273)," °C."
```

In [23]:

```
#Variable declaration:
h = 24.0 #Plant operating hour per day (h/day)
d = 350.0 #Plant operating day per year (day/yr)
#Calculation:
N = h*d #Operating hours per year (h/yr)
#From example 9.1:
Q = 8545.0 #Rate of energy loss (Btu/h)
Qy = Q*N #Steady-state energy loss yearly (Btu/yr)
#Result:
print "The yearly steady-state energy loss is :",round(Qy/10**7,2)," x 10^7 Btu/yr."
```

In [25]:

```
from sympy import symbols, integrate
#Variable declaration:
x = 0.3 #Length from the leading age of the plate (m)
L = 1.2 #Length of plate (m)
TS = 58.0 #Surface temperature of plate (°C)
Ta = 21.0 #Temperature of flowing air (°C)
#Calculation:
hx = 25/x**0.4 #Local heat transfer coefficient at 0.3m (W/m^2.K) (Part 1)
y = symbols('y') #Length
hy = 25/y**0.4 #hx at the end of the plate (W/m^2.K)
h = integrate(hy, (y,0,L))/L #Average heat transfer coefficient (W/m^2.K)
Q = hx*(TS-Ta) #Heat flux at 0.3m from leading edge of plate (W/m^2)
hL = 25/L**0.4 #Local heat transfer coefficient at plate end (W/m^2.K) (Part 2)
r = h/hL #Ratio h/hL at the end of the plate
#Result:
print "1. The heat flux at 0.3 m from the leading edge of the plate is :",round(Q)," W/m^2."
print "2. The local heat transfer coefficient at the end of the plate is :",round(hL,1)," W/m^2.K."
print "3. The ratio h/hL at the end of plate is :",round(r,3)," ."
```

In [26]:

```
#Variable declaration:
#From example 9.7:
b = 1.0 #Width of plate (m)
L = 1.2 #Length of plate (m)
TS = 58.0 #Surface temperture of plate (°C)
Ta = 21.0 #Air flow temperature (°C)
h = 38.7 #Average heat transfer coefficient (W/m^2.K)
#Calculation:
A = b*L #Area for heat transfer for the entire plate (m^2)
Q = h*A*(TS-Ta) #Rate of heat transfer over the whole length of the plate (W)
#Result:
print "The rate of heat transfer over the whole length of the plate is :",round(Q,-1)," W."
```

In [27]:

```
from math import pi
#Variable declaration:
m = 0.075 #Mass rate of air flow (kg/s)
D = 0.225 #Diameter of tube (m)
mu = 208*10**-7 #Dynamic viscosity of fluid (N)
Pr = 0.71 #Prandtl number
k = 0.030 #Thermal conductivity of air (W/m.K)
#Calculation:
Re = 4*m/(pi*D*mu) #Reynolds number
#From equation 9.26:
Nu = 0.023*(Re**0.8)*(Pr**0.3) #Nusselt number
h = (k/D)*Nu #Heat transfer coefficient of air (W/m^2.K)
#Result:
print "The Heat transfer coefficient of air is :",round(h,2)," W/m^2.K."
```

In [4]:

```
#Variable declaration:
D = 0.902/12.0 #Inside diameter of tube (ft)
T_in = 60.0 #Temperature water entering the tube (°F)
T_out = 70.0 #Temperature water leaving the tube (°F)
V = 7.0 #Average wave velocity water (ft/s)
p = 62.3 #Density of water (lb/ft^3)
mu = 2.51/3600.0 #Dynamic viscosity of water (lb/ft.s)
Cp = 1.0 #Viscosity of centipoise (Btu/lb.°F)
k = 0.34 #Thermal conductivity of water (Btu/h.ft.°F)
#Calculation:
Re = D*V*p/mu #Reynolds Number
Pr = Cp*mu/k*3600 #Prandtl number
#From equation 9.26:
Nu = 0.023*(Re**0.8)*(Pr**0.4) #Nusselt number
h = (k/D)*Nu #Average film heat transfer coefficient (Btu/h.ft^2.°F)
#Result:
print "The required average film heat transfer coefficient is :",round(h)," Btu/h.ft^2.°F."
```

In [10]:

```
#Variable declaration:
P = 1.0132 * 10**5 #Air pressure (Pa)
T = 300.0+273.0 #Air temperature (K)
V = 5.0 #Air flow velocity (m/s)
D = 2.54/100.0 #Diameter of tube (m)
R = 287.0 #Gas constant (m^2/s^2.K)
#From Appendix:
Pr = 0.713 #Prandtl number of nitrogen
mu = 1.784*10**(-5) #Dynamic viscosity of nitrogen (kg/m.s)
k = 0.0262 #Thermal conductivity of nitrogen (W/m.K)
Cp = 1.041 #Heat capacity of nitrogen (kJ/kg.K)
#Calculation:
p = P/(R*T) #Density of air
Re = D*V*p/mu #Reynolds number
#From table 9.5:
Nu = 0.023*(Re**0.8)*(Pr**0.3) #Nusselt number
h = (k/D)*Nu #Heat transfer coefficient (W/m^2.K)
#Result:
print "The required Heat transfer coefficient is :",round(h,2)," W/m^2.K."
```

In [11]:

```
#Variable declaration:
T1 = 15.0 #Water entering temperature (°C)
T2 = 60.0 #Water leaving temperature (°C)
D = 0.022 #Inside diameter of tube (m)
V = 0.355 #Average water flow velocity (m/s)
TC = 150.0 #Outside wall temperature (°C)
#From Appendix:
p = 993.0 #Density of water (kg/m^3)
mu = 0.000683 #Dynamic viscosity of water (kg/m.s)
Cp = 4.17*10**3 #Heat capacity of water (J/kg.K)
k = 0.63 #Thermal conductivity of water (W/m.K)
#Calculation:
Tav1 = (T1+T2)/2.0 #Average bulk temperature of water (°C)
Re = D*V*p/mu #Reynolds number
Pr = Cp*mu/k #Prandtl number
Tav2 = (Tav1+TC)/2.0 #Fluid's average wall temperature (°C)
#From Appendix:
mu_w = 0.000306 #Dynamic viscosity of fluid at wall (kg/m.s)
#From Table 9.5:
h = (k/D)*0.027*Re**0.8*Pr**0.33*(mu/mu_w)**0.14 #Heat transfer coefficient for water (W/m^2.K)
#Result:
print "The heat transfer coefficient for water is :",round(h,1)," W/m^2.K."
```

In [12]:

```
#Variable declaration:
#From example 9.7:
h = 38.7 #Average heat transfer coefficient (W/m^2.K)
L = 1.2 #Length of plate (m)
k = 0.025 #Thermal conductivity of air (W/m)
#Calculation:
Bi = h*L/k #Average Biot number
#Result:
print "The average Biot number is :",round(Bi)," ."
```

In [14]:

```
from math import pi
#Variable declaration:
k = 60.0 #Thermal conductivity of rod (W/m.K)
p = 7850.0 #Density of rod (kg/m^3)
Cp = 434.0 #Heat capacity of rod (J/kg.K)
h = 140.0 #Convection heat transfer coefficient (W/m^2.K)
D = 0.01 #Diameter of rod (m)
kf = 0.6 #Thermal conductivity of fluid (W/m.K)
L = 2.5 #Length of rod (m)
Ts = 250.0 #Surface temperature of rod (°C)
Tf = 25.0 #Fluid temperature (°C)
#Calculation:
#Case 1:
a = k/(p*Cp) #Thermal diffusivity of bare rod (m^2/s)
#Case 2:
Nu = h*D/kf #Nusselt number
#Case 3:
Bi = h*D/k #Biot number of bare rod
#Case 4:
Q = h*(pi*D*L)*(Ts-Tf) #Heat transferred from rod to fluid (W)
#Result:
print "1. The thermal diffusivity of the bare rod is :",round(a/10**-5,2)," x 10^-5 m^2/s."
print "2. The nusselt number is :",round(Nu,2)," ."
print "3. The Biot number is :",round(Bi,4)," ."
print "4. The heat transferred from the rod to the fluid is :",round(Q)," W."
```