Chapter9-Applications of the second law of thermodynamics

Example1-pg 152

In [2]:
import math
#calculate final temperatures and total entropy
##changeinitialisation of variables
p1= 3.##changeMpa
p2= 0.2 ##changeMpa
V1= 0.6 ##changem^3
V2= 1.##changem^3
M= 28. ##changegms
R= 8.314 ##changeJ/mol K
T= 400. ##changeC
T1= 150. ##changeC
k= 1.4
p3= 1.25 ##changeMpa
##changeCALCULATIONS
m1= p1*V1*10.*10.*10.*M/(R*(273.15+T))
m2= p2*V2*10.*10.*10.*M/(R*(273.15+T1))
p4= (p1*V1+p2*V2)/(V1+V2)
T2= (math.pow(p4/p1,k-1.)/k)*(273.15+T)
m3= p3*V1*M*10.*10.*10./(R*T2)
dm= m1-m3
m4= m2+dm
T4= p3*10.*10.*10.*V2/((R/M)*m4)
S= (R/M)*(m2*((k/(k-1.))*math.log(T4/(273.15+T1))-math.log(p3/p2))+dm*((k/(k-1.))*math.log(T4/(273.15+T))-math.log(p3/p1)))
##changeRESULTS
print'%s %.1f %s'%('final temperature =',T2,'K')
print'%s %.1f %s'%('final temperature =',T4,'K')
print'%s %.4f %s'%('Total entropy =',S,'KJ/K')
#ans is not matching because round of error 
final temperature = 338.8 K
final temperature = 1340.2 K
Total entropy = 2.5525 KJ/K

Example2-pg203

In [9]:
import math
#calculate work of the pump
##initialisation of variables
m= 10000 ##kg/h
P= 2.5 ##Mpa
P1= 100 ##kPa
v= 0.001003 ##m^3
##CALCULATIONS
W= -m*v*(P*10*10*10-P1)/3600
##RESULTS
print'%s %.3f %s'%(' work of the pump =',W,'kW')
 work of the pump = -6.687 kW

Example3-pg 205

In [8]:
import math
##initialisation of variables
m= 4. ##kg/s
R= 8.314 ##J/mol K
M= 29. ##gms
k= 1.4
T1= 27. ##C
p2= 1800. ##kPa
p1= 105. ##kPa
n= 1.22
cp= 1.4 ##Jmol K
##CALCULATIONS
T2= (273.15+T1)*(p2/p1)**((n-1)/n)
W= m*k*(R/M)*((273.15+T1)/(k-1))*(1-(p2/p1)**((k-1)/k))
Q= -m*R*(273.15+T1)*math.log(p2/p1)/M
W1= m*(R/M)*n*((273.15+T1)/(n-1))*(1-(p2/p1)**((n-1)/n))
Q1= m*(R/M)*(n-k)*(T2-T1-273.15)/((n-1)*(k-1))
T3= (273.15+T1)*(p2/p1)**((k-1)/(2*k))
Q2= m*cp*(R/M)*(T1+273.15-T3)/(k-1)
##RESULTS
print'%s %.1f %s'%('heat removed in adiabatic compression =',W,'kW')
print'%s %.1f %s'%('heat removed in isothermal compression =',Q,'kW')
print'%s %.1f %s'%('heat removed in polytropic process =',Q1,'kW')
print'%s %.2f %s'%('heat removed in adiabatic compression in two stages =',Q2,'kW')
heat removed in adiabatic compression = -1508.5 kW
heat removed in isothermal compression = -978.1 kW
heat removed in polytropic process = -471.2 kW
heat removed in adiabatic compression in two stages = -603.21 kW

Example4-pg 208

In [7]:
import math
#calculate enthalpy and entropy
##initialisation of variables
h1= 3422.25 ##kJ/kg
m= 8. ##kg/s
s2= 7.3755 ##kJ/kg K
s1= 6.8803 ##kJ/kg K
e= 0.8
h2s= 2496.8 ##kJ/kg
##CALCULATIONS
h2= h1+e*(h2s-h1)
W= m*(h1-h2)
S= s2-s1
##RESULTS
print'%s %.1f %s'%('Enthalpy  =',W,'kW')
print'%s %.4f %s'% ('Entropy =',S,'kJ/kg K')
Enthalpy  = 5922.9 kW
Entropy = 0.4952 kJ/kg K

Example5-pg209

