Chapter 1 : Thermodynamics Concepts

Example 1.4 Page No : 21

In [6]:
			
# Variables :
m = 500;			#Kg
g = 7.925;			#m/s**2
Z = 40; 			#Km
C = 2400;			#Kmph

# Calculations and Results
PE = m*g*Z*1000;	        		#Nm
print ("Relative to earth.");
print "Potential Energy in Nm : %.3e"%PE

KE = m*(C*1000./3600)**2/2;			#Nm
print "Kinetic Energy in Nm : %.3e"%KE
print ("Relative to moon.");

w = 2.94*m;	    		    #Nm
PE = w*Z*1000;	    		#Nm
print "Potential Energy in Nm : %.2e"%PE

KE = m*(C*1000./3600)**2/2;			#Nm
print "Kinetic Energy in Nm : %.3e"%KE
Relative to earth.
Potential Energy in Nm : 1.585e+08
Kinetic Energy in Nm : 1.111e+08
Relative to moon.
Potential Energy in Nm : 5.88e+07
Kinetic Energy in Nm : 1.111e+08

Example 1.5 Page No : 22

In [4]:
		
# Variables :
VGR = 57.;	    		#KN/m**2
Patm = 765.;			#mm of Hg

# Calculations
#101.325KN/m**2 = 760 mm of Hg
VGR = VGR*760/101.325;			#mm og Hg
Pabs = Patm-VGR;			#mm of Hg

# Results
print "Absolute pressure in mm of Hg : %.2f"%(Pabs)
Absolute pressure in mm of Hg : 337.46

Example 1.6 Page No : 22

In [7]:
# Variables :
g = 9.81;           			#m/s**2
rho_o = 0.825*10**3;			#Kg/m**3
rho_w = 1.*10**3;	    		#Kg/m**3
rho_Hg = 13.45*10**3;			#Kg/m**3
h_o = 50./100;   	    		#m
h_w = 65./100;	    	    	#m
h_Hg = 45./100;		    	    #m
Patm = 1.01325;			        #bar

# Calculations and Results
P_Hg = rho_Hg*g*h_Hg;			#N/m**2
P_w = rho_w*g*h_w;			    #N/m**2
P_o = rho_o*g*h_o;			    #N/m**2
Pbase = (Patm*10**5+P_Hg+P_o+P_w);			#N/m**2
print "Pressure at the base of column in N/m**2 : %.5e"%Pbase

P_OilWater = Patm*10**5+P_o;			#N/m**2
print "Pressure at the oil-water surface in N/m**2 : %.5e"%P_OilWater

P_WaterMercury = Patm*10**5+P_o+P_w;			#N/m**2
print "Pressure at the water-mercury surface in N/m**2 : %.5e"%P_WaterMercury

#Answer in the book is not accurate.
Pressure at the base of column in N/m**2 : 1.71123e+05
Pressure at the oil-water surface in N/m**2 : 1.05372e+05
Pressure at the water-mercury surface in N/m**2 : 1.11748e+05

Example 1.7 Page No : 23

In [7]:
import math 
			
# Variables :
rho = 1000.;			#Kg/m**3
d = 0.3;	    		#m
C = 1.5;		    	#m/s
h = 4.5;		    	#m
FlowRate = 2000.		#Kg/min
d2 = 15./100;			#diameter of discharging line in meter
t = 15.     			#min
r = 3.	        		#m

# Calculations and Results
WaterDischarge = rho*math.pi/4*(d/2)**2*C*t*60;			#Kg
WaterReceived = FlowRate*t;                 			#Kg
NetWaterReceived = WaterReceived-WaterDischarge;			#Kg
print "Mass change in tank in Kg : %.1f"%(NetWaterReceived)

#m = rho*A*h
h = NetWaterReceived/rho/(math.pi/4*r**2);			#m
print "Water level in meter : %.4f"%(h)
Mass change in tank in Kg : 6143.5
Water level in meter : 0.8691

Example 1.8 Page No : 23

In [8]:
			
# Variables :
Pmercury = 10.;			#cm of Hg
Patm = 76.  			#cm of Hg

# Calculations
Pwater = 3.5/13.6           			#cm of Hg
Pabs = Pmercury+Patm-Pwater;			#cm of Hg
Pabs = Pabs/76*1.01325;		        	#bar

