Chapter 02: Heat, Work, Internal Energy, Enthalpy, and The First Law of Thermodynamics

Example Problem 2.1, Page 18

In [1]:
from math import pi

#Variable Declaration  Part a
vi = 20.0             #Initial volume of ideal gas, L
vf = 85.0             #final volume of ideal gas, L
Pext = 2.5            #External Pressure against which work is done, bar

#Calculations
w = -Pext*1e5*(vf-vi)*1e-3

#Results
print 'Part a: Work done in expansion is %6.1f kJ'%(w/1000)

#Variable Declaration  Part b
ri = 1.00             #Initial diameter of bubble, cm
rf = 3.25             #final diameter of bubble, cm
sigm = 71.99          #Surface tension, N/m

#Calculations
w = -2*sigm*4*pi*(rf**2-ri**2)*1e-4

#Results
print 'Part b: Work done in expansion of bubble is %4.2f J'%w

#Variable Declaration  Part c
i = 3.20             #Current through heating coil, A 
v = 14.5             #fVoltage applied across coil, volts
t = 30.0             #time for which current is applied,s

from math import pi
#Calculations
w = v*i*t

#Results
print 'Part c: Work done in paasing the cuurent through coil is %4.2f kJ'%(w/1000)

#Variable Declaration  Part d
k = 100.0             #Constant in F = -kx, N/cm 
dl = -0.15            #stretch , cm

from math import pi
#Calculations
w = -k*(dl**2-0)/2

#Results
print 'Part d: Work done stretching th fiber is %4.2f J'%w
Part a: Work done in expansion is  -16.2 kJ
Part b: Work done in expansion of bubble is -1.73 J
Part c: Work done in paasing the cuurent through coil is 1.39 kJ
Part d: Work done stretching th fiber is -1.12 J

Example Problem 2.2, Page Number 20

In [2]:
#Variable Declaration  
m = 100.0            #Mass of water, g 
T = 100.0            #Temperature of water, °C
Pext = 1.0           #External Pressure on assembly, bar
x = 10.0             #percent of water vaporised at 1 bar,-
i = 2.00             #current through heating coil, A
v = 12.0             #Voltage applied, v
t = 1.0e3            #time for which current applied, s 
rhol = 997           #Density of liquid, kg/m3
rhog = 0.59          #Density of vapor, kg/m3

#Calculations
q = i*v*t
vi = m/(rhol*100)*1e-3
vf = m*(100-x)*1e-3/(rhol*100) + m*x*1e-3/(rhog*100)
w = -Pext*(vf-vi)*1e5
#Results
print 'Heat added to the water %4.2f kJ'%(q/1000)
print 'Work done in vaporizing liquid is %4.2f J'%w
Heat added to the water 24.00 kJ
Work done in vaporizing liquid is -1703.84 J

Example Problem 2.3, Page Number 22

In [3]:
#Variable Declaration  Part d
m = 1.5              #mass of water in surrounding, kg 
dT = 14.2            #Change in temperature of water, °C or K
cp = 4.18            #Specific heat of water at constant pressure, J/(g.K)

#Calculations
qp = m*cp*dT

#Results
print 'Heat removed by water at constant pressure %4.2f kJ'%qp
Heat removed by water at constant pressure 89.03 kJ

Example Problem 2.4, Page Number 28

In [4]:
from math import log

#Variable declaration
n = 2.0          #moles of ideal gas
R = 8.314        #Ideal gas constant, bar.L/(mol.K)
#For reverssible Isothermal expansion 
Pi1 = 25.0       #Initial Pressure of ideal gas, bar
Vi1 = 4.50       #Initial volume of ideal gas, L
Pf1 = 4.50       #Fianl Pressure of ideal gas, bar
Pext = 4.50      #External pressure, bar 
Pint = 11.0      #Intermediate pressure, bar

#Calcualtions reverssible Isothermal expansion 
T1 = Pi1*Vi1/(n*R)
Vf1 = n*R*T1/Pf1
w = -n*R*T1*log(Vf1/Vi1)

#Results
print 'For reverssible Isothermal expansion'
print 'Work done = %4.2e J'%w

#Calcualtions Single step irreverssible expansion 

w = -Pext*1e5*(Vf1-Vi1)*1e-3

#Results
print 'For Single step reverssible expansion'
print 'Work done = %4.2e J'%w

#Calcualtions Two step irreverssible expansion 
Vint = n*R*T1/(Pint)
w = -Pint*1e5*(Vint-Vi1)*1e-3 - Pf1*1e5*(Vf1-Vint)*1e-3

