In [1]:

```
import math
print"Introduction to heat transfer by S.K.Som, Chapter 10, Example 1"
#A brine solution is heated from temprature ,T1=8Â°C to temprature,T2=14Â°C in a double pipe heat exchanger.
T1=8.0;
T2=14.0;
#Water entering at temprature T3=55Â°C and leaving at temprature,T4=40Â°C at the mass flow rate of (mdot)=0.18kg/s
mdot=0.18;
T3=55.0;
T4=40.0;
#Specific heat (cp) of water =4.18kJ/(kg*K)
cp=4.18*10**3;
#overall heat transfer coefficient(U)=800 W/(m**2*K)
U=800.0;
#The rate of heat transfer from water is given by Q=mdot*cp*(T3-T4)
print"The rate of heat transfer from water is given by Q=mdot*cp*(T3-T4) in W"
Q=mdot*cp*(T3-T4)
print"Q=",Q
print"(a) For a parallel flow arrangement"
#For a parallel flow arrangement deltaT1=T3-T1 and deltaT2=T4-T2.
deltaT1=T3-T1;#deltaT1 is temprature difference
deltaT2=T4-T2;#deltaT2 is temprature difference
#LMTD(math.log mean temprature difference) is defined as (deltaT2-deltaT1)/(ln(deltaT2/deltaT1)) for both parallel and counter flow.
print"LMTD is given by (deltaT2-deltaT1)/(ln(deltaT2/deltaT1)) in Â°C "
#let X=math.log10((deltaT2/deltaT1)) and Y=math.log10(2.718281)
X=math.log10((deltaT2/deltaT1));
Y=math.log10(2.718281);
#ln=(ln(deltaT2/deltaT1))
ln=X/Y;
LMTD=(deltaT2-deltaT1)/ln
print"LMTD=",LMTD
#Area(A)=Q/(U*LMTD) in m**2
print"Area(A)=Q/(U*LMTD) in m**2"
A=Q/(U*LMTD)
print"A=",A
print"(b)For counterflow arrangement"
deltaT1=T3-T2;
deltaT2=T4-T1;
print"LMTD=(deltaT2-deltaT1)/(ln(deltaT2/deltaT1))inÂ°C "
X=math.log10((deltaT2/deltaT1));
Y=math.log10(2.718281);
ln=X/Y;
LMTD=(deltaT2-deltaT1)/ln
print"LMTD=",LMTD
print"Area(A)=Q/(U*LMTD) in m**2"
A=Q/(U*LMTD)
print"A=",A
```

In [3]:

```
import math
print"Introduction to heat transfer by S.K.Som, Chapter 10, Example 2"
#Hot oil(specific heat,ch=2.09kJ/(kg*K)) flows through counter flow heat excahnger at the mass flow rate of mdoth=(0.7kg/s)
ch=2.09*10**3;
mdoth=0.7;
#overall heat transfer coefficient(U)=650 W/(m**2*K)
U=650;
#It enters at temprature,Th1=200Â°C and leaves at temprature,Th2=70Â°C
Th1=200;
Th2=70;
#Cold oil(specific heat,cc=1.67kJ/(kg*K) exits at temprature,Tc2=150Â°C at the mass flow rate of mdotc=(1.2kg/s)
mdotc=1.2;
cc=1.67*10**3;
Tc2=150;
#The unknown inlet temprature(Tc1) of cold oil may be found from energy balance mdotc*(Tc2-Tc1)=mdoth*(Th2-Th1)
print"The inlet temprature(Tc1) of cold oil in Â°C "
Tc1=Tc2-((mdoth*ch)/(mdotc*cc))*(Th1-Th2)
print"Tc1=",Tc1
#The rate of heat transfer can be calculate as Q=mdoth*ch*(Th1-Th2)
print"The rate of heat transfer Q=mdoth*ch*(Th1-Th2) in W"
Q=mdoth*ch*(Th1-Th2)
deltaT1=Th1-Tc2;
print"Q=",Q
#deltaT1 is temprature difference between hot oil inlet temprature and cold oil exit temprature
deltaT2=Th2-Tc1;
#deltaT2 is temprature difference between hot oil exit temprature and cold oil inlet temprature
#LMTD(math.log mean temprature difference) is defined as (deltaT2-deltaT1)/(ln(deltaT2/deltaT1)) for counter flow.
print"LMTD is given by (deltaT2-deltaT1)/(ln(deltaT2/deltaT1)) in Â°C "
#let X=log10((deltaT2/deltaT1)) and Y=log10(2.718281)
X=math.log10((deltaT2/deltaT1));
Y=math.log10(2.718281);
#ln=(ln(deltaT2/deltaT1))
ln=X/Y;
LMTD=(deltaT2-deltaT1)/ln
print"LMTD=",LMTD
#Area(A)=Q/(U*LMTD) in m**2
print"Area(A)=Q/(U*LMTD) in m**2"
A=Q/(U*LMTD)
print"A=",A
```

