# Chapter 5 - First Law of Thermodynamics¶

## Example 1 - Pg 59¶

In [1]:
#Calculate the change in internal energy
#initialization of varaibles
V1=10 #cu ft
P1=15 #psia
V2=5 #cu ft
H=34.7 #Btu
#calculations
W=P1*(V2-V1)*144
dE=-H-W/778.
#results
print '%s %.1f %s' %("Internal energy change =",dE,"Btu")

Internal energy change = -20.8 Btu


## Example 2 - Pg 59¶

In [2]:
#Calculate the work done and the change in Internal energy
#initialization of varaibles
dT=35 #F
H=34 #Btu
cv=1.2 #B/lb F
m= 2 #lb
#calculations
U=cv*dT*m
W=H-U
#results
print '%s %d %s' %("Work done =",W,"Btu")
print '%s %.1f %s' %("\n Internal energy change =",U,"Btu")

Work done = -50 Btu

Internal energy change = 84.0 Btu


## Example 3 - Pg 60¶

In [3]:
#Calculate the change in internal energy in both cases
#initialization of varaibles
p=500 #psia
V2=0.9278 #cu ft
V1=0.0197 #cu ft
h2=1204.4 #B/lb
h1=449.4 #B/lb
#calculations
W=p*(V2-V1)*144.
du=h2-h1-144*p*(V2-V1)/778.
du2=h2-h1-W/778.
#results
print '%s %.1f %s' %("Change in internal energy = ",du,"Btu")
print '%s %.1f %s' %("\n Method 2, Internal energy change = ",du2,"Btu")

Change in internal energy =  671.0 Btu

Method 2, Internal energy change =  671.0 Btu


## Example 4a - Pg 61¶

In [4]:
#Calculate the heat liberated
#initialization of varaibles
import math
P1=75. #psia
P2=15. #psia
V1=6. #cu ft
g=1.2 #gamma
m=3. #lb
#calculations
V2=V1*math.pow((P1/P2),(1/g))
U=0.48*(P2*V2-P1*V1)
W=(P2*V2-P1*V1)*144./((1-g)*778.)
Q=U+W
#results
print '%s %.3f %s' %("Heat = ",Q,"Btu")
#The answer given in textbook is wrong. please check using a calculator

Heat =  47.162 Btu


## Example 4b - Pg 62¶

In [4]:
#Calculate the net work done
#initialization of varaibles
import math
P1=75. #psia
P2=15. #psia
V1=6. #cu ft
g=1.2 #gamma
m=3 #lb
#calculations
Q=30 #Btu
V2=V1*math.pow((P1/P2),(1/g))
U=0.48*(P2*V2-P1*V1)
W=Q-U
#results
print '%s %.1f %s' %("Work done =",W,"  Btu")
#The answer given in textbook is wrong. please check using a calculator

Work done = 80.8   Btu