In [1]:

```
from __future__ import division
#input data
P01=1#initial pressure of a fluid in bar
P02=10#final pressure of a fliud in bar
T01=283#initial total temperature in K
ntt=0.75#total-to-total efficiency
d=1000#density of water in kg/m**3
r=1.4#ratio of specific heats for air
Cp=1.005#specific at heat at constant pressure in kJ/kg.K
#calculations
h0s1=(1/d)*(P02-P01)*10**2#enthalpy in kJ/kg
h01=(h0s1/ntt)#enthalpy in kJ/kg
T02s=T01*(P02/P01)**((r-1)/r)#temperature in K
h0s2=(Cp*(T02s-T01))#enthalpy in kJ/kg
h02=(h0s2/ntt)#enthalpy in kJ/kg
#output
print '''The work of compression for adiabatic steady flow per kg of fliud if -
(a)The fliud is liquid water is %3.1f kJ/kg
(b)The fliud is air as a perfect gas is %3.2f kJ/kg'''%(h01,h02)
```

In [2]:

```
#input data
P01=7#Total initial pressure of gases at entry in bar
T01=1100#Total initial temperature in K
P02=1.5#Total final pressure of gases at exit in bar
T02=830#Total final temperature in K
C2=250#Exit velocity in m/s
r=1.3#Ratio of specific heats of gases
M=28.7#Molecular weight of gases
R1=8.314#Gas constant of air in kJ/kg.K
#calculations
T02s=T01*(P02/P01)**((r-1)/r)#Final temperature in K
ntt=((T01-T02)/(T01-T02s))#Total-to-total efficiency
R=(R1/M)#Gas constant of given gas in kJ/kg.K
Cp=((r*R)/(r-1))#Specific heat of given gas at constant pressure in kJ/kg.K
T2s=(T02s-((C2**2)/(2*Cp*1000)))#Temperature in isentropic process at exit in K
nts=((T01-T02)/(T01-T2s))#Total-to-static efficiency
#output
print '''The total-to-total efficiency of gases is %0.2f %%
The total-to-static efficiency of gases is %0.1f %%'''%(ntt*100,nts*100)
```

In [3]:

```
#input data
h0=6#Change in total enthalpy in kJ/kg
T01=303#Total inlet temperature of fluid in K
P01=1#Total inlet pressure of fliud in bar
Cp=1.005#specific at heat at constant pressure in kJ/kg.K
ntt=0.75#Adiabatic total-to-total efficiency
r=1.4#ratio of specific heats for air
#calculations
T02=T01+(h0/Cp)#Exit total termperature of fliud in K
P1=(1+((ntt*h0)/(Cp*T01)))**(r/(r-1))#Total pressure ratio of fluid
h0s=ntt*h0#Change in enthalpy of process in kJ/kg
P0=((h0s*1000)/100)#Change in pressure in bar
P02=P0+P01#Total outlet pressure of fliud in bar
P2=(P02/P01)#Total pressure ratio of fliud
#output
print '''(a)The exit total temperature of fliud is %3.2f K
(b)The total pressure ratio if:
(1)The fliud is air is %3.3f
(2)The fliud is liquid water is %3.0i'''%(T02,P1,P2)
```

In [4]:

```
#input data
W=100#Output power developed in kW
Q=0.1#Flow through device in m**3/s
d=800#Density of oil in kg/m**3
ntt=0.75#Total-to-total efficiency
C1=3#inlet flow velocity of oil in m/s
C2=10#outlet flow velocity of oil in m/s
#calculations
m=d*Q#Mass flow rate of oil in kg/s
h0=-(W/m)#Change in total enthalpy in kJ/kg
h0s=(h0/ntt)#Isentropic change in total enthalpy in kJ/kg
P0=((d*h0s)*(1/100))#Change in total pressure of oil in bar
P=P0-((d/(2000*100))*(C2**2-C1**2))#Change in static pressure in bar
#output
print '''The change in total pressure of oil is %3.1f bar
The change in static presure is %3.1f bar'''%(P0,P)
```

In [5]:

```
#input data
N=4#Number of stages in turbine handling
P=0.4#Stagnation presure ratio between exit and inlet of each stage
ns1=0.86#Stage efficiency of first and second stages
ns2=0.84#Stage efficiency of third and fourth stages
r=1.4#ratio of specific heats for air
#calculations
u=1-(P)**((r-1)/r)#constant
T03=(1-(u*ns1))**2#Temperature after the end of first two stages in (K*Cp*T01) where Cp is specific at heat at constant pressure in kJ/kg.K and T01 is initial temperature at entry of stage 1 in K
W12=u*(1+(1-(u*ns1)))*ns1#Actual work output from first two stages in (kW*Cp*T01)
W34=T03*u*(1+(1-(u*ns2)))*ns2#Actual work output from last two stages in (kW*Cp*T01)
W=(W12+W34)#Total actual work output from turbine in (kW*Cp*T01)
Ws=1-(1-u)**N#Total isentropic work due to single stage compressor in (kW*Cp*T01)
n=(W/Ws)#Overall turbine efficiency
#output
print 'the overall efficiency of the turbine is %.1f %%'%(n*100)
```

