In [1]:

```
#Given:
T2 = 27.+273 #Temperature of cooling pond in K
eta = 30. #Efficiency in percent
Q2 = 200. #Heat received by cooling pond in kJ/s
#Solution:
#Since, eta = (Q1-Q2)/Q1 = (T1-T2)/T1
T1 = T2/(1-(eta/100)) #Temperature of heat source in K
Q1 = Q2/(1-(eta/100)) #Heat supplied by source in kJ/s
Power = round(Q1-Q2) #Power of engine in kJ/s
#Results:
print " Temperature of heat source, T1 = %.1f degreeC"%(T1-273)
print " Power of engine = %d kW"%(Power)
```

In [3]:

```
import math
#Given:
T3 = 800+273.
T1 = 15.+273 #Temperature of a hot and cold reservoir in K
P3 = 210.
P1 = 1 #Maximum and minimum pressure in bar
#Solution:
#Refer fig 2.21
eta_carnot = 1-(T1/T3) #Efficiency of Carnot cycle
T4 = T3 #Isothermal process 3-4
g = 1.4 #Specific heat ratio(gamma)
P4 = P1*(T4/T1)**(g/(g-1)) #Initial pressure of isentropic process 4-1 in bar
R = 0.287 #Specific gas consmath.tant in kJ/kgK
Q3_4 = R*T3*math.log(P3/P4) #Heat supplied in kJ/kg
W3_4 = Q3_4 #Work supplied in kJ/kg
Net_work = eta_carnot*Q3_4 #Net work output in kJ/kg
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
W4_1 = cv*(T4-T1) #Work for isentropic process in kJ/kg
Gross_work = W3_4+W4_1 #Gross work supplied in kJ/kg
work_ratio = Net_work/Gross_work #Work ratio
#Results:
print " The efficiency of the Carnot cycle, eta_carnot = %.1f percent"%(eta_carnot*100)
print " The work ratio of the Carnot cycle = %.3f"%(work_ratio)
```

In [5]:

```
import math
#Given:
d = 17.
l = 30. #Bore and stroke in cm
V_c = 0.001025 #Clearance volume in m**3
#Solution:
V_s = (math.pi/4)*d**2*l #Swept volume in cc
V_c = V_c*10**6 #Clearance volume in cc
V = V_c+V_s #Total cylinder volume in cc
r = V/V_c #Compression ratio
g = 1.4 #Specific heat ratio(gamma)
eta = 1-1/r**(g-1) #Air standard efficiency
#Results:
print " The Air standard efficiency of Otto cycle, eta = %.1f percent"%(eta*100)
```

In [6]:

```
#Given:
P1 = 97. #Pressure at the beginning(1) in kN/m**2
T1 = 40.+273 #Temperature at the beginning(1) in K
r = 7. #Compression ratio
Q = 1200. #Heat supplied in kJ/kg
g = 1.4 #Specific heat ratio(gamma)
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
#Solution:
#(a)
T2 = T1*(r)**(g-1)
T3 = round(Q/cv+T2) #Temperature at 2, 3 in K
#(b)
eta = 1-1/r**(g-1) #Thermal efficiency
#(c)
W = Q*eta #Workdone per cycle in kJ/kg
#Results:
print " a)The maximum temperature attained in the cycle, T3 = %d degreeC"%(T3-273)
print " b)The thermal efficiency of the cycle, eta = %.1f percent"%(eta*100)
print " c)The workdone during the cycle/kg of working fluid, W = %d kJ"%(W)
```

In [7]:

