#Calculate the work and heat of vaporization of water
#initialization of varaibles
P=100. #psia
hfg=888.8 #B/lb
#calculations
print '%s' %("From steam tables,")
vg=4.432 #cu ft/lb
vf=0.001774 #cu ft/lb
W=P*(vg-vf)*144
ufg=807.1 #B/lb
W=hfg-ufg
sfg=1.1286
Q=788*sfg #Heat
#results
print '%s %.1f %s' %("Work done = ",W,"B/lb")
print '%s %d %s' %("\n Heat of vaporization of water =",Q,"B/lb")
#caclulate the pressure, temperature and enthalpy
#initialization of varaibles
s=1.6315 #B/lb R
#calculations
print '%s' %("From table 1 ")
h=1180.6 #B/lb
t=302.92 #F
p=70 #psia
#results
print '%s %d %s' %("Pressure = ",p,"psia")
print '%s %.2f %s' %("\n Temperature =",t,"F")
print '%s %.1f %s' %("\n Enthalpy =",h,"B/lb")
#calculate the Internal energy of the gas
#initialization of varaibles
T=250. #F
print '%s' %("From table 1,")
p=29.825 #psia
hg=1164 #B/lb
vg=13.821 #cu ft/lb
#calculations
ug=hg-(p)*144*vg/778.
#results
print '%s %.1f %s' %("Internal energy of the gas = ",ug,"B/lb")
#Calculate the specific volume, Enthalpy and Entropy of the gas
#initialization of varaibles
x=0.4
P=100. #psia
#calculations
y=1-x
print '%s' %("From table 2,")
vf=0.01774
vg=4.432
vx=x*vf+y*vg
hf=298.4
hfg=888.8
hx=hf+y*hfg
sg=1.6026
sfg=1.1286
sx=sg-x*sfg
#results
print '%s %.3f %s' %("Specific volume = ",vx,"cu ft/lb")
print '%s %.1f %s' %("\n Enthalpy =",hx,"B/lb")
print '%s %.4f %s' %("\n Entropy = ",sx,"B/lb R")
#Calculate the enthalpy of the gas
#initialization of varaibles
x=0.97
P=100. #psia
#calculations
print '%s' %("From table 2,")
hf=298.4
hfg=888.8
hx=hf+x*hfg
hg=1187.2
hx2=hg-(1-x)*hfg
#results
print '%s %d %s' %("\n Enthalpy =",hx,"B/lb")
print '%s %.1f %s' %("\n Accurate Enthalpy =",hx2,"B/lb")
#Calculate the specific volume and enthalpy of the process
#initialization of varaibles
s=1.7050 #B/lb R
#calculations
print '%s' %("From table 2,")
sx=1.7050
sg=1.7549
sfg=1.4415
dx=(sg-sx)/sfg
hg=1150.8
hfg=969.7
hx=hg-dx*hfg
vg=26.29
vfg=26.27
vx=vg-dx*vfg
#results
print '%s %.2f %s' %("Specific volume = ",vx,"cu ft/lb")
print '%s %.1f %s' %("\n Enthalpy =",hx,"B/lb")
#calculate the enthalpy required
#initialization of varaibles
P=150 #psia
T=400 #F
#calculations
print '%s' %("From table 3,")
h=1219.4 #B/lb
#results
print '%s %.1f %s' %("Enthalpy =",h,"B/lb")
#Calculate the temperature of steam
#initialization of varaibles
en=1303.7 #B/lb
P=300 #psia
#calculations
print '%s' %("Given hg is less than h, steam is superheated. T=580 F")
T=580 #F
#results
print '%s %d %s' %("Temperature =",T,"F")
#Calculate the Enthalpy and Volume of the gas
#initialization of varaibles
import math
T=100. #F
P=1000. #psia
#calculations
print '%s' %("From table 4")
dvf=-5.1*math.pow(10,-5)
dhf=2.7
vf=0.01613
hf=67.97
v=vf+dvf
h=hf+dhf
#results
print '%s %.2f %s' %("Enthalpy =",h,"B/lb")
print '%s %.5f %s' %("\n Volume = ",v,"cu ft/lb")
#calculate the Quality of steam
#initialization of varaibles
h1=1183.2 #B/lb
hg=1198.4 #B/lb
hfg=843.
#calculations
x=1- (hg-h1)/hfg
#results
print '%s %.3f' %("Quality =",x)