# Chapter 3 : Conservation of energy - First law of Thermodynamics¶

## Example 3.1 page : 47¶

In [1]:

# Variables
mass = 4000. 			#kg/m**2
Patm = 1.013*10**5 			#pa
g = 9.807
M = 28.
R = 8.3143*10**3
T = 303. 			#K
P1 = 800.*10**3 			#pa

# Calculations
Ps = Patm+mass*g
n = 1/M
V1 = n*R*T/P1
W = Ps*(2*V1)

# Results
print "Work done on the surroundings  =  %d J"%(W)

Work done on the surroundings  =  31609 J


## Example 3.2a page : 51¶

In [2]:

# Variables
t1 = 1000. 			#K
p1 = 20. 			#Mpa
p2 = 10. 			#Mpa
ti = 600. 			#K
t2 = 700. 			#K
v1 = 0.02188
vi = 0.02008
v2 = 0.02825
Ei = 2617.5
E2 = 2893.1
E1 = 3441.8
x = 0.22
m = 1. 			#kg
cp = 4.186
t3 = 639. 			#K
H3 = 2409.5
H1 = 3879.3

# Calculations
Tf =  ti+ (v1-vi)/(v2-vi) *(t2-ti)
Ef =  Ei+ x*(E2-Ei)
Q1 = Ef-E1

# Results
print ("part a")
print "Heat transfer  =  %.1f kJ/kg"%(Q1)

part a
Heat transfer  =  -763.7 kJ/kg


## Example 3.2b page : 52¶

In [4]:

# Variables
t1 = 1000. 			#K
p1 = 20. 			#Mpa
p2 = 10. 			#Mpa
ti = 600. 			#K
t2 = 700. 			#K
v1 = 0.02188
vi = 0.02008
v2 = 0.02825
Ei = 2617.5
E2 = 2893.1
E1 = 3441.8
x = 0.22
m = 1. 			#kg
cp = 4.186
t3 = 639. 			#K
H3 = 2409.5
H1 = 3879.3

# Calculations
Tf =  ti+ (v1-vi)/(v2-vi) *(t2-ti)
Hf = H3 - m*cp*(t3-Tf)
Q2 = Hf-H1

# Results
print ("part b")
print "Heat transfer  =  %.f kJ/kg"%(Q2)

part b
Heat transfer  =  -1541 kJ/kg


## Example 3.3 page : 63¶

In [5]:
import math

# Variables
p1 = 2.181
p2 = 2.637
p3 = 3.163
vg1 = 0.09150
vg2 = 0.07585
vg3 = 0.06323
vl1 = 0.00118
vl2 = 0.00120
vl3 = 0.00122
M = 18.
t1 = 490. 			#K
t2 = 500. 			#K
t3 = 510. 			#K
R = 8.3143

# Calculations
lam1 =  (p2-p1)*10**3 *M*(vg2-vl2) *2.154/ math.log(t3/t1)
lam2  =  math.log(p3/p1) *R/(1/t1 -1/t3)
err = (lam2-lam1)/lam1

# Results
print "latent heat umath.sing calyperon equation  =  %d kJ/kmol"%(lam1)
print " latent heat umath.sing the clasius calyperon equation  =  %d kJ/kmol"%(lam2)
print " Error  =  %d percent"%(err*100)

latent heat umath.sing calyperon equation  =  32990 kJ/kmol
latent heat umath.sing the clasius calyperon equation  =  38618 kJ/kmol
Error  =  17 percent


## Example 3.4 page : 66¶

In [6]:

# Variables
h1 = 147360
h2 = 29790

# Calculations
Hr = h1-h2

# Results
print "heat of reaction  =  %d kJ/kmol"%(Hr)

heat of reaction  =  117570 kJ/kmol


## Example 3.5 page : 73¶

In [12]:

# Variables
R = 8314.3
T = 700. 			#K
T2 = 437.5 			#K
T3 = 350. 			#K
T4 = T3
p2 = 0.552 			#Mpa
p1 = 2.758 			#Mpa
cp = 29.3
R0 = 8.3
k = 1.4

# Calculations
cv = cp-R0
Q1 = -R*T*math.log(p2/p1)
Q2 = cv*(T2-T)
dH2 =  cp*(T2-T)
p3 = p2*T3/T2
p3 = 0.345
Q3 = cp*(T3-T2)
dE3 = cv*(T3-T2)
W3 = Q3-dE3
T5 = T4*(p1/p3)**((k-1)/k)
dH4 =  cp*(T5-T4)
W4 = -cv*(T5-T4)
Q5 =  cp*(T-T5)
dE5 = cv*(T-T5)
W5 = Q5-dE5

