In [2]:

```
from __future__ import division
from math import log
#Variable Declaration:
r = 6 #Compression ratio:
v = 0.15 #Swept volume(in m**3):
p1 = 98 #Pressure at the beginning of compression(in kPa):
T1 = 60+273.15 #Temperature at the beginning of compression(in K):
Q23 = 150 #Heat supplied(in kJ/kg):
Cp = 1 #Value of Cp(in kJ/kg):
Cv = 0.71 #Value of Cv(in kJ/kg):
#Calculations:
n = round(Cp/Cv,1) #Adiabatic compression factor:
R = Cp-Cv #Gas constant(in kJ/kg.K):
v2 = v/(r-1) #Volume at point 2(in m**3):
v1 = r*v2 #Total cylinder volume(in m**3):
m = p1*v1/(R*T1) #Mass(in kg):
p2 = p1*(v1/v2)**n #Pressure at point 2(in kPa):
T2 = p2*v2*T1/(p1*v1) #Temperature at state 2(in K):
T3 = Q23/(m*Cv)+T2 #Temperature at state 3(in K):
v3 = v2
p3 = p2*v2*T3/(v3*T2) #Pressure at point 3(in kPa):
v4 = v1
p4 = p3*(v3/v4)**n #Pressure at point 4(in kPa):
T4 = p4*v4*T3/(p3*v3) #Temperature at point 4(in K):
dS = m*Cv*log(T4/T1) #Entropy change(in kJ/K):
Q41 = m*Cv*(T4-T1) #Heat rejected(in kJ):
W = Q23-Q41 #Net work done(in kJ):
e = W/Q23 #Efficiency:
mep = W/v #Mean effective pressure(in kPa):
#Results:
print "Thermal efficiency: ",round(e*100,2),"%"
print "Mean effective pressure: ",round(mep,2),"kPa"
```

In [5]:

```
from __future__ import division
#Variable Declaration:
pa = 138 #Pressure at A(in kPa):
pb = 1380 #Pressure at B(in kPa):
nt = 0.5 #Thermal efficiency:
nm = 0.8 #Mechanical efficiency:
c = 41800 #Calorific value of fuel(in kJ/kg):
n = 1.4 #Adiabatic compressive index:
#Calculations:
r1 = (pb/pa)**(1/n) #Ratio of va to vb:
r = (7/8*r1-1/8)/(7/8-r1/8) #Compression ratio:
p = (r-1)/15+1 #Cut off ratio:
nd = 1-1/(r**(n-1)*n)*(p**n-1)/(p-1) #Air standard efficiency for Diesel cycle:
no = nd*nt*nm #Overall efficiency:
fc = 75*60*60/(no*c*10**2) #Fuel consumption,bhp/hr(in kg):
#Results:
print "Compression ratio: ",round(r,2)
print "Air standard efficiency: ",round(nd*100,2),"%"
print "Fuel consumption,bhp/hr: ",round(fc,3),"kg"
```

In [8]:

```
from __future__ import division
#Variable Declaration:
Q = 1700 #Total heat added(in kJ/kg):
p3 = 5000 #Maximum pressure(in kPa):
T1 = 100+273.15 #Temperature at the beginning of compression(in K):
p1 = 103 #Pressureat beginning of compression(in kPa):
Cp = 1.005 #Value of Cp(in kJ/kg.K):
Cv = 0.71 #Value of Cv(in kJ/kg.K):
n = 1.4 #Adiabatic index of compression: #For Otto cycle:
R = Cp-Cv #Gas constant(in kJ/kg.K):
m = 1 #Considernig 1 kg of air, volume at 1(in m**3):
#Calculations:
V1 = m*R*T1/p1
V2 = 0.18 #By solving, volume at 2(in m**3):
r = V1/V2 #Compression ratio:
no = 1-1/(r**(n-1)) #Otto cycle efficiency:
V21 = 0.122 #By calculating, volume at state 2': #For mixed cycle:
p21 = 2124.75 #kPa
T31 = 2082 #K
T21 = 884.8 #K
T41 = 2929.5 #K
V31 = V21
V41 = V31*T41/T31 #Volume at state 4(in m**3):
T5 = T41*(V41/V1)**(n-1) #Temperature at state 5(in K):
Q51 = Cv*(T5-T1) #Heat rejected in the process 5-1(in kJ):
nm = (Q-Q51)/Q #Efficiency of mixed cycle:
#Results:
print "Efficiency of Otto cycle: ",round(no*100,2),"%"
print "Efficiency of mixed cycle: ",round(nm*100,2),"%"
```