```
#Given:
r = 8. #Compression ratio
P1 = 1.
P3 = 50. #Pressure at 1, 3 in bar
T1 = 100.+273 #Temperature at 1 in K
m = 1. #Air flow in kg
R = 0.287 #Specific gas consmath.tant in kJ/kgK
g = 1.4 #Specific heat ratio(gamma)
#Solution:
#Refer fig 2.22
#Point 1
V1 = m*R*10**3*T1/(P1*10**5) #Ideal gas equation, Volume at 1 in m**3
#Point 2
P2 = P1*r**g #Pressure at 2 in bar
V2 = V1/r #Volume at 2 in m**3
T2 = P2*V2*T1/(P1*V1) #Temperature at 2 in K
#Point 3
V3 = V2 #Constant volume process, Volume at 3 in m**3
T3 = (P3/P2)*T2 #Temperature at 3 in K (Wrong in book)
#Point 4
P4 = P3*(1/r)**g #Pressure at 4 in bar
V4 = V1 #Constant volume process, Volume at 4 in m**3
T4 = T1*(P4/P1) #Temperature at 4 in K
cv = R/(g-1) #Specific heat at consmath.tant volume in kJ/kgK
ratio = (cv*(T3-T2))/(cv*(T4-T1)) #Ratio of heat supplied to the heat rejected (Round off error)
#Results:
print " Point 1: Pressure = %d bar, Volume = %.4f m**3, Temperature = %d degreeC"%(P1,V1,T1-273)
print " Point 2: Pressure = %.1f bar, Volume = %.4f m**3, Temperature = %.1f degreeC"%(P2,V2,T2-273)
print " Point 3: Pressure = %.1f bar, Volume = %.4f m**3, Temperature = %.1f degreeC"%(P3,V3,T3-273)
print " Point 4: Pressure = %.2f bar, Volume = %.4f m**3, Temperature = %.1f degreeC"%(P4,V4,T4-273)
print " Ratio of heat supplied to the heat rejected = %.3f"%(ratio)
#Textbook answer for T3 is wrong
#Round off error in the value of 'ratio'
```

In [8]:

```
#Given:
P1 = 1. #Pressure at 1 in bar
T1 = 15.+273 #Temperature at 1 in K
r = 8. #Compression ratio
Q1 = 1000. #Heat added in kJ/kg
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
g = 1.4 #Specific heat ratio(gamma)
#Solution:
#Refer fig 2.23
#(a)
P2 = P1*(r)**g #Pressure at 2 in bar
T2 = T1*r**(g-1) #Temperature at 2 in K
T3 = Q1/cv+T2 #Temperature at 3 in K (Round off error)
#(b)
eta = 1-1/r**(g-1) #Air standard efficiency
#(c)
W = Q1*eta #Work done in kJ/kg (Round off error)
#(d)
Q2 = Q1-W #Heat rejected in kJ/kg
#Results:
print " a)The maximum temperature in the cycle, T3 = %d degreeC"%(T3-273)
print " b)The air standard efficiency, eta = %.1f percent"%(eta*100)
print " c)The workdone per kg of air = %d kJ/kg"%(W)
print " d)The heat rejected = %d kJ/kg"%(Q2)
#Round off error in the values of 'T3' and 'W'
```

In [9]:

```
#Given:
P1 = 1.05
P2 = 13.
P3 = 35. #Pressure at 1, 2, 3 in bar
T1 = 15.+273 #Temperature at 1 in K
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
R = 0.287 #Specific gas consmath.tant in kJ/kgK
#Solution:
r = "V1/V2" #Compression ratio
g = R/cv+1 #Specific heat ratio(gamma)
r = (P2/P1)**(1/g) #By adiabatic process relation
eta = 1-1/r**(g-1) #Air standard efficiency
T2 = P2*T1/(P1*r) #Temperature at 2 in K
T3 = (P3/P2)*T2 #Temperature at 3 in K
Q1 = cv*(T3-T2) #Heat added in kJ/kg
W = Q1*eta #Work done in kJ/kg
V1 = 1*R*10**3*T1/(P1*10**5) #Ideal gas equation, Volume at 1 in m**3/kg
V2 = V1/r #Volume at 2 in m**3/kg
V_s = V1-V2 #Swept volume in m**3/kg
mep = W*1000/(V_s*10**5) #Mean effective pressire in bar
#Results:
print " The air standard efficiency, eta = %.1f percent"%(eta*100)
print " The compression ratio, r = %d"%(r)
print " The mean effective pressure, mep = %.2f bar"%(mep)
```

In [10]:

```
#Given:
r = 8. #Compression ratio
T1 = 20.+273 #Temperature at 1 in K
P1 = 1. #Pressure at 1 in bar
Q1 = 1800. #Heat added in kJ/kg
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
g = 1.4 #Specific heat ratio(gamma)
#Solution:
T2 = T1*r**(g-1) #Temperature at 2 in K
T3 = Q1/cv+T2 #Temperature at 3 in K (printing error)
P2 = P1*(r)**g #Pressure at 2 in bar
P3 = P2*(T3/T2) #Pressure at 3 in bar
T4 = T3/r**(g-1) #Temperature at 4 in K
eta = 1-1./r**(g-1) #Air standard efficiency
W1_2 = cv*(T1-T2) #Work done for process 1-2 in kJ/kg
W3_4 = cv*(T3-T4) #Work done for process 3-4 in kJ/kg
W = W1_2+W3_4 #Net work done for the cycle in kJ/kg
V1 = cv*(g-1)*10**3*T1/(P1*10**5) #Ideal gas equation, Volume at 1 in m**3/kg
V2 = V1/r #Volume at 2 in m**3/kg
V_s = V1-V2 #Swept volume in m**3/kg
mep = W*1000/(V_s*10**5) #Mean effective pressire in bar
#Results:
print " The maximum temperature, T3 = %d K"%(T3)
print " The maximum pressure, P3 = %.1f bar"%(P3)
print " The temperature at the end of the expansion process, T4 = %d K"%(T4)
print " The air standard efficiency, eta = %.1f percent"%(eta*100)
print " The mean effective pressure of the cycle, mep = %.1f bar"%(mep)
#Answers in the book are wrong
```

In [12]:

```
import math
#Given:
power = 50. #Internal power in kW
N = 4800. #Engine speed in rpm
l = 80.
d = 80. #Stroke and bore of engine in mm
n = 4. #Number of cylinders
V_c = 50000. #Clearance volume in mm**3
delta_P = 45. #Pressure rise during combustion in bar
g = 1.4 #Specific heat ratio(gamma)
#Solution:
#Refer fig 2.24
V_s = (math.pi/4)*d**2*l #Swept volume in mm**3
r = (V_c+V_s)/V_c #Compression ratio
eta = 1-1/r**(g-1) #Air standard efficiency
ideal_mep = eta*delta_P/((g-1)*(r-1)) #Ideal mean effective pressure in bar
W = power*60*2/(n*N) #Actual work transfer per cycle per cylinder in kJ
V_s = V_s*1e-9 #Swept volume in m**3
actual_mep = W*1000/(V_s*10**5) #Actual mean effective pressire in bar
#Results:
print " The mean effective pressure of the engine, actual mep = %.2f bar"%(actual_mep)
print " The mean effective pressure of the Otto cycle, ideal mep = %.2f bar"%(ideal_mep)
```

In [13]:

```
from scipy.optimize import fsolve
import math
#Given:
CV = 42000. #Calorific value of the fuel in kJ/kg
a = 30./100
b = 70./100 #Fraction of compression stroke at point a, b
P_a = 1.33
P_b = 2.66 #Pressure at point a, b
n = 1.33 #Polytropic index
eta_cycle = 50./100 #Air standard cycle efficiency
#Solution:
#Refer fig 2.25
#Since, compression follows PV**n = C
#Thus, P_a*V_a**n = P_b*V_b**n
#Assume a_b = V_a/V_b
a_b = (P_b/P_a)**(1/n) #Ratio of volume at a to volume at b
#Defining the function, ratio of r(compression ratio)
def Volume(r):
V_a = 1+0.7*(r-1)
V_b = 1+0.3*(r-1)
return V_a/V_b-a_b
r = fsolve(Volume,1)
g = 1.4 #Specific heat ratio(gamma)
eta = round(1000*(1-1/r**(g-1)))/1000 #Air standard efficiency
eta_it = eta_cycle*eta #Indicated thermal efficiency
#Since, 1 kWh = 3600 kJ
Q1 = 3600/eta_it #Heat supplied in kJ/kWh
isfc = Q1/CV #Indicated specific fuel consumption in kg/kWh
#Results:
print " The compression ratio, r = %.2f"%(r)
print " The fuel consumption, isfc = %.3f kg/kWh"%(isfc)
```