#Results
print 'For Two step reverssible expansion'
print 'Work done = %4.2e J'%w
For reverssible Isothermal expansion
Work done = -1.93e+02 J
For Single step reverssible expansion
Work done = -9.22e+03 J
For Two step reverssible expansion
Work done = -1.29e+04 J

Example Problem 2.5, Page Number 32

In [5]:
from math import log

#Variable declaration
n = 2.5          #moles of ideal gas
R = 0.08314      #Ideal gas constant, bar.L/(mol.K)
cvm = 20.79      #Heat Capacity at constant volume, J/(mol.K)

p1 = 16.6       #Pressure at point 1, bar
v1 = 1.00       #Volume at point 1, L
p2 = 16.6       #Pressure at point 2, bar
v2 = 25.0       #Volume at point 2, L 
v3 = 25.0       #Volume at point 3, L

#Calculations
T1 = p1*v1/(n*R)
T2 = p2*v2/(n*R)
T3 = T1         #from problem statement
        #for path 1-2
DU12 = n*cvm*(T2-T1)
w12 = -p1*1e5*(v2-v1)*1e-3
q12 = DU12 - w12
DH12 = DU12 + n*R*(T2-T1)*1e2

        #for path 2-3
w23 = 0.0
DU23 = q23 = n*cvm*(T3-T2)
DH23 = -DH12


        #for path 3-1
DU31 = 0.0       #Isothemal process
DH31 = 0.0
w31 = -n*R*1e2*T1*log(v1/v3)
q31 = -w31

DU = DU12+DU23+DU31
w = w12+w23+w31
q = q12+q23+q31
DH = DH12+DH23+DH31

#Results
print 'For Path       q         w           DU            DH         '
print '1-2       %7.2f  %7.2f    %7.2f     %7.2f'%(q12,w12,DU12,DH12)
print '2-3       %7.2f    %7.2f   %7.2f    %7.2f'%(q23,w23,DU23,DH23)
print '3-1        %7.2f    %7.2f     %7.2f       %7.2f'%(q31,w31,DU31,DH31)
print 'Overall    %7.2f  %7.2f     %7.2f       %7.2f'%(q,w,DU,DH)
print 'all values are in J'
For Path       q         w           DU            DH         
1-2       139463.96  -39840.00    99623.96     139463.96
2-3       -99623.96       0.00   -99623.96    -139463.96
3-1        -5343.33    5343.33        0.00          0.00
Overall    34496.67  -34496.67        0.00          0.00
all values are in J

Example Problem 2.6, Page Number 34

In [6]:
#Variable Declaration  Part d
n = 2.5          #moles of ideal gas
R = 8.314        #Ideal gas constant, J/(mol.K)
cvm = 12.47      #Heat Capacity at constant volume, J/(mol.K)

pext = 1.00      #External Pressure, bar
Ti = 325.        #Initial Temeprature, K
pi = 2.50        #Initial Pressure, bar
pf = 1.25        #Final pressure, bar 

#Calculations  Adiabatic process q = 0; DU = w
q = 0.0     
Tf = Ti*(cvm + R*pext/pi)/(cvm + R*pext/pf )
DU = w = n*cvm*(Tf-Ti)
DH = DU + n*R*(Tf-Ti)

#Results
print 'The final temperature at end of adiabatic procees is %4.1f K'%Tf
print 'The enthalpy change of adiabatic procees is %4.1f J'%DH
print 'The Internal energy change of  adiabatic procees is %4.1f J'%DU
print 'The work done in expansion of adiabatic procees is %4.1f J'%w
The final temperature at end of adiabatic procees is 268.5 K
The enthalpy change of adiabatic procees is -2937.0 J
The Internal energy change of  adiabatic procees is -1762.2 J
The work done in expansion of adiabatic procees is -1762.2 J

Example Problem 2.7, Page Number 35

In [7]:
from math import log, exp

#Variable Declaration  Part d
h1 = 1000.0          #initial Altitude of cloud, m 
hf = 3500.0          #Final Altitude of cloud, m 
p1 = 0.802           #Pressure at h1, atm 
pf = 0.602           #Pressure at hf, atm
T1 = 288.0           #Initial temperature of cloud, K
cp = 28.86           #Specific heat of air, J/mol.K
R = 8.314            #Gas constant, J/mol.K

#Calculations
Tf = exp(-(cp/(cp-R)-1)/(cp/(cp-R))*log(p1/pf))*T1
#Results
print 'Final temperature of cloud %4.1f K'%Tf
if Tf < 273:
    print 'You can expect cloud'
else:
    print 'You can not expect cloud'
Final temperature of cloud 265.2 K
You can expect cloud