In [6]:
import math
calculate volume flow rate into composser and volume flow rate out composser and heat and work 
##initialisation of variables
m= 0.2 ##kg/s
v1= 1.0803 ##m^3/kg
T= 200 ##C
s2= 5.8041 ##kJ/kg K
s1= 7.5066 ##kJ/kg K
h1= 2328.1 ##kJ/kg
h2= 2654.4 ##kJ/kg
##CALCULATIONS
V1= m*v1
V2= 0.1*V1
Q= m*(273.15+T)*(s2-s1)
W= Q-m*(h1-h2)
##RESULTS
print'%s %.4f %s'%('volume flow rate into composser =',V1,'m^3')
print'%s %.4f %s'%('volume flow rate out of composser  =',V2,'m^3')
print'%s %.1f %s'%('Heat  =',Q,'kJ')
print'%s %.1f %s'%(' Work  =',W,'kJ')
volume flow rate into composser = 0.2161 m^3
volume flow rate out of composser  = 0.0216 m^3
Heat  = -161.1 kJ
 Work  = -95.8 kJ

Example6-pg211

In [5]:
import math
#calculate volume flow rate out and into the composser and work and heat
##initialisation of variables
m1= 0.2 ##kg/s
v1= 1.0803 ##m^3/kg
P= 200 ##kPa
T= 200 ##C
s1= 5.8041 ##kJ.kg K
s2= 7.5066 ##kJ/kg K
h1= 2870.5 ##kJ/kg
h2= 2495.9 ##kJ/kg
##CALCULATIONS
V1= m1*v1
V2= 0.1*V1
Q= m1*(273.15+T)*(s1-s2)
W= m1*((h1-h2)-(273.15+T)*(s2-s1))
##RESULTS
print'%s %.4f %s'% ('volume flow rate into composser =',V1,'m^3/s')
print'%s %.4f %s'%('volume flow rate out of composser  =',V2,'m^3/s') 
print'%s %.1f %s'%('Work  =',W,'kW')
print'%s %.1f %s'%('Heat  =',Q,'kW')
volume flow rate into composser = 0.2161 m^3/s
volume flow rate out of composser  = 0.0216 m^3/s
Work  = -86.2 kW
Heat  = -161.1 kW

Example7-pg213

In [4]:
import math
#calculate rate of transfer
##initialisation of variables
e= 0.82
m= 5 ##kg/s
T3= 450 ##C
T1= 200 ##C
##CALCULATIONS
Q= e*m*1.0035*(T3-T1)
##RESULTS
print'%s %.1f %s'%('rate of transfer =',Q,'kW')
rate of transfer = 1028.6 kW

Example8-pg 211

In [3]:
import math
#calculate heat at given enthalpy
##initialisation of variables
h1= 174.076 ##kJ/kg
h3= 74.527 ##kJ/kg
h4= 8.854 ##kJ/kg
m= 0.8 ##kg
e= 0.85
##CALCULATIONS
h2= h1+h3-h4
Q= m*(h2-h1-23)
Q1= e*Q
##RESULTS
print'%s %.2f %s'%('Heat =',Q,'kW')
print'%s %.2f %s'%('Heat =',Q1,'kW')
#round of error
Heat = 34.14 kW
Heat = 29.02 kW

Example9-pg 214

In [2]:
import math
#calculate enthalpy and entropy change
##initialisation of variables
W= 2000. ##kW
m= 2. ##kg/s
h1= 3023.5 ##kJ/kg
s2= 5.6106 ##kJ/kg K
s1= 6.7664 ##kJ/kg K
##CALCULATIONS
h2= h1-(W/m)
S=s2-s1
##RESULTS
print'%s %.1f %s'% ('enthalpy =',h2,'kJ/kg')
print'%s %.4f %s'%('entropy change =',S,'kJ/kg K')
enthalpy = 2023.5 kJ/kg
entropy change = -1.1558 kJ/kg K

Example10-pg 215

In [1]:
import math
#calculate enthalpy and entropy change
##initialisation of variables
m1= 1 ##kg
h1= 2967.6 ##kJ/kg
h2= 83.96 ##kJ/kg
m2= 10
s1= 7.5166 ##kJ/kg K
s2= 0.2966 ##kJ/kg K
s3= 1.1654 ##kJ/kg K
##CALCULATIONS
h3= (m1*h1+m2*h2)/(m1+m2)
S= -m1*s1-m2*s2+(m1+m2)*s3
##RESULTS
print'%s %.1f %s'% ('enthalpy =',h3,'kJ/kg')
print'%s %.4f %s'%('entropy change =',S,'kJ/kg K')
enthalpy = 346.1 kJ/kg
entropy change = 2.3368 kJ/kg K