#calculate the work done
#Initialization of variables
p1=100 #psia
p2=14.7 #psia
k=1.4
T1=700 #R
R=10.73/29.
V=50
cv=0.171
cp=0.24
R2=1.986/29.
#calculations
T2=T1/ (p1/p2)**((k-1)/k)
m1=p1*V/(R*T1)
m2=p2*V/(R*T2)
Wrev= cv*(m1*T1 - m2*T2) - (m1-m2)*(T2)*cp
#results
print '%s %d %s' %("Work done in case 1 =",Wrev,"Btu")
#calculate the Engine efficiency and Effectiveness
#Initialization of variables
p1=400 #psia
t1=600 #F
h1=1306.9 #Btu/lbm
b1=480.9 #Btu/lbm
p2=50 #psia
h2=1122 #Btu/lbm
h3=1169.5 #Btu/lbm
b3=310.9 #Btu/lbm
#calculations
print '%s' %("All the values are obtained from Mollier chart,")
dw13=h1-h3
dw12=h1-h2
dasf=b3-b1
etae=dw13/dw12*100
eta=abs(dw13/dasf)*100
dq=dw13+dasf
#results
print '%s %.1f %s' %("Engine efficiency =",etae," percent")
print '%s %.1f %s' %("\n Effectiveness =",eta," percent")
print '%s %.1f %s' %("\n Loss of available energy =",dq," Btu/lbm")
#calculate the friction of the process per pound of air
#Initialization of variables
p1=100. #psia
p2=10. #psia
n=1.3
T1=800. #R
cv=0.172
R=1.986/29
#calculations
T2=T1*(p2/p1)**((n-1)/n)
dwir=cv*(T1-T2)
dwr=R*(T2-T1)/(1-n)
dq=dwr-dwir
#results
print '%s %.1f %s' %("The friction of the process per pound of air =",dq," Btu/lbm")
#Calculate the Friction
#Initialization of variables
ms=10 #lbm
den=62.3 #lbm/ft^3
A1=0.0218 #ft^2
A2=0.00545 #ft^2
p2=50. #psia
p1=100. #psia
gc=32.2 #ft/s^2
dz=30. #ft
#calculations
V1=ms/(A1*den)
V2=ms/(A2*den)
df=-144./den*(p2-p1) - (V2**2 -V1**2)/(2*gc) - dz
#results
print '%s %.1f %s' %("Friction =",df,"ft-lbf/lbm")