In [14]:

```
#Given:
r = 14. #Compression ratio
P1 = 1. #Pressure at 1 in bar
T1 = 27+273.
T3 = 2500.+273 #Temperature at 1 and 3 in K
#Solution:
#Refer fig 2.26
g = 1.4 #Specific heat ratio(gamma)
T2 = T1*(r)**(g-1) #Temperature at 2 in K
P2 = P1*(T2/T1)**(g/(g-1)) #Pressure at 2 in bar
rho = T3/T2 #Cut off ratio
T3_T4 = (r/rho)**(g-1) #Temperature ratio T3/T4
T4 = round(T3/T3_T4) #Temperature at 4 in K
eta = 1-((T4-T1)/(g*(T3-T2))) #Efficiency of diesel cycle
R = 0.287
cp = 1.005
cv = 0.718 #Specific gas consmath.tant, heat capacities at consmath.tant pressure and volume in kJ/kgK
V1 = R*T1*10**3/(P1*10**5) #Volume at 1 in m**3/kg
V_s = V1*(1-1/r) #Stroke volume in m**3/kg
mep = (cp*(T3-T2)-cv*(T4-T1))*10**3/(V_s*10**5) #Mean effective pressure in bar
#Results:
print " The thermal efficiency of the diesel cycle, eta = %.1f percent"%(eta*100)
print " The mean effective pressure of the cycle, pm = %.2f bar"%(mep)
```

In [15]:

```
#Given:
P1 = 1.
P2 = 50. #Pressure at 1, 2 in bar
V1 = 1.
V3 = 0.1 #Volume at 1, 3 in m**3
T1 = 18.+273 #Temperature at 1 in K
g = 1.4 #Specific heat ratio(gamma)
#Solution:
T2 = T1*(P2/P1)**((g-1)/g) #Temperature at 2 in K
V2 = V1*(P1/P2)*(T2/T1) #Volume at 2 in m**3
T3 = round(T2*(V3/V2)) #Temperature at 2 in K (printing error)
V4 = V1 #Constant volume process, volume at 4 in m**3
T4 = T3*(V3/V4)**(g-1) #Temperature at 4 in K
eta = 1-((T4-T1)/(g*(T3-T2))) #Efficiency of diesel cycle
#Results:
print " Temperature at 1, T1 = %d K \
\nTemperature at 2, T2 = %.1f K \
\nTemperature at 3, T3 = %d K \
\nTemperature at 4, T4 = %.1f K"%(T1,T2,T3,T4)
print " The thermal efficiency of the cycle, eta = %.1f percent"%(eta*100)
#Answer in the book is printed wrong
```

In [16]:

```
#Given:
r = 18. #Compression ratio
p = 10. #percentage of stroke at which consmath.tant pressure process ends
P1 = 1.
T1 = 20.+273 #Pressure and temperature at 1 in bar and K
V_a = 100. #Volume of air used per hour in m**3/hr
g = 1.4 #Specific heat ratio(gamma)
#Solution:
#Refer fig 2.27
#Calculation of cut off ratio (rho)
V_s = r-V_c #Swept volume in unit
V3 = V_c+V_s*p/100 #Volume at consmath.tant pressure process ends or point 3 in unit
V2 = V_c #Volume at consmath.tant pressure process starts or point 2 in unit
rho = V3/V2 #Cut off ratio
eta = 1-((rho**g-1)/(r**(g-1)*g*(rho-1))) #Thermal efficiency
P2 = P1*(r)**g #Pressure at 2(maximum) in bar (printing error)
P3 = P2 #Constant pressure process, pressure at 3 in bar
T2 = T1*(r)**(g-1) #Temperature at 2 in K
T3 = T2*rho #Temperature at 3(maximum) in K
#Consider the cycle for 100 m**3 of swept volume with air, thus
V_s = V_a #Swept volume in m**3/hr
V2 = V_s/(r-1) #Volume at 2 in m**3/hr
V1 = V_s+V2 #Volume at 1 in m**3/hr
V3 = rho*V2 #Volume at 3 in m**3/hr
V4 = V1 #Constant volume process, volume at 4 in m**2
P4 = P3*(V3/V4)**g #Pressure at 4 in bar
W = (P2*(V3-V2)+((P3*V3-P4*V4)-(P2*V2-P1*V1))/(g-1))*10**5 #Work done in cycle in Nm
ip = W/3600
#Results:
print " a)The maximum temperature, T3 = %d degreeC and the maximum pressure, P2 = %.1f bar"%(T3-273,P2)
print " b)The thermal efficiency of the engine, eta = %d percent"%(eta*100)
print " c)The indicated power of the engine, ip = %.2f kW"%(ip/1000)
#Answers in the book are wrong
```

