import math
print "Introduction to heat transfer by S.K.Som, Chapter 12, Example 1"
#The pressure in the pipeline that transports helium gas at a rate of 4kg/s is maintained at pressure(p)=1 atm or 101*10**3 pascal.
#The internal daimeter of tube is (di)=6mm or .006m
#The temprature of both air and helium is (T)=25°C or 298 K.
#The diffusion coefficient of helium in air at normal atmosphere is(Dab)=7.20*10**-5 m**2/s
#The venting tube extends to a length(L)=20m in the atmosphere.
di=.006;
print "The flow area is given by A=(pi*di**2)/4 in m**2"
A=(math.pi*di**2)/4
print round(A,5)
p=101*10**3;
R=8.31*10**3;#gas constant
T=298;
Dab=7.20*10**-5;
L=20;
#c is the molar concentration
print "The molar concentration of mixture which is constant throughout is given by c=p/(R*T)"
c=p/(R*T)
print round(c,5)
#helium has been considered as species A so (helium mole fraction at the bottom of the tube)is Yao=1 and (helium mole fraction at the bottom of the tube)is Yal=0
Yal=0;
Yao=1;
#Nhe and Nair are molar rate of helium and air respectively
print "Nhe=Nair=(A*c*Db*(Yao-yal))/L in kmol/sec"
Nair=(A*c*Dab*(Yao-Yal))/L
Nhe=Nair;
#Molecular weights of air and helium are 29kg/kmol and 4 kg/kmol respectively.
Mhe=4;
Mair=29;
#mass flow rate of helium is mhe
print "mass flow rate of helium is given by m=Mhe*Nhe in kg/sec "
mhe=Mhe*Nhe
print round(mhe,12)
#mass flow rate of air is mair
print "mass flow rate of air is given by m=Mair*Nair in kg/sec "
mair=Mair*Nair
print round(mair,11)
import math
print "Introduction to heat transfer by S.K.Som, Chapter 12, Example 2"
#The temprature of atmospheric air (T)=40°C which flows over a wet bulb thermometer.
#The reading of wet bulb thermometer which is called the wet bulb temprature is (Tw)=20°C
T=40;
Tw=20.0;
#Tf is the film temprature
print "The film temperature is given by Tf=(T+Tw)/2 in °C "
Tf=(T+Tw)/2
print round(Tf,5)
Tinf=T;#surrounding temprature
#The properties of air at film temprature are density(rho=1.13kg/m**3),specific heat(cp=1.007kJ/(kg*K)),Thermal diffusivity(alpha=0.241*10**-4m**2/s)
#The diffusivity Dab=0.26*10**-4 m**2/s
#The enthalpy of vaporisation of water at 20°C is hfg=2407kJ/kg or 2407*10**3 J/kg
#The partial pressure of water vapour is the saturation pressure corresponding to 20°C so from steam table Ps=2.34kPa or 2.34*10**3 Pa.
rho=1.13;
cp=1.007*10**3;
alpha=0.241*10**-4;
Dab=0.26*10**-4;
hfg=2407*10**3;
Ps=2.34*10**3;
#The temprature at bulb surface Ts=20°C or 293K
Ts=Tw+273;#in kelvin
R=8.31*10**3;#gas constant
#The molecular weight of water is M=18
M=18;
#The density of water at bulb surface is rhos
print "The density of water at bulb surface is given by rhos=(Ps*M)/(R*Ts) in kg/m**3 "
rhos=(Ps*M)/(R*Ts)
print round(rhos,5)
#Let X=hheat/hmass=rho*cp*(alpha/Dab)**(2/3).
X=rho*cp*(alpha/Dab)**(2/3);
#At steady atate (Rate of heat transfer from air to wet cover of thermometer bulb)=(Heat removed by evaporation of water from the wet cover of thermometer bulb)
#hheat*(Tinf-Ts)=hmass*(rhos-rhoinf)*hfg
#Rearranging above we get rhoinf=rhos-(hheat/hmass)*((Tinf-Ts)/hfg)
#The concentration of water vapour at free stream is rhoinf
print "The concentration of water vapour at free stream is rhoinf=rhos-(hheat/hmass)*((Tinf-Ts)/hfg) in kg/m**3 "
rhoinf=rhos-((X)*((Tinf-Tw)/hfg))
print round(rhoinf,5)
#The mass concentration of saturated water vapour(rhosteam) at 40°C(as found from steam table) is .051 kg/m**3
rhosteam=.051;
#The relative humidity is (rehu)
print "The relative humidity is given by rehu=(rhoinf/rhosteam)*100 in percentage "
rehu=(rhoinf/rhosteam)*100
print round(rehu,5)
import math
print "Introduction to heat transfer by S.K.Som, Chapter 12, Example 3"
#The diameter of tube is (di)=35mm which measures binary diffusion coefficient of water vapour in air at temprature,T=20°C or 293 K.
#The measurement is done at height of 1500 m where the atmospheric pressure is (p)=80kPa.
p=80;
T=293.0;
#The distance from the water surface to the open end of the tube is L=500 mm or 0.5m.
L=.5;
#After t=12 days of continuous operation at constant pressure and temprature the amount of water evaporated was measured to be m= 1.2*10**-3kg.
m= 1.2*10**-3;
#From the steam table pvapour=3.17kPa
pvapour=3.17;#partial pressure of vapour
#Yao is the mole fraction of water vapour at the interface
print "The mole fraction of water vapour at the interface is given by Yao=pvapour/p"
Yao=pvapour/p
print round(Yao,5)
#The mole fraction of water vapour at the top end of the tube is Yal=0
Yal=0;
R=8.31*10**3;#gas constant
#The total molecular concentration is (c)
print "The total molecular concentration (c) through the tube remains constant is given by c=p/(R*T) in kmol/m**3"
c=(p*10**3)/(R*T)
print round(c,5)
di=35;
#A is the cross sectional area of the tube
print "The cross sectional area of the tube is given by A=(pi*(di*10**-3)**2)/4 in m**2"
A=(math.pi*(di*10**-3)**2)/4
print round(A,5)
#The molecular weight of wate is M=18
M=18;
#The mass flow rate is given by mdot=(m/(12*24*3600))
mdot=(m/(12*24*3600));
#N is the molar flow rate of water vapour
print "The molar flow rate of water vapour is given by N=mdot/M in kmol/s"
N=mdot/M
print round(N,10)
#The molar flow rate of water vapour can also be written as N=(c*Dab*A*ln[(1-Yal)/(1-Yao)])/L
#The diffusion coefficient of water vapour is Dab=(N*L)/(c*A*ln[(1-Yal)/(1-Yao)])
#let us take X=math.log10((1-Yal)/(1-Yao)) and Y=math.log10(2.7182)
X=math.log10((1-Yal)/(1-Yao));
Y=math.log10(2.7182);
#ln[(1-Yal)/(1-Yao)] is given by
ln=X/Y;
print "The diffusion coefficient of water vapour is Dab=(N*L)/(c*A*ln[(1-Yal)/(1-Yao)]) in m/s"
Dab=(N*L)/(c*A*ln)
print round(Dab,5)