Chapter 4 : First Law of Thermodynamics

Example 4.1 Page No : 80

In [1]:
import math 

# Variables			
p = 1.0;			# in MPa
p = p * 10**6;			# in N per m**2
del_v = 1.5;			# in m**3 per min

# Calculations
del_v = del_v * 60;			# in m**3 per h
W = p * del_v;			# in J
W = W * 10**-6;			# in MJ

# Results
print "Work done by the pump upon the water in MJ is : %.0f"%W
Work done by the pump upon the water in MJ is : 90

Example 4.2 Page No : 81

In [1]:
# Variables
# w = 2*g*h
g = 9.81;
m =(0.2+10./1000)*10**3 ;			# in gm
s = 1;			# in cal/gm°C
del_T = 2;			# in °C

# Calculations
H = m * s * del_T;			# in cal
H = H * 10**-3;			# kcal
J = 4.1868 * 1000;
# W= 2*g*h= J*H
h = J*H/(2 * g);			# in m

# Results
print "Height from which the mass should fall in meter is : %.2f"%h
Height from which the mass should fall in meter is : 89.63

Example 4.3 Page No : 83

In [3]:
# Variables
W1 = -25;			# in kJ
W2 = 45;			# in kJ
Q1 = 65;			# in kJ
Q2 = -40;			# in kJ

# Calculations
# del_U = Q - W and but for a cycle del_U = 0, So
# Q = W
# Q1 + Q2 +Q3 = W1 +W2
Q3 = W1 + W2 - Q1 - Q2;			# in kJ

# Results
print "Third Heat transfer in kJ is ",Q3
print "That is Third Heat transfer is of ",abs(Q3)," kJ from the fluid"
Third Heat transfer in kJ is  -5
That is Third Heat transfer is of  5  kJ from the fluid

Example 4.5 Page No : 98

In [3]:
# Variables			
m = 1.5;			# in kg
T1 = 90;			# in °C
T1 = T1 + 273;			#in K
T2 = 225;			# in °C
T2 = T2 + 273;			# in K
C_p = 0.24;
C_v = 0.17;

# Calculations
Q = (m * C_p * (T2-T1));			# in kcal
del_U = (m * C_v * (T2-T1));			# in kcal
W = Q - del_U;			# in kcal

# Results
print "The external work done in kcal is : %.1f"%W
The external work done in kcal is : 14.2

Example 4.7 Page No : 98

In [1]:
import math 

# Variables
v1 = 0.5;			# in m**3
v2 = 0.125;			# in m**3
p1 = 1.5;			# in bar
p1 = p1 * 10**5;			# in N per m**2
p2 = 9.;			#in bar
p2 = p2 * 10**5;			# in N per m**2
T1 = 100.;			# in °C
T1 = T1 + 273;			# in K
R = 8.31;

# Calculations and Results
# Formula p1*v1= n*R*T1
n= p1*v1/(R*T1);			# in mole
print "Mass of gas in mole is : %.2f"%n

# Part (b)
# Formula p1*v1/T1 = p2*v2/T2
T2 = (p2 * v2 * T1)/(p1 * v1);			# in K
print "Temperature at the end of compression in °C is : %.1f"%(T2-273)

# Part (c)
# Formula p1*v1**n = p2*v2**n
n1= math.log(p2/p1)/math.log(v1/v2)
print "Value of index n of compression is :",round(n1,1)

# Part (d)
F = 3;
C_v =1./2*R*F;
del_U = (n * C_v * (T2-T1));			# in J
print "Increase in internal energy of gas in kJ is : %.1f"%(del_U*10**-3)

# Part(e)
Gamma = 1.67;
Q_12 = n*(Gamma-n1)/(1-n1)*R*(T2-T1)/(Gamma-1);			# in J
Q_12 = Q_12 * 10**-3;			        # in kJ
print "Heat interaction in kJ is : %.2f"%Q_12

if Q_12<0:
    print "The -ve sign indicates heat rejection during the process"

# Note: There is some difference between the answer of book and coding . Both the answer is right but accurate answer is of coding.
# Because in the book, the intermediate values taken are appox. and in the coding the values taken are accurate
Mass of gas in mole is : 24.20
Temperature at the end of compression in °C is : 286.5
Value of index n of compression is : 1.3
Increase in internal energy of gas in kJ is : 56.2
Heat interaction in kJ is : -72.24
The -ve sign indicates heat rejection during the process