# Results
print "Absolute pressure of steam in bar : %.4f"%(Pabs)
Absolute pressure of steam in bar : 1.1431

Example 1.9 Page No : 23

In [9]:
			
# Variables :
Pmercury = 10.;			#cm of Hg
Patm = 760.    			#mm of Hg
Patm = 1.01325  		#bar
Pabs = 1.2  			#bar
sg_oil = 0.8;
sg_water = 13.6;
sg_mercury = 13.6;
rho_w = 1000.			#Kg.m**3
g = 9.81;	    		#gravity constant

# Calculations and Results
deltaP = Pabs-Patm;			#bar
deltaP = deltaP*10**5;			#N/m**2
#deltaP = rho_o*g*h_o
rho_o = sg_oil*rho_w;			#kg/m**3
h_o = deltaP/rho_o/g;			#m
print "Height of fluid in oil manometer in meter : %.4f"%(h_o)

h_w = deltaP/rho_w/g;			#m
print "Height of fluid in water manometer in meter : %.4f"%(h_w)

rho_m = sg_mercury*rho_w;			#kg/m**3
h_m = deltaP/rho_m/g;		    	#m
print "Height of fluid in mercury manometer in meter : %.4f"%(h_m)
Height of fluid in oil manometer in meter : 2.3796
Height of fluid in water manometer in meter : 1.9037
Height of fluid in mercury manometer in meter : 0.1400

Example 1.10 Page No : 24

In [10]:
			
# Variables :
Patm = 75.          			#mm of Hg
Patm = Patm*1.01325/76;			#bar
rho = 800.          			#Kg.m**3
h = 30/100.         			#m
g = 9.81                		#gravity constant

# Calculations
deltaP = rho*g*h*10**-5;			#bar
Pabs = deltaP+Patm;			        #bar

# Results
print "Absolute pressure of gas in bar : %.6f"%(Pabs)
Absolute pressure of gas in bar : 1.023462

Example 1.11 Page No : 24

In [11]:
# Variables :
h1 = 5.1/100;    	               		#m
h2 = 10./100;	        	        	#m
Patm = 75.5;		        	        #mm of Hg
Patm = Patm*1.01325/76*10**5;			#bar
sg_k = 0.8;
sg_Hg = 13.6;
rho_w = 1000.               			#Kg/m**3
g = 9.81;		                    	#gravity constant

# Calculations
P_kerosine = sg_k*rho_w*g*h1;			#N/m**2
P_Hg = sg_Hg*rho_w*g*h2     			#N/m**2
Pabs = P_Hg+Patm-P_kerosine;			#Nm**2

# Results
print "Absolute pressure of gas in KPa : %.2f"%(Pabs/1000)
Absolute pressure of gas in KPa : 113.60

Example 1.12 Page No : 24

In [9]:
from numpy import *
import math

# Variables :
t_ice = 0;			#degree centigrade
p_ice = 1.5;
t_steam = 100;			#degree centigrade
p_steam = 7.5;

# Calculations
#t = a*math.log(p)+b
#solving for a and b by matrix
A = array([[math.log(p_ice), 1],[math.log(p_steam) ,1]])
B = array([t_ice,t_steam])
#X = A**-1*B;
X = linalg.solve(A,B)
a = X[0]
b = X[1]
p = 3.5;			#bar
t = a*math.log(p)+b;			#degree C

# Results
print "Temperature scale in degree C : %.2f"%t
Temperature scale in degree C : 52.65

Example 1.13 Page No : 25

In [19]:
# Variables :
theta1_p1 = 273.16;			#K
p_gauge1 = 32.;			#mm of Hg
p_atm = 752.;			#mm of Hg
p_gauge2 = 76.;			#mm of Hg

# Calculations
P1 = p_gauge1+p_atm;		    	    #mm of Hg
P2 = p_gauge2+p_atm;	    	    	#mm of Hg
theta2_p2 = theta1_p1*(P2/P1);			#in K
theta2_p2 = theta2_p2-273;		    	#degree C

# Results
print "Temperature in degree C : %.2f"%theta2_p2
Temperature in degree C : 15.49