# Results
print ("part a isothermal")
print "dH  =  0, dE = 0,  Q =  W  =  %.f kJ/kmol"%(Q1/10**3)
print ("part 2 isometric")
print "dH  =  %d kJ/kmol, W = 0,  Q =  dE  =  %.f kJ/kmol"%(dH2,Q2)
print ("part 3 isobaric")
print "dE  =  %.f kJ/kmol, W =  %d kJ/kmol,  Q =  dH  =  %.f kJ/kmol"%(dE3,W3,Q3)
print "dH  =  %d kJ/kmol, W =  -dE  =  %d kJ/kmol,  Q =  0 kJ/kmol"%(dH4,W4)
print ("part 5 isobaric")
print "dE  =  %d kJ/kmol, W =  %d kJ/kmol,  Q =  dH  =  %d kJ/kmol"%(dE5,W5,Q5)
print ("The graph cannot be plotted since volume axis values are not known. In the textbook it is randomly drawn to be of that shape.")

# rounding off error.

part a isothermal
dH  =  0, dE = 0,  Q =  W  =  9363 kJ/kmol
part 2 isometric
dH  =  -7691 kJ/kmol, W = 0,  Q =  dE  =  -5512 kJ/kmol
part 3 isobaric
dE  =  -1838 kJ/kmol, W =  -726 kJ/kmol,  Q =  dH  =  -2564 kJ/kmol
dH  =  8317 kJ/kmol, W =  -dE  =  -5961 kJ/kmol,  Q =  0 kJ/kmol
part 5 isobaric
dE  =  1388 kJ/kmol, W =  548 kJ/kmol,  Q =  dH  =  1937 kJ/kmol
The graph cannot be plotted since volume axis values are not known. In the textbook it is randomly drawn to be of that shape.


## Example 3.6 page : 76¶

In [2]:
%matplotlib inline
from matplotlib.pylab import xlabel,ylabel,plot
import math

# Variables
p = [2.75, 0.5, 0.31, 0.31, 2.75]
v = [116.17, 654.8, 654.8, 597, 110.65]
t = [440, 440, 170, 140, 410]
h = [3325, 3356, 2802.6, 2738.5, 3257.7]
e = [3005.6, 3028.6, 2602.6, 2553.6, 2953.4]

# Calculations
dh1 = h[1] - h[0]
de1 = e[1] - e[0]
q2 = e[2] - e[1]
dh2 = h[2] - h[1]
dh3 = h[3] - h[2]
de3 = e[3] - e[2]
W3 =  p[2] *(v[3] - v[2])
Q3 =  de3+W3
dh4 = h[4]  -h[3]
de4 = e[4] -e[3]
dh5 = h[0] - h[4]
de5 =  e[0] - e[4]
W5 =  p[4] *(v[0] - v[4])
q5  =  de5+W5

# Results
print "In case 1 , dH  =  %.1f kJ/kg dE  =  %.1f kJ/kg W =  pDv kJ/kg Q =  %.1f + W kJ/kg"%(dh1,de1,de1)
print " In case 2, W  = 0 kJ/kg Q  =  dE  =  %d kJ/kg dH  =  %.1f kJ/kg"%(q2,dh2)
print " In case 3, dH =  %.1f kJ/kg dE  =  %.1f kJ/kg W =  %.1f kJ/kg Q  =  %.1f kJ/kg"%(dh3,de3,W3,Q3)
print " In case 4, Q =  0 kJ/kg dH  =  %.1f kJ/kg dE  =  -W  =  %.1f kJ/kg"%(dh4,de4)
print " In case 5, dH  =  %.1f kJ/kg dE  =  %.1f kJ/kg W  =  %.1f kJ/kg Q  =  %.1f kJ/kg"%(dh5,de5,W5,q5)
xlabel("Volume (m**3/kg)")
ylabel("Pressure (Mpa)")
plot(v,p)

In case 1 , dH  =  31.0 kJ/kg dE  =  23.0 kJ/kg W =  pDv kJ/kg Q =  23.0 + W kJ/kg
In case 2, W  = 0 kJ/kg Q  =  dE  =  -426 kJ/kg dH  =  -553.4 kJ/kg
In case 3, dH =  -64.1 kJ/kg dE  =  -49.0 kJ/kg W =  -17.9 kJ/kg Q  =  -66.9 kJ/kg
In case 4, Q =  0 kJ/kg dH  =  519.2 kJ/kg dE  =  -W  =  399.8 kJ/kg
In case 5, dH  =  67.3 kJ/kg dE  =  52.2 kJ/kg W  =  15.2 kJ/kg Q  =  67.4 kJ/kg