In [6]:

```
from __future__ import division
from math import log10
#input data
P=1400#Pressure developed by compressor in mm W.G
P1=1.01#Initial pressure of air in bar
T1=305#Initial temperature of air in K
T2=320#Final temperature of air in K
P=1400*9.81*10**-5#Pressure developed by compressor in bar
r=1.4#ratio of specific heats for air
#calculations
P2=P1+P#Final pressure of air in bar
T2s=T1*(P2/P1)**((r-1)/r)#Isentropic temperature at exit in K
nc=((T2s-T1)/(T2-T1))#compressor efficiency
np=((r-1)/r)*((log10(P2/P1))/(log10(T2/T1)))#Infinitesimal stage efficiency
#output
print '''(a)The compressor efficiency is %0.2f %%
(b)The infinitesimal stage efficiency is %0.2f %%'''%(nc*100,np*100)
```

In [7]:

```
#input data
P1=1.01#Input pressure to compressor in bar
T1=305#Input temperature to compressor in K
P2=3#Output pressure from compressor in bar
r=1.4#ratio of specific heats for air
nc=0.75#compressor efficiency
#calculations
T2s=T1*(P2/P1)**((r-1)/r)#Isentropic output temperature from compressor in K
T2=T1+((T2s-T1)/nc)#Actual output temperature from compressor in K
np=((r-1)/r)*((log10(P2/P1))/(log10(T2/T1)))#Infinitesimal efficiency of compressor
#output
print 'The infinitesimal efficiency of the compressor is %0.1f %%'%(np*100)
```

In [8]:

```
#input data
P=2.2#Pressure ratio across a gas turbine
n=0.88#Efficiency of a gas turbine
T1=1500#Inlet temperature of the gas in K
r=1.4#ratio of specific heats for air
#calculations
T2s=T1*(1/P)**((r-1)/r)#Isentropic output temperature from gas turbine in K
T2=T1-(n*(T1-T2s))#actual output temperature from gas turbine in K
np=(r/(r-1))*((log10(T1/T2))/(log10(P)))#Polytropic efficiency of the turbine
#output
print 'The polytropic efficiency of the turbine is %0.1f %%'%(np*100)
```

In [9]:

```
# input data
P=1.3#Pressure ratio of stages
N=8#Number of stages
m =45#The flow rate through compressor in kg/s
nc=0.8#Overall efficiency of the compressor
P1=1#Initial pressure of the air at entry in bar
T1=308#Initial temperature of the air at entry in K
r=1.4#ratio of specific heats for air
#calculations
PN=(P)**8#Overall pressure ratio of all 8 stages
TN=PN**((r-1)/r)#Overall temperature ratio of all 8 stages
TN1s=TN*T1#Ideal exit temperature in K
TN1=((TN1s-T1)/nc)+T1#Actual exit temperature in K
PN1=PN*P1#Actual exit pressure in bar
np=((r-1)/r)*((log10(PN1/P1))/(log10(TN1/T1)))#Polytropic efficiency of the cycle
ns=((((P)**((r-1)/r))-1)/(((P)**((r-1)/(r*np)))-1))#The stage efficiency of the cycle
#output
print '''(a)The state of air at compressor exit are-
(1)actual temperature is %3.1f K
(2)actual pressure is %3.2f bar
(b)The polytropic efficiency of the cycle is %0.f %%
(c)The stage efficiency of the cycle is %0.2f %%'''%(TN1,PN1,np*100,ns*100)
```

In [10]:

```
from math import log10
#input data
P=11#Overall pressure ratio in three stages of a gas turbine
nt=0.88#Overall efficiency in three stages of a gas turbine
T1=1500#Temperature at inlet of a gas turbine in K
r=1.4#ratio of specific heats for air
#calculations
T0=nt*T1*(1-(1/P)**((r-1)/r))#Overall change in temperature in all stages in K
TN1=T1-T0#Temperature at final stage of a gas turbine in K
np=((r/(r-1))*log10(T1/TN1))/(log10(P))#Overall polytropic efficiency of the gas turbine
Ts=T0/3#Individual stage change in temperature in K
T2=T1-Ts#Exit temperature at the end of first stage in K
P1=(T1/T2)**(r/(np*(r-1)))#Pressure ratio at first stage of gas turbine
ns1=((1-(1/P1)**((np*(r-1))/r))/(1-(1/P1)**((r-1)/r)))#Stage efficiency of first stage
T3=T2-Ts#Exit temperature at the end of second stage in K
P2=(T2/T3)**(r/(np*(r-1)))#Pressure ratio at second stage of gas turbine
ns2=((1-(1/P2)**((np*(r-1))/r))/(1-(1/P2)**((r-1)/r)))#Stage efficiency of second stage
T4=T3-Ts#Exit temperature at the end of third stage in K
P3=(T3/T4)**(r/(np*(r-1)))#Pressure ratio at the third stage of gas turbine
ns3=((1-(1/P3)**((np*(r-1))/r))/(1-(1/P3)**((r-1)/r)))#Stage efficiency of third stage
#output
print '''(a)The values for first stage are -
(1)Pressure ratio is %3.2f
(2)stage efficiency is %0.2f %%
(b)The values of second stage are -
(1)Pressure ratio is %3.3f
(2)Stage efficiency is %0.1f %%
(c)The values of third stage are -
(1)Pressure ratio is %3.2f
(2)Stage efficiency is %0.2f'''%(P1,ns1*100,P2,ns2*100,P3,ns3*100)
```