Example 1.14 Page No : 25

In [19]:
			
# Variables :
R0 = 2.8;			#ohm
t0 = 0;			#degree C
R1 = 3.8;			#ohm
t1 = 100;			#degree C
R2 = 5.8;			#ohm\

# Calculations
#R = R0*(1+alfa*t)
alfa = (R1/R0-1)/t1;
t2 = (R2/R0-1)/alfa;			#degree C

# Results
print "Temperature at R2 in degree C : ",t2
Temperature at R2 in degree C :  300.0

Example 1.16 Page No : 26

In [20]:
			
# Variables :
#F = 2*C;
FbyC = 2;

# Calculations
C = 32./(FbyC-9./5);			#degree C
F = C*FbyC;         			#degree F

# Results
print "Temperature fluid in degree R : ",F+460
print "Temperature fluid in degree K : ",C+273
Temperature fluid in degree R :  780.0
Temperature fluid in degree K :  433.0

Example 1.17 Page No : 26

In [23]:
import math 
from numpy import *
			
# Variables :
T1 = 0.;			#degree centigrade
K1 = 1.83;
T2 = 100.;			#degree centigrade
K2 = 6.78;

# Calculations
#T = a*math.log(K)+b
#solving for a and b by matrix
A = array([[math.log(K1),1],[math.log(K2), 1]])
B = array([T1,T2])
X = linalg.solve(A,B)
a = X[0]
b = X[1]
K = 2.42;			#bar
T = a*math.log(K)+b;			#degree C

# Results
print "Temperature in degree C : %.3f"%T
Temperature in degree C : 21.338

Example 1.18 Page No : 27

In [21]:
# Variables :
#t = N/30-100/3
#t = N

# Calculations
N = (-100./3)/(1-1./30);			#degree C

# Results
print "Temperatur at which degree C equals to degree N(degree C) : %.2f"%N
Temperatur at which degree C equals to degree N(degree C) : -34.48

Example 1.19 Page No : 28

In [26]:
# Variables :
#epsilon = 0.2*t-5*10**-4*t**2;			#mV
t_ice = 0.                  			#degree C
epsilon_ice = 0.2*t_ice-5*10**-4*t_ice**2;			#mV
t_steam = 100.                          			#degree C
epsilon_steam = 0.2*t_steam-5*10**-4*t_steam**2;			#mV

#At t = 60;
t = 60;			#degree C

# Calculations
epsilon = 0.2*t-5*10**-4*t**2;			#mV
reading = (t_steam-t_ice)/(epsilon_steam-epsilon_ice)*(epsilon-epsilon_ice)

# Results
print "Thermometer will read(degree C) : ",reading
Thermometer will read(degree C) :  68.0

Example 1.20 Page No : 28

In [22]:
import math 
from numpy import *

# Variables :
tA1 = 0.;			#degree centigrade
tB1 = 0.;			#degree centigrade
tA2 = 100.			#degree centigrade
tB2 = 100.			#degree centigrade
#tA = l+m*tB+n*tb**2
l = 0;			#by putting tA and tB equals to zero

#tA = m*tB+n*tB**2
#Thermometer immersed in oil bath
tA1 = 51.;			#degree centigrade
tB1 = 50.;			#degree centigrade
#solving for m and n by matrix
A = array([[tB1 ,tB1**2],[tB2, tB2**2]])
B = array([tA1,tA2])

# Calculations and Results
X = linalg.solve(A,B);
m = X[0]
n = X[1]
tA = 25;			#degree centigrade
P = [n ,m ,-tA];			#polynomial for calculation of tB
tB = roots(P);
tB = tB[1];			#neglecting +ve sign
print "When A reads 25 degree C, B reading in degree C : %.3f"%tB

#let tB = 25;			#degree C
tB = 25;			#degree C
tA = l+m*tB+n*tB**2;			#degree C
print "When B reads 25 degree C, A reading in degree C : ",tA
print ("B is correct. A shows error greater than B.")
#Answer is not accurate in the book.
When A reads 25 degree C, B reading in degree C : 24.265
When B reads 25 degree C, A reading in degree C :  25.75
B is correct. A shows error greater than B.

Example 1.21 Page No : 33

