In [1]:

```
import math
# Determining Mass Fractions from Mole Fractions
# Variables
yN2 = 0.781
yO2 = 0.209
yAr = 0.01 #Mole fractions
M_N2 = 28
M_O2 = 32
M_Ar = 39.9 #Molar Masses
# Calculations and Results
M_air = yN2*M_N2+yO2*M_O2+yAr*M_Ar #[kg/kmol]
print "The molar mass of air is",M_air,"kg/kmol"
w_N2 = yN2*M_N2/M_air;
w_O2 = yO2*M_O2/M_air;
w_Ar = yAr*M_Ar/M_air;
print "The mass fractions of N2, O2 and Ar in dry standard atmosphere are" \
,100*w_N2,"percent",",",100*w_O2,"percent","and",100*w_Ar,"percent","respectively"
```

In [2]:

```
import math
# Mole Fraction of Water Vapor at the surface of a Lake
# Variables
P_vapor = 1.705 #Partial Pressure of water vapor in the air at the lake surface is saturation pressure of watre at 15 degree Celcius[kPa]
T_lake = 15. #[degree Celcius]
P = 92. #Atmospheric pressure at lake level [kPa]
# Calculations and Results
y_vapor = P_vapor/P;
print "The mole fraction of water vapor in the air at the surface of lake is",y_vapor
y_water = 1-y_vapor #Since water contains dissolved air
print "Mole fraction of liquid water in lake",y_water
```

In [3]:

```
import math
# Mole Fraction of Dissolved Air in Water
# Variables
P_vapor = 1.96 #The partial presure of water vapor in the air at the lake surface is the saturation pressure of water at 17 degree Celcius
H = 62000. #Henry's consmath.tant for air dissolved in water at 290K[bar]
P = 92. #Atmospheric Pressure at lake level[kPa]
# Calculations and Results
P_dryair = P-P_vapor #[kPa]
print "The partial pressure of dry air is",P_dryair/100,"bar"
y_dryair = (P_dryair/100)/H;
print "The mole fraction of air in the water is",y_dryair
```

In [4]:

```
import math
# Diffusion of Hydrogen Gas into a Nickel Plate
# Variables
s = 0.00901 #Solubility of hydrogen in nickel at 358K[kmol/m**3.bar]
P_H2 = 300./100 #[bar]
M_H2 = 2 #Molar Mass of hydrogen[kg/kmol]
# Calculations and Results
C_H2 = s*P_H2 #[kmol/m**3]
print "The molar density of hydrogen in the nickel at the interface is",C_H2,"kmol/m**3"
rho_H2 = C_H2*M_H2 #[kg/m**3]
print "Mass Density of hydrogen is",rho_H2,"kg/m**3"
```

In [5]:

```
import math
# Diffusion of Hydrogen through a Spherical Container
# Variables
CA1 = 0.087
CA2 = 0 #Molar concentration of hydrogen in the nickel at inner and outer surfaces[kmol/m**3]
r2 = 4.8/2 #Outer radius[m]
t = 0.06 #Thickness of shell[m]
D_AB = 1.2*(10**(-12)) #Diffusion coefficient for hydrogen in the nickel at the specified temperature is[m**2/s]
M_H2 = 2 #Molar Mass of H2[kg/kmol]
# Calculations and Results
r1 = ((2*r2)-(2*t))/2 #Inner radius[m]
N_diff = 4*math.pi*r1*r2*D_AB*(CA1-CA2)/(r2-r1);
print "The molar flow rate of hydrogen through the shell by diffusion is",N_diff,"kmol/s"
m_diff = M_H2*N_diff;
print "The mass flow rate of hydrogen is",m_diff,"kg/s"
```

In [6]:

```
import math
# Condensation and Freezing of Moisture in Walls
Ti = 20
To = -16 #Indoor and outdoor temperatures[degree Celcius]
R_wall = 3.05 #Total thermal resismath.tance of the wall[m**2.degree Celcius/W]
A = 1 #Heat transfer area[m**2]
R_ext = 0.40 #The thermal resismath.tance of the exterior part of the wall beyond the insulation[m**2.degree Celcius/W]
Rv_int = 0.012+0.0004
Rv_ext = 0.0138+0.019 #Indoor and outdoor vapor resismath.tances[Pa.m**2.s/ng]
phi1 = 0.6
phi2 = 0.7 #Indoor and outdoor Relative Humidity
Psat1 = 2340
Psat2 = 151 #Indoor and outdoor saturation pressures[Pa]
# Calculations and Results
Q_wall = A*(Ti-To)/R_wall #[W]
print "The rate of heat transfer through unit area of wall is",Q_wall,"W"
T_I = To+(Q_wall*R_ext);
print "The temperature of outer sheathing interface is",T_I,"degree Celcius"
P = 234 #The saturation pressure of water at temp T_I[Pa]
Pv1 = phi1*Psat1;
Pv2 = phi2*Psat2;
print "The vapor pressure at the indoor and the outdoor is" \
,Pv1,"Pa","and",round(Pv2),"Pa"
mv_int = A*(Pv1-P)/Rv_int;
mv_ext = A*(P-Pv2)/Rv_ext;
print "The rate of moisture flow through the interior and exterior parts of the wall is" \
,mv_int,"ng/s","and",mv_ext,"ng/s"
mv_freezing = mv_int-mv_ext;
print "The moisture is freezing in the insulation at the rate of",mv_freezing,"ng/s"
```

In [7]:

```
import math
# Hardening of Steel by the diffusion of carbon
# Variables
D_AB = 4.8*10**(-10) #Diffusion coefficient of carbon in steel at the furnace temperature [m**2/s]
wA_i = 0.0015 #Initial carbon concentration
wA_e = 0.012 #Equilibrium concentration of carbon
wA_t = 0.01 #Concentration of carbon after desired time
x = 0.0005 #Diffusion dismath.tance[m]
# Calculations
a = (wA_t-wA_i)/(wA_e-wA_i);
#Tthe argument whose complimentary error function is a = 0.81 is 0.17
t = (x**2)/(4*D_AB*(0.17**2)) #[seconds]
# Results
print "Time taken to reach desired level of hardening is",round(t),"seconds"
```

In [10]:

```
import math
# Venting of Helium into the Atmosphere by Diffusion
# Variables
D_AB = 7.2*10**(-5) #Diffusion coefficient of air in helium[m**2/s]
M_He = 4
M_air = 29 #Molar masses of helium and air[kg/kmol]
D = 0.005 #Internal diameter of tube[m]
L = 15 #Length of tube[m]
R1 = 8.314 #Universal Gas Consmath.tant[kPa.m**3/kmol.K]
R2 = 2.0769 #Universal Gas Consmath.tant[kPa.m**3/kg.K]
T = 298 #/Ambient temperature[K]
# Calculations and Results
A = math.pi*(D**2)/4 #Flow area[m**2]
P_He0 = 1
P_HeL = 0 #Pressure of helium at x = 0 i.e. bottom of tube and at x = L i.e. at the top of the tube [atm]
N_He = D_AB*A*(P_He0-P_HeL)*(101.3)/(R1*T*L);
print "The molar flow rate of Helium is",N_He,"kmol/s"
m_He = N_He*M_He;
print "Mass flow rate of helium is",m_He,"kg/s"
N_air = -N_He #Equimolar counter diffusion process
m_air = N_air*M_air;
print "The flow rate of air into the pipeline is",m_air,"kg/s"
w_air = m_air/(m_air+m_He);
print "Mass fraction of air in the helium pipeline is",w_air,"which is negligible"
m_net = m_He+m_air #[kg/s]
#Taking density of mixture at x = 0 to be the density of helium as the
# mass fraction of air at the bottom is very small
rho = P_He0*101.325/(R2*T) #[kg/m**3]
V = m_net/(rho*A) #[m/s]
print "The average flow velocity at the bottom of the tube is",V,"m/s"
```

In [11]:

```
import math
# Measuring Diffusion Coefficient by the Stefan tube
# Variables
D = 0.03 #Diameter of tube[m]
P = 83.5 #Atmospheric Pressure at an elevation of 1600m[kPa]
T = 20+273 #Ambient temperature[K]
R = 8.314 #Universal Gas Consmath.tant[kPa.m**3/kmol.K]
P_vapor0 = 2.34 #The saturation pressure of water at 20 degree Celcius[kPa]
M_vapor = 18 #Molar mass of water vapor[kg/kmol]
x = 0.4 #Dismath.tance from water surface to the open end of the tube[m]
# Calculations and Results
#water vapor is species A
yA0 = P_vapor0/P;
print "The mole fraction of water vapor (species A) at the Interface is",yA0
yAL = 0 #mole fraction of water vapor on the top of the tube
C = P/(R*T) #[kmol/m**3]
A = math.pi*(D**2)/4 #[m**2]
print "The cross sectional area of tube",A,"m**2"
m_vapor = (1.23*10**(-3))/(15*24*3600) #Rate of evaporation [kg/s]
N_vapor = m_vapor/M_vapor;
print "The molar flow rate of vapor is",N_vapor,"kmol/s"
D_AB = (N_vapor/A)*(x/C)/math.log((1-yAL)/(1-yA0));
print "Binary diffusion coefficient of water vapor in air at 20 degree Celcius and 83.5kPa" \
,D_AB,"m**2/s"
```

