In [1]:

```
# Heat Generation in a Hair Dryer
import math
# Variables
E_gen = 1200. #[Total rate of heat generation]
L = 80 #Length of wire[cm]
D = 0.3 #Diameter of wire[cm]
# Calculations
V_wire = math.pi*(D**2)*L/4 #Volume of the wire[cm**3]
e_gen = E_gen/V_wire #[W/cm**3]
As = math.pi*D*L #Suface Area of wire[m**2]
Q_ = E_gen/As #[W/cm**2]
# Results
print "The rate of heat generation in the wire per unit volume and heat flux on the outer\
surface of the wire as a result of this heat generation are respectively",round(e_gen),"W/cm**3","and",Q_,"W/cm**2"
```

In [1]:

```
# Heat Conduction in a Resistance Heater
import math
# Variables
E_gen = 2000 #Total rate of heat generation in the wire[W]
L = 0.5 #Length of cyllindrical shaped wire[m]
D = 0.004 #Diameter of wire[m]
k_heater = 15 #Thermal conductivity of wire[W/m.K]
# Calculations and Results
#The resistance wire is considered to be a very long cylinder since
# its length is more than 100 times its diameter.Heat is generated uniformly in the wire and the conditions on the outer surface of the wire are uniform.Hence it is reasonable to math.expect the temperature int he wire to vary in radial r direction only and thus heat transfer to be one dimensional,T = T(r)
V_wire = math.pi*(D**2)*L/4 #Volume of the wire[m**3]
e_gen = E_gen/V_wire #[W/m**3]
print "The rate of heat generation in the wire per unit volume is",e_gen,"W/m**3"
const = e_gen/k_heater;
print "The equation governing the variation of temperature int\
he wire is simply (1/r)d/dr(r.dT/dr)+",const," = 0"
```

In [2]:

```
# Cooling of a Hot Metal Ball in Air
# Variables
T_ball = 300 #Temeprature of ball[degree Celcius]
T_surr = 25 #Temperature of ambient air[degree Celcius]
# Results
#The ball in initially at a uniform temperature and is cooled uniformly from the entire outer surface.Also, the temperature within the ball changes with the radial dismath.tance r and the time t. T = T(r,t)
print ("The thermal conductivity is given to be variable,and there is no heat\
generation in the ball, therefore the differential equation governing the variation of temperature in the ball is")
print ("(1/(r**2)d/dr((r**2)k(dT/dr)) = rho*c(dT/dt)")
```

In [4]:

```
# Heat Conduction in a Short Cylinder
# Variables
#Radius R and height h of the small cylinder
T = 300 #Temperature of cylinder[degree Celcius]
T_ambient = 20 #Temperature of ambient air[degree Celcius]
# Calculations and Results
#Variation is thermal conductivity is negligible
#The cylinder is cooled unifromly from the top and bottom surfaces in the z-direction as well as the lateral surface in the radial r-direction.Also Temperature at any point in the ball changes with time during cooling. Therefore this is a two dimensional transient heat conduction problem i.e. T = T(r,z,t)
print ("The differential equation governing the variation of temperature in the billet is ")
print ("((1/r)(d/dr)(k*r(dT/dr)))+((d/dz)(k(dT/dz))) = rho*c(dT/dt)")
print ("In case of consmath.tant thermal conductivity it reduces to")
print ("((1/r)(d/dr)(r(dT/dr)))+(d**2)T/(dz**2) = (1/a)(dT/dt)")
```

In [5]:

```
# Heat Flux boundary Condition
import math
# Variables
Q = 800 #Heat transfer rate[W]
D = 0.2 #Diameter of pan[m]
L = 0.003 #Thickness of pan[m]
T_in = 110 #T(L) Temperature of the inner surface of the pan[degree Celcius]
neta = 0.9 #Percent of total heat transferred to the pan
# Calculations
#The inner and outer surfaces of the bottom section of the pan can be
# represented by x = 0 and x = L,respectively. During steady operation
# the temperature will depend on x only and thus T = T(x).
actual_Q = neta*Q #90 percent of the 800W is transferred to the pan at that surface
A = math.pi*(D**2)/4 #Bottom Surface Area[m**2]
print ("-k*dT(0)/dx = q_")
q_ = actual_Q/(1000*A) #[kW/m**2]
# Results
#The boundary condition on this surface can be math.expressed as
print "T(L) = ",T_in,"degree Celcius"
print "where L = ",L,"m"
```