In [23]:
			
# Variables :
p = 10.;	    		#bar
T = 327.+273;			#K
M = 42.4;
m = 1.      			#Kg
Rdegree = 8314.3;			#Nm/KgK

# Calculations and Results
R = Rdegree/M;			#Nm/KgK
V = m*R*T/p/10**5;			#m**3/Kg
print "Specific volume in m**3/Kg ; %.4f"%V

rho = m/V;			#Kg/m**3
print "Density of gas in Kg/m**3 : %.3f"%rho
Specific volume in m**3/Kg ; 0.1177
Density of gas in Kg/m**3 : 8.499

Example 1.22 Page No : 33

In [24]:
			
# Variables :
Rdegree = 8314.3;			#Universal Gas Consmath.tant
M = 32.         			#Molecular weight of gas
p1 = 3*10.**6.  			#N/m**2
V1 = 250*10.**-3			#m**3
T1 = 20+273.    			#K
p2 = 1.8*10**6  			#N/m**2
V2 = V1;        			#m**3
T2 = 16+273.    			#K

# Calculations
R = Rdegree/M;			#Nm/KgK
m1 = p1*V1/R/T1;			#Kg
m2 = p2*V2/R/T2;			#Kg
mass_used = m1-m2;			#Kg

# Results
print "Mass of oxygen used in Kg : %.4f"%mass_used
Mass of oxygen used in Kg : 3.8589

Example 1.23 Page No : 34

In [25]:
import math
# Variables :
Rdegree = 8314.3;			#Universal Gas Consmath.tant
r = 12.         			#meter
Patm = 75.		          	#cm of Hg
Patm = Patm/76*1.01325*10**5;			#N/m**2
V = 4./3*math.pi*r**3;			#m**3
M_air = 28.97;
M_H2 = 2.
Tair = 18.+273;			#K
g = 9.81;   			#gravity consmath.tant

# Calculations and Results
Rair = Rdegree/M_air;			#Nm/KgK
RH2 = Rdegree/M_H2;			#Nm/KgK
#p*V = m*R*T
m_air = Patm*V/Rair/Tair;			#Kg
print "Mass of air in kg : %.2f"%m_air

n_air = m_air/M_air;			#moles
print "No. of moles : %.2f"%n_air

m_H2 = n_air*M_H2;			#Kg
print "Mass of H2 in kg : %.2f"%m_H2

Load = g*(m_air-m_H2);			#N
print "Load balloon can lift in N ; %.1f"%Load
Mass of air in kg : 8666.15
No. of moles : 299.14
Mass of H2 in kg : 598.28
Load balloon can lift in N ; 79145.8

Example 1.24 Page No : 35

In [37]:
# Variables :
p1 = 1. 			#bar
p2 = 0.45;			#bar
R = 287.			#KJ/KgK
V = 40. 			#m**3
V1 = 40.			#m**3
V2 = 40.			#m**3
T1 = 35.+273;			#K
T2 = 5.+273;			#K

# Calculations
m = p1*10**5*V1/R/T1-p2*10**5*V2/R/T2

# Results
print "Mass of air removed in Kg : %.2f"%m
Mass of air removed in Kg : 22.691

Example 1.26 Page No : 45

In [38]:
# Variables :
m = 1.  	    		#Kg
t = 80.	    	    	#degree C
mw = 10.		    	#Kg
t1 = 25.		    	#degree C
delta_t = 5;			#degree C

# Calculations
t2 = delta_t+t1;			#degree C
Sw = 4.187;			#Kj/KgK
#m*S*(t-t2) = mw*Sw*(t2-t1)
S = mw*Sw*(t2-t1)/m/(t-t2);			#Kj/KgK

# Results
print "Specific heat of metal in KJ/KgK :  ",S
Specific heat of metal in KJ/KgK :   4.187

Example 1.27 Page No : 45

In [26]:
# Variables :
m = 500.;			#Kg
t1 = 45.;			#degree C
t0 = 5.;			#degree C
CP = 4.18;			#KJ/Kg-degree C
Qdot = 41.87;			#MJ/hr

# Calculations
Q = m*CP*(t1-t0);			#KJ
Q = Q/1000;			#MJ
Time = Q/Qdot;			#hrs