In [11]:

```
#input data
N=4#Number of stages in compressor
m=45#mass flow rate of air delivered by compressor in kg/s
P1=1.2#Pressure ratio at first stage
ns=0.65#Stage efficiency of first stage
r=1.4#ratio of specific heats for air
Cp=1.005#specific at heat at constant pressure in kJ/kg.K
T1=293#Temperature of air at inlet in K
#calculations
P=(P1)**N#Overall pressure in all 4 stages
np=((r-1)/r)*((log10(P1))/(log10((((P1**((r-1)/r))-1)/ns)+1)))#Polytropic efficiency of the cycle
nc=(((P1**(N*((r-1)/r)))-1)/((P1**(N*((r-1)/(r*np))))-1))#Overall efficiency of the cycle
TN1=T1*((P1**(N))**((r-1)/(r*np)))#Final temperature at the exit of the compressor at final stage in K
W=m*Cp*(TN1-T1)#Power required to drive the compressor in kW
#output
print '''(a)The overall pressure ratio of the process is %3.1f
(b)The overall efficiency of the process is %0.2f %%
(c)The power required to drive the compressor is %3.2f kW'''%(P,nc*100,W)
# the answer in the textbook is not correct.
```

In [12]:

```
#input data
P0=0.2*9.81*(10**3)*(10**-5)#Total increase in pressure in bar
P01=1.04#Total inlet pressure of air in bar
T01=291#Total inlet temperature of air in K
ntt=0.72#Total-to-total efficiency of the process
r=1.4#ratio of specific heats for air
Cp=1.005#specific at heat at constant pressure in kJ/kg.K
#calculations
P2=P0+P01#The total exit pressure in bar
T02=((((P2/P01)**((r-1)/r)-1)*T01)/ntt)+T01#Total temperature at the outlet in K
h0=Cp*(T02-T01)#Actual change in total enthalpy in kJ/kg
h0s=h0*ntt#Isentropic change in total enthalpy in kJ/kg
#output
print '''(a)The total exit pressure is %3.4f bar
and the total exit temperature is %3.2f K
(b)The actual change in total enthalpy is %3.3f kJ/kg
and the isentropic change in total enthalpy is %3.3f kJ/kg'''%(P2,T02,h0,h0s)
```

In [13]:

```
#input data
P=5#Pressure ratio in the process
ntt=0.8#Total-to-total efficiency of the process
m=5#Air flow rate through turbine in kg/s
W=500#Total power output from the turbine in kW
r=1.4#ratio of specific heats for air
Cp=1.005*10**3#specific at heat at constant pressure in J/kg.K
C2=100#Flow velocity of air in m/s
#calculations
T=(W*10**3)/(m*Cp)#Total change in temperature in the process in K
T02s=(1/P)**((r-1)/r)#Isentropic temperature at the outlet from turvine in (K*T01)
T01=(T/ntt)*(1/(1-0.631))#Inlet total temperature in K
T02=T01-T#Actual exit total temperature in K
T2=T02-((C2**2)/(2*Cp))#Actual exit static temperature in K
T02s1=T02s*T01#Isentropic temperature at the outlet from turbine in K
T2s=T02s1-((C2**2)/(2*Cp))#Actual isentropic temperature in K
nts=(T/(T01-T2s))#Total-to-static efficiency
#output
print '''(a)The inlet total temperature is %i K
(b)The actual exit total temperature is %3.1f K
(c)The actual exit static temperature is %3.1f K
(d)The total-to-static efficiency is %0.2f %%'''%(T01,T02,T2,nts*100)
```

In [14]:

```
from math import log
#input data
N=3#Number of stages in turbine
P=2#Pressure ratio of each stage
ns=0.75#Stage efficiency of each stage
T1=873#Initial temperature of air in K
m=25#Flow rate of air in kg/s
r=1.4#ratio of specific heats for air
Cp=1.005#specific at heat at constant pressure in J/kg.K
#calculations
np=(r/(r-1))*((log(1-(ns*(1-(1/P)**((r-1)/r)))))/(log(1/P)))#Polytropic efficiency of the process
nt=((1-(1/P)**(N*np*((r-1)/r)))/(1-(1/P)**(N*((r-1)/r))))#Overall efficiency of the turbine
W=m*Cp*T1*(1-(1/P)**(N*np*((r-1)/r)))#Power developed by the turbine in kW
RF=nt/ns#Reheat factor of the process
#output
print '''(a)The overall efficiency of the turbine is %0.2f %%
(b)The power developed by the turbine is %i kW
(c)The reheat factor of the process is %3.2f'''%(nt*100,W,RF)
#comments
# the answer in the textbook is not correct.
```