In [12]:

```
import math
# Mass Convection inside a Circular Pipe
# Variables
D = 0.015 #Inner Diameter[m]
T = 300 #Temp of air[K]
P = 1 #Pressure of air[atm]
v = 1.2 #Average velocity of air[m/s]
nu = 1.58*10**(-5) #Vismath.cosity[m**2/s]
# Calculations and Results
#Water is Species Aand air is species B
D_AB = (1.87*10**(-10))*(T**2.072)/P #[m**2/s]
print "The mass diffusivity of water vapor in air at 300K is",D_AB,"m**2/s"
Re = v*D/nu;
print "The Reynolds number for internal flow is",round(Re)
if(Re<2300):
print ("laminar Flow")
Sh = 3.66 #Sherwood number equals to Nusselt number
h_mass = Sh*D_AB/D #[m/s]
print "The mass transfer coefficient is",h_mass,"m/s"
else:
print ("Flow is not laminar")
```

In [14]:

```
import math
# Anamath.logy between Heat and Mass Transfer
# Variables
#Napthalene is species A and air is species B
M_A = 128.2 #Molar Mass of A[kg/kmol]
M_air = 29. #Molar mass of B[kg/kmol]
P = 101325. #Pressure of Air[Pa]
T = 298. #Temperature[K]
D_AB = 0.61*10**(-5) #[m**2/s]
v = 2. #Stream velocity[m/s]
rho = 1.184 #Density of air[kg/m**3]
Cp = 1007. #Specific Heat[J/kg.K]
a = 2.141*10**(-5) #Absorptivity[m**2/s]
w_inf = 0. #Mass fraction of napthalene at free stream conditions
P_As = 11. #Vapor Pressure of Napthalene at surface[Pa]
mA = 12*10.**(-3) #Mass of napthalene sublimated[kg]
delta_t = 15.*60 #time of sublimation[s]
As = 0.3 #surface area of the body[m**2]
# Calculations and Results
w_As = (P_As/P)*(M_A/M_air);
print "Mass fraction at the surface is",w_As
m_evap = mA/delta_t #[kg/s]
print "The rate of evaporation of napthalene is",m_evap,"kg/s"
h_mass = m_evap/(rho*As*(w_As-w_inf));
print "The mass convection coefficient is",h_mass,"m/s"
#Using anamath.logy between heat and mass transfer
h_heat = rho*Cp*h_mass*((a/D_AB)**(2/3)) #[W/m**2.degree Celcius]
print "The average heat transfer coefficient is",round(h_heat),"W/m**2.degree Celcius"
```

In [15]:

```
import math
# Evaporative Cooling of a Canned Drink
# Variables
#Water is species A and air is species B
M_A = 18
M_B = 29; #Molar Masses of water and air[kg/kmol]
D_AB = 2.5*10**(-5) #Diffusivity of water vapor in air[m**2/s]
T_inf = 30 #Ambient Temperature[degree Celcius]
T_avg = (20+T_inf)/2 #Average temperature
P = 101.325 #Atmospheric Pressure[kPa]
#Properties of A at 20 degree Celcius
h_fg = 2454 #[kJ/kg]
Pv1 = 2.34 #Saturation vapor pressure[kPa]
Pv2 = 4.25 #Vapor Pressure at 30 degree Celcius[kPa]
#Properties of air at average temperature and 1 atm
Cp = 1.007 #[kJ/kg]
a = 2.141*10**(-5) #[m**2/s]
phi = 0.4 #Relative Humidity
# Calculations and Results
Le = a/D_AB;
print "The Lewis Number is",Le
Pv_inf = phi*Pv2 #[kPa]
print "The vapor pressure of air away from the surface is",Pv_inf,"kPa"
Ts = T_inf-(h_fg*M_A*(Pv1-Pv_inf)/(Cp*(Le**(2/3))*M_B*P));
print "The temperature of the drink can be lowered to",Ts,"degree Celcius"
```