In [18]:

```
#Given:
d = 15.
l = 20. #Diameter and stroke of cylinder in cm
p2 = 6. #Percentage of stroke at which cut off takes place
g = 1.4 #Specific heat ratio(gamma)
#Solution:
#Refer fig 2.28
V_s = (math.pi/4)*d**2*l #Stroke volume in cm**3
V_c = math.pi*V_s/100 #Clearance volume in cm**3
V1 = V_s+V_c #Total volume at 1 in cm**3
V2 = V_c #Volume at 2 in cm**3
V3 = V2+p2*V_s/100 #Volume at 3 in cm**3
r = V1/V2 #Compression ratio
rho = V3/V2 #Cut off ratio
eta = 1-((rho**g-1)/(r**(g-1)*g*(rho-1))) #Thermal efficiency
#Results:
print " The air standard efficiency of the engine, eta = %d percent"%(eta*100)
```

In [19]:

```
#Given:
r = 15. #Compression ratio
P1 = 1.
T1 = 25.+273
V1 = .1 #Pressure, temperature, volume at 1 in bar, K, m**3
P4 = 65.
T4 = 1500.+273 #Pressure and temperature at 4 in bar and K
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
g = 1.4 #Specific heat ratio(gamma)
#Solution:
#Refer fig 2.29
V2 = V1/r #Volume at 2 in m**3
P2 = P1*(r)**g #Pressure at 2 in bar
T2 = T1*(r)**(g-1) #Temperature at 2 in K
P3 = P4 #Pressure at 3 in bar
T3 = T2*(P3/P2) #Temperature at 3 in K
V3 = V2 #Volume at 3 in m**3
V4 = V3*(T4/T3) #Volume at 4 in m**3
V5 = V1 #Volume at 5 in m**3
P5 = P4*(V4/V5)**g #Pressure at 5 in bar
T5 = T4*(V4/V5)**(g-1) #Temperature at 5 in K
eta = 1-(T5-T1)/((T3-T2)+g*(T4-T3)) #Thermal efficiency
#Results:
print " Point 1: Pressure = %d bar \
\nVolume = %.1f m**3 \
\nTemperature = %d degreeC"%(P1,V1,T1-273)
print " Point 2: Pressure = %.1f bar \
\nVolume = %.4f m**3 \
\nTemperature = %d degreeC"%(P2,V2,T2-273)
print " Point 3: Pressure = %d bar \
\nVolume = %.4f m**3 \
\nTemperature = %d degreeC"%(P3,V3,T3-273)
print " Point 4: Pressure = %d bar \
\nVolume = %.4f m**3 \
\nTemperature = %d degreeC"%(P4,V4,T4-273)
print " Point 5: Pressure = %.2f bar \
\nVolume = %.1f m**3 \
\nTemperature = %d degreeC"%(P5,V5,T5-273)
print " The thermal efficiency of the cycle, eta = %d percent"%(eta*100)
#Answers in the book are wrong
```

In [20]:

```
#Given:
r = 18. #Compression ratio
P1 = 1.01
P3 = 69. #Pressure at 1, 3 in bar
T1 = 20.+273 #Temperature at 1 in K
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
cp = 1.005 #Specific heat at consmath.tant pressure in kJ/kgK
g = 1.4 #Specific heat ratio(gamma)
R = 0.287 #Specific gas consmath.tant in kJ/kgK
#Solution:
T2 = T1*r**(g-1) #Temperature at 2 in K
P2 = P1*r**g #Pressure at 2 in bar
T3 = T2*(P3/P2) #Temperature at 3 in K
Q_v = cv*(T3-T2) #Heat added at consmath.tant volume in kJ/kg
#Given, Heat added at consmath.tant volume is equal to heat added at consmath.tant pressure
T4 = Q_v/cp+T3 #Temperature at 4 in K
rho = T4/T3 #Cut off ratio
T5 = T4*(rho/r)**(g-1) #Temperature at 5 in K
Q1 = 2*Q_v #Heat supplied in cycle in kJ/kg
Q2 = cv*(T5-T1) #Heat rejected in kJ/kg
eta = 1-Q2/Q1 #Thermal efficiency
W = Q1-Q2 #Work done by the cycle in kJ/kg
V1 = 1*R*T1/(P1*100) #Volume at 1 in m**3/kg
V2 = V1/r #Volume at 2 in m**3/kg
V_s = V1-V2 #Swept volume in m**3/kg
mep = W/(V_s*100) #Mean effective pressure in bar
#Results:
print " The air standard efficiency, eta = %.1f percent"%(eta*100)
print " The mean effective pressure, mep = %.2f bar"%(mep)
```

In [22]:

```
import math
#Given:
P1 = 1. #Pressure at 1 in bar
T1 = 50.+273 #Temperature at 1 in K
r = 14.
rho = 2.
alpha = 2. #Compression ratio, cut off ratio, pressure ratio
g = 1.4 #Specific heat ratio(gamma)
cp = 1.005 #Specific heat at consmath.tant pressure in kJ/kgK
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
#Solution:
#Refer fig 2.30
T2 = T1*math.ceil(100*r**(g-1))/100 #Temperature at 2 in K
P2 = round(P1*r**g) #Pressure at 2 in bar
P3 = alpha*P2 #Pressure at 3 in bar
T3 = T2*(P3/P2) #Temperature at 3 in K
T4 = T3*rho #Temperature at 4 in K
e = r/rho #Expansion ratio
T5 = T4/e**(g-1) #Temperature at 5 in K (Round off error)
Q1 = cv*(T3-T2)+cp*(T4-T3) #Heat added in kJ/kg
Q2 = cv*(T5-T1) #Heat rejected in kJ/kg
eta = 1-Q2/Q1 #Air standard efficiency
#Results:
print " The temperature\tT1 = %d K\tT2 = %d K\tT3 = %d K\tT4 = %d K\tT5 = %d K"%(T1,T2,T3,T4,T5)
print " The ideal thermal efficiency, eta = %.1f percent"%(eta*100)
#Round off error in the value of 'T5'
```

In [24]:

```
import math
from sympy import Symbol, solve
#Given:
r = 15. #Compression ratio
P1 = 1.
P3 = 55. #Pressure at 1, 3 in bar
T1 = 27.+273 #Temperature at 1 in K
g = 1.4 #Specific heat ratio(gamma)
cp = 1.005 #Specific heat at consmath.tant pressure in kJ/kgK
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
#Solution:
#Refer fig 2.31
T2 = T1*r**(g-1) #Temperature at 2 in K
P2 = P1*r**g #Pressure at 2 in bar
alpha = P3/P2 #Constant volume pressure ratio
T3 = T2*(P3/P2) #Temperature at 3 in K
Q1_v = cv*(T3-T2) #Heat supplied at consmath.tant volume in kJ/kg
T4 = Symbol("T4") #Defining temperature at 4 as unknown in K
#Given, heat supplied at consmath.tant volume, Q1_v is twice of heat supplied at consmath.tant pressure, Q1_p
Q1_p = cp*(T4-T3) #Heat supplied at consmath.tant pressure in kJ/kg
T4 =solve(Q1_v-2*Q1_p)[0] #Temperature at 4 in K
rho = T4/T3 #Cut off ratio
e = r/rho #Expansion ratio
T5 = T4/e**(g-1) #Temperature at 5 in K
eta = 1-(T5-T1)/((T3-T2)+g*(T4-T3)) #Thermal efficiency
eta = round(100*eta)
#Results:
print " The consmath.tant volume pressure ratio, alpha = %.2f"%(alpha)
print " The cut off ratio, rho = %.2f"%(rho)
print " The thermal efficiency of the cycle, eta = %d percent"%(eta)
```