# Results
print "Time required in hours : %.5f"%Time
Time required in hours : 1.99666

Example 1.28 Page No : 45

In [10]:
import scipy
from scipy.integrate import quad 
			
# Variables :
V1 = 2;			#m**3
V2 = 4;			#m**3

# Calculations
def f24(V): 
	 return 10**5*(V**2+6*V)

W =  quad(f24,V1,V2)[0]

W = W/1000.;			#KJ

# Results
print "Work done in KJ : %.1f"%W
Work done in KJ : 5466.7

Example 1.29 Page No : 46

In [44]:
import math 
from scipy.integrate import quad 


# Variables :
p1 = 3.;			#bar
V1 = 0.18;			#m**3/Kg
p2 = 0.6;			#bar
C = p1*10**5*V1**2;			#Nm
V2 = math.sqrt((p1/p2)*V1**2);			#m**3Kg

# Calculations
def f27(V): 
    return C/V**2

W =  quad(f27,V1,V2)[0]

W = W/1000;			#KJ/Kg

# Results
print "Work done in KJ/Kg : %.3f"%W
Work done in KJ/Kg : 29.850

Example 1.30 Page No : 46

In [11]:
import math 
from numpy import *

# Variables :
W = 160.	    		#kJ
W = W*1000.		    	#J
V1 = 800.   			#litres
V1 = V1/1000.			#m**3

# Calculations
#p = 7-3*V
#[7*(V2-V1)-1.5*(V2**2-V1**2)]-W/10**5 = 0;			#Nm or J
#7*V2-7*V1-1.5*V2**2+1.5*V1**2-W/10**5;			#Nm or J
#P = [-10**5*1.5 10**5*7 -10**5*7*V1+10**5*1.5*V1**2-W]
P = array([-1.5, 7, -7*V1+1.5*V1**2-W/10**5])
V2 = roots(P);			#m**3
V2 = V2[1]			    #(V2(1) gives -ve value which is not possible)
print "Final Volume in m**3 : %.4f"%V2

P2 = 7-3*V2;			#bar
print "Final Pressure in bar : %.3f"%P2
#Answer is wrong in the book as calculation is wrong for V2.
Final Volume in m**3 : 1.2000
Final Pressure in bar : 3.400

Example 1.31 Page No : 47

In [46]:
import scipy
from scipy.integrate import quad 

# Variables :
p0 = 1.     			#bar
p0 = p0*10**5;			#N/m**2
V1 = 0;		        	#m**3
V2 = 0.7;			    #m**3

# Calculations
#No p.dV work for cylinder as boundaries are 
def f18(V): 
    return 1.

W = p0* quad(f18,V1,V2)[0]

W = W/1000.;			#KJ/Kg

# Results
print "Workdone by the system  in KJ : ",W
Workdone by the system  in KJ :  70.0

Example 1.32 Page No : 48

In [47]:
import scipy
from scipy.integrate import quad 
			
# Variables :
p0 = 101.3;			#KPa
V1 = 1.2;			#m**3
V2 = 0;			#m**3

# Calculations
def f6(V): 
	 return 1

W = p0* quad(f6,V1,V2)[0]

# Results
print "Workdone by the air  in KJ : ",W
Workdone by the air  in KJ :  -121.56

Example 1.33 Page No : 48

In [12]:
import scipy
from scipy.integrate import quad 
			
# Variables :
T1 = 300;			#K
T2 = 2300;			#K
Gamma = 1.5;
m = 1;			#Kg

# Calculations and Results
def f14(T): 
	 return m*(0.85+0.00004*T+5*10**-5*T**2)

H2subH1 =  quad(f14,T1,T2)[0]

print "Change in enthalpy in KJ/Kg : %.1f"%H2subH1

def f15(T): 
	 return m*(0.85+0.00004*T+5*10**-5*T**2)/Gamma

U2subU1 =  quad(f15,T1,T2)[0]

print "Change in internal energy in KJ : %.1f"%U2subU1
Change in enthalpy in KJ/Kg : 204137.3
Change in internal energy in KJ : 136091.6

Example 1.34 Page No : 53

In [34]:
			
