Chapter5 -The ideal gas

Example1-pg 85

In [2]:
import math
#calculate specific volumes at given pressure
##initialisation of variables
R= 8.314 ##J/mol K
M= 18.016 ##gms
T= 400. ##C
p= 0.01 ##Mpa
p1= 0.1 ##Mpa
p2= 20. ##Mpa
##CALCULATIONS
v= R*(273.156+T)/(M*p*1000)
v1= R*(273.156+T)/(M*p1*1000)
v2= R*(273.156+T)/(M*p2*1000)
##RESULTS
print'%s %.3f %s'%(' specific voulme =',v,'m^3/kg')
print'%s %.3f %s'%('specific voulme = ', v1,'m^3/kg')
print'%s %.3f %s'%('specific voulme = ',v2,'m^3/kg')
 specific voulme = 31.065 m^3/kg
specific voulme =  3.106 m^3/kg
specific voulme =  0.016 m^3/kg

Ex3-pg87

In [2]:
##initialisation of variables
R=8.314
V= 20 ##L
m= 0.050 ##gms
M= 29 ##gms
T1= 20 ##C
T2= 150 ##C
k= 1.4
V1= 0.05 ##m**3
##CALCULATIONS
p1= m*R*(273.15+T1)/(M*(V/10))
p2= m*R*(273.15+T2)/(M*(V/10))
dU= p1*V1*(((273.15+T2)/(273.15+T1))-1)*100/(k-1)
dH= k*dU
##RESULTS
print'%s %.2f %s'% (' intial pressure =',p1,' kPa')
print'%s %.2f %s'% ('  final pressure = ',p2,' kPa')
print'%s %.2f %s'% ('  internal energy = ',dU,' kJ')
print'%s %.2f %s'% ('  enthalpy = ',dH,' kJ')
 intial pressure = 2.10  kPa
  final pressure =  3.03  kPa
  internal energy =  11.65  kJ
  enthalpy =  16.31  kJ

Ex4-pg91

In [4]:
import math
##initialisation of variables
T1= 200 ##K
p= 600 ##kPa
p1= 50 ##kPa
n= 1.8
M= 4. ##gms
k= 5/3.
m= 0.007 ##gms
R= 8.314 ##J/mol K
##CALCULATIONS
T2= T1*(p/p1)**((n-1)/n)
W= m*R*(T1-T2)/((n-1)*M)
Q= ((n-k)*m*R*(T2-T1))/((n-1)*(k-1)*M)
##RESULTS
print'%s %.2f %s'% (' final temperature = ',T2,' K')
print'%s %.2f %s'% ('  work = ',W,' kJ')
print'%s %.2f %s'% ('  energy = ',Q,' kJ')
 final temperature =  603.48  K
  work =  -7.34  kJ
  energy =  1.47  kJ

example 5-pg92

In [9]:
import math
#calculate final temperature and pressure and work ,energy
##initialisation of variables
p1= 300.##kPa
V1= 0.03 ##m^3
V2= 0.08 ##m^3
T1= 27. ##C
##CALCULATIONS1
T2= T1+273
p2= p1*(V1/V2)*(T2/(T1+273))
W= 0
Q= 0
##RESULTS
print'%s %.2f %s'%('final temperature =',T2,'K')
print'%s %.1f %s'%('final pressure =',p2,'kPa')
print'%s %.f %s'%('work = ',W,'kJ')
print'%s %.f %s'%('energy =',Q,'kJ')
 
final temperature = 300.00 K
final pressure = 112.5 kPa
work =  0 kJ
energy = 0 kJ

Example6 -pg93

In [11]:
import math
#calculate mass of nitrogen and final temperature and piston rise
##initialisation of variables
p1= 2. ##Mpa
V1= 0.2 ##m^3
R= 8.314 ##J/mol K
T1= 500. ##C
M= 28. ##gms
p2= 0.3 ##Mpa
T2= 250 ##C
k= 1.4
A= 0.1 ##m^2
##CALCULATIONS
m1= p1*10*10*10*V1*M/(R*(273.15+T1))
m2= p2*10*10*10*V1*M/(R*(273.15+T2))
m3= -(m2-m1)
T3= (m1*(273.15+T1)-m2*(273.15+T2))/(k*m3)
z3= m3*R*T3/(p2*10*10*10*A*M)
##RESULTS
print'%s %.4f %s'%(' mass of nitrogen =',m3,'kg')
print'%s %.1f %s'%('final temperature =',T3,'K')
print'%s %.2f %s'%('piston rise =',z3,'m')
 mass of nitrogen = 1.3561 kg
final temperature = 603.1 K
piston rise = 8.10 m

Ex7-pg94

In [6]:
import math
##initialisation of variables
m= 0.3 ##kg
R= 8.314 ##J/mol K
M= 28 ##gms
T1= 500. ##C
p1= 500. ##kPa
k= 1.4
V3= 0.3 ##m**2
##CALCULATIONS
V1= m*R*(273.15+T1)/(M*p1)
T3= k*(273.15+T1)
p3= m*R*T3*100/(M*V)
##RESULTS
print'%s %.2f %s'% (' final pressure =',p3,' kPa')
 final pressure = 482.10  kPa