In [25]:

```
#Given:
n = 6. #Number of cylinders
V_s = 300. #Engine swept volume in cm**3 per cylinder
r = 10. #Compression ratio
N = 3500. #Engine speed in rpm
bp = 75. #Brake power in kW
P1 = 1. #Pressure at 1 in bar
T1 = 15.+273 #Temperature at 1 in K (misprint)
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
cp = 1.005 #Specific heat at consmath.tant pressure in kJ/kgK
g = 1.4 #Specific heat ratio(gamma)
#Solution:
#Refer fig 2.32
#Otto cycle
eta_o = 1-1/r**(g-1) #Cycle efficiency
Q1 = bp/eta_o #Rate of heat addition in kW
P_o = bp/n #Power output per cylinder in kW
W_o = P_o/(N/(2*60)) #Work output per cycle per cylinder in kJ
mep_o = W_o/V_s*10**6/100 #Mean effective pressure in bar
T2 = T1*r**(g-1) #Temperature at 2 in K
Q1 = Q1/(n*N/(2*60)) #Heat supplied per cycle per cylinder in kJ
R = 0.287 #Specific gas consmath.tant in kJ/kgK
v1 = R*T1/(P1*100) #Volume of air in m**3/kg
V1 = V_s/(1-1/r)*10**-6 #Volume at 1 in m**3
m = V1/v1 #Mass of the air in kg
T3 = T2+Q1/(m*cv) #Temperature at 3 in K
#Diesel cycle
T31 = T2+Q1/(m*cp) #Temperature at 3 in diesel cycle in K
rho = T31/T2 #Cut off ratio for diesel cycle
eta_d = 1-((rho**g-1)/(r**(g-1)*g*(rho-1))) #The air standard efficiency
Power = eta_d*bp/(eta_o) #Power output in kW
P_d = Power/n #Power output per cylinder in kW
W_d = P_d/(N/(2*60)) #Work output per cycle per cylinder in kJ
mep_d = W_d/V_s*10**6/100 #Mean effective pressure in bar
#Results:
print " The rate of heat addition same for both Petrol and Diesel engine, Q1 = %.1f kW"%(bp/eta_o)
print " For Petrol engine\t Cycle efficiency, eta = %.3f\t Mean effective pressure, mep = %.2f bar\t The maximum temperature of the cycle, Tmax = %.0f K"%(eta_o,mep_o,T3)
print " For Diesel engine\t Cycle efficiency, eta = %.2f\t Mean effective pressure, mep = %.2f bar\t The maximum temperature of the cycle, Tmax = %.0f K\t Power output = %.1f kW"%(eta_d,mep_d,T3,Power)
```

In [26]:

```
#Given:
r = 10. #Compression ratio
P1 = 1. #Pressure at 1 in bar
T1 = 40.+273 #Temperature at 1 in K
Q1 = 2700. #Heat added in kJ
#Solution:
#Refer fig 2.33
g = 1.4 #Specific heat ratio(gamma)
R = 0.287 #Specific gas consmath.tant in kJ/kgK
cp = 1.005 #Specific heat at consmath.tant pressure in kJ/kgK
V1 = 1*R*T1/(P1*100) #Volume at 1 in m**3/kg
V5 = V1 #Volume at 5 in m**3/kg
V2 = V1/r #Volume at 2 in m**3/kg
V3 = V2 #Volume at 3 in m**3/kg
V_s = V1-V2 #Swept volume in m**3/kg
T2 = T1*r**(g-1) #Temperature at 2 in K
P2 = P1*r**g #Pressure at 2 in bar
#(a)Limited-pressure cycle
P3 = 70 #Limited maximum pressure in bar.
T3 = T2*(P3/P2) #Temperature at 3 in K
cv = 0.718 #Specific heat at consmath.tant volume in kJ/kgK
Q_v = cv*(T3-T2) #Heat supplied at consmath.tant volume in kJ
Q_p = Q1-Q_v #Heat supplied at consmath.tant pressure in kJ
T4 = Q_p/cp+T3 #Temperature at 4 in K
V4 = V3*(T4/T3) #Volume at 4 in m**3/kg
T5 = T4*(V4/V5)**(g-1) #Temperature at 5 in K
Q2 = cv*(T5-T1) #Heat rejected in kJ/kg
W = Q1-Q2 #Work done in kJ/kg
eta1 = W/Q1 #Efficiency of Limited pressure cycle
mep1 = W/(V_s*100) #Mean effective pressure in bar
#(b)Constant volume cycle
#All the heat is supplied at consmath.tant volume in consmath.tant volume cycle
T6 = Q1/cv+T2 #Temperature at 6 in K
P6 = P2*T6/T2 #Pressure at 6 in bar
T7 = T6*(1/r)**(g-1) #Temperature at 7 in K
Q2 = cv*(T7-T1) #Heat rejected in kJ/kg
W = Q1-Q2 #Work done in kJ/kg
eta2 = W/Q1 #Efficiency of consmath.tant volume cycle
mep2 = W/(V_s*100) #Mean effective pressure in bar
#If gases expanded isentropically to their original pressure of 1 bar, this point is named as 8
P8 = P1 #Pressure at 8 in bar
T8 = T6*(P8/P6)**((g-1)/g) #Temperature at 8 in K
Q3 = cp*(T8-T1) #Heat rejected at consmath.tant pressure in kJ/kg
W_inc = Q2-Q3 #Work increased if gas expanded isentropically in kJ/kg
#Results:
print " a)For Limited pressure cycle\t The mean effective pressure, mep = %.2f bar \
\nThe thermal efficiency, eta = %.1f percent"%(mep1,eta1*100)
print " a)For Constant volume cycle\t The mean effective pressure, mep = %.1f bar \
\nThe thermal efficiency, eta = %.1f percent"%(mep2,eta2*100)
print " Additional work per kg of charge = %.1f kJ"%(W_inc)
```

In [27]:

```
#Given:
r = 6. #Compression ratio
P1 = 1.
P3 = 20. #Pressure at 1, 3 in bar
T1 = 27.+273 #Temperature at 1 in K
g = 1.4 #Specific heat ratio(gamma)
#Solution:
#Refer fig 2.34
eta_otto = 1-1/r**(g-1) #Efficiency of Otto cycle (printing error)
#For Atkinson cycle
e = (P3/P1)**g #Expansion ratio
eta_atk = 1-g*(e-r)/(e**g-r**g) #Efficiency of Atkinson cycle
#Results:
print " Efficiency of Otto cycle = %.2f percent"%(eta_otto*100)
print " Efficiency of Atkinson cycle = %.1f percent"%(eta_atk*100)
#Answer in the book is printed wrong
```

In [29]:

```
#Given:
P1 = 1.02
P2 = 6.12 #Pressure at 1, 2 in bar
T1 = 15.+273
T3 = 800+273. #Temperature at 1, 3 in K
g = 1.4 #Specific heat ratio(gamma)
cp = 1.005 #Specific heat at consmath.tant pressure in kJ/kgK
#Solution:
#Refer fig 2.18
r_p = P2/P1 #pressure ratio
eta = 1-1/r_p**((g-1)/g) #Thermal efficiency
r_w = 1-(T1/T3)*r_p**((g-1)/g) #Work ratio
#Results:
print " The thermal efficiency, eta = %.1f percent"%(eta*100)
print " The work ratio, r_w = %.2f"%(r_w)
```