In [6]:

```
# Convection and Insulation Boundary Conditions
# Variables
T_steam = 200 #Temperature of steam[degree Celcius]
r_in = 0.08 #Inner radii of pipe[m]
r_out = 0.085 #Outer radii of pipe[m]
h = 65 #convection heat transfer coefficient on the inner surface of the pipe[W/m**2.K]
# Calculations and Results
#Heat transfer through the pipe material predominantly is in the radial
# direction and thus can be approximated as being one-dimensional
print ("Taling the direction of heat transfer to be the positive r direction, the boundary\
condition on that surface can be math.expressed as")
print ("-k(dT(r_in,t)/dr) = h(T_steam-T(r1))")
#The pipe is said to be well insulated on the outside, and thus heat loss
# through the outer surface of the pipe can be assumed to be negligible.
print ("Then the boundary at the outer surface can be math.expressed as")
print ("dT(r_out,t)/dr = 0")
```

In [7]:

```
# Combined Convection and Radiation Condition
# Variables
T_ball = 300 #Temperature of spherical metal ball[degree Celcius]
T_ambient = 27 #Temperature of ambient air[degree Celcius]
k = 14.4 #Thermal conductivity of the ball material[W/m.K]
h = 25 #average convection heat transfer coefficient on the outer surface of the ball[W/m**2.K]
e = 0.6 #Emissivity of outer surface of the ball
T_surr = 290 #
# Calculations and Results
#This is one-dimensional transient heat transfer problem math.since the temperature within the ball changes with the radial dismath.tance r and the time t i.e. T = T(r,t)
#Taking the moment the ball is removed from the oven to be t = 0
print ("The initial condition can be math.expressed as")
print ("T(r,0) = T_ball")
print ("degree Celcius",T_ball)
#The problem possesses symmetry about the mid point(r = 0) math.since the isotherms in this case are concentric spheres, and thus no heat is crosmath.sing the mid point of the ball.
print ("The boundary condition at the midpoint i.e. r = 0 can be math.expressed as dT(0,t)/dr = 0")
#The heat conducted to the outer surface of the ball is lost to the environment by convection and radiation.
print ("Taking the direction of heat transfer to be the positive r direction, the boundary condition on the outer surface can be math.expressed as")
print ("-k(dT(r_out,t)/dr) = h[T(r_out)-T_ambient]+e*sigma[(T(r_out)**4)-(T_ambient**4)]")
```

In [8]:

```
# Combined Convection, Radiation and Heat Flux
# Variables
T_surf1 = 20 #Ambient temperature in the interior of the house[degree Celcius]
T_surf2 = 5 # Ambient temperature outside the house[degree Celcius]
L = 0.2 # Thickness of the wall[m]
a = 0.5 # absorptivity of outer surface of wall
h_in = 6 #Convection heat transfer coefficient for inner surface of wall[W/m**2.degree Celcius]
h_out = 25 #Convection heat transfer coefficient for outer surface of wall[W/m**2.degree Celcius]
k = 0.7 #The thermal conductivity of wall material[W/m.degree Celcius]
e = 0.9 #Emissivity of outer surface of wall
# Calculations and Results
#The heat transfer though the wall is given to be steady and one dimensional and thus temperature depends on x only i.e. T = T(x)
print ("The boundary condition ont the inner surface of the wall at x = 0 can be math.expressed as -k(dT(0)/dx) = h_in[T_surf1-T(0)]")
print "where h_in and T_surf are respectively ",h_in,"W/m**2.degree Celcius","and",T_surf1,"degree Celcius"
print ("The boundary condition on the outer surface at x = L can be math.expressed as ")
print ("-kdT(L)/dx = h_out[T(L)-T_surf2]+e*sigma[(T(L)**4)-(T_sky**4)]-a*q_solar")
print ("where T_sky is temperature of the sky and q_solar is the incident solar heat flux")
```

In [10]:

```
# Heat Conduction in a Plane Wall
# Variables
k_wall = 1.2 #Thermal conductivity of wall[W/m.degree Celcius]
L = 0.2 #Thickness of wall[m]
As = 15 #Surface area[m**2]
T1 = 120
T2 = 50 #The two sides of the wall are maintained at these consmath.tant temperatures[degree Celcius]
# Calculations and Results
print ("Differential equation can be math.expressed as d**2(T)/(dx**2) = 0")
print ("with boundary conditions ")
print "T(0) = T1 = ",T1,"degree Celcius"
print "T(L) = T2 = ",T2,"degree Celcius"
print ("integrating this we get,")
print ("dT/dx = C1", "where C1 is an arbitrary constant")
print ("integrating we obtain temperature to follow following relation :-")
print ("and substituting values in above equation","T(x) = ((T2-T1)/L)*x+T1 ")
T3 = (((T2-T1)/L)*(0.1))+T1;
print "The value of temperature at x = 0.1m is",T3,"degree Celcius"
Q_wall = -k_wall*As*((T2-T1)/L) #[W]
print "The rate of heat conduction through the wall is",Q_wall,"W"
```

In [11]:

```
# Heat Conduction in the Base Plate of an Iron
# Variables
k = 15. #[W/m.degree Celcius]
A = 300.*10**(-4) #Base Area[m**2]
L = 0.005 #Thickness[m]
T_surr = 20 #Temp of surrounding[degree Celcius]
h = 80 #Convection het transfer coefficient[W/m**2.degree Celcius]
Q = 1200 #[W]
# Calculations and Results
q = Q/A #[W/m**2]
print "Uniform Heat Flux to whicj inner surface of the base plate is subjected",q,"W/m**2"
#Integration Constants
C1 = -q/k;
C2 = T_surr+(q/h)+(q*L/k);
T_0 = T_surr+q*((L/k)+(1/h)) #[degree Celcius]
T_L = T_surr+q*(1/h) #[degree Celcius]
print "The temperatures at the inner and outer surfaces of the plate i.e. at x = 0 and x = L are" \
,round(T_0),"degree Celcius","and",T_L,"degree Celcius","respectively"
```

In [14]:

```
from scipy.optimize import fsolve
import math
# Heat Conduction in a Solar Heated Wall
# Variables
L = 0.06 #Thickness of wall[m]
k = 1.2 #Thermal Conductivity[W/m.degree Celcius]
e = 0.85 #Emissivity
a = 0.26 #Solar absorptivity
T1 = 300 #Temp of Inner surface of Wall[K]
q_solar = 800 #Incident rate of solar radiation[W/m**2]
T_space = 0 #Temp of outer space[K]
# Calculations
#Integrating results into
def temp(T):
return (((a*q_solar)-(e*5.67*10**(-8)*T[0]**4))*(L/k))+T1-T[0];
# Results
x0 = [1]
xs = fsolve(temp,x0)
print "The outer surface temperature is ",xs[0],"K"
#First execute the program with
q = k*(T1-xs)/L;
print "The steady rate of heat conduction through the wall is",round(q),"W/m**2"
```

In [15]:

```
import math
# Heat Loss through a Steam Pipe
# Variables
L = 20. #Pipe Length[m]
k = 20. #[W/m.degree Celcius]
r1 = 0.06 #Inner Radius[m]
r2 = 0.08 #Outer Radius[m]
T1 = 150. #Temp of inner surface[degree Celcius]
T2 = 60. #Temp of outer surface[degree Celcius]
# Calculations
#Integrating differential equation we get T(r) = C1math.logr+C2, where C1 and C2 are
C1 = (T2-T1)/math.log(r2/r1);
C2 = T1-((T2-T1/math.log(r2/r1))*math.log(r1));
Q_cyl = 2*math.pi*k*L*(T1-T2)/(math.log(r2/r1));
# Results
print "The rate of heat conduction through the pipe is",round(Q_cyl/1000),"kW"
```

