In [2]:

```
#Heat Loss Through Insulating Wall
#Variable declaration
L = 0.0254 #Thickness of fibre insulating board
T1 = 352.7 #Temperature of hot face, °C
T2 = 297.1 #Temperature of cold face, °C
A = 1.0 #Suface area, m2
k = 0.048 #Thermal conductivity of fibre insulating board, W/(m.K)
#Calculation
q = k*(T1-T2)/L
#Result
print "Heat loss per unit area:", round(q,1), "W/m2"
```

In [3]:

```
#Length of tubing for Cooling Coil
from math import log, pi
#Variable declaration
ri = 0.005 #Inside radius of tubing
ro = 0.02 #Outside radius of tubing
k = 0.151 #Thrmal conductivity of rubber tubing, W/mK
Ti = 274.9 #Inside wall temaperature, K
To = 297.1 #Outside wall temaperature, K
Q = 14.65 #Total heat tranfer rate, W
#Calculation
Ai = 2*pi*ri*1.0
Ao = 2*pi*ro*1.0
Alm = (Ai-Ao)/(log(Ai/Ao))
Q1 = k*Alm*(To-Ti)/(ro-ri)
L = Q/Q1
#Result
print "Length of tubing required ",round(L,3) , "m"
```

In [5]:

```
#Heat Flow Through an Insulated Wall of a Cold Sorage
#Variable declaration
L1 = 0.0127 #Thickness of inner wall, m
L2 = 0.1016 #Thickness of middle wall, m
L3 = 0.0762 #Thickness of outer wall, m
k1 = 0.151 #Thermal conductivity of inner wall, W/mK
k2 = 0.0433 #Thermal conductivity of middle wall, W/mK
k3 = 0.768 #Thermal conductivity of outer wall, W/mK
A = 1.0 #Heat Area area, m2
Ti = 255.4 #Inner wall surface temperature, K
To = 297.1 #outer wall surface temperature, k
#Calculation
R1 = L1/(k1*A) # Resistance of the inner wall, K/W
R2 = L2/(k2*A) # Resistance of the middle wall, K/W
R3 = L3/(k3*A) # Resistance of the outer wall, K/W
Rt = R1 + R2 + R3
q = (Ti-To)/Rt
T2 = Ti - q*R1
#Result
print 'Resistance offered by 1st wall %5.4f K/W'%(R1)
print 'Resistance offered by 2nd wall %5.4f K/W'%(R2)
print 'Resistance offered by 3rd wall %5.4f K/W'%(R3)
print 'Total Resistance of composite wall %5.4f K/W'%(Rt)
print "Heat loss",round(q,2),'W/m2'
print "Temperature at interface between pine wood and cork",round(T2,2), "K"
```

In [7]:

```
#Heat Loss from an Insulated pipe
from math import log, pi
#Variable declaration
ks = 21.63 #Heat transfer coefficient of the pipe (W/K.m)
ki = 0.2423 #Heat transfer coefficient of the insulation (W/K.m)
d1 = 0.0254 #Inner diameter of the pipe (m)
d2 = 0.0508 #Inner diameter of the insulation (m)
thks = 0.0254
T1 = 811 #The wall temperature of the pipe (K)
T3 = 310.8 #The temperature of the outside wall of the insulation (k)
L = .305 #Length of the pipe (m)
#Calculation
r1 =d1/2.
r2 = d2/2.
r3 = r2 + thks
A1 = 2*pi*r1*L
A2 = 2*pi*r2*L
A3 = 2*pi*r3*L
A12lm = (A1-A2)/log(A1/A2)
A23lm = (A2-A3)/log(A2/A3)
R12 = (r2-r1)/(ks*A12lm)
R23 = (r3-r2)/(ki*A23lm)
Q = (T1-T3)/(R12+R23)
T2 = T1 - Q*R12
#Results
print "Temperature of Interface", round(T2,1) ,"K"
print "Heat loss", round(Q,1) ,"W"
```

In [8]:

```
#Heat Loss by Convection and Conduction and Overall U
from math import log, pi
#Variable declaration
di = 0.824 #Inner diameter of the pipe (m)
do = 1.05 #Outer diameter of the pipe (m)
thki = 1.5
hi = 1000 #Convective heat transfer coefficient (btu/h.ft2)
ho = 2. #Convective heat transfer coefficient on the outside (btu/h.ft2)
km = 26. #Mean thermal cunductivity of metal (btu/h.ft)
ki = 0.037 #Mean thermal cunductivity of insulation (btu/h.ft)
Ts = 267 #Surface temperature of the pipe (F)
Ta = 80 #Surrounding air temperature (F)
L = 1.
#Calculation
ri = di/(12.*2.)
r1 = do/(12.*2.)
ro = r1 + thki/12.
Ai = 2*pi*ri*L
A1 = 2*pi*r1*L
Ao = 2*pi*ro*L
Ai1lm = (Ai-A1)/log(Ai/A1)
A1olm = (A1-Ao)/log(A1/Ao)
Ri1 = (r1-ri)/(km*Ai1lm)
R1o = (ro-r1)/(ki*A1olm)
Ri = 1./(hi*Ai)
Ro = 1./(ho*Ao)
Rt = Ri+Ri1+R1o+Ro
Q = (Ts-Ta)/(Rt)
Ui = 1./(Ai*Rt)
Q1 = Ui*Ai*(Ts-Ta)
#Result
print "Heat lost to the surrounding using resistance",round(Q,1), "Btu/hr"
print "Heat lost to the surrounding using Overall Heat TRansfer Coeff",round(Q1,1), "Btu/hr"
```

