Chapter 1 : Introduction

example 1.1 page number 19

In [1]:
import math 

y_oxygen = 0.21       #mole fraction of oxygen
y_nitrogen = 0.79     #mole fraction of nitrogen
molar_mass_oxygen = 32.
molar_mass_nitrogen = 28.

molar_mass_air = y_oxygen*molar_mass_oxygen+y_nitrogen*molar_mass_nitrogen;
mass_fraction_oxygen =y_oxygen*molar_mass_oxygen/molar_mass_air;
mass_fraction_nitrogen = y_nitrogen*molar_mass_nitrogen/molar_mass_air;

print "mass fraction of oxygen = %f "%(mass_fraction_oxygen)
print "mass fraction of nitrogen = %f "%(mass_fraction_nitrogen)

V1 = 22.4       #in liters
P1 = 760.        #in mm Hg
P2= 735.56      #in mm Hg
T1= 273.         #in K
T2 = 298.     #in K

V2= (P1*T2*V1)/(P2*T1);
density = molar_mass_air/V2;

print "density = %f gm/l"%(density)
mass fraction of oxygen = 0.233010 
mass fraction of nitrogen = 0.766990 
density = 1.141558 gm/l

example 1.2 page number 20

In [3]:
import math 
mass_propane=14.2    #in kg
molar_mass=44       #in kg

moles=(mass_propane*1000)/molar_mass;
volume=22.4*moles;   #in liters

print "volume = %d liters"%(volume)
volume = 7229 liters

example 1.3 page number 20

In [4]:
import math 

y_CO2 = 0.25;
y_CO = 0.002;
y_SO2 = 0.012;
y_N2 = 0.680;
y_O2 = 0.056;

Mm = y_CO2*44+y_CO*28+y_SO2*64+y_N2*28+y_O2*32;
print  " molar mass = %d "%(Mm)

print " finding weight composition "
w_CO2 = y_CO2*44*100/Mm;
print  " weight_CO2 = %f "%(w_CO2)
w_CO = y_CO*28*100/Mm;
print  "weight_CO = %f "%(w_CO)
w_SO2 = y_SO2*64*100/Mm;
print  "weight_SO2 = %f "%( w_SO2)
w_N2 = y_N2*28*100/Mm;
print  "weight_N2 = %f "%( w_N2)
w_O2 = y_O2*32*100/Mm;
print  "weight_O2 = %f "%( w_O2)

print "if SO2 is removed "
v_CO2 = 25;
v_CO = 0.2;
v_N2 = 68.0;
v_O2 = 5.6;
v = v_CO2+v_CO+v_N2+v_O2;
v1_CO2 = (v_CO2*100/98.8);

print  "volume_CO2 = %f "%( v1_CO2)
v1_CO = (v_CO*100/98.8);
print  "volume_CO = %f "%(v1_CO)
v1_N2 = (v_N2*100/98.8);
print  "volume_N2 = %f "%(v1_N2)
v1_O2 = (v_O2*100/98.8);
print  "volume_O2 = %f "%(v1_O2 )
 molar mass = 32 
 finding weight composition 
 weight_CO2 = 33.684468 
weight_CO = 0.171485 
weight_SO2 = 2.351788 
weight_N2 = 58.304753 
weight_O2 = 5.487506 
if SO2 is removed 
volume_CO2 = 25.303644 
volume_CO = 0.202429 
volume_N2 = 68.825911 
volume_O2 = 5.668016 

example 1.4 page number 24

In [5]:
import math 

p=1.    #atm
H=2.7   #atm

x=p/H;

mole_ratio = (x)/(1-x);
moles_of_water=(100*1000)/18.;
moles_of_NH3=mole_ratio*moles_of_water;

print "moles of NH3 dissolved = %f"%(moles_of_NH3)

volume_NH3=(moles_of_NH3*22.4*293)/273;
print "volume of NH3 dissolved = %f liters"%(volume_NH3)
moles of NH3 dissolved = 3267.973856
volume of NH3 dissolved = 78565.443271 liters

example 1.5 page number 24

In [6]:
import math 
p=746    #in mm Hg
H=1.08*10**6   #in mm Hg, Henry's constant

x= p/H;    #mole fraction of CO2
X=x*(44./18);   #mass ratio of CO2 in water

initial_CO2 = 0.005;     #kg CO2/kg H20
G=1000*(initial_CO2-X);