Example 4.8 Page No : 99

In [10]:
import math 

# Variables
p1 = 0.01;			# in N/mm**2
p1 = p1 * 10**3;			# in kN/m**2
p2 = 50.;			# in kN/m**2
v1 = 5.;			# in m**3
v2 = 1.5;			# in m**3
Gamma = 1.4;

# Calculations and Results
# Formula p1*v1**n = p2*v2**n
n= round(math.log(p2/p1)/math.log(v1/v2),2)
print "Part (a)    The value of n is : %.2f"%n
print ("The process followed during air compression is POLYTROPIC");

# Part (b)
print "Part (b)    The law of the process is %.2f p*v**"%n," = constant"

# Part (c)
W= (p1*v1-p2*v2)/(n-1);			# in kNm or (kJ)
print "Part (c)    Work done during the process in kJ is : %.1f"%W
print ("The -ve sign indicates that the work has been done on the system")

# Part (d)
Q = ((Gamma - n)/(Gamma - 1) * W);			# in kJ
print "Part (d)    Heat transfer during the process in kJ is : %.3f"%Q
print ("The -ve sign indicates that the heat is rejected from the system")
Part (a)    The value of n is : 1.34
The process followed during air compression is POLYTROPIC
Part (b)    The law of the process is 1.34 p*v**  = constant
Part (c)    Work done during the process in kJ is : -73.5
The -ve sign indicates that the work has been done on the system
Part (d)    Heat transfer during the process in kJ is : -11.029
The -ve sign indicates that the heat is rejected from the system

Example 4.9 Page No : 101

In [1]:
from scipy.integrate import quad 


# Variables
# Relation of specific internal energy of the gas
# U= 1.5*p*v-85 kJ/kg
p1 = 1000;			# in kpa
p2 = 200;			# in pa
v1 = 0.20;			# in m**3
v2 = 1.20;			# in m**3
m = 1.5;			# in kg

# Calculations and Results
U1= 1.5*p1*v1-85;			#  kJ/kg
U2= 1.5*p2*v2-85;			#  kJ/kg
delU= U2-U1;	    		# in kJ
print "Change in internal energy in kJ is",delU
# p1= a+b*v1          (i)
# p2= a+b*v2          (ii)
# From eq(i) and (ii)
b= (p1-p2)/(v1-v2);			# in kN/m**2
a= p1-b*v1;     			# in kN/m**2 
print "The value of a in kN/m**2 is ",a
print "The value of b in kN/m**2 is ",b

# Part (c)
# Work done = integration of p w.r.t. v and p = a+b*v1

def f5(v): 
    return a+b*v

W=  quad(f5,v1,v2)[0]
print "Work done in kJ is :",W

# Part (d)
Q= delU+W;			# in kJ
print "The net heat transfer in kJ is : ",Q
Change in internal energy in kJ is 60.0
The value of a in kN/m**2 is  1160.0
The value of b in kN/m**2 is  -800.0
Work done in kJ is : 600.0
The net heat transfer in kJ is :  660.0

Example 4.10 Page No : 102

In [2]:
# Variables
a= 1160.;			# in kN/m**2
b= -800.;			# in kN/m**2

# Calculations
v= -a/(2*b)
Umax= 1.5*(a*v+b*v**2)-85;			# in kJ/kg
# For 1.5 kg mass of gas it is
Umax= Umax*1.5;			# in kJ/kg

# Results
print "The maximum internal energy of the gas in kJ/kg is : ",Umax
The maximum internal energy of the gas in kJ/kg is :  818.625

Example 4.11 Page No : 103

In [8]:
# Exa 4.11
import math 

# Variables
T1 = 127.;			# in °C
T1 = T1 + 273;			# in K
R = 287.;
V1 = 300.;			# in m/s
p1 = 2.;			# in MPa
p2 = 0.5;			# in MPa
p1 = p1 * 10**6;			# in Pa
p2 = p2 * 10**6;			# in Pa
C_P = 1.005*10**3;			# in J/ kg-K
Gamma = 1.4;

# Calculations and Results
V2 = math.sqrt(2 * C_P *T1 *(1-(p2/p1)**((Gamma-1)/Gamma)) + V1**2);			# in m/s
print "The exit velocity of air in m/s is : %.3f"%V2

m = 600.;			# in kg/hr
m = m / 3600;			# in kg/sec
v1 = (R * T1)/p1;			# in m**3 per kg
# m = (A1*V1)/v1 = (A2* V2)/v2
A1 = (m * v1)/V1;			# in m**2
A1 = A1 * 10**6;			# in mm**2
print "Inlet area of the nozzle in square milimeter is : %.2f"%A1

T2 = T1*(p2/p1)**((Gamma-1)/Gamma);			# in K
v2 = (R * T2)/(p2);			# in m**3/kg
A2 = (m * v2)/V2;			# in m**2
A2 = A2 * 10**6;			# in mm**2
print "Exit area of nozzel in square milimeter is : %.2f"%A2
The exit velocity of air in m/s is : 594.094
Inlet area of the nozzle in square milimeter is : 31.89
Exit area of nozzel in square milimeter is : 43.35

Example 4.17 Page No : 106

In [13]:
# Variables
W = -1;			# in kWh
W = W * 10**3 * 3600;			# in J
del_U = -5000;			# in kj

# Calculations
del_U = del_U * 10**3;			# in J
Q = del_U + W;			# in J
Q = Q * 10**-6;			# in MJ

# Results
print "Net heat transfer for the system in MJ is : ",Q
Net heat transfer for the system in MJ is :  -8.6

Example 4.20 Page No : 107

In [2]:
# Variables
Q_acb = 84;			#in kJ
W_acb = 32;			# in kJ

# Calculations and Results
#Formula Q_acb = del_U+W_acb where del_U = U_b - U_a;
del_U = Q_acb - W_acb;			# in kJ
# Part (a) Path a b d
W_abd = 10.5;			# in kJ
Q_abd = del_U + W_abd;			# in kJ
print "Heat flows into the system along the path a b d in kJ is : ",Q_abd

# Part (b) curved path b a
W_ba = -(21);			# in kJ
Q_ba = -(del_U) + W_ba;			# in kJ
print "Heat liberated by the system in kJ is : ",(Q_ba)

# Part (c) process a b and d b
W_ad = 10.5;			# in kJ
del_U1 = 42;			# in kJ
Q_ad = del_U1 + W_ad;			# in kJ
print "Heat absorbed in processes ad  in kJ is : ",Q_ad

W_db = -(42);			# in kJ
del_U2 = 52;			# in kJ
Q_bd = del_U2 + W_db;			# in kJ
print "Heat absorbed in processes bd in kJ is : ",Q_bd

W_db = 0;
W_abd = W_ad + W_db;			# in kJ
print "Heat absorbed in processes in ad and db in kJ is : ",W_abd
Heat flows into the system along the path a b d in kJ is :  62.5
Heat liberated by the system in kJ is :  -73
Heat absorbed in processes ad  in kJ is :  52.5
Heat absorbed in processes bd in kJ is :  10
Heat absorbed in processes in ad and db in kJ is :  10.5

Example 4.21 Page No : 108

In [11]:
# Variables
v1 = 5.;			# in m**3
p1 = 2.;			# in bar
p2 = 6.;			# in bar
p3 = 2.;			# in bar

# Calculations
p1 = p1 * 10**5;			# in N/m**2
p2 = p2 * 10**5;			# in N/m**2
p3 = p3 * 10**5;			# in N/m**2
n = 1.3;
v2 = v1 * ((p1/p2)**(1/1.3));			# in m**3
W1_2 = ((p2 * v2)-(p1 * v1))/(1-n);			# in J
Gamma = 1.4;
v3 = v2 * ((p2/p3)**(1/Gamma));			# in m**3
W2_3 = ((p3 * v3) - (p2 * v2))/(1-Gamma);			# in J
W_net = W1_2 + W2_3;			# in J
W_net = W_net * 10**-3;			# in kJ

# Results
print "net work done in kJ is : %.2f"%W_net
net work done in kJ is : -94.02