In [9]:

```
#Heat Generation in a cylinder
from math import pi
#Variable declaration
i = 200. #Current through the wire, A
r = 0.001268 #radius of the wire, m
L = 0.91 #Length of wire, m
R = 0.126 #Resistance of stainless steel, ohm
Tw = 422.1 #Wall temperature of the wire, K
k = 22.5 #Thermal conductivity of steel, W/mK
#Calculation
Q = i**2*R
qdot = Q/(pi*r**2*L)
To = Tw + qdot*r**2/(4*k)
#Result
print "Temperature at the centre of the wire",round(To,1),"K"
```

In [10]:

```
#Insulating an Electrical Wire and Critical Radius
from math import log, pi
#Variable declaration
d = 1.5 #Diameter of electrical wire, mm
thki = 2.5 #Thickness of insulation, mm
Ta = 300. #Temrature of air, K
ho = 20. #Outside Heat transfer coefficient, W/m2.K
ki = 0.4 #Thermal conductivity of insulation, W/mK
Tw = 400. #Surface temperature of the wire, K
L = 1. #Length of wire, m
#Calculation
r1 = d*1e-3/2.
r2 = r1+thki*1e-3
r2c = ki/ho
A1 = 2*pi*r1*L
Q = ho*A1*(Tw-Ta)
Qi = 2*pi*L*(Tw-Ta)/(log(r2/r1)/ki + 1./(ho*r2))
#Result
print "(a) Critical radius of insulation",round(r2c*1e3,1),"mm"
print "(b) Heat Transfer rate without insulation",round(Q,2),"W/m"
print "(c) Heat Transfer rate with insulation",round(Qi,2),"W/m"
```

In [11]:

```
#Two dimenssional conduction by Graphical Proceedure
#Variable declaration
T1 = 600. #Inside temperature, K
T2 = 400. #Outside temperature, K
k = 0.9 #Thermal conductivity, W/mK
L = 5. #Length of flue, m
N = 4 #Number of temperature subdivisions
M = 9.25 #
#Calculation
Q = 4*(M*k*L*(T1-T2)/4.)
#Result
print "Heat Transfer Rate :",round(Q), "W"
```

In [12]:

```
#Heating of Air in Turbulent Flow
#Variable declaration
Tc = 477.6 #Average temperature of air, K
v = 7.62 #Velocity of air, m/s
di = 0.0254 #inner diameter, m
Ts = 488.7 #Steam temperature, K
muab = 2.6e-5 #Viscosity of air, Pa.s
ka = 0.03894 #Thermal conductivity of air, W/mK
Npr = 0.686
muw = 2.64e-5 #Viscosity of air at wall temperature, Pa.s
P = 206.8 #Pressure, kPa
#Calculation
rhoa =28.97*(1./22.414)*(P/101.325)*273.2/Tc
Nre = di*v*rhoa/muab
Nnu = 0.027*Nre**0.8*Npr**(1./3)*(muab/muw)**0.14
hL = Nnu*ka/di
q = hL*(Ts-Tc)
#Result
print "Average Heat Transfer Coefficient for L/D > 60", round(hL,2), "W/m2.K"
print "Heat Flux", round(q,2), "W/m2"
print 'The answers different than book, because of book uses rounded numbers'
```

In [15]:

```
#Water Heated by Steam, Trial and Error Solution
from math import pi
#Variable declaration
di = 0.0266 #Inner diameter of the pipe (m)
do = 0.0334 #Outer diameter of the pipe (m)
L = 0.305 #Lenth of pipe, m
T = 65.6 #Average temperature of the steel pipe (deg C)
v = 2.44 #Velocity of the water flow (m/s)
Ts = 107.8 #Temperature of the steam (deg C)
ho = 10500. #Heat transfer coefficient on the steam side (W/m2.K)
# Properties of water at T=65.6°C
Npr = 2.72 #Prandtl number
rho = 980. #Density of water (kg/m3)
kw = 0.663 #Thermal conductivity of Water (W/m.K)
mu = 4.32e-4 #Viscosity of water (Pa.s)
k = 45. #Thermal conductivity of metal wall (W/m.K)
# Properties of water at T=80°C
muw = 3.56e-4
#Calculation
#Part A
Nre = di*v*rho/mu
Nnu = 0.027*(Nre**0.8)*(Npr**(1./3))*(mu/muw)**0.14
hi = Nnu*kw/di
#Part B
Ai = pi*di*L
Ao = pi*do*L
Am = pi*L*(do+di)/2
Ri = 1./(hi*Ai)
Ro = 1./(ho*Ao)
Rm = (do-di)/(2*k*Am)
SR = Ri+Ro+Rm
DelT = (Ts-T)
DelTw = Ri*DelT/SR
Tw = T + DelTw
Ui = 1.0/(Ai*SR)
Q = Ui*Ai*DelT
#Result
print "Inside Heat Transfer Coefficient:", round(hi), "W/m2.K"
print "The assumed temperature of water 80°C is comparable with Calculated", round(Tw,2)
print "Heat Transfer Rate", round(Q),"W"
print 'The answers are different than book, because of book uses rounded numbers'
```

In [16]:

```
#Liquid-Metal Heat Transfer Inside a Tube
from math import pi
#Variable declaration
mdot = 4. #Flowrate of liquid metal (kg/s)
di = 0.05 #Inner diameter of pipe (m)
Ti = 500. #Initial temperature of liquid entering (K)
To = 505. #Final temperature of liquid leaving (K)
mu = 7.1e-4 #Viscosity of the liquid (Pa.s)
rho = 7400. #Density of the liquid (kg/m3)
cp = 120. #Specific heat (J/kg.K)
k = 13. #Heat transfer coefficient (W/m.K)
delT = 30.
#Calculation
Ac = pi*di**2/4.
G = mdot/Ac
Nre = di*G/mu
Npr = cp*mu/k
Npe = Nre*Npr
Nnu = 0.625*Npe**0.4
hL = Nnu*k/di
Q = mdot*cp*(To-Ti)
As = Q/(hL*delT)
L = As/(pi*di)
#Result
print "Heat Transfer coefficient",round(hL,2),"W/m2.K"
print "The Length of the tube required",round(L,3),"m"
```

In [18]:

```
#Heat Transfer Area and Log Mean Temperature Difference
from math import log
#Variable declaration
cpm = 2300. #Specific heat of the hydrocarbon oil (J/kg.K)
Ti = 371.9 #Initial temperature of the oil (K)
To = 349.7 #Final temperature of the oil (K)
mdotoil = 3630. #Flowrate of oil (kg/h)
mdotw = 1450. #Flowrate of water (kg/h)
cpw = 4187. #Specific heat of water (J/kg.K)
Twi = 288.6 #Temperature of the inlet water (K)
Ui = 340. #Overall heat tranfer coefficient (W/m2.K)
#Calculations
Q = mdotoil*cpm*(Ti-To)/3600
Two = Twi + Q/((mdotw/3600)*cpw)
#Contercurrent
delT1 = To - Twi
delT2 = Ti - Two
deltLM = (delT1-delT2)/log(delT1/delT2)
Ai = Q/(Ui*deltLM)
#Result
print "Heat lost by oil",round(Q,1),"W"
print "Outlet Temperature of cooling water",round(Two,1),"K"
print "Area required for cooling in Countercurrent flow:",round(Ai,2),"m2"
#Co-current/Parallel flow
delT1 = Ti - Twi
delT2 = To - Two
deltLM = (delT1-delT2)/log(delT1/delT2)
Ai = Q/(Ui*deltLM)
#Result
print "Area required for cooling in Co-current/Parallel flow:",round(Ai,2),"m2"
print 'The answers different than book because book uses rounded numbers'
```

In [22]:

```
#Laminar Heat Transfer and Trial and Error
from scipy import interpolate
from math import pi
#Variable declaration SI Units
Ti = 150. #Initial temperature of the hydrocarbon oil (F)
di = 0.0303 #Inside diameter of the pipe (ft)
L = 15. #Length of the tube (ft)
mdot = 80. #Flowrate of the oil (lbm/h)
Tw = 350. #Inside wall temperature of the wall (F)
Cp = 0.5 #Specific heat of oil (btu/lbm)
km = 0.083 #Thermal conductivity, Btu/(h.ft.°F)
T=[150,200,250,300,350] #Temperature of hydrocarbon oil, °F
mu=[6.5,5.05,3.8,2.82,1.95] #Viscosity of hydrocarbon oil, °F
cf = 2.4191 #Specific Heat of hydrocarbon oil, °F
#Calculations
f = interpolate.interp1d(T,mu)
muw = cf*f(Tw)
Ac = pi*di**2/4.
G = mdot/Ac
Toass = 250.
xx = 1.2
#Calculation
while(xx > 0.0001):
Tb = int((Ti+Toass)/2.)
mub = cf*f(Tb)
Nre = di*G/mub
Npr = Cp*mub/km
Nnu = 1.86*(Nre*Npr*di/L)**(1./3)*(mub/muw)**0.14
h = Nnu*km/di
tau = h*pi*di*L/(mdot*Cp)
tau2 = tau/(1+tau/2.)
To = (tau*(Tw-Ti/2.)+Ti)/(1+tau/2.)
xx = abs((Toass - To)/Toass)
Toass = To
#Result
print "The outlet temperature of the oil",round(Toass,0),"°F"
print "The heat transfer coefficient calculated is",round(h,2),"Btu/(hr.ft2)"
print 'The answers are different than book because book uses rounded numbers'
```

In [23]:

```
#Cooling of Cooper Fin
#Variable declaration
l = 0.051 #length of square fin, m
T = 82.2 #Temperature of fin, °C
Ta = 15.6 #Temperature of air, °C
P = 1. #Absolute Pressure of air, atm
v = 12.2 #Velocity of air, m/s
k = 0.028 #Thermal conductivity of air at 48.9°C, W/(m.K)
rho = 1.097 #Density of air at 48.9°C, kg/m3
mu = 1.95e-5 #viscosity of air at 48.9°C, W/(m.K)
Npr = 0.704 #Prandtl numbe for air at 48.9°C, W/(m.K)
#Calculation
Tf = (T+Ta)/2.
Nre = l*v*rho/mu
Nnu = 0.664*Nre**0.5*Npr**(1./3.)
ha = Nnu*k/l
Nnu = 0.0366*Nre**0.8*Npr**(1./3.)
hb = Nnu*k/l
#Result
print " A) Heat Transfer Coeficient for Laminar Flow", round(ha,1),"W/(m2.K)"
print " B) Heat Transfer Coeficient for Turbulent Conditions", round(hb,1),"W/(m2.K)"
```