# Variables :
m = 1.; 			    #Kg
v = 1.;	        		#m**3
T = 127.+273;			#K
a = 138.;		    	#KNm**4/(Kgmol)**2
a = a*10.**3;			#Nm**4/(Kgmol)**2
M_O2 = 32.;			    #
vm = v*M_O2;			#m**3/Kgmol

#p*v = n*R*T
n = 1.
R = 8314.3;			    #gas constant
p = n*R*T/vm;			#N/m**2
print "Pressure using perfect gas equation in N/m**2 : %.1f"%p

#[p+a/vm**2]*[vm-b] = R*T
b = 0.0318;
p = R*T/(vm-b)-a/vm**2;			#N/m**2
print "Pressure using Vander Walls equation in N/m**2 : %.1f"%p
Pressure using perfect gas equation in N/m**2 : 103928.7
Pressure using Vander Walls equation in N/m**2 : 103897.4

Example 1.35 Page No : 54

In [35]:
			
# Variables :
m = 22.;			#Kg
T = 300.;			#K
V = 5.; 			#m**3
M = 44.;			#Kg/Kgmol
a = 362.9;			#KNm**4/Kgmol**2
b = 0.0314;			#m**3/Kgmol
Rdash = 8314.3;			#gas consmath.tant

# Calculations and Results
R = Rdash/M;			#Nm/KgK
p = m*R*T/V;			#Pa
p = p/10**5;			#bar
print "Pressure, when gas behaves like a perfect gas in bar : %.4f"%p

Vdash = V/m*M;			#m**3/Kgmole
#[p+a/vm**2]*[vm-b] = R*T
p = Rdash*T/(Vdash-b)-a*10**3/Vdash**2;			#N/m**2
print "Pressure umath.sing Vander Walls equation in bar : %.4f"%(p/10**5)
Pressure, when gas behaves like a perfect gas in bar : 2.4943
Pressure umath.sing Vander Walls equation in bar : 2.4659

Example 1.36 Page No : 54

In [36]:
			
# Variables :
pc = 37.7;			#bar
Tc = 132.5;			#K
vc = 0.093;			#m**3Kgmol
R = 287.;			#Nm/KgK
m = 10.;			#Kg
T = 300.;			#K
V = 0.3;			#m**3

# Calculations
a = 27.*R**2*Tc**2./64./pc/10**5;
b = R*Tc/8/pc/10**5;			#
#(p+a/V**2)*(V-b) = R*T
p = R*T/(V-b)-a/V**2;			#N/m**2
p = p/10**5;			#bar

# Results
print "Pressure exerted by air in bar : %.4f"%p
Pressure exerted by air in bar : 2.8641

Example 1.37 Page No : 55

In [37]:
			
# Variables :
pc = 221.2;			#bar
Tc = 374.15+273;			#K
p = 100.;			#bar
T = 400.+273;			#K
R = 462.;			#Nm/KgK

# Calculations
#p*v = R*T
v = R*T/p/10**5;			#m**3/Kg
print "Specific volume, v by perfect gas equation in m**3/Kg : %.5f"%v

# Results
pr = p/pc;
Tr = T/Tc;
Z = 0.84;			#From compressibility chart
v = Z*R*T/p/10**5
print "Specific volume, v by compressibility chart in m**3/Kg : %.5f"%v
Specific volume, v by perfect gas equation in m**3/Kg : 0.03109
Specific volume, v by compressibility chart in m**3/Kg : 0.02612

Example 1.38 Page No : 55

In [60]:
			
# Variables :
pr = 5;
Z = 0.8;
pc = 46.4;			#bar
Tc = 191.1;			#K
Tr = 1.44;			#

# Calculations and Results
p = pr*pc;			#bar
print "Pressure in bar : ",p

T = Tr*Tc;			#K
print "Temperature in K : ",T
Pressure in bar :  232.0
Temperature in K :  275.184

Example 1.39 Page No : 56

In [38]:
			
# Variables :
V = 0.01653;			#m**3
m = 5.6;    			#Kg
M = 28. 	    		#Kg/Kgmol
p = 200.		    	#bar
Z = 0.605;
Rdash = 8314.3;			#J/Kgk
R = Rdash/M;			#J/Kgk