In [10]:

```
from __future__ import division
#Variable Declaration:
T3 = 1200 #Maximum temperature(in K):
T1 = 300 #Minimum temperature(in K):
n = 1.4 #Adiabatic compression ratio:
Cp = 1.005 #Value of Cp(in kJ/kg.K):
#Calculation:
rp = (T3/T1)**(n/(2*(n-1))) #Optimum pressure ratio for maximum work output:
T2 = T1*rp**((n-1)/n) #Temperature at state 2(in K):
T4 = T3*rp**((1-n)/n) #Temperature at state 4(in K):
Q23 = Cp*(T3-T2) #Heat supplied(in kJ/kg):
Wc = Cp*(T2-T1) #Compressor work(in kJ/kg):
Wt = Cp*(T3-T4) #Turbine work(in kJ/kg):
nth = (Wt-Wc)/Q23*100 #Thermal efficiency:
#Results:
print "Compressor work: ",round(Wc,2),"kJ/kg"
print "Turbine work: ",round(Wt,2),"kJ/kg"
print "Thermal efficiency: ",round(nth,2),"%"
```

In [12]:

```
from __future__ import division
#Variable Declaration:
p1 = 1 #Pressure at state 1(in bar):
p2 = 6.2 #Pressure at state 2(in bar):
p3 = 6.2 #Pressure at state 3(in bar):
p4 = 1 #Pressure at state 4(in bar):
T1 = 300 #Temperature at state 1(in K):
r = 0.017 #Fuel by air ratio:
nc = 0.88 #Compressor effeciency:
nt = 0.90 #Turbine internal efficiency:
H = 44186 #Heating value of fuel(in kJ/kg):
n = 1.4 #Adiabatic index of compression:
n1 = 1.33
Cpc = 1.147 #Value of Cp for combination(in kJ/kg.K):
Cpa = 1.005 #Value of Cp for air(in kJ/kg.K):
#Calculations:
T2 = T1*(p2/p1)**((n-1)/n) #Temperature at state 2(in K):
T21 = (T2-T1)/nc+T1 #Actual temperature after compression(in K):
T3 = (r*H+Cpa*T21)/((1+r)*Cpc) #Temperature at state 3(in K):
T4 = T3*(p4/p3)**((n1-1)/n1) #Temperature at state 4(in K):
T41 = T3-nt*(T3-T4) #Actual temperature at turbine inlet considering internal efficiency of turbine(in K):
Wc = Cpa*(T21-T1) #Compressor work, per kg of air compressed(in kJ/kg):
Wt = Cpc*(T3-T41) #Turbine work, per kg of air compressed(in K):
Wnet = Wt-Wc #Net work(in kJ/kg):
Q = r*H #Heat supplied(in kJ/kg):
nth = Wnet/Q*100 #Thermal effeciency:
#Results:
print "Compressor work: ",round(Wc,2),"kJ/kg"
print "Turbine work: ",round(Wt,2),"kJ/kg"
print "Thermal efficiency: ",round(nth,2),"%"
```

In [14]:

```
from __future__ import division
#Variable Declaration:
T5 = 1200 #Maximum temperature(in K):
T1 = 300 #Minimum temperature(in K):
T3 = 300
ni = 0.85 #Isentropic efficiency:
nt = 0.9 #Turbine efficiency:
n = 1.4 #Adiabatic index of compression:
#Calculations:
rpopt = (T1/(T5*ni*nt))**(2*n/(3*(1-n)))#Overall optimum pressure ratio:
#Results:
print "Overall optimum pressure ratio: ",round(rpopt,1)
```

In [16]:

```
from __future__ import division
from math import log
#Variable Declaration:
rp = 1.35 #Ratio of pressure:
m = 50 #Flow rate through compressor(in kg/s):
no = 0.90 #Overall efficiency:
p1 = 1 #Initial pressure(in bar):
T1 = 313 #Initial temperature(in K):
r = 1.4 #Adiabatic index of compression:
R = 0.287 #Gas constant(in kJ/kg.K):
#Calculation:
p9 = p1*rp**8 #Exit pressure(in bar):
T9 = T1*(p9/p1)**((r-1)/r) #Temperature at exit(in K):
T9a = (T9-T1)/0.82+T1 #Considerinf efficiency, actual temperature at exit(in K):
n = log(p9/p1)/(log(p9/p1)-log(T9a/T1)) #Actual index of compression:
np = ((r-1)/r)*(n/(n-1)) #Polytropic efficiency:
T2 = T1*rp**((r-1)/r) #Temperature at state 2(in K):
T2a = T1*(rp)**((n-1)/n) #Actual temperature at state 2(in K):
ns1 = (T2-T1)/(T2a-T1) #Stage efficiency:
Wc = (n/(n-1))*m*R*T1*((p9/p1)**((n-1)/n)-1) #Work done by compressor(in kJ/s):
Wca = Wc/no #Actual compressor work(in kJ/s):
#Results:
print "Pressure at exit of comppressor: ",round(p9,2),"bar"
print "Temperature at the exit of compressor: ",round(T9a,2),"K"
print "Polytropic efficiency: ",round(np*100,2),"%"
print "Stage efficiency: ",round(ns1*100,1),"%"
print "Power required to drive compressor: ",round(Wca,2),"kJ/s",
```

In [20]:

```
from __future__ import division
#Variable Declaration:
T1 = 27+273 #Temperature at which air is supplied(in K):
p2 = 8 #Initial pressure(in bar):
T3 = 1100 #Temperature of air leaving the combustion chamber(in K):
p4 = 1 #Pressure at state 4(in bar):
E = 0.8 #Effectiveness of heat exchanger:
npc = 0.85 #Polytropic efficiency of the compressor:
npt = 0.90 #Polytropic efficinency of the turbnie:
r = 1.4 #Adiabatic index of compression:
Cp = 1.0032 #Value of Cp(in kJ/kg.K):
#Calculations:
p3 = p2
p1 = p4
nc = r*npc/(r*npc-(r-1)) #Compression index:
nt = r/(r-npt*(r-1)) #Expansion index:
T2 = T1*(p2/p1)**((nc-1)/nc) #Temperature at state 2:
T4 = T3*(p4/p3)**((nt-1)/nt) #Temperature at state 4(in K):
T5 = (T4-T2)*E+T2 #Using heat exchanger effectiveness, temperature at state 5(in K):
qa = Cp*(T3-T5) #Heat added in combustion chambers(in kJ/kg):
Wc = Cp*(T2-T1) #Compressor work(in kJ/kg):
Wt = Cp*(T3-T4) #Turbine work(in kJ/kg):
ncycle = (Wt-Wc)/qa #Cycle efficiency:
Wr = (Wt-Wc)/Wt #Work ratio:
swo = Wt-Wc #Specific work output(in kJ/kg):
#Results:
print "Cycle efficiency: ",round(ncycle*100,2),"%"
print "Work ratio: ",round(Wr,3)
print "Specific work output: ",round(swo,2),"kJ/kg"
```

In [22]:

```
from __future__ import division
#Variable Declaration:
p1 = 1 #Initial pressure(in bar):
T1 = 27+273 #Initial temperature(in K):
p2 = 5 #Pressure at state 2(in bar):
nc = 0.85 #Isentropic efficiency:
T3 = 1000 #Temperature at state 3(in K):
p3 = p2-0.2 #Pressure at state 3(in bar):
p4 = p1 #Pressure at state 4(in bar):
nth = 0.20 #Thermal efficiency of plant:
r = 1.4 #Adiabatic index of compression:
Cp = 1.0032 #Value of Cp(in kJ/kg.K):
#Calculations:
T21 = T1*(p2/p1)**((r-1)/r) #Temperature at state 2'(in K):
T2 = (T21-T1)/nc+T1 #Temperature at state 2(in K):
T41 = T3*(p4/p3)**((r-1)/r) #Temperature at state 4'(in K):
Wc = Cp*(T2-T1) #Compressor work per kg(in kJ/kg):
qa = Cp*(T3-T2) #Heat added(in kJ/kg):
T4 = T3-(qa*(-nth)+Wc)/Cp #Temperature at state 4(in K):
nt = (T3-T4)/(T3-T41) #Isentropic efficiency of turbine:
#Results:
print "Turbine isentropic efficiency: ",round(nt*100,3),"%"
```

In [24]:

```
from __future__ import division
from math import sqrt
#Variable Declaration:
p1 = 1 #Pressure at which air is supplied(in bar):
T1 = 27+273 #Temperature at which air is supplied(in K):
T5 = 1000 #Maximum temperature in the cycle(in K):
p6 = 3 #Pressure at state 6(in bar):
p3 = 3
T7 = 995 #Temperature at state 7(in K):
c = 42000 #Calorific value of fuel(in kJ/kg):
Cp = 1.0032 #Value of Cp(in kJ/kg):
m = 30 #Air flow in compressor(in kg/s):
nc = 0.85 #Isentropic efficiency of compression:
ne = 0.90 #Isebtropic efficiency of expansion:
r = 1.4 #Adiabatic index of compression:
#Calculations:
p8 = p1
p7 = p6
p4 = 10
p5 = p4
rp = round(sqrt(10),2) #Pressure ratio for perfect intercooling:
T21 = round(T1*rp**((r-1)/r),2) #Temperature at state 2'(in K):
T3 = T1 #For perfect intercooling:
T2 = round((T21-T1)/nc+T1,2) #Temperature at state 2(in K):
T41 = round(T3*(rp)**((r-1)/r),2) #Temperature at state 4'(in K):
T4 = round((T41-T3)/nc+T3,2) #Temperature at state 4(in K):
Wc = round(2*Cp*(T2-T1),2) #Total compressor work(in kJ/kg):
T61 = round(T5*(p6/p5)**((r-1)/r),2) #Temperature at state 6'(in K):
T6 = round(T5-(T5-T61)*ne,2) #Temperature at state 6(in K):
T81 = round(T7*(p8/p7)**((r-1)/r),2) #Temperature at state 8'(in K):
T8 = round(T7-(T7-T81)*ne,2) #Temperature at state 8(in K):
Wt = Cp*(T5-T6+T7-T8) #Expansion work output per kg air(in kJ/kg):
qa = Cp*(T5-T4+T7-T6) #Heat added per kg air(in kJ/kg):
mf = qa/ #Fuel required per kg of air:
afr = 1/mf #Air-fuel ratio:
Wnet = (Wt-Wc)*m #Net output(in kW):
nth = (Wt-Wc)/qa #Thermal efficiency:
print T21
#Results:
print "Thermal efficiency: ",round(nth*100,2),"%"
print "Net output: ",round(Wnet,2),"kW"
print "A/F ratio: ",round(afr,2)
print "___There is a calculation mistake in calculating Wt, in the book hence answer varies____"
```

In [26]:

```
from __future__ import division
#Variable Declaration:
p1 = 1 #Pressure of air at each state(in bar):
p2 = 4
p3 = 4
p4 = 8
p6 = p4
p7 = 4
p8 = 4
p9 = 1
T1 = 300 #Temperature at each state(in K):
T3 = 290
T6 = 1300
T8 = 1300
E = 0.80 #Effectiveness:
c = 42000 #Heating value of fuel(in kJ/kg):
r = 1.4 #Adiabatic index of combustion:
Cp = 1.0032 #Value of Cp(in kJ/kg):
#Calculations:
T2 = T1*(p2/p1)**((r-1)/r) #Temperature at state 2(in K):
T4 = T3*(p4/p3)**((r-1)/r) #Temperature at state 4(in K):
T7 = T6*(p7/p6)**((r-1)/r) #Temperature at state 7(in K):
T9 = T8*(p9/p8)**((r-1)/r) #Temperature at state 9(in K):
T5 = (T9-T4)*E+T4 #Temperature at state 5(in K):
Wc = Cp*(T2-T1+T4-T3) #Compressor work per kg of air(in kJ/kg):
Wt = Cp*(T6-T7+T8-T9) #Turbine work per kg of air(in kJ/kg):
qa = Cp*(T6-T5+T8-T7) #Heat added per kg air(in kJ/kg):
mf = qa/c #Total fuel per kg of air:
Wnet = Wt-Wc #Net work(in kJ/kg):
n = Wnet/qa*100 #Cycle thermal efficiency:
afr1 = Cp*(T6-T5)/c #Fuel per kg air in combustion chamber 1:
afr2 = Cp*(T8-T7)/c #Fuel per kg air in combustion chamber 2:
#Results:
print "A/F ratio in the two combustion chambers: ",round(afr1,4),round(afr2,4)
print "Total turbine work",round(Wt,2),"kJ/kg"
print "Cycle thermal efficiency",round(n,2),"%"
```