In [16]:

```
import math
# Heat Conduction through a Spherical Shell
# Variables
r1 = 0.08 #Inner Radius[m]
r2 = 0.1 #Outer radius[m]
k = 45. #Thermal conductivity[W/m.degree Celcius]
T1 = 200. #Temperature of inner surface[degree Celcius]
T2 = 80. #Temperarure of outer surface[degree Celcius]
# Calculations
#Integrating the differential equation twicw we get T(r) = -C1/r+C2, where
C1 = r1*r2*(T1-T2)/(r2-r1);
C2 = ((r2*T2)-(r1*T1))/(r2-r1);
Q_sphere = 4*math.pi*k*r1*r2*(T1-T2)/(r2-r1);
# Results
print "The rate of heat conduction through the container wall is",Q_sphere/1000,"kW"
```

In [17]:

```
import math
# Centerline Temperature of a Resismath.tance Heater
# Variables
k = 15. #Thermal conductivity of heater wire[W/m.K]
E_gen = 2000. #Total heat generation[W]
l = 0.5 #Length of resismath.tance heater wire[m]
D = 0.004 #Diameter of wire[m]
Ts = 105. #Outer sorface Temperarure[degree Celcius]
# Calculations and Results
V_wire = math.pi*(D**2)*l/4 #Volume of wire[m**3]
e_gen = E_gen/V_wire #[W/m**3]
print "The heat generation per unit volume of the wire is",e_gen,"W/m**3"
Tc = Ts+(e_gen*(D**2)/(4*4*k)) #[degree Celcius]
print "The center temperature of the wire is ",round(Tc),"degree Celcius"
```

In [18]:

```
import math
# Variation of Temperature in a Resismath.tance Heater
# Variables
k = 13.55 #[W/m.degree Celcius]
ro = 0.005 #[m]
e_gen = 4.3*10**7 #rate of resismath.tance heating[W/m**3]
Ts = 108 #Surface temperature[degree Celcius]
# Calculations
#Integrating we get
#T(r) = Ts+((e_gen*(ro**2-r**2)/4k))
T_0 = Ts+((e_gen*ro**2)/(4*k));
# Results
print "The temperature at the centreline,r = 0 is",round(T_0),"degree Celcius"
```

In [19]:

```
import math
# Heat Conduction in a two layer medium
# Variables
k_wire = 15
k_ceramic = 1.2 #[W/m.degree Celcius]
r1 = 0.002
r2 = 0.007 #[m]
e_gen = 50*10**6 #[W/m**3]
Ts = 45. #[degree Celcius]
# Calculations and Results
T1 = (((e_gen*(r1**2)*math.log(r2/r1))/(2*k_ceramic))+Ts) #[degree Celcius]
print "The Interface temperature is",T1,"degree Celcius"
T_wire = T1+((e_gen*(r1**2))/(4*k_wire)) #[degree Celcius]
print "The temperature at the centreline(r = 0) is",T_wire,"degree Celcius"
print ("Thus the temperature of the centreline is slightly above the interface temperature")
```

In [20]:

```
import math
# Heat Conduction through a Wall with k(T)
# Variables
#k varies with temperature as k = k0(1+bT)
k0 = 38 #[W/m]
b = 9.21*(10**(-4)) #[k**(-1)]
h = 2
w = 0.7
t = 0.1 #Height,width and thickness of plates respectively[m]
T1 = 600
T2 = 400 #Temperature maintained on the two sides of the plate[K]
# Calculations and Results
A = h*w #Surface area of plate[m**2]
Tavg = (T1+T2)/2 #Average temperature of plate[K]
kavg = k0*(1+(b*Tavg)) #[W/m.K]
print "The average thermal conductivity of the medium is",kavg,"W/m.K"
Q_ = kavg*A*(T1-T2)/t #[W]
print "The rate of heat conduction through the plate is",round(Q_/1000),"kW"
```