Week 2 Air standard Cycle
AIM : To make a python code to plot a p-v diagram of Air Standard Otto and calculating its thermal efficiency.
PROBLEM STATEMENT : Find the thermal efficiency of air standard Otto Cycle and plot the p-v diagram if the following information is given:
Bore = 0.10 m Stroke = 0.10 m
Compression Ratio = 6 gamma = 1.4
Length of Connecting Rod = 0.15m
Pressure at the start of compression process = 1 atm
Temperature at the start of the compression process = 500 K
Maximum Temperature = 2300 K
THEORY : An air standard Otto cycle has air as the working fluid. It consists of 4 cycles:
Process 1-2 : Isentropic compression process due to which pressure and temperature increases from P1,T1 to P2, T2 and volume decreases from V1 to V2 (clearance volume).
Process 2-3 : Constant Volume Heat Addition Process in which the fuel is injected into the cylinder due to which pressure and temperature raises.
Process 3-4 : Isentropic expansion process in which the combustion mixture expands and pressure drops from P3 to P4.
Process 4-1 : Constant volume heat rejection process in which the piston forces the exhaust gases to go outside of the engine cylinder and pressure inside the cylinder becomes equal to P1.
SOLUTION PROCEDURE
# importing libraries
import math
import matplotlib.pyplot as plt
# cylinder configuration
bore = 0.10 # bore diameter in m
stroke = 0.10 # stroke length in m
cr= 6 # Compression ratio,cr = v1/v2
g= 1.4 # Gamma for air
con_rod = 0.15 # length of connecting rod in m
vs= math.pi* bore**2 * stroke/4 # stroke vol
vc = vs/(cr-1) # clearance volume
# function for calculating volume during compression process
def compression(bore,cr, con_rod, stroke, s_theta, end_theta):
a = stroke/2 # Radius of crank
R = con_rod/a
sc = math.radians(s_theta) # angle made by crank at start of compression in radians
ec = math.radians(end_theta) # angle made by crank at end of compression in radians
n = 50
v_comp = [] # empty list that will store volume
for i in range(n):
theta = sc + i*(ec -sc)/(n-1)
# formula for calculating volume
term1 = 0.5 *(cr-1)
term2 = R+1- math.cos(theta)
term3 = R**2 - pow(math.sin(theta), 2)
term4 = pow(term3, 0.5)
v_comp.append((1 + term1 * (term2 - term4))*vc)
p_comp = [] # empty list for storing pressure values
for vol in v_comp:
p_comp.append(p1* pow((v1/vol), g)) # calculating and appending pressure values in p_comp
return v_comp,p_comp
# function for calculating volume during expansion
def expansion(bore,cr, con_rod, stroke, s_theta, end_theta):
a = stroke/2 # Radius of crank
R = con_rod/a
sc = math.radians(s_theta) # angle made by crank at start of compression in radians
ec = math.radians(end_theta) # angle made by crank at end of compression in radians
n = 50
v_ex = [] # empty list for storing volume values
for i in range(n):
theta = sc + i*(ec -sc)/(n-1)
# formula for calculating volume
term1 = 0.5 *(cr-1)
term2 = R+1- math.cos(theta)
term3 = R**2 - pow(math.sin(theta), 2)
term4 = pow(term3, 0.5)
v_ex.append((1 + term1 * (term2 - term4))*vc)
p_ex = [] # empty list for storing volume values
for vol in v_ex:
p_ex.append(p3*pow((v3/vol), g)) # calculating and appending pressure values in p_comp
return v_ex,p_ex
# state variables of point 1
v1 = vc+vs # volume in cubic metre
p1 = 101325 # pressure in pascal
t1 = 500 # temperature in Kelvin
v_comp,p_comp = compression(bore, cr, con_rod, stroke, 180,0) # isentropic compression curve points
# state variables of point 2
v2 = vc
p2 = p1* pow(cr, g) # using p1*v1^g = p2*v2^g
t2 = t1* pow(cr, g-1) # using t2/t1 = (v1/v2)^(g-1)
# state variables of point 3
v3 = v2
t3 = 2300
p3 = p2 * t3/t2 # using ideal gas equation i.e p2*v2/t2= p3*v3/t3
v_ex,p_ex = expansion(bore, cr, con_rod, stroke, 0, 180) # isentropic expansion curve points
# state variables of point 4
v4 = v1
p4 = p3/ pow(cr ,g) # using p3*v3^g = p4*v4^g
t4 = t3/ pow(cr, g-1) # using t4/t3 = (v3/v4)^(g-1)
# Thermal Efficiency
te = 1 - (1/pow(cr,g-1))
t_efficiency = te*100
print("Thermal efficiency of Otto Cycle is:", t_efficiency, " %")
# code for plotting and showing the graph
plt.plot([v2,v3], [p2, p3], label =" Constant volume heat addition")
plt.plot(v_comp , p_comp, label ="Isentropic compression ")
plt.plot(v_ex , p_ex, label = "Isentropic expansion ")
plt.plot([v4, v1], [p4,p1] , label =" Constant volume heat rejection" )
plt.xlabel("Volume")
plt.ylabel("Pressure")
plt.legend()
plt.show()
- Importing ‘math’ and ‘matplotlib’ modules and defining and initializing the known parameters.
- Calculated stroke and clearance volume using the formula:
Stroke volume, vs= `(pi* (bore)^2 *stroke)/4`
Clearance volume,vc = stroke volume/(cr-1)
Where cr = compression ratio = V1/V2 = (vc+vs)/vc
- Calculated volume at the start of compression process and defined the state variables .
V1=vs +vc , p1 = 101325 Pa, T1 = 500 K
- For calculating the volume and pressure at each point of compression process, a function compression() has been called which takes some input parameters and return the pressure and volume array. The starting crank angle would be 1800 and ending crank angle would be 00 because the piston moves from BDC to TDC. Equation for calculating V is:
Equation for calculating pressure: p1*v1^gamma = p2*v2^gamma
Here v is known as computed earlier and corresponding to each v, p is computed and stored in list p_comp using for loop.
def compression(bore,cr, con_rod, stroke, s_theta, end_theta):
a = stroke/2 # Radius of crank
R = con_rod/a
sc = math.radians(s_theta) # angle made by crank at start of compression in radians
ec = math.radians(end_theta) # angle made by crank at end of compression in radians
n = 50
v_comp = [] # empty list that will store volume
for i in range(n):
theta = sc + i*(ec -sc)/(n-1)
# formula for calculating volume
term1 = 0.5 *(cr-1)
term2 = R+1- math.cos(theta)
term3 = R**2 - pow(math.sin(theta), 2)
term4 = pow(term3, 0.5)
v_comp.append((1 + term1 * (term2 - term4))*vc)
p_comp = [] # empty list for storing pressure values
for vol in v_comp:
p_comp.append(p1* pow((v1/vol), g)) # calculating and appending pressure values in p_comp
return v_comp,p_comp
5. Point 2 represents the end of compression stroke and start of heat addition process at constant volume and therefore
V2 = clearance volume and p2 and t2 are found out using the relations:
6. Point 3 represents the end of heat addition process at constant volume. Therefore, v3 =v2 and t3 is given to be 2300 K. Now p3 can be found out using the ideal gas relation : p3/t3 = p2/t2 ( since v3 = v2, it is cancelled out)
For calculating volume at each point of compression process we again use the equation that we use for calculating compression volume but now the starting crank angle would be 00 and ending crank angle would be 1800 because the piston moves from TDC to BDC.
In the similar way pressure has been calculated using the function expansion().
7. The point 4 represents the end of the isentropic expansion process and start of constant volume heat rejection process. Therefore, V4 = V1 , and pressure and temperature can be found out using the following relations:
8. Thermal efficiency of Otto cycle is given by:
Using this formula efficiency is calculated and printed on the screen using print() function.
9. Finally p-v graph is plotted using the plot() function.
RESULTS AND CONCLUSIONS:
This program plots the p-v diagram of Otto cycle and calculates its efficiency. From the diagram it is clear that there are 2 isentropic processes and 2 constant volume processes. Also for these engine parameters and initial conditions the efficiency of Otto cycle is almost half of Carnot cycle.