In [5]:

```
import math
print"Introduction to heat transfer by S.K.Som, Chapter 10, Example 3"
#A cross flow heat exchanger with both fluids unmixed is used to heat water((specific heat,cc=4.18kJ/(kg*K)) from temprature Tci=50Â°C to Tco=90Â°C
#flowing at the mass flow rate of (mdotc)=1kg/s
Tci=50;
Tco=90;
cc=4.18*10**3;
mdotc=1;
#The hot engine oil has (specific heat,ch=1.9kJ/(kg*K)) flowing at the mass flow rate of mdoth=3kg/s enters at temprature Thi=100Â°C
mdoth=3;
Thi=100;
ch=1.9*10**3;
#The unknown outlet temprature(Tho) of oil may be found from energy balance mdotc*(Tco-Tci)=mdoth*(Tho-Thi)
print"The outlet temprature(Tho) of oil in Â°C "
Tho=Thi-((mdotc*cc)/(mdoth*ch))*(Tco-Tci)
print"Tho=",Tho
print"For a counterflow heat exchanger"
deltaT1=Thi-Tco;#deltaT1 is temprature difference
deltaT2=Tho-Tci;#deltaT2 is temprature difference
print"deltaT1=",deltaT1
print"deltaT2=",deltaT2
#LMTD(math.log mean temprature difference) is defined as (deltaT2-deltaT1)/(ln(deltaT2/deltaT1)) for counter flow.
print"LMTD is given by (deltaT2-deltaT1)/(ln(deltaT2/deltaT1)) in Â°C "
#let X=log10((deltaT2/deltaT1)) and Y=log10(2.718281)
X=math.log10((deltaT2/deltaT1));
Y=math.log10(2.718281);
ln=X/Y;
LMTD=(deltaT2-deltaT1)/ln
print"LMTD=",LMTD
#Area(A)=20m**2
A=20;
#We have to employ correction factor(F) for the cross flow arrangement.
#We evaluate dimensionless parameters P=(Tco-Tci)/(Thi-Tco) and R=(Thi-Tho)/(Tco-Tci).
print"dimensionless parameters P and R are"
P=(Tco-Tci)/(Thi-Tci)
R=(Thi-Tho)/(Tco-Tci)
print"P=",P
print"R=",R
print"correction factor(F) for the cross flow arrangement as obtained from graph of F vs Single Pass flow with fluids unmixed"
F=0.75
#The rate of heat transfer can be calculate as Q=mdoth*ch*(Th1-Th2)
Q=mdotc*cc*(Tco-Tci);
print"Q=",Q
#overall heat transfer coefficient(U)=Q/(A*F*LMTD)
print"overall heat transfer coefficient(U)=Q/(A*F*LMTD)in W/(m**2*K)"
U=Q/(A*F*LMTD)
print"U=",U
```

In [7]:

```
import math
print"Introduction to heat transfer by S.K.Som, Chapter 10, Example 5"
#Water is heated from temprature ,Tin=30Â°C to Tout=90Â°C in a counter flow double pipe heat exchanger.
Tin=30;
Tout=90;
#Water flows at a mass flow rate of mdotw=1.2kg/s
mdotw=1.2;
#The heating is accomplished by a geothermal fluid which enters the heat exchanger at temprature ,Thin=160Â°C at the mass flow rate of mdoth=2kg/s
mdoth=2;
Thin=160;
#The inner tube is thin walled having diameter(D)=15mm or 0.015m
D=0.015;
#overall heat transfer coefficient(U)=600 W/(m**2*K)
U=600;
#The specific heat of water and geothermal fluid is (cpw=4.18kJ/(kg*K))and(cph=4.31kJ/(kg*K)) respectively
cpw=4.18*10**3;
cph=4.31*10**3;
#The rate of heat transfer in heat exchanger can be calculate as Q=mdotw*cpw*(Tout-Tin)
print"(a)Applying LMTD method"
print"The rate of heat transfer Q=mdotw*cpw*(Tout-Tin) in W"
Q=mdotw*cpw*(Tout-Tin)
print"Q=",Q
#The unknown outlet temprature(Thout) of geothermal fluid may be found from energy balance mdotw*cpw*(Tout-Tin)=mdoth*cph*(Thin-Thout)
print"The unknown outlet temprature(Thout) of geothermal fluid in Â°C "
Thout=Thin-Q/(mdoth*cph)
print"Thout=",Thout
deltaT1=Thin-Tout;#Temprature difference between inlet temprature of hot fluid and outlet temprature of cold fluid
deltaT2=Thout-Tin;#Temprature difference between outlet temprature of hot fluid and inlet temprature of cold fluid
#LMTD is defined as (deltaT2-deltaT1)/(ln(deltaT2/deltaT1)) for counter flow.
print"LMTD is given by (deltaT2-deltaT1)/(ln(deltaT2/deltaT1)) in Â°C "
#let X=math.log10((deltaT2/deltaT1))and Y=math.log10(2.718281)
X=math.log10((deltaT2/deltaT1));
Y=math.log10(2.718281);
ln=X/Y;
LMTD=(deltaT2-deltaT1)/ln
print"LMTD=",LMTD
#Area(A)=Q/(U*LMTD) in m**2
print"Area(A)=Q/(U*LMTD) in m**2"
A=Q/(U*LMTD)
print"A=",A
print"To provide this surface area ,The length(L) of the tube required is given by L=A/(pi*D) in m"
L=A/(math.pi*D)
print"L=",L
print"(b)Applying NTU method"
#The heat capacity rates are defined as Ch=mdoth*cph and Cc=mdotw*cw in KW/Â°C
print"The heat capacity rates are defined as Ch=mdoth*cph and Cc=mdotw*cpw in KW/Â°C"
Ch=(mdoth*cph)/1000
Cc=(mdotw*cpw)/1000
print"Ch=",Ch
print"Cc=",Cc
#So Cmin=Cc and Cmax=Ch
Cmin=Cc;
Cmax=Ch;
#C is defined as Cmin/Cmax
print"C=Cmin/Cmax"
C=Cmin/Cmax
print"C=",C
#Heat transfer effectiveness is (eff)
print"Heat transfer effectiveness is defined as eff=Q/(Cmin*(Thin-Tin))"
eff=(Q/1000)/(Cmin*(Thin-Tin))
print"eff=",eff
print"NTU is determined by NTU=(1/(C-1))*ln((eff-1)/(eff*C-1))"
#let X=math.log10((eff-1)/(eff*C-1)) and Y=math.log10(2.718281)
X=math.log10((eff-1)/(eff*C-1));
Y=math.log10(2.718281);
#ln=ln((eff-1)/(eff*C-1))
ln=X/Y;
#NTU is Number of transfer units
NTU=(1/(C-1))*ln
print"NTU=",NTU
#NTU =U*A/Cmin
print"Area(A)=(NTU*Cmin)/U in m**2"
A=(NTU*Cmin*1000)/U
print"A=",A
print"To provide this surface area ,The length(L) of the tube required is given by L=A/(pi*D) in m"
L=A/(math.pi*D)
print"Hence same result is obtained for both methods"
print"L=",L
```

In [8]:

```
import math
print"Introduction to heat transfer by S.K.Som, Chapter 10, Example 6"
#Water having specific heat,cw=4.18kJ/(kg*K) enters a counterflow double pipe heat exchanger at temprature,Tci=35Â°C flowing at the mass flow rate of mdotw=0.8 kg/s.
cw=4.18;
mdotw=0.8;
Tci=35;
#It is heated by oil having specific heat,co=1.88kJ/(kg*K) flowing at the mass flow rate of mdoto=1.5 kg/s from an inlet temprature(Thi) of 120Â°C.
co=1.88;
mdoto=1.5;
Thi=120;
#For an area(A) of 15m**2 and an overall heat transfer coefficient(U) of 350W/(m**2*K).
A=15;
U=350;
#Cwater and Co are heat capacities for water and oil respectively
#Cwater=mdotw*cw and Co=mdoto*co
Cwater=mdotw*cw;
Co=mdoto*co;
#C=Cmin/Cmax
Cmin=min(Cwater,Co);
Cmax=max(Cwater,Co);
C=Cmin/Cmax;
#NTU is number of transfer units
#NTU=(U*A)/Cmin
print"NTU is defined as (U*A)/Cmin "
NTU=(U*A)/(Cmin*1000)
print"NTU=",NTU
#Heat transfer effectiveness(eff) is defined as (1-e**(-NTU*(1-C))/(1-C*e**(-NTU*(1-C))
print"Heat transfer effectiveness(eff) is defined as (1-e**(-NTU*(1-C))/(1-C*e**(-NTU*(1-C))"
eff=(1-math.e**(-NTU*(1-C)))/(1-C*math.e**(-NTU*(1-C)))
print"eff=",eff
#Hence The total heat transfer rate (Q)=eff*Cmin*(Thi-Tci)in kW.
print"The total heat transfer rate (Q)=eff*Cmin*(Thi-Tci) in kW"
Q=eff*Cmin*(Thi-Tci)
print"Q=",Q
```

In [9]:

```
import math
print"Introduction to heat transfer by S.K.Som, Chapter 10, Example 7"
#Water enters a cross flow heat exchanger (both fluids unmixed) at temprature(Tci)=20Â°C amd flows at a mass flow rate of mdotw=7kg/s
Tci=20;
mdotw=7;
#The air flows at a mass flow rate of mdota=10kg/s from Temprature(Thi)=125Â°C
mdota=10;
Thi=125;
#The overall heat transfer coefficient(U)=220W/(m**2*K)and Area(A)=250m**2.
U=220;
A=250;
#The specific heat of air (cpa=1.01kJ/(kg*K)) and water is (cpw=4.18kJ/(kg*K))
cpa=1.01;
cpw=4.18;
#Cair and Cwater are heat capacities of air and water respectively
Cair=mdota*cpa;
Cwater=mdotw*cpw;
#C=Cmin/Cmax
Cmin=min(Cwater,Cair);
Cmax=max(Cwater,Cair);
C=Cmin/Cmax;
#NTU is number of transfer units
#NTU=(U*A)/Cmin
print"NTU is defined as (U*A)/Cmin "
NTU=(U*A)/(Cmin*1000)
print"NTU=",NTU
#To determine the effectiveness of heat exchanger we have to find out the suitable expression
#For this type of heat exchanger The effectiveness(eff)is determined by (1-e**((NTU**.22*(e**-(C*NTU**0.78)-1)/C)
print"The effectiveness of heat exchanger is"
eff=(1-math.e**((NTU**0.22))*(math.e**(-C*NTU**0.78)-1)/C)
print"eff=",eff
#Hence The total heat transfer rate(Q)=eff*Cmin*(Thi-Tci)in W.
print"The total heat transfer rate(Q)=eff*Cmin*(Thi-Tci) in W"
Q=eff*Cmin*1000*(Thi-Tci)
print"Q=",Q
#The exit temprature(Tho) of air is given by Thi-(Q/(mdota*cpa))
print"The exit temprature of air in Â°C "
Tho=Thi-(Q/(mdota*1000*cpa))#NOTE:-The answer slightly varies from the answer in book(i.e Tho=26Â°C) because the value of Q taken in book is approximated to 1*10**6W.
print"Tho=",Tho
```

In [10]:

```
import math
print"Introduction to heat transfer by S.K.Som, Chapter 10, Example 8"
#A double pipe heat exchanger of length(L)=0.30m is to be used to heat water(specific heat,cc=4.18kJ/(kg*K)) and mass flow rate(mdotw=2kg/s)
L=0.30;
cc=4.18;
mdotw=2;
#The water enters at temprature(Tci)=25Â°C and leaves at temprature(Tco)=50Â°C
#The flow rate of oil is mdoth
Tci=25;
Tco=50;
#The oil used as hot fluid has(specific heat,ch=1.88kJ/(kg*K)) and has inlet temprature(Thi)=100Â°C
ch=1.88;
Thi=100;
print"(a)Considering a parallel flow arrangement "
#For minimum value of mdoth
#The theoretical minimum value of outlet temprature of hot fluid(Tho) under this situation is equal to Tco
Tho=Tco;
print"Tho=",Tho
#The mass flow rate of oil is given by energy balance as mdoth=(mdotw*cpw*(Tco-Tci))/(cph*(Thi-Tho))
print"The minimum flow rate required for the oil in kg/s"
mdoth=(mdotw*cc*(Tco-Tci))/(ch*(Thi-Tho))
print"mdoth=",mdoth
print"(b)Theoretical question"
print"If LMTD--->0,Then for a finite value of heat transfer rate U*A--->infinity.For a given finite length this implies value of U which is not possible."
print"(c)Let us consider a counter flow arrangement"
#In this case value of Tho=Tci.
Tho=Tci;
#The mass flow rate of oil is given by energy balance as mdoth=(mdotw*cpw*(Tco-Tci))/(cph*(Thi-Tho))
print"The minimum flow rate required for the oil in kg/s"
mdoth=(mdotw*cc*(Tco-Tci))/(ch*(Thi-Tci))
#Now Heat capacities are Ch=mdoth*ch and Cc=mdotw*cc
Ch=mdoth*ch;
Cc=mdotw*cc;
print"Ch=",Ch
print"Cc=",Cc
Cmin=min(Ch,Cc);#minimum heat capacity in Ch and Cc
#Effectiveness of heat exchanger is eff.
#Tho=Tci for this kind of arrangement
Tho=Tci;
print"Effectiveness of heat exchanger is "
eff=(mdoth*ch*(Thi-Tho))/(mdoth*ch*(Thi-Tci))
print"eff=",eff
```