In [5]:

```
from __future__ import division
import math
# Initialization of Variable
V = 0.5 #volume in m3
P1 = 1 #pressure bar
P2 = 1.5 #pressure bar
vf1 = 1.0432/1000 # m3/kg
vf2=1.0528/1000 # m3/kg
vg1 = 1.694 # in m3/kg
vg2 = 1.159 # in m3/kg
x1 = 0.5
# calculations:
#The specific volume at state 1 and 2
v1 = vf1 + x1*(1.694-vf1)
v2 = v1
#from table T-3
T1 = 99.63; # in deg C
T2 = 111.4
# the total mass, m
m = V/v1
# the mass of vapor at state 1 and 2
mg1 = x1*m
x2 = (v1-vf2)/(vg2-vf2)
mg2 = x2*m
#if heating continued, from table:
vg3 = 0.8475 #m3/kg
p3 = 2.11 # bar
#Results
print "a) temperature = ", round(T1,2),"degC at stage 1 and ", round(T2,2),"degC at stage 2"
print "b) mass of vapor =", round(mg1,3)," kg at stage 1 and",round(mg2,3),"kg at stage 2"
print "c) If heating continued, when the container holds only saturated vapor then pressure =", round(p3,2),"bar"
```

In [3]:

```
from __future__ import division
import math
# Initialization of Variable
m = 0.1; # mass in lb
P2=20 #pressure in lbf/in2
T2 = 65 # in deg F
# calculations:
# from table, specific volumes
vg1=2.2661
v1 = vg1
#volumes occupied by the refrigerant at states 1 and 2
V1 = m*v1
# from table, specific volume at stage 2
v2=2.6704;
V2 =m*v2
# work
W = P2*(V2-V1)*144/778 # in Btu
#Results
print "a) volumes occupied by the refrigerant at states 1 and 2 are", round(V1,4),"ft3 and ", round(V2,4),"ft3 respectively"
print "b) work for the process is", round(W,4),"Btu"
```

In [6]:

```
from __future__ import division
import math
# Initialization of Variable
V=10.0# volume ft3
T1 = 212 # indeg F
P2 = 20 # pressure in lbf/in2
#calculations:
# from table, specific volume
v1 = 26.8 # in ft3/lb
u1=1077.6 #btu/lb
v2 = v1
# therefore
u2 = 1161.6 # in Btu/lb
T2 = 445 # deg F
# work
m = V/v1
W = -1*m*(u2-u1)
#Results
print "a) Temperature is", T2," deg F"
print "b) work during the process is", round(W,1)," Btu"
```

In [9]:

```
from __future__ import division
import math
# Initialization of Variable
P1 = 10 #pressure bar
T1 = 400 # temp in deg C
T2 = 150 # temp in deg C
vf3 = 1.0905E-3 # in m3/kg
vg3 = 0.3928 # in m3/kg
# calculations:
#From Table, specific volume at state 1 and 2
v1 = 0.3066 #in m3/kg
u1 = 2957.3 # in kJ/kg
v2 = 0.1944 # m3/kg
#work
Wm = P1*(v2-v1)*10**2
#heat transfer
v3 = v2
x3 = (v3 - vf3)/(vg3 - vf3)
#from Table
uf3 = 631.68 # kJ/kg
ug3 = 2559.5 #kJ/kg
u3 = uf3 + x3*(ug3-uf3)
Qm = u3 - u1 + Wm
#Results
print "b)Work =",round(Wm,1),"kJ/kg"
print "c)Heat Transfer =",round(Qm,1),"kJ/kg"
#answer approximated in book
```

In [10]:

```
from __future__ import division
import math
# Initialization of Variable
P1 = 20E6 # pressure pa
T1 = 520 # temp in deg C
T2 = 400 #temp deg C
M = 18.02 #molar mass in kg/kmol
Rbar = 8314 #in Nm/kmol-K
#calculations:
R = Rbar/M
#From Table T-1
Tc = 647.3 #in K
Pc = 22.09E6 # in Pa
#reduced Temp
Tr1 = (T1 + 273)/Tc
#reduced Pressure
Pr1 = P1/Pc
#compressibility factor
Z = 0.83
#specific volume
v1 = Z*Rbar*(T1+273)/(M*P1)
#Constant refuced value of spec vol
vr = v1*Pc/(R*Tc)
#at state 2, reduced Temp
Tr2 = (T2+273)/Tc
# from compressibility chart
Pr2 = 0.69
P2 = Pc*Pr2
#Results
print "a) specific volume of the water vapor at initial stage is", round(v1,4),"m3/kg"
print "b) Pressure at final stage is", round(P2/1E6,2),"Mpa"
```

In [11]:

```
from __future__ import division
import math
# Initialization of Variable
m = 1 #mass in lb
P1 = 1 # atm
T1 = 540 # in deg R
P2 = 2 # in Atm
R = 1545/28.97
#calculations:
#Using pv=RT, the temperature at state 2 is
T2 = P2*T1/P1
#Since pv=RT, the specific volume at state 3 is
v3 = R*T2/(P1*14.7*144)
#Results
print "b)temperature at state 2 is", round(T2,0),"degR"
print "c)specific volume at state 3 is ", round(v3,1) ,"ft3/lb"
```

In [12]:

```
from __future__ import division
import math
# Initialization of Variable
m = 2 # mass lb
T1 = 540 #in degR
P1 = 1 # in atm
T2 = 840 #in degR
P2 = 6 # in atm
Q = -20 # in Btu
# calculations:
#From Table T-9E
u1 = 92.04 # in Btu/lb
u2 = 143.98 # in Btu/lb
#work
W = Q - m*(u2-u1)
#Results
print "work done during the process is", round(W,1),"Btu"
```

In [13]:

```
from __future__ import division
import math
# Initialization of Variable
m1co = 2 #kg
T1co = 77 # degC
P1co = 0.7 #bar
m2co = 8 #kg
T2co = 27 # degC
P2co = 1.2 #bar
Tf = 42 # degC
Cv = 0.745 #kJ/kg-K
#calculations:
#final pressure
Pf = (m1co + m2co)*Tf/((m1co*T1co/P1co) + (m2co*T2co/P2co))
#heat
Q = m1co*Cv*(Tf-T1co) + m2co*Cv*(Tf-T2co)
#Results
print "a)final pressure is", round(Pf,2),"bar"
print "b)heat transfer for the process is", round(Q,2),"kJ"
```

In [14]:

```
from __future__ import division
import math
# Initialization of Variable
P1 = 1 #atm
T1 = 70 # degF
P2 = 5 #atm
n = 1.3
R = 1.986/28.97 #Btu/lb-degR
#calculations:
#Temp at 1 in rankine
T1r = (((T1 - 32)*5/9)+273)*1.8
#temp at 2 in Rankine
T2r = T1r*(P2/P1)**((n-1)/n)
#work per unit mass
Wm = R*(T2r-T1r)/(1-n)
#heat per unit mass
#from table T-9E
u2 = 131.88 #Btu/lb
u1 = 90.33 #Btu/lb
Qm = Wm + (u2-u1)
#Results
print "Work per unit mass is", round(Wm,2),"Btu/lb"
print "heat transfer per unit mass is",round(Qm,2),"Btu/lb"
# answer wrong in book
```