In [28]:

```
from __future__ import division
from math import log
#Variable Declaration:
T2 = 700 #Maximum temperature(in K):
T1 = 300 #Minimum temperature(in K):
r = 3 #Compression ratio:
qa = 30 #Total heat added(in kJ/s):
E = 0.90 #Regenerator efficiency:
p = 1 #Pressure at the beginning of compression(in bar):
n = 100 #Number of cycles:
Cv = 0.72 #Value of Cv:
R = 29.27 #Gas constant(in kJ/kg.K):
#Calculations:
W = R*(T2-T1)*log(r) #Work done per kg of air(in kJ/kg):
q = R*T2*log(r)+(1-E)*Cv*(T2-T1) #Heat added per kg of air(in kJ/kg):
m = qa/q #Mass of air for 30 kJ/s of heat supplied(in kg/s):
mc = m/n #Mass of air per cycle(in kg/cycle):
BP = W*m #Brake output(in kW):
V = mc*R*T1/(p*10**2) #Stroke volume(in m**3):
#Results:
print "Brake output: ",round(BP,2),"kW"
print "Stroke volume: ",round(V,5),"m**3"
```

In [32]:

```
from __future__ import division
#Variable Declaration:
T1 = 17+273 #Ambient temperature(in K):
T3 = 1400 #Temperature at state 3(in K):
T5 = 420 #Temperature at state 5(in K):
p1 = 1 #Ambient pressure(in bar):
p2 = 10 #As pressure ratio is 10, pressure at state 2(in bar):
p3 = 10
p4 = 1
ph = 6000 #Pressure in HSRG(in kPa):
pc = 15 #Condensor pressure(in kPa):
O = 37.3 #Combined cycle output(in MW):
r = 1.4 #Adiabatic index of compression:
Cp = 1.0032 #Value of Cp(in kJ/kg.K):
#From steam tables:
ha = 3177.2 #kJ/kg
sa = 6.5408 #kJ/kg.K
sb = sa
x = 0.7976
hb = 2118.72 #kJ/kg
hc = 225.94 #kJ/kg
vc = 0.001014 #m**3/kg
#Calculations:
T2 = T1*(p2/p1)**((r-1)/r) #Temperature at state 2(in K):
T4 = T3*(p4/p3)**((r-1)/r) #Temperature at state 4(in K):
Wc = Cp*(T2-T1) #Compressor work per kg(in kJ/kg):
Wt = Cp*(T3-T4) #Turbine work per kg(in kJ/kg):
qa = Cp*(T3-T2) #Heat added in combustion chamber(in kJ/kg):
WnetGT = Wt-Wc #Net gas turbine output(in kJ/kg air):
qHSRG = Cp*(T4-T5) #Heat recovered in HSRG for steam generation(in kJ/kg):
hd = vc*(ph-pc)*10**2 #Enthalpy at exit of feed pump(in kJ/kg):
had = ha-hd #Heat added per kg of steam(in kJ/kg):
m = qHSRG/had #Mass of steam generated per kg of air:
WnetST = ha-hb-(hd-hc) #Net steam turbine cycle output(in kJ/kg):
sco = WnetST*m #Steam cycle output per kg(in kJ/kg air):
tco = WnetGT+sco #Total combined output(in kJ/kg air):
ncc = tco/qa #Combined cycle efficiency:
ngt = WnetGT/qa #Gas turbine efficiency:
#Results:
print "Overall efficiency",round(ncc*100,2),"%"
print "Steam per kg of air",round(m,3),"kg steam/kg air"
```

In [34]:

```
from __future__ import division
#Variable Declaration:
T1 = 27+273 #Temperature of working fuel at the beginning of compression(in K):
rp = 70 #Pressure ratio:
rv = 15 #Compression ratio:
r = 1.4 #Adiabatic index of compression:
#Calculations:
T2 = T1*(rv)**(r-1) #Temperature at state 2(in K):
T3 = T2*rp/(rv**r) #Temperature at state 3(in K):
T4 = T3+(T3-T2)/r #Temperature at state 4(in K):
T5 = T4*(T3/T4*rv)**(1-r) #Temperature at state 5(in K):
n = 1-(T5-T1)/(r*(T4-T3)+(T3-T2))#Air standard thermal efficiency:
#Results:
print "Air standard thermal efficiency",round(n*100,2),"%"
```