In [1]:

```
import math
from __future__ import division
#Variable declaration
r=8; # Compression ratio of an engine
p1=100; # Pressure of air before compression in lPa
T1=300; # Temperature air before compression in kelvin
qH=1800; # Heat added to the air in kJ/kg
k=1.4; # Index of reversible adiabatic process
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
R=0.287; # characteristic gas constant of air in kJ/kg K
#Calculation for (1)
# Otto cycle
# (1) state 2
p2=p1*(r)**k; # Pressure at the end of compression
T2=T1*(p2/p1)**((k-1)/k);# Temperature at the end of compression
# state 3
T3=(qH/Cvo)+T2; # Temperatue after heat addition
p3=p2*(T3/T2); # Pressure after heat addition
# state 4
p4=p3*(1/r)**k; # Pressure after expansion
T4=T3*(p4/p3)**((k-1)/k);# Temperature after expansion
#Result for (1)
print "(1).state 1","\n Pressure of air before compression = ",p1,"kPa","\n Temperature air before compression =",T1,"K"
print "state 2","\n Pressure of air at the end of compression = ",round(p2,0),"kPa"
print " Temperature at the end of compression =",round(T2,1),"K"
print "state 3","\n Pressure after heat addition = ",round(p3,0),"kPa (round off error)"
print " Temperature after heat addition =",round(T3,1),"K (round off error)"
print "state 4","\n Pressure after expansion = ",round(p4,1),"kPa (round off error)"
print " Temperature after expansion =",round(T4,1),"K (round off error)"
#Calculation for (2)
# (2).Thermal efficiency
qL=Cvo*(T4-T1); # Heat rejected
eff_th=1-qL/qH; # thermal efficiency
#Result for (2)
print "\n(2).Thermal efficienvy = ",round(eff_th*100,2),"% (round off error)"
#Calculation for (3)
# (3). Mean effective pressure
wnet=qH-qL; # net work
v1=R*T1/p1; # Specific volume at state 1
v2=v1/r; # Specific volume at state 2
pm=wnet/(v1-v2); # Mean effective pressure
#Result for (3)
print "\n(3).Mean effective pressure = ",round(pm,0),"kPa"
```

In [2]:

```
#Variable declaration
r=18; # Compression ratio of an engine
p1=100; # Pressure of air before compression in lPa
T1=300; # Temperature air before compression in kelvin
qH=1800; # Heat added to the air in kJ/kg
k=1.4; # Index of reversible adiabatic process
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
R=0.287; # characteristic gas constant of air in kJ/kg K
#Calculation
# Diesel cycle
# state 2
T2=T1*(r)**(k-1); # Temperature at the end of compression
p2=p1*(r)**k; # Pressure at the end of compression
# state 3
T3=(qH/Cpo)+T2; # Temperatue after heat addition
p3=p2; #constant pressure
Tmax=T3; # maximum temperature
Pmax=p3; # Maximum pressure
# state 4
v3=R*T3/p3; # Specific volume at state 3
v4=R*T1/p1; # Specific volume at state 4
T4=T3*(v3/v4)**(k-1); # Temperature after expansion
p4=p3*(v3/v4)**k; # Pressure after expansion
qL=Cvo*(T4-T1); # Heat rejected
wnet=qH-qL; # net work
eff_th=wnet/qH; # thermal efficiency
v1=R*T1/p1; # Specific volume at state 1
v2=v1/r; # Specific volume at state 2
pm=wnet/(v1-v2); # Mean effective pressure
#Results
print "Maximum pressure = ",Pmax,"kPa","Maximum Temperature = ",Tmax,"K"
print "Thermal efficienvy = ",round(eff_th*100,1),"%"
print "Mean effective pressure = ",round(pm,0),"kPa (Error in textbook)"
```

In [3]:

```
#Variable declaration
p1=0.1; # Pressure of air at inlet in MPa
T1=300; # Temperature of air at inlet in kelvin
p2=0.6; # Pressure of air at exit in MPa
T3=1200; # Maximun temperature of air in kelvin
k=1.4; # Index of reversible adiabatic process
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
R=0.287; # characteristic gas constant of air in kJ/kg K
#Calculation
# Brayton cycle
rp=p2/p1; # pressure ratio
T2=T1*(p2/p1)**((k-1)/k);# Temperature at the end of compression
wc=Cpo*(T2-T1); # compressor work
T4=T3*(p1/p2)**((k-1)/k);# Temperature at the end of expansion
wT=Cpo*(T3-T4); # Turbine work
qH=Cpo*(T3-T2); # heat addition
wnet=wT-wc; # net work
eff_th=wnet/qH; # thermal efficiency
rw=wnet/wT; # worh ratio
#Result
print "Thermal Efficiency = ",round(eff_th*100,1),"%"
print "Work Ratio = ",round(rw,3)
```

