In [12]:

```
from __future__ import division
# Given data
T1 = 550 # in degree C
T1 = T1 + 273 # in K
T2 = 27 # in degree C
T2 = T2 + 273 # in K
Eta = ((T1-T2)/T1)*100 # in %
print "Maximum possible efficiency for staem turbine plant = %0.2f %% " %Eta
T1 = 2500 # in degree C
T1 = T1 + 273 # in K
T2 = 400 # in degree C
T2 = T2 + 273 # in K
Eta = ((T1-T2)/T1)*100 # in %
print "Maximum possible efficiency for internal combustion engine = %0.2f %% " %Eta
T1 = 450 # in degree C
T1 = T1 + 273 # in K
T2 = 15 # in degree C
T2 = T2 + 273 # in K
Eta = ((T1-T2)/T1)*100 # in %
print "Maximum possible efficiency for nuclear power plant = %0.2f %% " %Eta
```

In [13]:

```
from numpy import pi
# Given data
D = 0.3 # in m
L = 0.45 # in m
V_s = (pi/4)*(D)**2*L # in m**3
V_c = 0.0114 # in m**3
V = V_c+V_s # in m**3
r = V/V_c
Gamma = 1.4
Eta = (1-((1/r)**(Gamma-1)))*100 # in %
print "Efficiency of engine = %0.1f %% " %Eta
```

In [14]:

```
import math
# Given data
P1 = 0.93 # in bar
T1 = 93 # in degree C
T1 = T1 + 273 # in K
V2 = 1 # assumed
V1 = 8.5*V2
r = V1/V2
Gamma = 1.4
P2 = P1 * ((V1/V2)**(Gamma)) # in bar
print "Pressure at the beginning of compression stroke = %0.1f bar " %P2
T2 = (P2*V2*T1)/(P1*V1) # in K
print "Temperature at the beginning of compression stroke = %0.0f °C" %(T2-273)
P3 = 38 # in bar
T3 = T2 * (P3/P2) # in K
print "Pressure at the beginning of expansion stroke = %0.0f bar" %P3
print "Temperature at the beginning of expansion stroke = %0.0f °C" %(T3-273)
V3 = V2
V4 = V1
P4 = P3 * ((V3/V4)**(Gamma)) # in bar
T4 = T1 * (P4/P1) # in K
T4 = math.ceil(T4-273) # in degree C
print "Pressure at the end of expansion stroke = %0.1f bar " %P4
print "Temperature at the end of expansion stroke = %0.0f °C" %T4
Eta = 1 - (1/((r)**(Gamma-1)))
Eta = Eta * 100 # in %
print "Standard air efficiency = %0.1f %% " %Eta
```

In [15]:

```
# Given data
CalorificValue= 14.887*10**3 # in kJ/m**3
Vs= 1 # in m**3 (assumed)
Vc= 0.25*Vs # clearance volume in m**3
V= Vs+Vc # in m**3
Ratio= V/Vc # ratio of compression
Gamma= 1.4
r= 5
Eta=1-1/(r**(Gamma-1))
Eta= Eta*100 # in %
print "Air standard efficiency = %0.1f %%" %Eta
Eta_Th= Eta*60/100 # thermal efficiency
print "Thermal efficiency = %0.2f %%" %Eta_Th
Eta_br_th= Eta_Th*75/100 # break thermal efficiency
print "Brake thermal efficiency = %0.2f %%" %Eta_br_th
E= 3600 # energy equivalent of brake in kJ
GasConsumption= E/CalorificValue # in m**3
print "The consumption of gas = %0.3f m**3" %GasConsumption
```

In [16]:

```
# Given data
Gamma = 1.4
r = 8
Eta = 1 - (1/((r)**(Gamma-1)))
Eta = Eta * 100 # in %
print "Otto engine efficiency = %0.1f %% " %Eta
r = 13
x = 1
Rho = 2.5
Eta = 1-(1/r)**(Gamma-1)*((Rho**Gamma-1)/(Gamma*(Rho-1)))
Eta = Eta * 100 # in %
print "Diesel engine efficiency = %0.1f %% " %Eta
r = 13
x = 3.5
Rho = 2.5
Eta = 1-(1/r)**(Gamma-1)*((x*Rho**Gamma-1)/((x-1)+x*Gamma*(Rho-1)))
Eta = Eta * 100 # in %
print "Dual engine efficiency = %0.1f %% " %Eta
```

In [17]:

```
from numpy import pi
# Given data
D = 15
L = 25
V_s = (pi/4) * (D)**2 * L # in cm**3
V_c = 400 # in cm**3
V = V_s+V_c # in cm**3
r = V/V_c
Rho = (V_c +( V_s*(5/100) ))/V_c
Gamma = 1.4
Eta = 1-((1/r)**(Gamma-1)) * ( (((Rho)**(Gamma))-1)/(Gamma*(Rho-1)) )
Eta = Eta * 100 # in %
print "Efficiency of diesel cycle = %0.3f %% " %Eta
# Note: Calculation in the book is wrong, So the answer in the book is wrong
```

In [18]:

```
# Given data
C_P = 0.966 # in kJ/kg-K
C_v = 0.712 # in kJ/kg-K
T1 = 83 # in degree C
T1 =T1 + 273 # in K
T3 = 1800 # in degree C
T3 = T3+273 # in K
r = 13
Gamma = 1.4
T2 = T1 * (r)**(Gamma-1) # in K
print "Temperature at the end of compression = %0.0f °C " %(T2-273)
Rho = T3/T2
T4 = ((Rho)**(Gamma)) * T1 # in K
print "Temperature at the end of expansion = %0.0f °C " %(T4-273)
Q = C_P * (T3-T2) # in kJ
print "Heat supplied at constant pressure = %0.0f kJ " %Q
Q1 = C_v * (T4-T1) # in kJ
print "Heat rejected at constant volume = %0.1f kJ " %Q1
Eta = ((Q-Q1)/Q) * 100 # in %
print "Thermal efficiency = %0.1f %% " %Eta
# Note: The answer in the book is not accurate
```

In [19]:

```
# Given data
r = 10
Gamma = 1.4
P1 = 1 # in bar
P2 = 1 * ((r)**(Gamma)) # in bar
P3 = 40 # in bar
P4 = P3 # in bar
T1 = 80 # in degree C
T1 = T1+273 # in K
T2 = T1 * ((r)**(Gamma-1)) # in K
T3 = (P3/P2)*T2 # in K
T4 = 1700 # in degree C
T4 = T4 + 273 # in K
Vc= 1 # in m**3(assumed)
V4= Vc*T4/T3
V1= 10*Vc # volume at beginning of compression in m**3
Vs= V1-Vc # in m**3
PercentageStroke= (V4-Vc)/Vs*100 # in %
print "Percentage of stroke at which heat reception must stop = %0.1f %%" %PercentageStroke
r= V1/V4
P5= P4/r**Gamma # in bar
ratio= (P4*V4-P5*V1)/(P2*Vc-P1*V1)
print "Ratio of work done during expansion to that done during compression = %0.2f" %ratio
```

In [20]:

```
# Given data
P1 = 1 # in bar
T1 = 320 # in K
r= 11.6
Vc= 1 # in m**3 (assumed)
Vs= 10.6*Vc #in m**3
V1= r*Vc # in m**3
Gamma= 1.4
P2= P1*r**Gamma # in bar
V2= Vc # in m**3
V3= Vc # in m**3
V4=1.38*Vc # in m**3
P3= 1.53*P2 # in bar
P4= P3 # in bar
expansionRatio= V1/V4
P5= P4/expansionRatio**Gamma # in bar
V5= r*Vc # in m**3
W= (P3*(V4-Vc)+(P4*V4-P5*V5)/(Gamma-1)-(P2*V2-P1*V1)/(Gamma-1))*10**5 # in joule
Pm= W/(Vs*10**4) # in N/cm**2
print "The mean effective pressure of the cycle = %0.2f N/cm**2" %Pm
# Note: The calculation in the book is wrong
```

In [21]:

```
from math import log
# Given data
C_P = 0.998 # in kJ/kg-K
C_v = 0.707 #in kJ/kg-K
T1 = 15 # in degree C
T1 = T1 +273 # in K
T2 = 400 # in degree C
T2 = T2 + 273 # in K
Eta = (1 - (T1/T2))*100 # in %
print "The ideal efficiency when engine is fitted with a perfect regenerator = %0.2f %% " %Eta
R = C_P-C_v # in kJ/kg-K
r = 3
Eta_r = 0.8
Eta = ((R*(log(r)))*(T2-T1))/( (R*(log(r))*T2) + (1-Eta_r) * C_v * (T2-T1) )*100 # in %
print "The ideal efficicency when efficiency of the regenrator is 0.8 = %0.1f %% " %Eta
```

In [22]:

```
# Given data
T1 = 15 # in degree C
T1 = T1 + 273 # in K
P1 = 1 # in bar
P2 = 5 # in bar
Gamma = 1.4
T2 = T1 * ((P2/P1)**((Gamma-1)/Gamma)) # in K
C_P = 1.003 # in kJ/kg-K
CompWork = C_P*(T2 - T1) # Compressure work in kJ/kg
T3 = 800 # in degree C
T3 = T3 + 273 # in K
T4 = T3/((P2/P1)**((Gamma-1)/Gamma)) # in K
T4= round(T4) # in K
turbineWork = C_P * (T3-T4) # Turbine work in kJ/kg
Q = C_P * (T3-T2) # Heat input in kJ/kg
W = turbineWork-CompWork # in kJ/kg
W= round(W) #in kJ/kg
Eta = (W/Q)* 100 # in %
print "the thermal efficiency of plant = %0.0f %% " %round(Eta)
print "Output of gas turbine installation",int(W),"kW per kg of flow per second"
```

In [23]:

```
from math import log
# Given data
C_v = 0.711 # in kJ/kg-K
T3 = 850 # in degree C
T3 = T3 + 273 # in K
T2 = 90 # in degree C
T2 = T2 + 273 # in K
E = C_v * (log(T3/T2)) # Entropy change in kJ/kg-K
print "Entrophy change = %0.3f kJ/kg-K " %E
W = (E * (T3-T2))/2 #output work in kJ/kg
Q = T2+E #rejected heat in kJ/kg
Q1 = W + Q #heat supplied in kJ/kg
Eta = (W/Q1) # in %
print "The efficiency of cycle = %0.3f %% " %Eta
```