Out[2]:
[<matplotlib.lines.Line2D at 0x10a39acd0>]

## Example 3.7 page : 80¶

In [14]:
import math

# Variables
P = 0.1*10**6 			#Pa
P2 = 0.55*10**6 			#Pa
M = 28.84
R = 8314.4
T1 = 303.1 			#K
T2 = 316.1 			#K
d1 = 0.154 			#m
d2 = 0.028 			#m
mass = 0.25 			#m**3/s
Q = 2.764*10**8 			#J/h
cp = 29.3*10**3

# Calculations
rho1 =  P*M/(T1*R)
u1 = mass/(math.pi/4 *d1**2)
rho2 =  P2*M/(R*T2)
u2 = u1*d1**2 *rho1/(d2**2 *rho2)
Wsd =  (u2**2 - u1**2 )/2 + cp/M *(T2-T1) + Q/(mass*rho1*3600)
mdot =  u1*math.pi/4 *d1**2 *rho1
Ws = Wsd*mdot/745.7

# Results
print "Power input to the compressor  =  %d hp"%(Ws)

Power input to the compressor  =  109 hp


## Example 3.8 page : 81¶

In [15]:
import math

# Variables
u1 = 1.1 			#m/s
rho1 = 1.21*10**3 			#kg/m**3
d1 = 0.078
z1 = 4
h2 = 18 			#m
g = 9.806

# Calculations
mdot =  u1*rho1*math.pi/4 *d1**2
Wsd =  z1+h2
Ws = Wsd*mdot*g
dP =  Ws*rho1/mdot

# Results
print "Power input  =  %d W"%(Ws)
print "Pressure drop  =  %.3f Mpa"%(dP/10**6)

Power input  =  1372 W
Pressure drop  =  0.261 Mpa


## Example 3.9 page : 87¶

In [16]:
import math

# Variables
eff = 0.75
Hf = [-110600, -241980, -393770, 0]
Hc = [30.35, 36, 45.64, 29.30]
T2 = 540. 	    		#C
T1 = 25. 		    	#C
mass = 500. 			#kmol H2 produced

# Calculations
dHr =  Hf[2] + Hf[3] - Hf[0] -Hf[1]
dHpr =  (eff*(Hc[2] +Hc[3]) + (1-eff)*(Hc[1]+Hc[0]))*(T2-T1)
q =  dHr*eff +dHpr
heat  =  q*mass/eff

# Results
print "Heat produced  =  %.3e kJ"%(heat)

Heat produced  =  4.397e+06 kJ


## Example 3.10 page : 87¶

In [17]:
import math

# Variables
eff = 0.75
Hf = [-110600, -241980, -393770, 0]
Hc = [30.35, 36 ,45.64, 29.30]
T2 = 540. 			#C
T1 = 25. 			#C
mass = 500. 			#kmol H2 produced
work = 10.**6 			#kJ

# Calculations
dHr =  Hf[2] + Hf[3] - Hf[0] -Hf[1]
dHpr =  (eff*(Hc[2] +Hc[3]) + (1-eff)*(Hc[1]+Hc[0]))*(T2-T1)
q =  dHr*eff +dHpr
heat  =  q*mass/eff
qe = heat-work

# Results
print "Heat produced  =  %.3e kJ"%(qe)

Heat produced  =  3.397e+06 kJ


## Example 3.11 page : 89¶

In [3]:
from numpy import array

# Variables
so3 = 6.
h2 = -296840. 			#kJ/kmol
h3 = -395720. 			#kJ/kmol
t2 = 400. 			#C
t1 = 25. 			#C

# Calculations
Hr = so3*(h3-h2)
cp = array([1.059, 0.967, 0.714])
n = array([82.76, 11 ,8])
M = array([28, 32, 64])
Ht =  sum(cp*n*M)
Hre = Ht*(t2-t1)
Hpr = Hre-Hr
Tf = t1 + Hpr/3261.6

# Results
print "temperature of exit gases  =  %d C"%(Tf)

temperature of exit gases  =  570 C


## Example 3.12 page: 91¶

In [4]:
from numpy import array

# Variables
x = 0.25
Hr = 1.4278*10**6 			#kJ/kmol
ti = 25.         			#C
cp = array([1.24, 2.39, 1.11])
M = array([44 ,18, 32])
z = array([12, 3, 0.5])
r = 4.186

# Calculations
v = cp*M*z
v2 = sum(v)
T = ti+ Hr/(v2)

# Results
print "Theoretical temperature  =  %d C"%(T)

Theoretical temperature  =  1806 C