In [26]:

```
#Cooling of Sphere
#Variable declaration
d = 0.051 #Diameter of sphere, m
T = 82.2 #Temperature of fin, °C
Ta = 15.6 #Temperature of air, °C
P = 1. #Absolute Pressure of air, atm
v = 12.2 #Velocity of air, m/s
k = 0.028 #Thermal conductivity of air at 48.9°C, W/(m.K)
rho = 1.097 #Density of air at 48.9°C, kg/m3
mu = 1.95e-5 #viscosity of air at 48.9°C, W/(m.K)
Npr = 0.704 #Prandtl numbee for air at 48.9°C, W/(m.K)
hflat = 77.2 #Film coeff for heat transfer from flat plate, W/(m2.K)
#Calculation
Tf = (T+Ta)/2.
Nre = d*v*rho/mu
Nnu = 2.+ 0.6*Nre**0.5*Npr**(1./3.)
h = Nnu*k/d
#Result
print "Reynolds number", round(Nre)
print "Heat transfer coeffiecient", round(h,1), "W/(m2.K) is less than Heat Transfer coeff for flat plate in prevoius problem"
print 'The answers are different than book because book uses rounded numbers'
```

In [34]:

```
#Heating of air by a bank of tubes
from math import pi
#Variable declaration
do = 0.0254 #Outside Diameter of tube,m
L = 0.305 #Length of tube bank,m
Sn = 0.0381 #Normal Tube spacing, m
Sp = 0.0381 #Parallel tube spacing,m
Nt = 40 #Number of tubes in bank
Tw = 57.2 #Surface temperature of tubes, °C
Ti = 15.6 #Air inlet temperature, °C
To = 21.1 #Assumed oultet temperature of air, °C
P = 1. #Air Pressure, atm abs
v = 7.62 #Velocity of air, m/s
rho = 1.137 #Density of air, kg/m3
mu = 1.9e-5 #Viscosity of air, Pa.s
Cp = 1004.8 #Specific heat of air, kJ/(kg.K)
Npr = 0.705 #Prandtl number of air
k = 0.027 #Thermal conductivity of air,W/(m.K)
rho156 = 1.2224 #Density of air at 15.6°C, kg/m3
#Calculation
snd = Sn/do
spd = Sp/do
#From table 4.6-2
C, m = 0.278, 0.620
er = 1.0
while er >= 0.2:
Tb = (Ti+To)/2.
Tf = (Tw+Tb)/2.
vmax = v*Sn/(Sn-do)
Nre = do*vmax*rho/mu
Nnu = C*Nre**m*Npr**(1./3.)
h = Nnu*k/do
#Correction factor for heat transfer coefficient from table4.3-3 for four transverse tubes
#is 0.9
hc = 0.9*h
A =Nt*pi*do*L
Q = hc*A*(Tw-Tb)
Af = 10*Sn*L #Frontal Area
m = Af*v*rho156
delT = Q/(m*Cp)
Tout = Ti + delT
er = abs(To-Tout)
To = (To+Tout)/2
#Result
print "Total Heat transfer Rate", round(Q),"W"
print 'The calculated outlet bulk gas temperature is %4.2f °C'%To
print 'The answers are different than book because book uses rounded numbers'
```

In [36]:

```
#Natural Convection from Vertical Wall of an Oven
#Variable Declaration
H = 1. #Height of the wall (ft)
Tw = 450 #Temperature of the wall (deg F)
Tb = 100. #Temperature of the wall in contact (F)
L = 1. #Length of the wall (m)
k = 0.0198 #Heat transfer cofficient of the wall (btu/h.ft.F)
rho = 0.0541 #Density of air (lbm/ft3)
Pr = 0.69 #Prandtl number
mu = 0.0562 #Viscosity of air (cp)
g = 32.174 #Graitational accleration (ft/s2)
#Calculations
#English Units
Tf = (Tw+Tb)/2.
beta = 1./(460.+Tf)
delT = Tw - Tb
Gr = L**3*rho**2*g*beta*3600**2*delT/(mu**2)
a = 0.59
m = 1./4.
Nu = a*(Gr*Pr)**m
h = k*Nu/L
A = L*H
Q = h*A*delT
#Results
print "In English Units"
print "The heat transfer cofficient is ",round(h,2),"btu/h.ft2.F"
print "The heat transfer rate across the wall is ",round(Q),"btu/h"
#SI Units
H = 0.305 #Height of the wall (m)
Tw = 505.4 #Temperature of the wall (K)
Tb = 311.0 #Temperature of the wall in contact (K)
L = 0.305 #Length of the wall (m)
k = 0.0343 #Thermal conductivity of the wall (W/(m.K)
rho = 0.867 #Density of air (kg/m3)
Pr = 0.69 #Prandtl number
mu = 2.32e-5 #Viscosity of air (cp)
g = 9.806 #Graitational accleration (m/s2)
#Calculations
Tf = (Tw + Tb)/2
beta = 1./Tf
delT = Tw - Tb
Gr = L**3*rho**2*g*beta*delT/(mu**2)
a = 0.59
m = 1./4.
Nu = a*(Gr*Pr)**m
h = k*Nu/L
A = L*H
Q = h*A*delT
#Results
print "In SI Units"
print "The heat transfer cofficient is ",round(h,2),"W/(m2.K)"
print "The heat transfer rate across the wall is ",round(Q,1),"W"
print 'The answers are different than book because book uses rounded numbers'
```

In [5]:

```
#Natural Convection and Simplified Equation
#Variable Declaration
#From previous Example 4.7-1 Page Number 254
L = 0.305 #Length of the wall (m)
delT = 194.4 #Temperature diffrence (K)
#Calculation
A = 0.305*0.305 #Area of the wall (m2)
h = 1.37*(delT/L)**.25
Q = h*A*delT
#Results
print "The heat transfer coefficient calculated is ",round(h,2),"W/m2/K"
print "The heat transfer rate across the wall is ",round(Q,2),"W"
print 'The answers are different than book because book uses rounded numbers'
```

In [7]:

```
#Natural Convection in Enclosed Vertical Space
#Variable Declaration
L = 0.6 #Length of the plate (m)
W = 0.4 #Width of the plates (m)
d = 0.03 #Distance between the plates (m)
T1 = 394.3 #Temperature at one side of the plate (k)
T2 = 366.5 #Temperature at the other side of the plate (k)
rho = 0.9295 #Density of air (kg/m3)
mu = 2.21e-5 #Viscosity of air (Pa.s)
k = 0.03219 #Heat transfer coefficient of wall (W/m.K)
Pr = 0.693 #Prandtl number
g = 9.806 #Gravitational accleration (m/s)
#Calculations
Tf = (T1 + T2)/2.
beta = 1/Tf
Gr = d**3*rho**2*g*beta*(T1-T2)/(mu**2)
h = k/d*0.2*(Gr*Pr)**(1./4.)/(L/d)**(1./9.)
A = L*W
Q = h*A*(T1-T2)
#Results
print "Heat Transfer Coefficient", round(h,3),"W/m2.K"
print "Heat Transfer Rate", round(Q,2),"W"
```

In [8]:

```
#Rate of Heat Transfer in a Jacketed Kettle
#Variable Declaration
Tjs = 115.6 #Temperature of steam being condensed (deg C)
dki = 0.656 #Inside diameter of the kettle (m)
hk = 0.984 #Height of the kettle (m)
tw = 0.0032 #Thickness of the wall of the jacket (m)
k = 16.27 #Heat transfer coefficient of the wall (W/m.K)
hi = 10200. #Condensing steam cofficient (W/m2.K)
Tsat = 100. #Saturation temperature (deg C)
A = 1.0
#Calculations
Twa = 110.
Ri = 1./(hi*A)
Rw = tw/(k*A)
Riw = Ri + Rw
xx = 1.2
while(xx > 0.1):
delT = Twa - Tsat
ho = 5.56*delT**3
q = ho*delT
Ro = 1./(ho*A)
Rs = Riw + Ro
delTc = Ro*(Tjs-Tsat)/Rs
Tw = Tsat + delTc
xx = abs(Tw-Twa)
Twa = (Tw + Twa)/2.
#Results vary because more iterations are done
#Result
print "Ri:%5.2e" %Ri
print "Rw:%5.2e" %Rw
print "Ro:%5.2e" %Ro
print 'Wall Temperature: %4.1f'%Tw
print "Boiling Heat Transfer Coefficient", round(ho,1),"W/(m2.K)"
print "Results vary because more iterations are done"
print 'The answers are different than book because book uses rounded numbers'
```

In [9]:

```
#Condensation on Vertical Tubes
from math import pi
#Variable Declaration English Units
Ps, Tsat = 10., 193 #Saturation Pressure ans temperature, psia and °F
L , do = 1., 1./12 #Lenght and ouside diameter of the tube, m
Tw = 187. #Wall temperature, °F
hv, hl = 1143.3, 161. #Latent heat of evaporation and enthalpy of liquid
vl,vg = 0.01657, 40.95 #specific volume of liquid and vapor, ft3/lbm
mul = 0.324 #Viscosity of liquid, lbm/(ft.hr)
kl = 0.390 #Thermal conductivity of liquid, Btu/(ft.hr.°F)
g = 32.174 #Gravitational acceleration, ft/s2
#Calculation English Units
g = g*3600**2
mul = mul*2.4191
rhol , rhov = 1./vl , 1./vg
Tf = (Tw + Tsat)/2.
hfg = hv-hl
delT = Tsat - Tw
Nu = 1.13*(rhol**2*g*hfg*L**3/(mul*kl*delT))**(1./4)
h=Nu*kl/L
A = pi*do*L
Q = h*A*delT
mdot = Q/hfg
Re = 4*mdot/(pi*do*mul)
print "Average heat transfer coefficient",round(h,2),"Btu/(h.ft2.°F)"
print "Reynolds number is,", round(Re,1), "hence flow is laminar"
#Variable Declaration SI Units
Ps, Tsat = 68.9, 89.44
L , do = 0.305, 0.0254
Tw = 86.11
hv, hl = 2657800, 374600
vl,vg = 0.01657/16, 40.95/16
mul = 3.24e-4
kl = 0.675
g = 9.806
#Calculation SI Units
rhol , rhov = 1./vl , 1./vg
Tf = (Tw + Tsat)/2.
hfg = hv-hl
delT = Tsat - Tw
Nu = 1.13*(rhol**2*g*hfg*L**3/(mul*kl*delT))**(1./4)
h=Nu*kl/L
A = pi*do*L
Q = h*A*delT
mdot = Q/hfg
Re = 4*mdot/(pi*do*mul)
#Results
print "Average heat transfer coefficient",round(h,2),"W/(m2.K)"
print "Reynolds number is,", round(Re,1), "hence flow is laminar"
print 'The answers are different than book because book uses rounded numbers'
```

In [10]:

```
#Temperature Correction Factor for a Heat Exchanger
#Variable Declration
mdotc = 2.52 #Mass flow rate of water, kg/s
Tci, Tco = 21.1, 54.4 #Inlet and outlet temperature of cold water, °C
Thi, Tho = 115.6, 48.9 #Inlet and outlet temperature of hot water, °C
Ao = 9.3 #Outside surface area of exchanger, m2
Cp = 4187. #mean specific heat of water, J/(kg.K)
#Calculations
Qc= mdotc*Cp*(Tco-Tci)
delT1 = Thi-Tco
delT2 = Tho-Tci
delTLM = (delT1-delT2)/log(delT1/delT2)
Z = (Thi-Tho)/(Tco-Tci)
Y = (Tco-Tci)/(Thi-Tci)
#PART "A" 1-2 pass
Fta = 0.74 # correction factor for Z and Y values in part a from chart
delTMa = Fta*delTLM
Uoa = Qc/(Ao*delTMa)
#PArt "B" 2-4
Ftb = 0.94 # correction factor for Z and Y values in part b from chart
delTMb = Ftb*delTLM
Uob = Qc/(Ao*delTMb)
#Result
print "PART A"
print "Mean Temperature Difference for 1-2 pass Heat Exchanger", round(delTMa,1),"°C or K"
print "Required Overall outside Heat Transfer coefficient for 1-2 pass", round(Uoa,1),"W/(m.K)"
print "PART B"
print "Mean Temeperature Difference for 2-4 pass Heat Exchanger", round(delTMb,1),"°C or K"
print 'The answers are different than book because book uses rounded numbers'
```

In [12]:

```
#Effectiveness of Heat Exchanger
from math import exp
#Variable Declaration
mc, mh = 0.667, 2.85 #mass flow rate of cold water and hot oil,kg/s
cpc, cph = 4192., 1890. #Specific heat of cold water and hot oil,kJ/(kg.K)
Tci,Thi = 308., 383. #Inlet temperatures of cold water and hot oil, °C
U,A = 300., 15. #Overall heat transfer coefficient W/(m2.K) and Surface area, m2
#Calcualtions
Cc = mc*cpc #(m*cp)C
Ch = mh*cph #(m*cp)H
if Cc > Ch:
Cmin = Ch
Cmax = Cc
else:
Cmin = Cc
Cmax = Ch
NTU = U*A/Cmin
Cminbymax = Cmin/Cmax
#Using figure "a" on page 274
Enum = 1. - exp(-NTU*(1-Cminbymax))
Eden = 1. - Cminbymax*exp(-NTU*(1-Cminbymax))
Tco= 350.
epsilon = Enum/Eden
Q = epsilon*Cmin*(Thi-Tci)
Tco = Q/Cmin + Tci
#Results
print "Heat Tranfer Rate", round(Q,2),"W"
print "Outlet Temperature of cold fluid", round(Tco,1),"K"
print 'The answers are different than book because book uses rounded numbers'
```

In [14]:

```
#Radiation to Metal Tube
import scipy.constants as sc
from math import pi
#Variable Declaration
do, L = 0.0254, 0.61 #Outside diameter of tube, and length, m
Ts = 588. #Surface temperature of the tube, K
ep = 0.6 #emmisivity of metal tube at 1088 K
Te = 1088. #Temperature of surrounding air, K
#Calculations
#SI Units
A = pi*do*L
Q = ep*A*5.676e-8*(Ts**4-Te**4)
print "Heat Transferred to tube from the surrounding in SI units", round(Q,1), "W"
#Variable Declaration
do, L = 1./12, 2.0 #Outside diameter of tube, and length, ft
Ts = 600 #Surface temperature of the tube, °F
ep = 0.6 #emmisivity of metal tube at 1500 °F
Te = 1500. #Temperature of surrounding air, °F
#Calculations
#English Units
A = pi*do*L
Q = ep*A*0.1714e-8*((Ts+460)**4-(Te+460)**4)
print "Heat Transferred to tube from the surrounding in English units", round(Q,1), "Btu/hr"
print 'The answers are different than book, because of book uses rounded numbers'
```

In [16]:

```
#Combined Covection Plus Radiation from a Tube
import scipy.constants as sc
from math import pi
#Variable declaration
do, L = 0.0254, 0.61 #Outside diameter of tube, and length, m
Ts = 588. #Surface temperature of the tube, K
ep = 0.6 #emmisivity of metal tube at 1088 K
Te = 1088. #Temperature of surrounding air, K
#Calculations
A = pi*do*L
hc = 1.32*((Te-Ts)/do)**0.25
hr = ep*5.676e-8*(Te**4-Ts**4)/(Te-Ts)
Q = A*(hc + hr)*(Ts-Te)
#Results
print "Convective Heat Transfer Coefficient",round(hc,2)
print "Radiation Heat Transfer Coefficient",round(hr,2)
print "Heat Transferred to the tube from the surrounding", round(Q,2), "W"
print 'The answers are different than book, because of book uses rounded numbers'
```

In [17]:

```
#Radiation between Parallel Plated
import scipy.constants as sc
#Variable declaration
ep1, ep2 = 0.8, 0.7 #emmissivities of plate 1 and 2
T1, T2 = 866.5, 588.8 #Temperatures of surface 1 and 2, K
#Calculations PART "SI"
q12 = 5.676e-8*(T1**4-T2**4)/(1./ep1+1./ep2-1.)
q12b = 5.676e-8*(T1**4-T2**4)
#Results
print "SI Units"
print "a) Heat Flux from Plate 1 to Plate 2", round(q12,2),"W/m2"
print "b) Heat Flux from Plate 1 to Plate 2 when both surfaces are balck body", round(q12b,2),"W/m2"
#Variable declaration
#Calculations PART "British"
ep1, ep2 = 0.8, 0.7 #emmissivities of plate 1 and 2
T1, T2 = 1100, 600 #Temperatures of surface 1 and 2, °F
q12 = 0.1714e-8*((T1+460)**4-(T2+460)**4)/(1./ep1+1./ep2 -1.)
q12b = 0.1714e-8*((T1+460)**4-(T2+460)**4)
#Results
print "English Units"
print "a) Heat Flux from Plate 1 to Plate 2", round(q12,2),"Btu/ft2.h"
print "b) Heat Flux from Plate 1 to Plate 2 when both surfaces are balck body", round(q12b,2),"Btu/ft2.h"
print 'The answers are different than book, because of book uses rounded numbers'
```

In [19]:

```
#Gas Radiation to a Furnace Enclosure
import scipy.constants as sc
#Variable Declaration
L = 0.3 #Inside length of cubical furnace, m
P = 1. #Pressure of gas inside furnace, atm
Tg = 1100. #Temperature of gas, K
Tw = 600. #Temperature of furnace wall, K
xco2 = 0.1 #mole fraction of CO2
#Calculations
Lbm = .60*L
pco2 = P*xco2
pgL = pco2*Lbm
#from figure 4.11-10
epg = 0.064
alphag600 = pgL*(Tw/Tg)
alphaguc = 0.048
alphagc = alphaguc*(Tg/Tw)**0.65
q = sc.sigma*(epg*Tg**4-alphagc*Tw**4)
A = L*L*6
Q = q*A
#Results
print "Heat Transfer rate in Gas radiation", round(Q/1000,3), "kW"
print 'The answer is different than book, because of book uses rounded numbers'
```

In [22]:

```
#Heating a Non-Newtonian Fluid in Laminar Flow
from scipy.optimize import root
#Variable Declaration
mdot = 7.56e-2 #Mass flow rate of non-Newtonian fluid, kg/s
di = 0.0254 #Inside Diameter of the tube, m
L = 1.524 #Length of the tube, m
Ti = 37.8 #Inlet temperature of the fluid, °C
Tw = 93.3 #Inside wall temperature, °C
rho = 1041. #density of fluid, kg/m3
cpm = 2.093e3 #specific heat of fluid, J/(kg.K)
k = 1.212 #Thermal conductivity of fluid, W/(m.K)
n = 0.4 #Rheological constants for fluid
K378 = 139.9
K933 = 62.5
#Calculations
Tbo = 54.4
Tb = (Ti + Tbo)/2.0
slope = (log(K378)-log(K933))/(Ti-Tw)
c = log(139.9)-slope*Ti
Kb = exp(slope*Tb+c)
Kw = exp(slope*Tw+c)
delta = (3.*n+1)/(4*n)
NGz = mdot*cpm/(k*L)
gamabw = Kb/Kw
Nu = 1.75*delta**(1./3)*NGz**(1./3)*gamabw**0.14
ha = k*Nu/di
Tk = (2.*Tw-Ti)/2.
mT = 1./2
f = lambda T: mdot*cpm*(T-Ti)-ha*pi*di*L*(Tk-mT*T)
sol = root(f,25)
Tbo = sol.x[0]
#Results
print "Gratez Number", round(NGz,1)
print "Heat Transfer Coefficient", round(ha,1),"W/m2.K"
print "Oultlet bulk temperature of the fluid",round(Tbo,1),"°C"
print 'The answers are different than book, because of book uses rounded numbers'
```

In [29]:

```
#Heat Transfer Coefficient in Agitated Vessel
#Variable Declaration
Dt = 1.83 #Diameter of agitated vessel,m
Tl = 300. #Temperature of liquid to be heated, K
Da = 0.61 #Diameter of agitator vessel,m
N = 100. #RPM of agitator
Tw = 355.4 #Wall temperature of Jaket, K
rho = 961. #Density of liquid, kg/m3
cp = 2500. #Density of liquid, K/(kg.K)
k = 0.173 #Thermal conductivity of liquid, W/(m.K)
mu = 1.0 #Viscosity of liquid at 300K, Pa.s
muw = 0.084 #Viscosity of liquid at Wall temperature 355.5K, Pa.s
#Calculations
Nre = Da**2*(N/60)*rho/mu
Npr = cp*mu/k
#for equation 4.13-1 a = 0.74, b=2/3
a = 0.74
b = 2./3
Nu = a*Nre**b*Npr**(1./3)*(mu/muw)**0.14
h = Nu*k/Dt
#Results
print 'Reynolds number is %3.0f'%Nre
print 'Prandtl number is %5.0f'%Npr
print "Heat transfer coefficient to the wall of jacket",round(h,1),"W/(m2.K)"
print 'The answers are different than book, because of book uses rounded numbers'
```

In [30]:

```
#Fin efficiency and Heat Loss from Fin
#Variable Declaration
k = 222. #W/(m.K)
r1 = 0.04 #Outer radius of tube, m
L = 0.04 #Fin length, m
To = 523.2 #Fin base temperature, K
Ta = 343.2 #Surrounding Temperature, K
t = 2./1000 #Thickness of fin, m
h = 30. #Surrounding convective coefficient, W/(m2.K)
#Calculation
Lc = L + t/2
asbc = Lc*(h/k*t)**0.5
param = (Lc+r1)/r1
#From fig4.13-5 b for parameter and abscisa value eff = 0.89
eff = 0.89
Afc = 2*pi*((Lc+r1)**2-r1**2)
qf = eff*h*Afc*(To-Ta)
#Result
print "Efficiency of the fin is", round(eff,4)
print "Rate of Heat Loss", round(qf,1),"W"
print 'The answers are different than book, because of book uses rounded numbers'
```

In [19]:

```
#Steady State Heat Conduction in Two Directions
import numpy as np
#Variable Declaration
D = 8.0 #Ouside dimention of square, m
Hi = 4.0 #Inside Height of chamber, m
Wi = 2.0 #Inside width of chamber, m
Ti = 600.0 #Inside Temperature of chamber, K
To = 300.0 #Outside Temperature of chamber, K
k = 1.5 #Thermal conductivity of material, W/(m.K)
Gl = Gw = 1.0 #Grid size in Height and width Directions, m
L = 1.0 #Length of Chamber, m
#Calculations
np.set_printoptions(precision=1)
#Column indices used are one less than used in book
T0 = np.zeros(3)
T1 = np.zeros(3)
T2 = np.zeros(6)
T3 = np.zeros(6)
T4 = np.zeros(6)
T5 = np.zeros(6)
def printT():
print 'Temperature at various nodes are as follows'
print 'T 2 3 4 5'
print 1,T1[1:2]
print 2,T2[1:2]
print 3,T3[1:5]
print 4,T4[1:5]
#Initialize
T0[2]=T1[2]=T2[2]=T2[3]=T2[4]=T2[5]=600. #INNER NODES
T0[0]=T1[0]=T2[0]=T3[0]=T4[0]=T5[0]=T5[1]=T5[2]=T5[3]=T5[4]=T5[5]=300 #outer nodes
T1[1]=T3[3]=450.
T2[1]=T3[1]=T3[2]=T4[4]=400.
T3[4]=500.
T4[1]=325.
T4[2]=350.
T4[3]=375.
T0[1]=T2[1]
T3[5]=T3[3]
T4[5]=T4[3]
r = 1.2 #Initial value of residue
#Calculations
while abs(r)>0.001:
r11 = T1[0]+T1[2]+T0[1]+T2[1]-4*T1[1]
T1[1]=(T1[0]+T1[2]+T0[1]+T2[1])/4
r21 = (T2[0]+T2[2]+T1[1]+T3[1]-4*T2[1])
T2[1]=T0[1]=(T2[0]+T2[2]+T1[1]+T3[1])/4
r31=(T3[0]+T3[2]+T2[1]+T4[1]-4*T3[1])
T3[1]=(T3[0]+T3[2]+T2[1]+T4[1])/4
r32 = T2[2]+T4[2]+T3[1]+T3[3]-4*T3[2]
T3[2] =(T2[2]+T4[2]+T3[1]+T3[3])/4
r33 = T3[2]+T3[4]+T2[3]+T4[3]-4*T3[3]
T3[3]=T3[5]=(T3[2]+T3[4]+T2[3]+T4[3])/4
r34 = T3[3]+T3[5]+T2[4]+T4[4]-4*T3[4]
T3[4]=(T3[3]+T3[5]+T2[4]+T4[4])/4
r41 = T4[0]+T4[2]+T3[1]+T5[1]-4*T4[1]
T4[1]=(T4[0]+T4[2]+T3[1]+T5[1])/4
r42 = T4[1]+T4[3]+T3[2]+T5[2]-4*T4[2]
T4[2]=(T4[1]+T4[3]+T3[2]+T5[2])/4
r43 = T4[2]+T4[4]+T3[3]+T5[3]-4*T4[3]
T4[3]=T4[5]=(T4[2]+T4[4]+T3[3]+T5[3])/4
r44 = T4[3]+T4[5]+T3[4]+T5[4]-4*T4[4]
T4[4] = (T4[3]+T4[5]+T3[4]+T5[4])/4
r = r11+r21+r31+r32+r33+r34+r41+r42+r43+r44
#Results
print 'Recidue at convergence %10.8f'%r
printT()
Q1 = 4*k*(0.5*(T1[2]-T1[1]) + (T2[2]-T2[1]) + (T2[2]-T3[2]) + (T2[3]-T3[3]) + 0.5*(T2[4]-T3[4]))
Q2 = 4*k*(0.5*(T1[1]-T1[0]) + (T2[1]-T2[0]) + (T3[1]-T3[0]) + (T4[1]-T4[0]) + (T4[1]-T5[1])+(T4[2]-T5[2])+(T4[3]-T5[3])+0.5*(T4[4]-T5[4]))
print 'Heat transfer from inner surface %5.1f into the solid'%Q1
print 'Heat transfer from outer surface %5.1f out from solid'%Q2
Qavg = (Q1+Q2)*0.5
print "Average Heat loss per unit chamber length",round(Qavg,1),"W/m"
print 'Book is using rounded values of temperature throughout the iterations hence answers are different'
```