#Find the efficiency, and the work per pound of fluid circulated, for a
#Baryton cycle working between pressures of 15 psia and 75 psia, if the
#minimum temp. in the cycle is 550 R and the max. temp is 1700R?
import math
#initialisation of variables
p= 15. #psia
p1= 75. #psia
T= 550. #R
T1= 1700. #R
k= 1.4
#CALCULATIONS
Ta= T*math.pow((p1/p),((k-1)/k)) #Temperature at A
Tc= T1/(math.pow((p1/p),((k-1)/k))) #Temperature at C
cp= 0.24
Q1= cp*(T1-Ta) #Heat in 1
Q2= cp*(Tc-T) #Heat in 2
Wnet= Q1-Q2 #Work done
n= Wnet/Q1 #efficiency
hb= 422.59 #Btu/lb
hc= 269.27 #Btu/lb
ha= 208.41 #Btu/lb
hd= 131.46 #btu/lb
Q1i= hb-ha #Heat in 1 case 2
Q2i= hc-hd #Heat in 2 case 2
Wnet1= Q1i-Q2i #work in case 2
n1= Wnet1/Q1i #efficiency 2
#RESULTS
print '%s %.2f' %('Efficiency = ',n)
print '%s %.3f' %( 'Efficiency in case 2= ',n1)
raw_input('press enter key to exit')
#Repeat for example 1 for a cycle using a regenerator of 75% effectiveness
#initialisation of variables
import math
p= 15. #psia
p1= 75. #psia
T= 550 #R
T1= 1700 #R
k= 1.4
n= 75.
cp= 0.24
#CALCULATIONS
Ta= T*math.pow((p1/p),((k-1)/k)) #Temperature at A
Tc= T1/(math.pow((p1/p),((k-1)/k))) #Temperature at C
Ta1= (n/100.)*(Tc-Ta)+Ta #Temperature at A in case 2
Tc1= Ta+Tc-Ta1 #Temperature at C in case 2
Q1= cp*(T1-Ta1) #Heat in 1
Q2= cp*(Tc1-T) #heat in 2
Wnet= Q1-Q2 #Net work done
n1= Wnet/Q1 #Efficiency
#CALCULATIONS
print '%s %.2f' %('Efficiency = ',n1)
raw_input('press enter key to exit')
#Find the efficiency, air rate and back work ratio for a gas turbine plant
#of the following description. T=60 F, p1=15. p2/p1=6; macchine efficiences
#of compressor and turbine both 60%. LHV=18500. Turbine inlet temp=1450 F.
#initialisation of variables
h1= 124.27 #Btu/lb
Pr1= 1.2147 #psia
r= 6
p4= 15. #psia
p1= 15. #psia
h2s= 197.5 #Btu/lb
Wnet= 48.9 #Btu/lb air
hs= 18500 #Btu/lb
wfbywa= 0.0146 #lb fuel/lb sir
W= 2545 #Btu/lb air
dh=-91.5 #Btu/lb
Wc= 91.5 #Btu/lb air
#CALCULATIONS
n= Wnet/(wfbywa*hs) #Efficiency
n1= W/Wnet #Air rate
n2= Wc/Wnet #Back work ratio
#RESULTS
print '%s %.3f' %('Efficiency = ',n)
print '%s %.2f' %(' \n air rate (lb air/hphr) = ',n1)
print '%s %.2f' %(' \n back work ratio = ',n2)
raw_input('press enter key to exit')