Chapter 2 : The First law of Thermodynamics

Example 2.1 Page No : 38

In [6]:
import math 

z1 = 10. 			#[m]
z2 = 0. 			#[m],Taking ground as state 2,reference
v1 = 0.
g = 9.81            #m/s

#From conservation of total energy we get
# (1/2*m*v2**2-1 / 2*m*v1**2)+(m*g*z2 - m*g*z1) = 0
#   1/2*m*v2**2 - m*g*z1 = 0
v2 = math.sqrt(2 * g * z1) ; 			#[m/s]

# Results
print 'Final velocity = %.f m/s'%(v2);
Final velocity = 14 m/s

Example 2.2 Page No : 41

In [7]:
# Variables
V2 = 14.             			# [m/s]
u_cap_l1 = 104.86 ; 			#[kJ/kg],at 25*C internal energy of saturated water
u_cap_l_t25 = 104.86 ; 			#[kJ/kg], From steam table 
u_cap_l_t30 = 125.77 ; 			#[kJ/kg], From steam table
T1 = 25.         		    	#[*C]
T2 = 30. 		        	    #[*C]

# Calculations
#For unit mass change in kinetic energy
Delta_e_cap_k = 1./2 * V2**2 * 10**-3 ; 			#[kJ/kg]
Delta_u_cap = Delta_e_cap_k ;
#For final state of water:
u_cap_l2 = Delta_u_cap + u_cap_l1 ;

x = (u_cap_l2 - u_cap_l_t25) / (u_cap_l_t30 - u_cap_l_t25) ;
T_unknown = T1 + x*(T2 - T1) ;

# Results
print 'Final temperature of water = %.2f degreeC'%(T_unknown);
Final temperature of water = 25.02 degreeC

Example 2.3 Page No : 43

In [8]:
import math 
import scipy.integrate

# Variables
P_ex = 1*10**5 ; 			#[Pa]}

# Calculations
#To calculte work done
def f(x):
    return 1
    
I = scipy.integrate.quadrature(f,10,15.2)[0]
W = -P_ex * I * 10**-3 ; 			#[J]

# Results
print 'Work done = %g J'%(W);
Work done = -520 J

Example 2.4 page no : 57

In [6]:
from scipy.integrate import quad

# Variables
V = 1.0           # m**3
m = 10            # kg
p1p2 = .2
u1 = 2600.3        #kJ/kg
P1 = 20
v1 = 0.1

# Calculations
v = V/m
v2 = (p1p2*v**1.5)**(1./1.5)

def fun(v):
    return P1*v1**1.5/v**1.5

w =  -quad(fun,0.1,.0342)[0]
    
u2 = 3045.8 + (3144.5 - 3045.8) * (v2 - .03279)/(.03564 - .03279)
T2 = 500 + (550 - 500) * (v2 - .03279)/(.03564 - .03279)

# results
print "The specific volume of initial state = %.2f m**3/kg"%v
print "V2 = %.4f m**3/kg"%v2
print "Work done = %.f kJ/kg"%(w*100)
print "U2 = %.1f kJ/kg"%u2
print "T2 = %.f C"%T2
The specific volume of initial state = 0.10 m**3/kg
V2 = 0.0342 m**3/kg
Work done = 284 kJ/kg
U2 = 3094.6 kJ/kg
T2 = 525 C

Example 2.5 Page No : 63

In [4]:
# variables
#From steam table specific enthalpy at state1 and state2 are
h_cap_1 = 3373.6 			#[kJ/kg]
h_cap_2 = 2675.5 			#[kJ/kg]
m_dot1 = 10.     			#[kg/s],As we are dealing with steady state
m_dot2 = 10. 	    		#[kg/s]

# Calculations
Ws_dot = m_dot1 * (h_cap_2 - h_cap_1) ; 			#[kW]

# Results
print 'Power generated = %g kW'%(Ws_dot);
Power generated = -6981 kW

Example 2.6 Page No : 64

In [1]:
# Variables
h_cap_in = 3241.		#[kJ/kg] , From steam table
P_final = 10. 			#[MPa]

# Calculations and Results
u_cap_2 = h_cap_in ;
T2 = 600. ; 			# From steam table .No calculation is involved .
print 'a)   The final temperature of the system = %g *C'%(T2);

u_cap_2 = h_cap_in ;
# So temperature is T2 = 600*C (From table).
#Solution(b)
print "(b)   The temperature of the fluid increases in the system due to the receipent of flow work ."
a)   The final temperature of the system = 600 *C
(b)   The temperature of the fluid increases in the system due to the receipent of flow work .

Example 2.7 Page No : 72

In [5]:
import scipy.integrate.quadrature 

# Variables
n = 2. 			#[mol]
A = 3.470 ;
B = 1.450*10**-3 ;
D = 0.121*10**5 ;
T1 = 473. ; 			#[K]
T2 = 773. ; 			#[K]

# Calculations and Results
def f(T):
    return 8.314*(A + B*T + D*T**-2)
    
Delta_h = scipy.integrate.quadrature(f,T1,T2)[0]

Q = n * Delta_h ;

print 'a)Heat required = %d J'%(Q);

#From steam table
h_cap_1 = 2827.9 ; 			#[kJ/kg]
h_cap_2 = 3478.4 ; 			#[kJ/kg]
m = 2*0.018 ; 			#[kg]

Delta_h_cap = (h_cap_2 - h_cap_1) * 10**3 ; 			#[J/kg]
Q = m * Delta_h_cap;
print 'b)Heat required = %g J'%(Q);
a)Heat required = 21981 J
b)Heat required = 23418 J

Example 2.8 Page No : 73

In [6]:
# Variables
T1 = 298.;
T2_start = 300.;
A = 3.355;
B = 0.575*10**-3;
D = -0.016*10**5;

# Calculations
def f(T):
    return 8.314*(A*T + B/2*T**2 - D/T)

for T2_start in range(300,1000+1,100):
    del_h = f(T2_start) - f(T1);
    Cp = del_h /(T2_start - 298);
    print 'At temperatureK %g,     Molar heat capacity J/molK, %.2f'%(T2_start,Cp);   
At temperatureK 300,     Molar heat capacity J/molK, 29.17
At temperatureK 400,     Molar heat capacity J/molK, 29.45
At temperatureK 500,     Molar heat capacity J/molK, 29.71
At temperatureK 600,     Molar heat capacity J/molK, 29.97
At temperatureK 700,     Molar heat capacity J/molK, 30.22
At temperatureK 800,     Molar heat capacity J/molK, 30.46
At temperatureK 900,     Molar heat capacity J/molK, 30.71
At temperatureK 1000,     Molar heat capacity J/molK, 30.95

Example 2.9 Page No : 73

In [2]:
# Variables
n_dot_air = 10. ; 			#[mol/min]
C_bar_P_900 = 30.71 ; 			#[J/molK]
C_bar_P_600 = 29.97 ; 			#[J/molK]
T1 = 600. ; 			#[K]
T2 = 900. ; 			#[K]
T_ref = 298. ; 			#[K]

# Calculations
# Q_dot = n_dot_air * (h_900 - h_600)...........Eqn E2.8A
Q_dot = n_dot_air * (C_bar_P_900 * (T2 - T_ref) - C_bar_P_600 * (T1 - T_ref)); 

# Results
print 'Heat rate required = %.3f J/min'%(Q_dot/1000);

# note: answer may vary because of rounding error.
Heat rate required = 94.365 J/min

Example 2.10 Page No : 74

In [11]:
import math

# Variables
P1 = 100000. ; 			    # [N/m**2]
T1 = 298. ; 		    	#[K]
V1 = 0.1 * 0.1 ; 			# [m**3]
T2 = 373. ; 			    # [N]
P_ext = 100000. ; 			#[N/m**2]
k = 50000.       			#[N/m]
A = 0.1 ; 		           	#[m**2]

# Calculations and Results
a = k / (T2 * A**2) ;
b = (P_ext / T2) - k * V1 / (A**2 * T2) ;
c = -P1 * V1 / T1 ;
V2 = (-b + math.sqrt ( b**2 - (4*a*c))) / (2 * a) ;
W = -P_ext * (V2 - V1) - ( k * (V2 - V1)**2)/(2 * A**2);			#From eqn E2.9C

print 'a) Work required = %.f J '%(W);


A = 3.355 ;
B = 0.575 * 10**-3 ;
D = -0.016 * 10**5 ;
P1 = 10**5 ; 			#[N/m**2]
V1 = 0.01 ; 			#[m**3]
R = 8.314 ;
T1 = 298 ;

n = (P1 * V1) / (R * T1) ;
def f(T):
    return R*((A - 1) * T + B/2 * T**2 -D/T)

del_u = f(373) - f(298) ;
del_U = n * del_u ;
Q = del_U - W;
print 'b).Heat transfered  = %.f  J'%(Q);
a) Work required = -166 J 
b).Heat transfered  = 803  J

Example 2.11 Page No : 78

In [10]:
# Variables
n_dot = 10. 	    		#[mol/s]
T1 = 298.2      			#[K]
T2 = 342.   			    #[K]
T3 = 373.2  		    	#[K]
Cp_298_342 = 216.3 			#[J/molK]
A = 3.025 
B = 53.722 * 10**-3
C = -16.791 * 10**-6
del_h_vap = 28.88  			#[kJ/mol]

# Calculations
del_h_1 = Cp_298_342 * (T2 - T1) * 10**-3 ; 			#[kJ/mol]
del_h_2 = del_h_vap ;
def f(T):
    return 8.314*(A*T + (B/2)*(T**2) + (C/3)*(T**3))* 10**-3 ;

del_h_3 = f(T3) - f(T2) ;
Q = n_dot * (del_h_1 + del_h_2 + del_h_3) ;

print 'Rate of heat supplied = %d kJ/s'%(Q );
Rate of heat supplied = 435 kJ/s

Example 2.12 Page No : 79

In [4]:
# Variables
m_1_v = 4.3  			#[kg]
m_1_l = 50. 			#[kg]
u_cap_1_v = 2437.9   			#[kJ/kg],From steam table
u_cap_1_l = 191.8    			#[kJ/kg],From steam table
v_cap_1_v = 14.67  	    		#[m**3],From steam table
v_cap_1_l = 0.001  		    	#[m**3],From steam table

# Calculations
V2 = m_1_l * v_cap_1_l + m_1_v * v_cap_1_v ;
m_2_v = m_1_l + m_1_v ;
v_cap_2_v = V2 / m_2_v ; 			#[m**3/kg]
P2= 0.15                 			#[MPa]
u_cap_2_v = 2519.6       			#(kJ/kg)
Q = ((m_2_v * u_cap_2_v) -(m_1_l * u_cap_1_l + m_1_v * u_cap_1_v))*1000;

# Results
print 'Minimum amount of heat required = %.2e J'%(Q);
Minimum amount of heat required = 1.17e+08 J

Example 2.13 Page No : 83

In [14]:
# Variables
del_h0_f_CO2 = -393.51 ; 			# [kJ/mol]
del_h0_f_H2 = 0 ; 			# [kJ/mol]
del_h0_f_H2O = -241.82 ; 			# [kJ/mol]
del_h0_f_CH3OH = -200.66 ; 			# [kJ/mol]

# Calculations
del_h0 = del_h0_f_CO2 + 3 * del_h0_f_H2 - del_h0_f_H2O - del_h0_f_CH3OH ;

# Results
print 'Enthalpy of reaction = %.f kJ/mol'%(del_h0);
Enthalpy of reaction = 49 kJ/mol

Example 2.14 page no : 84

In [14]:
# variables
Vp = 3*10**6 *0.7*10**6
MW = 114.2                 # g/mol


#Calculations
n = Vp/MW
H = -9.3 * 10**16         # J
Ep = 200 * 0.10*24*3600      # energy density
A = -H/Ep

# Results
print "a) Area A = %.1e m**2"%A
a) Area A = 5.4e+10 m**2

Example 2.15 Page No : 85

In [26]:
import math 
from numpy import *
from scipy.integrate import *

# Variables
del_h0_f_CO2 = -393.51   			#[kJ/mol], From Appendix A.3 
del_h0_f_CO = -110.53  	    		#[kJ/mol], From Appendix A.3
del_h0_f_H2O = -241.82  			#[kJ/mol], From Appendix A.3
del_h0_f_C3H8 = -103.85  			#[kJ/mol], From Appendix A.3
del_h0_f_O2 = 0.  			        #[kJ/mol], From Appendix A.3
A_CO2 = 5.457    			        # From table E2.13
B_CO2 = 1.05 * 10**-3 
D_CO2 = -1.16 * 10**5 
A_CO = 3.379 
B_CO = 5.57 * 10**-4
D_CO = -3.1 * 10**3 
A_H2O = 3.470 
B_H2O = 1.45 * 10**-3
D_H2O = 1.21 * 10**4 
A_N2 = 3.280 
B_N2 = 5.93 * 10**-4 
D_N2 = 4.00 * 10**3 
 
# Calculations 
n_C3H8 = 10.         			#[mol]
n_N2 = (0.79/0.21) * (9.7/2) * n_C3H8 ; 			#[mol]
n_CO2 = 2.7 * n_C3H8 ; 			#[mol]
n_CO = 0.3 * n_C3H8 ; 			#[mol]
n_H2O = 4 * n_C3H8 ; 			#[mol]
n_O2 = (9.7 / 2)* n_C3H8 		#[mol]
T_reff = 298.        			#[K]
del_H_rxn_298 = n_CO2 * del_h0_f_CO2 + n_CO * del_h0_f_CO + n_H2O * del_h0_f_H2O - n_C3H8 * del_h0_f_C3H8 - n_O2 * del_h0_f_O2 ; 			#[kJ]

#The co-efficients of T2 in the equation of degree 3 are
a = 8.314*(n_CO2 * (B_CO2/2) + n_CO * (B_CO/2) + n_H2O * (B_H2O/2) + n_N2 * (B_N2/2));
b = 8.314*(n_CO2 * A_CO2 + n_CO * A_CO + n_H2O * A_H2O + n_N2 * A_N2) ;
d =8.314*(- n_CO2 * D_CO2 - n_CO * D_CO - n_H2O * D_H2O -n_N2 * D_N2) ;
c = (del_H_rxn_298 *1000) + 8.314 * (n_CO2 * (- T_reff * A_CO2 - B_CO2/2 * T_reff**2 + D_CO2/T_reff) + n_CO * (- T_reff * A_CO - B_CO/2 * T_reff**2 + D_CO/T_reff) + n_H2O * (- T_reff * A_H2O - B_H2O/2 * T_reff**2 + D_H2O/T_reff) + n_N2 * (-T_reff * A_N2 - B_N2/2 * T_reff**2 + D_N2/T_reff));

T2=poly1d([a,b,c,d])
M = roots(T2);


# Results
print "T2 = %.f [K]"%(round(round(M[1]),-1))

# Note: python has only 1 method to find roots so part 1-2 can be calculated same way here.
T2 = 2350 [K]

Example 2.16 pageno : 89

In [21]:
# variables

# Calculations
deltaH1rxn298 = (-393.51) - 1*(-110.53) -0          # Reaction 1
deltaH2rxn298 = 1*(-110.53) -0 - 0                  # Reaction 2
E1 = 3
E2 = 1

deltaHrxn = E1*deltaH1rxn298*1000 + E2*deltaH2rxn298*1000
nCO2 = 4 - E1 + E2
nO22 = 4 - (1./2*E1) - 1./2*E2
nCO22 = 0 + E1
nC2 = 2 - E2
s = 52000.
Q = deltaHrxn + s

# Results
print "extensive enthalpy of reaction %.2e J"%deltaHrxn
print "amount of energy transferred by heat %.1e J"%Q
extensive enthalpy of reaction -9.59e+05 J
amount of energy transferred by heat -9.1e+05 J

Example 2.18 Page No : 96

In [2]:
from numpy import *

# Variables
V1 = 350.    		    	#[m/s]
A = 3.355 
B = 0.575*10**-3
D = -0.016*10**5
Tin = 283.   	    		#[K]
MW = 29.*10**-3 ; 			#[kg/mol]

ek = 1./2 * MW * V1**2 
a = B/2.
b = A ;
c = -(Tin * A + Tin**2*B/2 - (D/Tin) + ek/8.314)
d=-D  

T2=poly1d([a,b,c,d])#'T2',0);
M = roots(T2);


# Results
print "Temperature T2 = %.f [K]"%M[1]
Temperature T2 = 344 [K]

Example 2.19 Page No : 97

In [5]:
# Variables
V_dot_2 = 0.001 ; 			#[m**3/kg]
v_cap_2 = 0.001 ; 			#[m**3/kg], Specific volume of water
z2 = 250.        			#[m] ; Taking ground as the reference level
e_cap_2 = 9.8 * z2 			#[kg*m**2/s**2]

# Calculations
m_dot_2 = V_dot_2 / v_cap_2  			#[kg/s]
W_dot_s = m_dot_2 * e_cap_2 * 10**-3 ;

# Results
print 'Minimum power required is = %.1f kW'%(W_dot_s);
Minimum power required is = 2.5 kW

Example 2.20 Page No : 98

In [3]:
# Variables
n_dot = 10.              			#[mol/min]
del_h_vap_CO2 = 10400. ; 			#[J/mol]
A_CO2 = 5.457 ; 		        	#From appendix A.3
B_CO2 = 1.045 * 10**-3 ;
D_CO2 = -1.157 * 10**5 ;
A_air = 3.355 ; 
B_air = 0.575 * 10**-3 ;
D_air = -0.016 * 10**5 ;
T1 = 273. ; 			#[K]
T2 = 283. ; 			#[K]
T3 = 323. ; 			#[K]
T4 = 293. ; 			#{k}

def f1(T):
    return 8.314 * (A_CO2 * T + (B_CO2/2) * T**2 - D_CO2/T)

sen_heat_CO2 = f1(T2) - f1(T1) ;
Q_dot = n_dot * (del_h_vap_CO2 + sen_heat_CO2) ; 			#[J/min]

def f2(T):
    return 8.314 * (A_air * T + B_air/2*T**2 - D_air /T)

sen_heat_air = f2(T4) - f2(T3);
n_dot_air = - Q_dot / sen_heat_air ;
print 'Air required = %.F mol/min'%(n_dot_air); 
Air required = 123 mol/min

Example 2.21 Page No : 100

In [17]:
# Variables
m_dot_1 = 10.    			#[kg/s]
h_cap_1 = 3238.2 ;			#[kJ/kg], Super heated steam at 500*C & 200bar
h_cap_2 = 93.3 ;			#[kL/kg], subcooled liquid at 20*C & 100bar
h_cap_3 = 2724.7 ;			#{kJ/kg}, Super heated vapour at 100bar 

# Calculations
m_dot_2 = m_dot_1 * (h_cap_1 - h_cap_3) / (h_cap_3 - h_cap_2);

# Results
print 'Flow of liquid stream = %.2f kg/s'%(m_dot_2);
Flow of liquid stream = 1.95 kg/s

Example 2.22 Page No : 101

In [18]:
# Variables
h_cap_st_1 = 2923.4 ; 			# [kJ/kg]
h_cap_200 = 2875.3 ; 			# {kJ/kg} , At 100kPa
h_cap_250 = 2974.3 ; 			# {kJ/kg} , At 100 kPa
del_T = 250.-200 ;
T1 = 200.            			#[K]

# Calculations
h_cap_st_2 = h_cap_st_1 ;			#Assumimg bulk kinetic energy of the stream and heat transfered is  negligible
T2 = T1 + del_T * (h_cap_st_2 - h_cap_200) / (h_cap_250 - h_cap_200) ;

# Results
print 'The exit temperature is = %d *C'%(T2) ;
The exit temperature is = 224 *C

Example 2.23 Page No : 105

In [2]:
import math
from numpy import zeros

# Variables
Cv = 3./2 * 8.314 ;
Cp = 5./2 * 8.314 ;
n = 1.; 
R = 8.314 ; 
T1 = 1000. ; 			#[K]
P1 = 10. ; 	    		#[bar]
T2 = 1000. ; 			#[K]
P2 = 0.1 ;   			#[bar]
T3 = 300. ; 			#[K]
T4 = 300. ; 			#[K]

# Calculations and Results
k = Cp / Cv ;
P3 = P2 * (T3 / T2)**(k/(k-1)); 			#[bar]
P4 = P1 * (T4 / T1)**(k/(k-1)) ; 			#[bar]

del_U_12 = 0 ; 			# As process 1-2 is isothermal 
W_12 = n * R * T1 * math.log(P2 / P1);
Q_h_12 = W_12 ;
print 'a)    1)   del_U = %d J'%(del_U_12) ;
print '           Work  = %d J'%(W_12) ;
print '           Heat = %d J'%(Q_h_12) ;

Q_23 = 0 ; 			# As adiabatic process
del_U_23 = n * Cv *(T3 - T2) ;
W_23 = del_U_23 ;
print '      2)   del_U  = %g J'%(round(del_U_23,-1)) ;
print '           Work J = %d J'%(round(W_23,-1)) ;
print '           Heat J = %d J'%(Q_23) ;

del_U_34 = 0 ; 			# As isothermal process
W_34 = n * R * T3 * math.log(P4 / P3) ; 			# Eqn E2.20.A
Q_c_34 = del_U_34 - W_34 ;
print '     3)    del_U = %g J'%(del_U_34) ;
print '           Work = %d J'%(W_34) ;
print '           Heat = %d J'%(Q_c_34) ;

Q_41 = 0 ; 			# As adiabatic process
del_U_41 = n * Cv * (T1 - T4) ;
W_41 = del_U_41 ;
print '     4)    del_U = %g J'%(round(del_U_41,-1)) ;
print '           Work = %d J'%(round(W_41,-1)) ;
print '           Heat = %d J'%(Q_41) ;

#Solution (c)
W_total = W_12 + W_23 + W_34 + W_41 ;
Q_absor = Q_h_12 ;
effi = W_total / Q_absor ;
print 'c)   efficiency = %g'%(effi)

#Solution (d)
x = 1 - T3 / T1 ;
print 'd)   1 - Tc/Th = %g'%(x);
print "    i.e  Efficiency = 1 - Tc/Th"

#Solution (e)
print "(e) The process can be made more efficient by raimath.sing Th or by   lowering Tc ."
print "Table E2.20B"
print "       T(K)       P(bar)   v(m**3/mol)"
P = [P1 , P2 , P3 , P4 ] ;
T = [T1 , T2 , T3 , T4 ] ;
v = zeros(4)
for i in range(4):
    v[i] = R * T[i] * 10**-5/ P[i] ;
    print "       %6d    %8.4f    %.4f "%(T[i],P[i],v[i]) ;
a)    1)   del_U = 0 J
           Work  = -38287 J
           Heat = -38287 J
      2)   del_U  = -8730 J
           Work J = -8730 J
           Heat J = 0 J
     3)    del_U = 0 J
           Work = 11486 J
           Heat = -11486 J
     4)    del_U = 8730 J
           Work = 8730 J
           Heat = 0 J
c)   efficiency = 0.7
d)   1 - Tc/Th = 0.7
    i.e  Efficiency = 1 - Tc/Th
(e) The process can be made more efficient by raimath.sing Th or by   lowering Tc .
Table E2.20B
       T(K)       P(bar)   v(m**3/mol)
         1000     10.0000    0.0083 
         1000      0.1000    0.8314 
          300      0.0049    5.0597 
          300      0.4930    0.0506