Chapter 04:First Law of Thermodynamics

Ex4.1:pg-72

In [1]:
import math
V1 = 0.3 # Initial volume in m**3
V2 = 0.15 # Final volume in m**3
P = 0.105 # Initial Pressure in MPa
Q = -37.6 # Heat transferred in kJ
W = P*(V2-V1)*1e6 # Work done
U = Q*1e3-W # Internal energy change
print "\n Example 4.1"
print "\n The internal energy of the gas decrease by ",abs(U)/1e3," kJ in the process."
 Example 4.1

 The internal energy of the gas decrease by  21.85  kJ in the process.

Ex4.2:pg-73

In [3]:
import math
Qacb = 84 # Heat transfer along the path acb in kJ 
Wacb = 32 # Work done along the path acb in kJ
Uba = Qacb-Wacb # Ub-Ua
# Part (a)
Wadb = 10.5 # Work done along the path adb in kJ
Qadb = Uba+Wadb # Heat flow into the system along the path adb
print "\n Example 4.2"
print "\n The heat flow into the system along the path adb is ",Qadb ," kJ"
# Part (b)
Wb_a = -21 # work done along the path ba in kJ
Uab = - Uba # Change in internal energy along the path ab in kJ
Qb_a = Uab+Wb_a # Heat liberated along the path b-a
print "\n The heat liberated along the path b-a is ",Qb_a," kJ"



# Part (c)
Wdb = 0 # Constant volume
Wad = 10.5 # work done along the path ad in kJ
Wadb = Wdb-Wad # work done along the path adb in kJ
Ud = 42
Ua = 0
Qad = Ud-Ua+Wad # Heat flow into the system along the path ad in kJ
Qdb = Qadb-Qad  #Heat flow into the system along the path db in kJ

print "\n The heat absorbed in the path ad and db are ",Qad ," kJ nd ",Qdb ," kJ respectively."
 Example 4.2

 The heat flow into the system along the path adb is  62.5  kJ

 The heat liberated along the path b-a is  -73  kJ

 The heat absorbed in the path ad and db are  52.5  kJ nd  10.0  kJ respectively.

Ex4.3:pg-73

In [2]:
import math
# Process a-b
Qab = 0 # Heat transfer along the path ab in kJ/ min
Wab = 2170 # Work transfer along the path ab in kJ/min
Eab = Qab-Wab # Change in internal energy along the path ab in kJ/min
# Process b-c

Qbc = 21000 # Heat transfer along the path bc in kJ/ min
Wbc = 0 # Work transfer along the path bc in kJ/min
Ebc = Qbc-Wbc # Change in internal energy along the path bc in kJ/min

# Process c-d

Qcd = -2100 # Heat transfer along the path cd in kJ/ min
Ecd = -36600  # Change in internal energy along the path cd in kJ/min
Wcd = Qcd-Ecd  # Work transfer along the path cd in kJ/min

# Process d-a

Q = -17000  # Total heat transfer in kJ/min
Qda = Q-Qab-Qbc-Qcd # Heat transfer along the path da in kJ/ min 
Eda = -Eab-Ebc-Ecd  # Change in internal energy along the path da in kJ/min 
Wda = Qda-Eda # Work transfer along the path da in kJ/min

print "\n Example 4.3"



M = [[Qab, Wab, Eab] , [Qbc, Wbc, Ebc], [Qcd, Wcd, Ecd], [Qda, Wda, Eda]]
print"The completed table is:",M     
W = Qab+Qbc+Qcd+Qda     
print "\n Net rate of work output is ",W/60 ," kW"
 Example 4.3
The completed table is: [[0, 2170, -2170], [21000, 0, 21000], [-2100, 34500, -36600], [-35900, -53670, 17770]]

 Net rate of work output is  -284  kW

Ex4.4:pg-75

In [14]:
import math
# Part (a)

m = 3 # mass of substance in kg
V1 = 0.22 # Initial volume of system in m**3
P1 = 500 # Initial pressure of system in kPa
P2 = 100 # Final pressure of system in kPa  
V2 = V1*(P1/P2)**(1/1.2) # Final volume of system
dU = 3.56*(P2*V2-P1*V1) # Change in internal energy of substance in kJ/kg
n = 1.2 # polytropic index
W = (P2*V2-P1*V1)/(1-n) # work done in process
Q = dU+W # Heat addition in process

print "\n Example 4.4"
print "\n Part A:"
print "\n For the quasi static process is: \n "
print "Q:   ",Q ,"kJ"
print "\n dU: ",dU ,"kJ"
print "\n W: ",round(W,2) ,"kJ",

#The provided in the textbook is wrong

# Part (b)

print "\n\n Part B:"
Qb = 30 # heat transfer in kJ
Wb = Qb-dU # Work done in kJ
print "\n Work transfer for the process is ",round(Wb,2) ,"kJ." 
#The answers vary due to round off error
# Part (c)

print "\n\n Part C:"
print "\n Wb is not equal to integral(p*dv) since the process is not quasi static."
 Example 4.4

 Part A:

 For the quasi static process is: 
 
Q:    37.2676405731 kJ

 dU:  -92.1338891945 kJ

 W:  129.4 kJ 

 Part B:

 Work transfer for the process is  122.13 kJ.


 Part C:

 Wb is not equal to integral(p*dv) since the process is not quasi static.

Ex4.5:pg-76

In [4]:
import math
import numpy as np
from scipy.integrate import quad
V1 = 0.03 # initial volume in m**3

P1 = 170.0 # Initial pressure in kPa

P2 = 400.0 # Final pressure in kPa

V2 = 0.06 # Final volume in m**3

U = 3.15*(P2*V2-P1*V1) # internal energy in kJ

b = np.matrix([P1, P2])

B=b.transpose()

A = np.matrix([[1,V1],[1,V2]]) 

x = A.getI()*B 

a = x[0] ; b = x[1] 

def pressure(V): 
    P = a+b*V
    return P

    endfunction 

W, err = quad(pressure, V1, V2)
    
#W = integrate(pressure,V1,V2)  
    
Q = U+W # heat flow into the system in kJ
    
print "\n Example 4.5"
    
print "\n The work done by the system is ",W ," kJ"
    
print "\n The heat flow into the system is ",Q ," kJ"
    
    
 Example 4.5

 The work done by the system is  8.55  kJ

 The heat flow into the system is  68.085  kJ