In [4]:

```
#Variable declaration
p1=0.1; # Pressure of air at inlet in MPa
T1=300; # Temperature of air at inlet in kelvin
p2=0.6; # Pressure of air at exit in MPa
T3=1200; # Maximun temperature of air in kelvin
k=1.4; # Index of reversible adiabatic process
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
R=0.287; # characteristic gas constant of air in kJ/kg K
eff_t=0.85; # Turbine efficiency
eff_c=0.8; # Compressor efficienct
#Calculation
# Brayton cycle
rp=p2/p1; # pressure ratio
T2s=T1*(p2/p1)**((k-1)/k);# Isentropic Temperature at the end of compression
T2=((T2s-T1)/eff_c)+T1; # Actual Temperature at the end of compression
p3=0.585; # as per given in MPa
p4s=0.11; # As per given in MPa
T4s=T3*(p4s/p3)**((k-1)/k); # Isentropic temperature after reversible adiabatic expansion
T4=T3-(eff_t*(T3-T4s));# Actual temperature at state 4
wc=Cpo*(T2-T1); # compressor work
wT=Cpo*(T3-T4); # Turbine work
qH=Cpo*(T3-T2); # heat addition
wnet=wT-wc; # net work
eff_th=wnet/qH; # thermal efficiency
rw=wnet/wT; # worh ratio
#Result
print "Thermal Efficiency = ",round(eff_th*100,0),"%"
print "Work Ratio = ",round(rw,3)
```

In [5]:

```
#Variable declaration
p1=0.1; # Pressure of air at inlet in MPa
T1=300; # Temperature of air at inlet in kelvin
p2=0.6; # Pressure of air at exit in MPa
T3=1200; # Maximun temperature of air in kelvin
k=1.4; # Index of reversible adiabatic process
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
R=0.287; # characteristic gas constant of air in kJ/kg K
#Calculation
# Brayton cycle
rp=p2/p1; # pressure ratio
T2=T1*(p2/p1)**((k-1)/k);# Temperature at the end of compression
T4=T3*(p1/p2)**((k-1)/k);# Temperature at state 4
Tx=T4; Ty=T2; # regenerator temperatures
qH=Cpo*(T3-Tx); # Heat added in the cycle with regenerator
qL=Cpo*(Ty-T1);# Heat rejected in the cycle with regenerator
eff_th=1-qL/qH; # Thermal efficiency
#Result
print "Thermal efficiency with regenerator = ",round(eff_th*100,1),"%"
```

In [6]:

```
import math
from __future__ import division
#Variable declaration
V1=250; # Velocoty of jet aircraft in m/s
p1=60; # Atmospheric pressure in kPa
T1=260; # Atmospheric temperature in kelvin
rp=8; # Pressure ratio of compressor
T4=1350; # Temperature of gas at turbine inlet in kelvin
k=1.4; # Index of reversible adiabatic process
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
R=0.287; # characteristic gas constant of air in kJ/kg K
#Calculation for (a)
# (a).The pressure and temperature at each point of the cycle
# process 1-2 isentropic diffusion
T2=T1+(V1**2)/(2*Cpo*10**3); # Temperature at state 2
p2=p1*(T2/T1)**(k/(k-1)); # Pressure at state 2
# process 2-3 isentropic compression
p3=rp*p2; # perssure at state 3
T3=T2*(p3/p2)**((k-1)/k); # Temperature at state 3
wc=Cpo*(T3-T2); # compressor work
# process 3-4 Constant pressur heat addition
qH=Cpo*(T4-T3); # heat addition
p4=p3; # constant pressure
# process 4-5 isentropic expansion in turbine
wT=wc;
T5=T4-(wT/Cpo); # Temperature at state 5
p5=p4*(T5/T4)**(k/(k-1)); # Pressure at state 5
# process 5-6 Isentropic expansion in nozzle
p6=p1;
T6=T5*(p6/p5)**((k-1)/k); # Temperature at state 6
#Result for (a)
print "(a).The pressure and temperature at each point of the cycle","\n State 1","\n p1 =",p1,"kPa","\n T1 =",T1,"K"
print "\n State 2","\n p2 =",round(p2,1),"kPa","\n T2 =",round(T2,1),"K",
print "\n State 3","\n p3 =",round(p3,0),"kPa","\n T3 =",round(T3,1),"K"
print "\n State 4","\n p4 =",round(p4,0),"kPa","\n T4 =",T4,"K"
print "\n State 5","\n p5 =",round(p5,0),"kPa (roundoff error)","\n T5 =",round(T5,1),"K (roundoff error)"
print " State 6","\n p6 =",p6,"kPa","\n T6 =",round(T6,0),"K"
#Calculation for (b)
# (b).Exit velocity of jet
V6=math.sqrt (2*Cpo*10**3*(T5-T6)); # Exit velocity of jet
#Result for (b)
print "\n\n(b).Exit velocity of jet =",round(V6,0),"m/s (roundoff error)"
#Calculation for (c)
# (c).Specific thrust and work output
F_mair=(V6-V1); # Specific thrust
w=F_mair*V1/1000; # Work output
#Result for (c)
print "\n\n(c).Specific thrust and work output","\nSpecific thrust =",round(F_mair,0),"N (roundoff error)"
print "Work output = ",round(w,1),"kJ/kg"
#Calculation for (d)
# (d).Propulsion efficiency
eff_p=w/(w+(V6**2-V1**2)/2000);# Propulsion efficiency
#Result for (d)
print "\n\n(d).Propulsion efficiency =",round(eff_p*100,1),"%"
#Calculation for (e)
# (e).Overall thermal efficiency
eff_th=w/qH; # Overall thermal efficiency
#Result for (e)
print "(e).Overall thermal efficiency =",round(eff_th*100,1),"%"
```

In [7]:

```
#Variable declaration
p1=100; # Pressure of air at inlet in kPa
T1=288; # Temperature of air at inlet in kelvin
rp=12; # Pressure ratio of the compressor
k=1.4; # Index of reversible adiabatic process
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
R=0.287; # characteristic gas constant of air in kJ/kg K
T3=T1; # From figure
#Calculation
# process 1-2
p2=12*p1; # Pressure at state 2
T2=T1*(p2/p1)**((k-1)/k); # Temperature at state 2
wc=Cpo*(T2-T1); # Compressor work
# process 2-3
qH=Cpo*(T2-T3); # Heat added
# process 3-4
T4=T3*(1/rp)**((k-1)/k); # Temperature at state 4
# process 4-1 Refrigerating coil
qL=Cpo*(T1-T4); # heat rejected
wnet=qH-qL; # net work
cop=qL/wnet; # Cop of plant
pc=wnet/qL; # Power consumption per kW of refrigeration
#Result
print "COP of the cycle =",round(cop,3),"\nPower consumption per kW of refrigeration =",round(pc,3),"kW/kW"
```

In [8]:

```
#Variable declaration
p1=100; # Pressure of air at inlet in kPa
T1=288; # Temperature of air at inlet in kelvin
rp=12; # Pressure ratio of the compressor
T4=223; # Temperature at state 4
k=1.4; # Index of reversible adiabatic process
Cvo=0.7165; # Specific heat at constant volume in kJ/kg K
Cpo=1.0035; # Specific heat at constant pressure in kJ/kg K
R=0.287; # characteristic gas constant of air in kJ/kg K
T3=T1; # From figure
#Calculation
# process 1-2
p2=12*p1; # Pressure at state 2
T2=T1*(p2/p1)**((k-1)/k); # Temperature at state 2
wc=Cpo*(T2-T1); # Compressor work
# process 2-3
qH=Cpo*(T2-T3); # Heat added
# process 3-4 cooling in regenerative heat exchanger
qregen=Cpo*(T3-T4); # cooling in regenerative heat exchanger
# process 4-5 Expander
T5=T4*(1/rp)**((k-1)/k); # Temperature at state 5
wE=Cpo*(T4-T5); # Expander work
# process 5-6 Refrigerating coil
T6=T4; # From figure 9.32
qL=Cpo*(T6-T5); # Heat rejected
# process 6-1 Heating in regenerative heat exchanger
qregen=Cpo*(T1-T6); # Heat supplied
wnet=qH-qL; # net work
cop=qL/wnet; # Cop of plant
#Result
print "COP of the modified cycle =",round(cop,3)
```