print "CO2 given up by 1 cubic meter of water = %f kg CO2/cubic meter H20"%(G)
CO2 given up by 1 cubic meter of water = 3.311523 kg CO2/cubic meter H20

example 1.6 page number 27

In [7]:
import math 

pa1 = 23.6;      #VP of ethyl alchohal at 10 degree C
pa3=760.      #VP of ethyl alchohal at 78.3 degree C in mm Hg
pb1 = 9.2      #VP of ethyl water at 10 degree C in mm Hg
pb3=332.      #VP of ethyl water at 78.3 degree C in mm Hg

C=(math.log10(pa1/pa3)/(math.log10(pb1/pb3)));

pb2=149.      #VP of water at 60 degree C in mm Hg

pas=(pb3/pb2);
pa=C*math.log10(pas);
pa2=pa3/(10**pa);

print "vapor pressure of ethyl alcholoh at 60 degree C = %f mm Hg"%(pa2)
vapor pressure of ethyl alcholoh at 60 degree C = 349.872551 mm Hg

example 1.7 page number 28

In [8]:
import math 
t1 = 41.     #in degree C
t2=59.        #in degree C
theta_1 =83.        #in degree C
theta_2=100.        #in degree C

K = (t1-t2)/(theta_1-theta_2);
t=59+(K*(104.2-100));

print  "boiling point of SCl2 at 880 Torr = %f degree celcius"%(t)
boiling point of SCl2 at 880 Torr = 63.447059 degree celcius

example 1.8 page number 29

In [9]:
import math 

vp_C6H6 = 520.    #in torr
vp_H2O = 225.     #in torr
mass_water=18.
mass_benzene=78.

amount_of_steam = (vp_H2O/vp_C6H6)/(mass_benzene/mass_water);

print "amount of steam = %f"%( amount_of_steam)
amount of steam = 0.099852

example 1.9 page number 30

In [3]:
import math 

p0b = 385.     #vapor pressue of benzene at 60 degree C in torr
p0t=140.     #vapor pressue of toluene at 60 degree C in torr
xb=0.4;
xt=0.6;

pb=p0b*xb;
pt=p0t*xt;
P=pb+pt;

print "total pressure = %.0f torr"%(P)

yb=pb/P;
yt=pt/P;
print "vapor composition of benzene = %f  vapor composition of toluene = %f"%(yb,yt)

x=(760.-408)/(1013-408);
print "mole fraction of benzene in liquid mixture = %.3f mole fraction of toluene in liquid mixture= %.3f"%(x,1-x)
print "Thus, the liquid mixture contained %.1f mole %% benzene and %.1f mole %% toluene"%(x*100,(1-x)*100)
total pressure = 238 torr
vapor composition of benzene = 0.647059  vapor composition of toluene = 0.352941
mole fraction of benzene in liquid mixture = 0.582 mole fraction of toluene in liquid mixture= 0.418
Thus, the liquid mixture contained 58.2 mole % benzene and 41.8 mole % toluene

example 1.10 page number 33

In [21]:
import math 

sigma_x=23.393;
sigma_y=-12.437;
sigma_x2=91.456
sigma_xy=-48.554;

m=((6*sigma_xy)-(sigma_x*sigma_y))/(6*sigma_x2-(sigma_x)**2);
print "m = %f "%(m)

c=((sigma_x2*sigma_y)-(sigma_xy*sigma_x))/(6*sigma_x2-(sigma_x)**2);
print "c = %f "%(c)

print "f=0.084*Re**-0.256"
m = -0.256233 
c = -1.073825 
f=0.084*Re**-0.256

example 1.11 page number 35

In [1]:
import math
from numpy import *
from matplotlib.pyplot import * 

%matplotlib inline

u = array([2,1.92,1.68,1.28,0.72,0]);
r = array([0,1,2,3,4,5]);

z = u*r;
plot(r,z)
suptitle("variation of ur with r")
xlabel("r")
ylabel("ur")
show()
u_avg = (2./25)*12.4

print "average velocity = %f cm/s"%(u_avg)
Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['draw_if_interactive', 'new_figure_manager']
`%pylab --no-import-all` prevents importing * from pylab and numpy
average velocity = 0.992000 cm/s

example 1.12 page number 37

In [23]:
import math 

