#Cooling of a Steel Ball
from math import pi, exp
#Variable declaration #English Units
r = 1./12 #Radius of a Steel Ball, ft
Tbi = 800. #Initial uniform temperature of the steel ball, °F
Tinf = 250. #Temeperature of a constant temperature bath, °F
h = 2.0 #Convective Heat Transfer Coefficient, Btu/(h.ft2°F)
t = 1. #Time at which temperature of the ball is to be determined, s
k = 25. #Thermal conductivity of the steel ball, Btu/(h.ft°F)
rho = 490. #Density of a steel ball, lbm/ft3
cp = 0.11 #Specific heat of steel ball, Btu/(lbm.°F)
#Calculation
x1 = r/3
NBi = h*x1/k
A = 4*pi*r**2
V = 4*pi*r**3/3.
tau = h*A/(cp*rho*V)
Tb = Tinf + (Tbi - Tinf)*exp(-tau*t)
#Result
print "Temperature of ball after one hour: ", round(Tb),"°F"
#Variable declaration # SI Units
r = 0.0254 #Radius of a Steel Ball, m
Tbi = 699.9 #Initial uniform temperature of the steel ball, K
Tinf = 394.3 #TEmeperature of a constant temperature bath, K
h = 11.36 #Convective Heat Transfer Coefficient, W/(m2K)
t = 3600. #Time at which temperature of the ball is to be determined, s
k = 43.3 #Thermal conductivity of the steel ball, W/(mK)
rho = 7849. #Density of a steel ball, kg/m3
cp = 460.6 #Specific heat of steel ball, J/(kg.K)
#Calculation
x1 = r/3
NBi = h*x1/k
A = 4*pi*r**2
V = 4*pi*r**3/3.
tau = h*A/(cp*rho*V)
Tb = Tinf + (Tbi - Tinf)*exp(-tau*t)
#Result
print "Temperature of ball after one hour: ", round(Tb,1),"°C"
#Total amount of heat in cooling
from math import pi
#Variable declaration
r = 0.0254 #Radius of a Steel Ball, m
Tbi = 699.9 #Initial uniform temperature of the steel ball, K
Tinf = 394.3 #TEmeperature of a constant temperature bath, K
h = 11.36 #Convective Heat Transfer Coefficient, W/(m2K)
t = 3600. #Time at which temperature of the ball is to be determined, s
k = 43.3 #Thermal conductivity of the steel ball, W/(mK)
rho = 7849. #Density of a steel ball, kg/m3
cp = 460.6 #Specific heat of steel ball, J/(kg.K)
#Calculation
x1 = r/3
NBi = h*x1/k
A = 4*pi*r**2
V = 4*pi*r**3/3.
tau = cp*rho*V/(h*A)
Q = cp*rho*V*(Tbi-Tinf)*(1-exp(-t/tau))
#Result
print 'Amount of Heat Transffered %6.4e'%(Q),"J"
#Freezing Temperature in the ground
from math import pi, erfc, exp
# Variable declaration
Ti = 15.6 #Earths constant temperature, degC
Tc = -17.8 #Cold wave temperature, deg C
h = 11.36 #Convective heat transfer coefficient, W/(m2K)
alpha = 4.65e-7 #THermal diffusivity of soil, m2/s
k = 0.865 #Thermal conductivity of soil, W/(mK)
t = 5*3600 #Time in seconds
x = 0. #Surface position , m
T0 = 0. #Freezing temperature for water
# Calculation SI units
absc = x/(2*sqrt(alpha*t))
param = h*sqrt(alpha*t)/k
corr = erfc(absc) - exp(param*(2*absc+param))*erfc(absc+param)
T = Ti + (Tc - Ti)*(erfc(absc) - exp(param*(2*absc+param))*erfc(absc+param))
ordi = (T0-Ti)/(Tc-Ti)
abscOrd = .16
x0 = 2*sqrt(alpha*t)*abscOrd
#Results
print "(a) Temperature of the surface after 5 hour:", round(T,1), "°C"
print "(b) Location of Freezing Temperature after 5 hour:",round(x0,4),"m"
# Variable declaration English units
Ti = 60. #Earths constant temperature, degF
Tc = -0. #Cold wave temperature, deg F
h = 2. #Convective heat transfer coefficient, Btu/(ft2Fhr)
alpha = 0.018 #THermal diffusivity of soil, ft2/hr
k = 0.5 #Thermal conductivity of soil, Btu/(ft F)
t = 5 #Time in hr
x = 0. #Surface position , ft
T0 = 32. #Freezing temperature for water
# Calculation SI units
absc = x/(2*sqrt(alpha*t))
param = h*sqrt(alpha*t)/k
corr = erfc(absc) - exp(param*(2*absc+param))*erfc(absc+param)
T = Ti + (Tc - Ti)*(erfc(absc) - exp(param*(2*absc+param))*erfc(absc+param))
ordi = (T0-Ti)/(Tc-Ti)
abscOrd = .16
x0 = 2*sqrt(alpha*t)*abscOrd
#Result
print "(a) Temperature of the surface after 5 hour:", round(T,1), "°F"
print "(b) Location of Freezing Temperature after 5 hour:",round(x0,4),"ft"
print 'The answers are different than book, because of book uses rounded numbers and rounded values of \ncomplimentary error function whereas code used built in erfc function'
#Heat Conduction in the slab
# Variable declaration
x1 = .0462 #Thickness of the slab, m
T0 = 277.6 #Uniform temperature of the slab, K
T1 = 297.1 #Ambient temperature of the fluid, K
h = 8.52 #Convective heat transfer coefficient, W/m2.K
t = 5*3600 #Time, s
rho = 998. #Density of H2O at 4 deg C (kg/m3)
k = 0.197 #Thermal conductivity of butter, W/m.K
cp = 2300 #Specific heat of butter, J/kg.K
# Calculation
alpha = k/(rho*cp) #Thermal diffusivity, m2/s
#PART A Calculation of temperature at the surface
param = k/(h*x2)
X = alpha*t/x2**2
x = 0.0462 #Distance from surface at which temperature needs to be calculated, m
n = x/x2
Y = 0.25 #From fig 5.3-5
T = T1 - Y*(T1-T0)
#Result
print "Answers to part A"
print "Paramenter m for fig 5.3-5:", round(param,3)
print "Abscisa X for fig 5.3-2:", round(X,3)
print "Parameter n for fig 5.3-2:", round(n,3)
print "Temeprature of the surface at .0462 m after 5 hour", round(T,1), "K", round(T-273.2,1), "°C"
#PART B Calculation of temperature at 25.4 mm below the surface
param = k/(h*x2)
X = alpha*t/x2**2
x = 0.0208 #Distance from surface at which temperature needs to be calculated, m
n = x/x2
Y = 0.45 #From fig 5.3-5
T = T1 - Y*(T1-T0)
#Result
print "Answers to part B"
print "Paramenter m for fig 5.3-5:", round(param,3)
print "Abscisa X for fig 5.3-2:", round(X,3)
print "Parameter n for fig 5.3-2:", round(n,3)
print "Temeprature of the surface at .0208 m after 5 hour", round(T,1), "K", round(T-273.2,1), "°C"
#PART C Calculation of temperature at 46.2 mm below the surface
param = k/(h*x1)
X = alpha*t/x1**2
n = x/x1
Y = 0.5 #From fig 5.3-5
T = T1 - Y*(T1-T0)
#Result
print "Answers to part B"
print "Paramenter m for fig 5.3-5:", round(param,2)
print "Abscisa X for fig 5.3-2:", round(X,2)
print "Parameter n for fig 5.3-2:", round(n,1)
print "Temeprature of the surface at .0462 m after 5 hour", round(T,1), "K", round(T-273.2,1), "°C"
#Transient Heat Conduction in a Can of Pea Puree
# Variable declaration
D = 0.0681 #Diameter of a Can, m
T0 = 29.4 #Uniform temperature of the slab, deg C
T1 = 115.6 #Ambient temperature of the steam, deg C
h = 4540 #Convective heat transfer coefficient, W/m2.K
t = 0.75*3600 #Time, s
x = 0.0 #Centre of the Can, m
k = 0.830 #Thermal conductivity of butter, W/m.K
alpha = 2.007e-7 #THermal diffusivity, m2/s
# Calculation
x1 = D/2.
n = x/x1
param = k/(h*x1)
X = alpha*t/x1**2
Y = 0.13 #From fig 5.3-8
T = T1 - Y*(T1-T0)
#Result
print "Paramenter m for fig 5.3-8:", round(param,5)
print "Abscisa X for fig 5.3-8:", round(X,3)
print "Parameter n for fig 5.3-8:", n
print "Temeprature at the centre after 0.75 hour", round(T,1),"°C "
#Two-Dimensional Conduction in a Short Cylinder
# Variable declaration
D = 0.0681 #Diameter of a Can, m
H = 0.1016 #Height of a Can, m
T0 = 29.4 #Uniform temperature of the slab, deg C
T1 = 115.6 #Ambient temperature of the steam, deg C
h = 4540 #Convective heat transfer coefficient, W/m2.K
t = 0.75*3600 #Time, s
x = 0.0 #Centre of the Can in radial direction, m
y = 0.0 #Centre of the Can in axial direction, m
k = 0.830 #Thermal conductivity of butter, W/m.K
alpha = 2.007e-7 #THermal diffusivity, m2/s
# Calculation
x1 = D/2.
y1 = H/2.
#Radial direction
n = x/x1
m = k/(h*x1)
X = alpha*t/x1**2
Yx = 0.13 #From fig 5.3-8
print "Prameters for Radial Direction"
print "Paramenter m for fig 5.3-8:", round(m,5)
print "Abscisa X for fig 5.3-8:", round(X,4)
print "Parameter n for fig 5.3-8:", n
print "Parameter Yx from figure 5.3-8:", round(Yx,3)
#Axial Direction
n = y/y1
m = k/(h*y1)
X = alpha*t/y1**2
Yy = 0.8 #From Fig 5.3.6
print "\nPrameters for Axial Direction"
print "Paramenter m for fig 5.3-8:", round(m,5)
print "Abscisa X for fig 5.3-8:", round(X,4)
print "Parameter n for fig 5.3-8:", n
print "Parameter Yy from figure 5.3-8:", round(Yy,3)
Yxy = Yx*Yy
Txy = T1 - Yxy*(T1-T0)
#Result
print "\nThe Temperature at the Centre of short cylinder:", round(Txy,1), "°C"
#Unsteady State Conduction and the Schmidt Numerical Method
import matplotlib.pyplot as plt
import copy
#Variable declaration
thk = 1.0 #Thickness of slab, m
Ti = 100. #Initial uniform temperature of slab, °C
Ta = 0. #Constant Temperature of environment, °C
alpha = 2.0e-5 #Thermal diffusivity of slab, m2/s
ns = 5 #Number of slices
M = 2.0 #M for Schmidt numerical method
tmax = 6000 #Time at which temperature of the slab at various location to be calculated, s
#Calculation and Result
dx = thk/ns
x = [0,.2,.4,.6,.8,1.]
dt = dx**2/(alpha*M)
ylim(-1.,110.)
xlim(0,1.1)
#m = tmax/dt
t=0
T = [Ti,Ti,Ti,Ti,Ti,Ti]
plt.plot(x,T,'ko-',label='Initial Temperature Profile')
T[0] = Ta
Tcal = [0,0,0,0,0,0]
for i in range(1,7,1):
t = int(dt*i)
for j in range(len(T)):
if j==0:
Tcal[j]= Ta
#print Tcal[j]
elif j>=1 and j<(len(T)-1):
Tcal[j]=(T[j-1]+T[j+1])/2.
#print T[j-1], T[j+1],Tcal[j]
else:
Tcal[j]=((M-2)*T[j]+2*T[j-1])/M
#print Tcal[j]
T = copy.copy(Tcal)
plt.plot(x,T, 'o-',label=str(i)+'th iteration Temp. Profile.')
print "At 6000s"
for i in range(1,7,1):
print "Temperature of the node",i,"is", round(T[i-1],2),"°C"
plt.xlabel('Node number')
plt.ylabel('Temperature, degC')
plt.legend(loc='lower right',fontsize='small' )
#Unsteady-State Conduction Using the Digital Computer
import copy
#Variable declaration
thk = 1. #Thickness of slab, m
Ti = 100. #Initial uniform temperature of slab, °C
Ta = 0. #Constant Temperature of environment, °C
alpha = 2.0e-5 #Thermal diffusivity of slab, m2/s
ns = 20 #Number of slices
M = 2.0 #M for Schmidt numerical method
tmax = 6000 #Time at which temperature of the slab at various location to be calculated, s
#Calculation and Result
dx = thk/ns
x = range(21)
dt = dx**2/(alpha*M)
m = tmax/dt
t=0
T = [Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti,Ti]
T[0] = Ta
Tcal = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
for i in range(1,96,1):
t = int(dt*i)
for j in range(len(T)):
if j==0:
Tcal[j]= Ta
#print Tcal[j]
elif j>=1 and j<(len(T)-1):
Tcal[j]=(T[j-1]+T[j+1])/2.
#print T[j-1], T[j+1],Tcal[j]
else:
Tcal[j]=((M-2)*T[j]+2*T[j-1])/M
#print Tcal[j]
T = copy.copy(Tcal)
#plt.plot(x,T, 'o-',label=str(i)+'th iteration Temp. Profile.')
print "At 6000s"
for i in range(1,22,4):
print "Temperature of the node",i,"is", round(T[i-1],2),"°C"
print 'The difference in the answers is due to rounding error'
#Unsteady-State conduction with Convective Boundary Conditions
import copy
#Variable declaration
thk = 1.0 #Thickness of slab, m
Ti = 100. #Initial uniform temperature of slab, °C
Ta = 0. #Constant Temperature of environment, °C
alpha = 2.0e-5 #Thermal diffusivity of slab, m2/s
ns = 5 #Number slices
h = 25.0 #Covective coefficient, W/m2K
k = 10.0 #Thermal conductivity of slab, W/mK
M = 2.0 #M for Schmidt numerical method
tmax = 6000 #Time at which temperature of the slab at various location to be calculated, s
#Calculation and Result
dx = thk/ns
N = h*dx/k
M = 2*N+2
M =round(M+1)
dt = dx**2/(alpha*M)
m = tmax/dt
T = [Ti,Ti,Ti,Ti,Ti,Ti]
Tcal = [0,0,0,0,0,0]
x = range(6)
for i in range(1,13,1):
for j in range(len(T)):
if j==0:
Tcal[j]= (1/M)*(2*N*Ta+(M-(2*N+2))*T[j]+2*T[j+1])
elif j>=1 and j<(len(T)-1):
Tcal[j]=(1/M)*(T[j+1]+(M-2)*T[j]+T[j-1])
else:
Tcal[j]=(1/M)*((M-2)*T[j]+2*T[j-1])
T = copy.copy(Tcal)
print 'i:%3d and time %5d s'%(i,i*dt)
for i in range(len(T)):
print "Temperature of the node",i+1,"is", round(T[i],2),"°C"
# Chilling Dressed Beef
#Variable Declaration
rho = 1073. #Density of a beef, kg/m3
cp = 3480. #Specific heat of Beef, J/(kg.K)
k = 0.498 #Thermal conductivity of beef, W/(m.K)
thk = 0.203 #Thickness of beef slab, m
Ti = 37.8 #Initial beef temperature, deg C
Tf = 1.7 #Uniform fluid temeperature, deg C
T = 10. #Temperature of the centre, deg C
h = 39.7 #Convective heat Transfer coefficient, W/(m2.K)
x = 0
#Calculation
alpha = k/(rho*cp) #Thermal diffusivity of beef slab, m2/s
x1 = thk/2 #Centre of slab, m
n = x/x1
m = k/(h*x1)
Y = (Tf-T)/(Tf-Ti)
X = 0.90
t = X*x1**2/alpha
#Result
print "The parameter to be used in association with Fig. 5.3-6"
print "n: ", n
print "m: ", round(m,4)
print "Y: ", round(Y,4)
print "Time required to attend 10°C: ", round(t,1),"s OR", round(t/3600,1), "hr"
#Freezing of Meat
#Variable Declaration
rho = 1057. #Density of a meat, kg/m3
cp = 3480. #Specific heat of Beef, J/(kg.K)
k = 1.038 #Thermal conductivity of meat, W/(m.K)
a = 0.0635 #Thickness of beef slab, m
Tf = 270.4 #Initial meat temperature, deg C
T1 = 244.3 #Uniform air blast temeperature, K
h = 17.0 #Convective heat Transfer coefficient, W/(m2.K)
Lambdafw = 335000 #Latent heat of fusion of for Water, J/kg
#Calculations
Lambdameat = 0.75*Lambdafw
t = Lambdameat*rho/(Tf-T1)*(a/(2*h)+a**2/(8*k))
#Results
print "Latent heat of freezing of meat:", round(Lambdameat/1000,1), "kJ/kg"
print 'Time required for freezing:%4.3e s OR %3.2f'%(t,t/3600)