# Calculations
#p*V = m*Z*R*T
T = p*10**5*V/m/Z/R;			#K

# Results
print "Temperature in K : %.2f"%T
Temperature in K : 328.62

Example 1.40 Page No : 61

In [39]:
			
# Variables :
mCO = 0.45;			#Kg
mAir = 1;			#Kg
V = 0.4;			#m**3
T = 15.+273;			#K
MCO = 28.;			#Kg/Kgmo
MO2 = 32.;			#Kg/Kgmol
MN2 = 28.;			#Kg/Kgmol

# Calculations
mO2 = 23.3/100*mAir;			#Kg
mN2 = 76.7/100*mAir;			#Kg
Rdash = 8314.3;			#J/Kgk
#p*V = m*Z*R*T
pCO = mCO*Rdash/MCO*T/V/10**5;			#bar
pO2 = mO2*Rdash/MO2*T/V/10**5;			#bar
pN2 = mN2*Rdash/MN2*T/V/10**5;			#bar

# Results
print "Pressure of CO in bar : %.4f"%pCO
print "Pressure of O2 in bar : %.4f"%pO2
print "Pressure of N2 in bar : %.4f"%pN2
p = pCO+pO2+pN2;			#bar
print "Total pressure in vessel in bar : %.4f"%p
Pressure of CO in bar : 0.9621
Pressure of O2 in bar : 0.4359
Pressure of N2 in bar : 1.6398
Total pressure in vessel in bar : 3.0378

Example 1.41 Page No : 61

In [40]:
			
# Variables :
ma = 0.4;			#Kg
mb = 0.8;			#Kg
Ma = 44.;
Mb = 29.;
V = 0.4;			#m**3
T = 300.;			#K
Rdash = 8314.3;			#J/Kgk

# Calculations
Ra = Rdash/Ma;			#Nm/KgK
Rb = Rdash/Mb;			#Nm/KgK
na = ma/Ma;			#moles
nb = mb/Mb;			#moles
#p*V = n*R*T
pa = na*Rdash/1000*T/V;			#bar
pb = nb*Rdash/1000*T/V;			#bar

# Results
print "Pressure of container A in KPa : %.2f"%pa
print "Pressure of container B in KPa : %.2f"%pb
p = pa+pb;			#Kpa
print "Pressure of mixture in KPa : %.2f"%p

#Ans of Pb is wrong in the book.
Pressure of container A in KPa : 56.69
Pressure of container B in KPa : 172.02
Pressure of mixture in KPa : 228.71

Example 1.42 Page No : 62

In [41]:
			
# Variables :
Rdash = 8314.3;			#J/Kgk
mO2 = 23.15/100;
mN2 = 75.52/100;
mArgon = 1.29/100;
mCO2 = 0.04/100;
MO2 = 32.;
MN2 = 28.;
MArgon = 40.;
MCO2 = 44.;

# Calculations and Results
RO2 = Rdash/MO2;			#J/KgK
RN2 = Rdash/MN2;			#J/KgK
RArgon = Rdash/MArgon;			#J/KgK
RCO2 = Rdash/MCO2;			#J/KgK
R = (mO2*RO2+mN2*RN2+RArgon*mArgon+RCO2*mCO2)/(mO2+mN2+mArgon+mCO2);			#J/KgK
print "Characteristic gas constant for air in J/KgK : %.2f"%R

M = Rdash/R;			#Kg/Kgmol
print "Molecular weight of air in Kg/Kgmol : %.3f"%M

p = 1.013;      			#bar
nO2 = mO2/MO2;	    		#moles
nCO2 = mCO2/MCO2;			#moles
nN2 = mN2/MN2;		    	#moles
nArgon = mArgon/MArgon;			#moles
n = nO2+nN2+nArgon+nCO2;
pO2 = nO2/n*p;		        	#bar
pN2 = nN2/n*p;		    	    #bar
pArgon = nArgon/n*p;			#bar
pCO2 = nCO2/n*p;	    		#bar

print "Pressure of O2 in bar : %.4f"%pO2
print "Pressure of N2 in bar : %.4f"%pN2
print "Pressure of Argon in bar : %.4f"%pArgon
print "Pressure of CO2 in bar : %.5f"%pCO2
Characteristic gas constant for air in J/KgK : 287.15
Molecular weight of air in Kg/Kgmol : 28.954
Pressure of O2 in bar : 0.2122
Pressure of N2 in bar : 0.7911
Pressure of Argon in bar : 0.0095
Pressure of CO2 in bar : 0.00027