In [16]:

```
import math
# Heat Loss from Uncovered Hot Water Baths
# Variables
Ts = 50+273 #Uniform temperature of water[K]
T_surr = 20+273 #Average temperature of surrounding surfaces[K]
T_inf = 25+273 #Ambient temperature[K]
As = 3.5*1 #Surface area of water bath[m**2]
p = 2*(3.5+1) #Perimeter of top surface of water bath[m]
e = 0.95 #Emissivity of liquid water
phi = 0.52 #Relative Humidity
Rv = 0.4615 #Universal Gas Consmath.tant[kPa.m**3/kg.K]
Ra = 0.287 #Universal Gas Consmath.tant[kPa.m**3/kg.K]
g = 9.81 #[m**2/s]
# Calculations and Results
#(a)
Q_rad = e*As*(5.67*10**(-8))*((Ts**4)-(T_surr**4));
print "The radiation heat loss from the water to the surrounding surface is",round(Q_rad),"W"
#(b)
Tavg = (Ts+T_inf)/2 #Average temperature[degree Celcius]
P = 92 #Atmospheric pressure[kPa]
#At average temperature Tavg and Pressure P,Properties of dry air:-
k = 0.02644 #[W/m.degree Celcius]
Pr = 0.7262 #Prandtl number, independent of pressure
a = (2.312*10**(-5))/P #Absorptivity[m**2/s]
nu = (1.849*10**(-5)) #Kinematic vismath.cosity[m**2/s]
#At T_surr properties of water are:-
h_fg = 2383 #[kJ/kg]
Pvs = 12.35 #[kPa]
Psat = 3.17 #Saturation Pressure of water at surface temp[kPa]
#The air at surface is saturated therefore vapor pressure at surface is simple the saturation pressure of water at the surface temperature
Pv_inf = phi*Psat #[kPa]
#At the surface
rho_vs = Pvs/(Rv*Ts);
print "Density of water vapor at the surface is",rho_vs,"kg/m**3"
rho_as = (P-Pvs)/(Ra*Ts);
print "Density of air at the surface is",rho_as,"kg/m**3"
rho_s = rho_vs+rho_as;
print "Density of mixture at the surface is",rho_s,"kg/m**3"
#Away from the surface
rho_vinf = Pv_inf/(Rv*T_inf);
print "Density of vapor away from the surface is",rho_vinf,"kg/m**3"
rho_ainf = (P-Pv_inf)/(Ra*T_inf);
print "Density of air away from the surface is",rho_ainf,"kg/m**3"
rho_inf = rho_ainf+rho_vinf;
print "The density of mixture away from the surface is",rho_inf,"kg/m**3"
Lc = As/p;
print "The characteristic length is",Lc,"m"
Gr = g*(rho_inf-rho_s)*(Lc**3)/(((rho_inf+rho_s)/2)*(nu**2));
print "The Grashof number is",Gr
Nu = 0.15*((Gr*Pr)**(1/3));
print "The Nusselt number is",Nu
h_conv = Nu*k/Lc;
print "The convection heat transfer coefficient is" \
,h_conv,"W/m**2.degree Celcius"
Q_conv = h_conv*As*(Ts-T_inf);
print "The natural convection heat transfer rate is" \
,Q_conv,"W"
#(c)
D_AB = (1.87*10**(-10))*(Tavg**2.072)/(P/101.325);
print "The mass diffusivity of water vapor in air at the average temperature is" \
,D_AB,"m**2/s"
Sc = nu/D_AB;
print "The Schmidt Number is",Sc
Sh = 0.15*((Gr*Sc)**(1/3));
print "The Sherwood Number is",Sh
h_mass = Sh*D_AB/Lc;
print "The mass transfer coefficient is",h_mass,"m/s"
mv = h_mass*As*(rho_vs-rho_vinf);
print "The evaporation rate is",mv,"kg/s"
Q_evap = mv*h_fg;
print "The rate of heat transfer by evaporation is",Q_evap,"kW"
Q_total = Q_rad+Q_conv+1000*Q_evap;
print "The total rate of heat transfer from the water to the surrounding air and surfaces is" \
,Q_total,"W"
```