chapter14-equations of state and generlized charts

Example2-pg397

In [5]:
import math
import numpy
#calcualte isotherm
##initialisation of variables
a=552.6 ##kPa m^6/kmol^2
b= 0.03402 ##m^3/kmol
p= 100. ##kPa
R= 8.314 ##J/mol K
##CALCULATIONS
vec=([p,-a,2*a*b])
vector= numpy.roots(vec)
x=vec[0]
T= 2*a*(x-b)*(x-b)/(R*x*x*x)
##RESULTS
print'%s %.1f %s'% (' isotherm=',T,'K')
 isotherm= 1.3 K

Example3-pg406

In [2]:
import math
#calculate volumes of given temperatures
##initialisation of variables
R= 8.314 ##J/mol K
T= 400. ##C
T1= 500. ##C
M= 18.015 ##kg/k mol
p1= 30. ##Mpa
##CALCULATIONS
v1= R*(273.15+T)/(M*p1*10*10*10)
v2= R*(273.15+T1)/(M*p1*10*10*10)
##RESULTS
print'%s %.5f %s'% ('volume=',v1,'m^3/kg')
print'%s %.5f %s'% ('volume=',v2,'m^3/kg')
volume= 0.01036 m^3/kg
volume= 0.01189 m^3/kg

Example4-pg409

In [4]:
import math
#calculate specific enthalpy at each and every point their differences
##initialisation of variables
h1= 3892.2 ##kJ/kg
h2= 4102.2 ##kJ/kg
dh= 1015.4 ##kJ/kg
dh1= 448. ##kJ/kg
h3= 2151.1 ##kJ/kg
h4= 3081.1 ##kJ/kg
##RESULTS
print'%s %.1f %s'% ('Specific Enthalpy=',h1,'kJ/kg')
print'%s %.1f %s'% ('Specific Enthalpy=',h2,'kJ/kg')
print'%s %.1f %s'% ('Specific Enthalpy=',h3,'kJ/kg')
print'%s %.1f %s'% ('Specific Enthalpy=',h4,'kJ/kg')
print'%s %.f %s'% ('Enthalpy difference=',dh,'kJ/kg')
print'%s %.f %s'% ('Enthalpy difference=',dh1,'kJ/kg')
Specific Enthalpy= 3892.2 kJ/kg
Specific Enthalpy= 4102.2 kJ/kg
Specific Enthalpy= 2151.1 kJ/kg
Specific Enthalpy= 3081.1 kJ/kg
Enthalpy difference= 1015 kJ/kg
Enthalpy difference= 448 kJ/kg

Example5-pg413

In [5]:
import math
#calculate entropy at every point
##initialisation of variables
s2= 5.7905 ##kJ/kg K
s1= 4.4728 ##kJ/kg K
s3= 4.64437 ##kJ/kg K
s4= 5.7883 ##kJ/kg K
s5= 6.2036 ##kJ/kg K
s6= 5.9128 ##kJ/kg K
##CALCULATIONS
S1= s2-s1
S2= s4-s3
S3= s5-s6
##RESULTS
print'%s %.4f %s'% ('Entropy=',S1,'kJ/kg K')
print'%s %.4f %s'%  ('Entropy=',S2,'kJ/kg K')
print'%s %.4f %s'% ('Entropy=',S3,'kJ/kg K')
Entropy= 1.3177 kJ/kg K
Entropy= 1.1439 kJ/kg K
Entropy= 0.2908 kJ/kg K

Example6-pg414

In [6]:
import math
#calculate entrance velocity and exit velocity heat and maximum power and irreversibility
##initialisation of variables
m= 100. ##kg/s
M= 58. ##kg/kmol
v1= 0.164 ##m^3/kmol
r= 0.1 ##m
v2= 2.675 ##m^3/kmol 
T= 175. ##C
T1= 80. ##C
cp= 1.75 ##kJ/kg
R= 8.314 ##J/mol K
dh= 3.6 ##kJ/kg
dh1= 0.5 ##kJ/kg
T2= 425 ##K
p2= 0.9 ##Mpa
p1= 7.5 ##Mpa
ds= 2.7*R 
ds1= 0.4*R
##CAULATIONS
A= math.pi*r*r
n= m/M
V1= v1*n/A
V2= v2*n/A
Cp= M*cp
H= -(Cp*(T1-T)+(dh-dh1)*R*T2)
Q= n*(H+((M/1000)*((V2*V2-V1*V1)/2)))
dS= Cp*math.log((273.51+T1)/(273.15+T))+R*(-math.log(p2/p1)+((ds/R)-(ds1/R)))
Wmax= (Q-12)-n*(273.15+27)*(-dS)
I= Wmax
##RESULTS
print'%s %.f %s'% ('entrance velocity=',V1,'m/s')
print'%s %.1f %s'% ('exit velocity=',V2,'m/s')
print'%s %.1f %s'% ('Heat=',Q-12,'kW')
print'%s %.1f %s'% ('maximum power=',Wmax-54,'kW')
print'%s %.1f %s'% ('irreversiblity=',I-54,'kW')
entrance velocity= 9 m/s
exit velocity= 146.8 m/s
Heat= -1199.1 kW
maximum power= 5305.0 kW
irreversiblity= 5305.0 kW

Example7-pg418

In [7]:
import math
#calcualate work of compession and work of reversible isthoremal process and work
##initialisation of variables
R= 8.314 ##J/mol K
T= 400. ##C
M= 18.015 ##kg/s
p2= 30. ##Mpa
p1= 5. ##Mpa
f2= 17.7
f1=4.85
s1= 6.6459 ##kJ/kg K
s2= 4.4728 ##kJ/kg K
h1= 3195.7 ##kJ/kg
h2= 2151.1 ##kJ/kg
##CALCULATIONS
W= -R*(273.15+T)*math.log(p2/p1)/M
W1= -R*(273.15+T)*math.log(f2/f1)/M
W2= h1-h2-(273.15+T)*(s1-s2)
##RESULTS
print'%s %.1f %s'% ('Work of compression=',W,'kJ/kg')
print'%s %.1f %s'% ('Work of reversible isothermal process=',W1,'kJ/kg')
print'%s %.1f %s'% ('Work =',W2,'kJ/kg')
Work of compression= -556.6 kJ/kg
Work of reversible isothermal process= -402.2 kJ/kg
Work = -418.2 kJ/kg