Example 1.43 Page No : 63

In [42]:
        
# Variables :
yO2 = 0.3;
yN2 = 0.5;
yCO2 = 0.2;
V = 1.; 			#m**3
T = 27+273;			#K
m = 8.;	    		#Kg
MO2 = 32.;
MN2 = 28.;
MCO2 = 44.;

# Calculations and Results
M = 1/(yO2/MO2+yN2/MN2+yCO2/MCO2);			#Kg/Kgmol
print "Molecular mass for mixture in Kg/Kgmol : %.3f"%M

Rdash = 8314.3;			#J/Kgk
R = Rdash/M;			#Nm/KgK
print "Gas consmath.tant R of mixture in Nm/KgK : %.1f"%R

p = m*R*T/V/10**5;			#bar
print "Pressure exerted by gases in bar : %.3f"%p

nO2 = yO2/MO2*m;			#moles
nCO2 = yCO2/MCO2*m;			#moles
nN2 = yN2/MN2*m;			#moles
print "Mole fraction of O2(moles) : %.4f"%nO2
print "Mole fraction of N2(moles) : %.4f"%nN2
print "Mole fraction of CO2(moles) : %.4f"%nCO2
Molecular mass for mixture in Kg/Kgmol : 31.469
Gas consmath.tant R of mixture in Nm/KgK : 264.2
Pressure exerted by gases in bar : 6.341
Mole fraction of O2(moles) : 0.0750
Mole fraction of N2(moles) : 0.1429
Mole fraction of CO2(moles) : 0.0364

Example 1.44 Page No : 64

In [44]:
# Variables :
mN2 = 4.;			#Kg
mO2 = 2.4;			#Kg
mCO2 = 1.6;			#Kg
MO2 = 32.;
MN2 = 28.;
MCO2 = 44.;
Gamma = 1.4;

# Calculations
#Rdash = Cpdash*(1-1/Gamma)
Rdash = 8.3143;			#J/KgK
Cpdash = Rdash*Gamma/(Gamma-1);			#KJ/KgmolK
Cvdash = Cpdash/Gamma;			#KJ/KgmolK
CpO2 = Cpdash/MO2;			#KJ/KgmolK
CpN2 = Cpdash/MN2;			#KJ/KgmolK
CpCO2 = Cpdash/MCO2;			#KJ/KgmolK
CvO2 = Cvdash/MO2;			#KJ/Kg
CvN2 = Cvdash/MN2;			#KJ/Kg
CvCO2 = Cvdash/MCO2;			#KJ/Kg


# Results
print ("Specific heat of gases : ");
print "For N2, Cp is %.3f"%(CpN2)," KJ/Kg & Cv is %.4f"%CvN2," KJ/Kg."
print "For O2, Cp is %.3f"%CpO2," KJ/Kg & Cv is %.4f"%CvO2," KJ/Kg."
print "For CO2, Cp is %.3f"%CpCO2," KJ/Kg & Cv is %.4f"%CvCO2," KJ/Kg."
Cp = (mO2*CpO2+mN2*CpN2+mCO2*CpCO2)/(mO2+mN2+mCO2);			#KJ/KgK
print "Specific heat of mixture, Cp in KJ/KgK : %.5f"%Cp
Cv = (mO2*CvO2+mN2*CvN2+mCO2*CvCO2)/(mO2+mN2+mCO2);			#KJ/KgK
print "Specific heat of mixture, Cv in KJ/KgK : %.4f"%Cv
Specific heat of gases : 
For N2, Cp is 1.039  KJ/Kg & Cv is 0.7423  KJ/Kg.
For O2, Cp is 0.909  KJ/Kg & Cv is 0.6496  KJ/Kg.
For CO2, Cp is 0.661  KJ/Kg & Cv is 0.4724  KJ/Kg.
Specific heat of mixture, Cp in KJ/KgK : 0.92473
Specific heat of mixture, Cv in KJ/KgK : 0.6605