n = 6.;
h = (3. - 0)/n;

I = (h/2.)*(0+2*0.97+2*1.78+2*2.25+2*2.22+2*1.52+0);
u_avg = (2./3**2)*I;

print "average velocity = %f cm/s"%(u_avg)

print ('Simpsons rule')

n = 6.;
h = 3./n;
I = (h/3)*(0+4*(0.97+2.25+1.52)+2*(1.78+2.22)+0);
u_avg = (2./3**2)*I;

print "average velocity = %f cm/s"%(u_avg)
average velocity = 0.971111 cm/s
Simpsons rule
average velocity = 0.998519 cm/s

example 1.13 page number 38

In [24]:
import math 

z0 = 30.84;
z1 = 29.89;
z2 = 29.10;
h = 4;

u1_t0 = (-3*z0+4*z1-z2)/(2*h);
u1_t4 = (-z0+z2)/(2*h);
u1_t8 = (z0-4*z1+3*z2)/(2*h);

z0 = 29.89;
z1 = 29.10;
z2 = 28.30;
u2_t4 = (-3*z0+4*z1-z2)/(2*h);
u2_t8 = (-z0+z2)/(2*h);
u2_t12 = (z0-4*z1+3*z2)/(2*h);

z0 = 29.10;
z1 = 28.30;
z2 = 27.50;
u3_t8 = (-3*z0+4*z1-z2)/(2*h);
u3_t12 = (-z0+z2)/(2*h);
u3_t16 = (z0-4*z1+3*z2)/(2*h);

u_t4 = (u1_t4+u2_t4)/2;
u_t8 = (u1_t8+u2_t8+u3_t8)/3;
u_t12 = (u2_t12+u3_t12)/2;

print "u_t0 = %f cm/min u_t4 = %f cm/min u_t8 = %f cm/min  u_t12 = %f/n cm/min u_t16 =%f/n cm/min "%(u1_t0,u_t4,u_t8,u_t12,u3_t16)
u_t0 = -0.257500 cm/min u_t4 = -0.206875 cm/min u_t8 = -0.192083 cm/min  u_t12 = -0.200625/n cm/min u_t16 =-0.200000/n cm/min 

example 1.16 page number 49

In [25]:
import math 

density_water=988.     #in kg/m3
viscosity_water=55.*10**-5   #in Ns/m2
density_air=1.21      #in kg/m3
viscosity_air=1.83*10**-5   #in Ns/m2
L=1     #length in m


L1=10.*L   #length in m
Q=0.0133;

Q1=((Q*density_water*viscosity_air*L)/(L1*viscosity_water*density_air))

print "flow rate = %f cubic meter/s"%(Q1)


p=9.8067*10**4;     #pressure in pascal
p1=(p*density_water*Q**2*L**4)/(density_air*Q1**2*L1**4);

print "pressure drop corresponding to 1kp/square cm = %f kP/square cm"%(p1/p)
flow rate = 0.036134 cubic meter/s
pressure drop corresponding to 1kp/square cm = 0.011062 kP/square cm

example 1.17 page number 50

In [26]:
import math 

L=1.       #length of prototype in m
L1=10*L    #length of model in m
density_prototype=2.65    #gm/cc
density_water=1.      #gm/cc

density_model=(L**3*(density_prototype-density_water))/(L1**3)+1;

print "specific gravity of plastic = %f"%(density_model)
specific gravity of plastic = 1.001650

example 1.18 page number 53

In [1]:
import math 
from numpy import linspace
from matplotlib.pyplot import *


ly = 8   #in cm
my = ly/((1/0.25) - (1/0.5));
lz = 10.15   #in cm

mz = lz/((1./2.85) - (1/6.76));
mx = (my*mz)/(my+mz);
print "mx = %f cm"%(mx)
err = ((1-0.9945)/0.9945)*100;
print "error = %f "%(err)
mx = 3.703774 cm
error = 0.553042 

example 1.19 page number 54

In [28]:
import math 

w=450.     #in kg/hr
density=1000.   #in kg/m3
d=16.   #in mm

u=(w/density)/(3.14*d**2/4);
Re=u*density*d/0.001;

if Re>2100:
    print "flow is turbulent and d= %f mm"%(d)
else:
    print  ("flow is laminar and this nomograph is not valid")

    
flow is turbulent and d= 16.000000 mm
In [ ]: