Chapter 3 : Entropy and the Second law of Thermodynamics

Example 3.2 Page No : 144

In [1]:
import math 


# Variables
del_U = 0. ; 			# As no work or heat transfered across its boundaries during the process 
T_1 = 500. ; 			# [K]

# Calculations and Results
V1 = 1.6682 / 2 * 10**-3; 			# [m**3]
V2 = 2. * V1 ; 
del_S_sur = 0 ; 			# As no heat transfered across its boundaries during the process 


print "(a)For an ideal gas u = u(T only)"
print '   Final temperature = %g K '%(T_1);

q_rev = 8.314 * T_1 * math.log(V2/V1) ;
del_S_sys = q_rev / T_1 ;
del_S_univ = del_S_sys + del_S_sur ;

print 'b)Entropy change for universe = %.2f J/molK)'%(del_S_univ);
(a)For an ideal gas u = u(T only)
   Final temperature = 500 K 
b)Entropy change for universe = 5.76 J/molK)

Example 3.3 Page No : 145

In [2]:
import math

# Variables
T_1_1 = 273. ;			# {K}
T_1_2 = 373. ; 			#[K]
Cp = 24.5 ; 			# [J/molK]
del_S_sur = 0. ; 			#Since the system is isolated 

# Calculations
T2 = (T_1_1 + T_1_2)/2 ;
del_S = Cp / 2 * math.log(T2**2 / (T_1_1 * T_1_2)) ;

# Results
print "Entropy change for the system = %.2f J/mol K)"%( del_S);
Entropy change for the system = 0.30 J/mol K)

Example 3.4 Page No : 147

In [3]:
# Variables
del_h_vap = 38.56 * 10**3 ; 			#[J/mol] , From Table 
Tb = 78.2 + 273.             			#[K] ,From table

# Calculations
del_S = - del_h_vap / Tb * 10**-3 ;

# Results
print "Change in entropy = %.4f kJ/mol K"%(del_S);
Change in entropy = -0.1098 kJ/mol K

Example 3.5 Page No : 149

In [3]:
import math

# Variables
P_1 = 300. * 10**3      		#[N/m**2]
T_1 = 700.       		    	# [*C]
V_bar_1 = 20. ; 			    #[m/s]
P_2 = 200. * 10**3 ; 			# [N/m**2]
h_cap_1 = 3927.1 * 10**3 ; 		# [J/kg] , From table
S_cap_1 = 8.8319  			    # [kJ/kgK] , From table

# Calculations
S_cap_2 = S_cap_1    			# Reverssible adiabatic process 
T2 = 623.            			# [*C] ,From table by interpolation
h_cap_2 = 3754.7 * 10**3		# [J/kgK] ,From table by interpolation
V_bar_2 = math.sqrt(2 * (h_cap_1 - h_cap_2) + V_bar_1**2) ; 

# Results
print 'The final temperature is %g C and the exit velocity is %.1f m/s'%(T2,V_bar_2);
The final temperature is 623 C and the exit velocity is 587.5 m/s

Example 3.6 page no : 150

In [2]:
# Variables
m1 = 10          # kg/s
m2 = 1.95          # kg/s
s1 = 6.14           # kJ / kg K
s2 = .2945           # kJ / kg K
s3 = 5.6140           # kJ / kg K

# Calculations
m3 = m1 + m2
dSdT = (m3 * s3) - (m1 *s1) + (m2*s2)

#results
print "dS/dTuniv = %.2f kW/k"%dSdT

# note : answer in book is wrong. 
dS/dTuniv = 6.26 kW/k

Example 3.7 Page No : 153

In [4]:
import math

# Variables
V_1 = 0.5 ; 			#[m**3]
P_1 = 150. ; 			#[kPa]
T_1 = 20. + 273.		#[K]
P_2 = 400. ; 			# [kPa]
Cp = 2.5 * 8.314 ;


# Calculations and Results
Q = V_1 * (P_1 - P_2)
print "a)Heat transferd = %g kJ"%(Q);
del_S_sys = (P_1 * V_1) / T_1 * -math.log(P_2 / P_1) ;
print 'b)Entropy change of system = %.2f kJ/K '%(del_S_sys);
Q_surr = - Q ;
del_S_surr = Q_surr / T_1 ;
print '  Entropy change of surrounding = %.2f kJ/K '%(del_S_surr) ; 
del_S_univ = del_S_sys + del_S_surr ;
print '  Entropy change of universe =%.2f kJ/K '%(del_S_univ) ;

print "c)Since entropy of the universe increases , the process is irreverssible ."
a)Heat transferd = -125 kJ
b)Entropy change of system = -0.25 kJ/K 
  Entropy change of surrounding = 0.43 kJ/K 
  Entropy change of universe =0.18 kJ/K 
c)Since entropy of the universe increases , the process is irreverssible .

Example 3.8 Page No : 154

In [5]:
# Variables
import math
A = 3.355            			# from table
B = 0.575 * 10**-3 ; 			# from table
D = -0.016 * 10**5 ; 			# from table
R = 8.314 ;
P1 = 1.              			#[bar]
P2 = 0.5 ; 			            #[bar]

# Calculations
def f(T):
        return R * (A * math.log(T) + B * T + D / (2 * T**2))

S1 = f(373.) - f(298.) ;
S2 = R * math.log(P1 / P2) ; 
del_S = S1 - S2 ; 

# Results
print 'Entropy change = %.2f J/mol K'%(del_S);

# Note : Answer may be different because of rouding error.
Entropy change = 0.88 J/mol K

Example 3.9 Page No : 155

In [7]:
import math
# Variables
P = 1.       			#[bar]
p_O2 = 0.5 ; 			#[bar]
p_N2 = 0.5 ; 			# [bar]
n_O2 = 1.    			#[mol]
n_N2 = 1.    			#[mol]
R = 8.314    			# J/mol K

# Calculations
del_S_1_O2 = -n_O2 * R * math.log(p_O2 / P) ;
del_S_1_N2 = -n_N2 * R * math.log(p_N2 / P) ; 
del_S_2 = 0.
del_S = del_S_2 + del_S_1_O2 + del_S_1_N2 ;

# Results
print "    Entropy of mixing = %.2f J/K"%(del_S);
    Entropy of mixing = 11.53 J/K

Example 3.11 Page No : 157

In [6]:
import math
#Variables
P_1 = 10. ; 			#[bar]
T_1 = 298. ; 			# [K]
P_2 = 1. ; 			#[bar]
T_2 = 298. ; 			# [K]
P_3 = 1. ; 			#[bar]
R = 8.314 ; 			# [J/mol K]
n = 4. ; 			#[mol]
X = 0.01 ;

# Calculations
del_S_sys = - R * math.log(P_2 / P_1);
del_S_surr = - R * (1 - P_2 / P_1) ;
del_s_univ_1 = del_S_sys + del_S_surr ; 
Del_S_univ_1 = n * del_s_univ_1 ;

Del_S_univ_2 = 0 ;
n_3 = n * P_3 / P_1 ;

n_out = n - n_3 ;
del_S_sys_3 = - n_out * R * math.log(X) ;
Del_S_univ_3 = del_S_sys_3
Del_S_univ = Del_S_univ_1 + Del_S_univ_2 + Del_S_univ_3 ;

# Results
print "Total entropy change of universe = %.2f J/K "%(Del_S_univ) ;
print "No matter how slow the leak , the driving force for the expansion is finite . \
So the process canot be reverssible ."

# Note : answer is different becuase of rounding error.
Total entropy change of universe = 184.48 J/K 
No matter how slow the leak , the driving force for the expansion is finite . So the process canot be reverssible .

Example 3.12 Page No : 162

In [9]:
# Variables
n_dot = 250.         			# [mol/s]
P_1 = 125. * 10**5 ; 			# [N/m**2]
V_cap_1 = 5. * 10**-4  			# [m**3/mol]
P_2 = 8 * 10.**5 ; 		    	# [N/m**2]

# Calculations
X = 3 * P_1**0.6667 * V_cap_1 * ( P_2**(1./3) - P_1**(1./3)) ;
W_dot_s = n_dot * X * 10**-6 

# Results
print 'Power generated = %.1f MW'%(W_dot_s) ;
Power generated = -2.8 MW

Example 3.13 Page No : 163

In [10]:
# Variables
Ws_real = -2.1 ; 			#[MW]
Ws_rev = -2.8 ; 			# [MW]

# Calculations
n_tur = Ws_real / Ws_rev ;

# Results
print "Isentropic efficiency of turbine = %.2f %%"%( n_tur * 100);
Isentropic efficiency of turbine = 75.00 %

Example 3.14 Page No : 166

In [9]:
# Variables
P_1 = 10. * 10**6 ; 			# [N/m**2]
T_1 = 600. + 273 ; 			    #[K]
T_H = T_1 ;
T_C = 100. + 273 ; 			    #[K]
P_3 = 10. * 10**4 ; 			#[N/m**2]
P_4 = P_1 ;
h_cap_1 = 3625.3 ; 			# [kJ/kg],From steam table
S_cap_1 = 6.9028 ; 			#[kJ/kgK],From steam table
S_cap_2 = S_cap_1 ; 			#[kJ/kgK],From steam table
S_cap_v = 7.3593 ; 			#[kJ/kgK],From steam table
S_cap_l = 1.3025 ; 			#[kJ/kgK],From steam table
h_cap_l = 417.44 ;			# [kJ/kg],From steam table
h_cap_v = 2675.5 ;			# [kJ/kg],From steam table
V_cap_l = 10**-3 ; 			# [m**3/kg],From steam table

# Calculations
X = (S_cap_2 - S_cap_l) / (S_cap_v - S_cap_l);
h_cap_2 = (1 - X) * h_cap_l + X * h_cap_v ;
W_cap_s = h_cap_2 - h_cap_1 ;
h_cap_3 = h_cap_l ;

W_cap_c = V_cap_l * (P_4 - P_3) * 10**-3 ;
h_cap_4 = h_cap_3 + W_cap_c ;
W_net = W_cap_s + W_cap_c ; 			# [kJ/kg]
n_turb = ( -W_cap_s - W_cap_c) / (h_cap_1 - h_cap_4) ;

# Results
print "Efficiency of the Rankine cycle = %.1f %% "%(n_turb * 100 );
n_carnot = 1 - T_C / T_H ;
print "Efficiency of the Carnot cycle = %.1f %%"%(n_carnot * 100);
print "The Rankine efficiecy is lower than Carnot efficiency ."
Efficiency of the Rankine cycle = 34.7 % 
Efficiency of the Carnot cycle = 57.3 %
The Rankine efficiecy is lower than Carnot efficiency .

Example 3.15 Page No : 167

In [10]:
# Variables
n_turb = 0.85 ;
n_comp = 0.85 ;
W_cap_s_rev = -1120. ; 			#[kJ/kg]
h_cap_1 = 3625.3 ;   			#[kJ/kg]
h_cap_l = 417.44 ; 	    		#[kJ/kg]
W_cap_c_rev = 9.9 ; 			#[kJ/kg]

# Calculations
W_cap_s_act = n_turb * W_cap_s_rev ;
h_cap_2_act = W_cap_s_act + h_cap_1 ;
h_cap_3 = h_cap_l ;
W_cap_c_act = W_cap_c_rev / n_comp ;
h_cap_4_act = W_cap_c_act + h_cap_3 ;
W_cap_net = W_cap_s_act + W_cap_c_act ;
n_rank_act = (-W_cap_s_act - W_cap_c_act) / (h_cap_1 - h_cap_4_act) ;

# Results
print "W_cap_net = %.1f kJ/kg"%(W_cap_net) ;
print "Efficiency of Rankine cycle = %.1f %%"%(n_rank_act*100) 
W_cap_net = -940.4 kJ/kg
Efficiency of Rankine cycle = 29.4 %

Example 3.16 Page No : 171

In [11]:
# Variables
P_1 = 120. * 10**3 ; 			#[N]
P_2 = 900. * 10**3 ; 			#[N]
h_4 = 25.486         			#[kJ/mol], From table
h_1 = h_4 ;
h_2 = 39.295 ; 		        	#[kJ/mol], From table
S_2 = 177.89 ;  		    	#[kJ/molK], From table
S_3 = S_2 ;  			        #[kJ/mol]
h_3 = 43.578         			#[kJ/mol] , Enthalpy corresponding to S3 value which     equales to S2
Q_dot_c_des = 10. 	    		#[kW]

# Calculations
q_c = h_2 - h_1 ;
Q_dot_c = h_2 - h_1 ;
W_dot_c = h_3 - h_2 ;
COP = Q_dot_c / W_dot_c ;
n_dot = Q_dot_c_des / q_c ;

# Results
print "COP of the refrigerator is = %.2f \nMass flow rate needed = %.3f mol/s"%(COP,n_dot)
COP of the refrigerator is = 3.22 
Mass flow rate needed = 0.724 mol/s