An Otto Cycle P-V plot and calculation of thermal efficiency using Python
Aim- Write a python program for the PV plot and calculation for thermal efficiency of Otto Cycle
Theory- Otto Cycle - Otto Cycle is a idealized thermodynamic cycle, that describes the functioning of a typical spark ignition piston engine. The Otto cycle is the name of the cycle used in spark ignition internal combustion engine such as hydrogen and gasoline fuelled automobile engine. The Otto cycle consists of following processes-
1. Process 0-1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
2. Process 1-2 is an adiabatic(isentropic) compression of the charge as the piston moves from bottom dead centre(BDC) to top dead centre(TDC)
3. Process 2-3 is a constant volume heat addition to the working gas from an external source while the piston is at top dead centre. This process is intended to represent the ignition of the fuel-air mixture & the subsequent rapid burning.
4. Process 3-4 is a adiabatic(isentropic) expansion (power stroke).
5. Process 4-1 completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at bottom dead centre.
6. Process 1-0 the mass of air is released th the atmosphere in a constant pressure proces
Following are the various plots of the Otto Cycle-
Otto Cycle T-S diagram & P-V diagram
Efficiency of the cycle- The theoretical efficiency of the Otto cycle deoends on the compression ratio and the specific heat ratio γ of the gas in the combustion chamber.
The isentropic processes are governed by the following equation mentioned in the tutorial :
V = 1 + 0.5*(cr – 1) * (R+ 1 –cos(θ) – (R^2 - sin(θ)^2 )(0.5) *Vc)
Since this is a large equation, it was broken into three different terms and used in the code. Also in order to calculate the thermal efficiency of the Otto Cycle, the following formula was used :
ηth = (1- ((t4-t1) / (t3-t2)) * 100
Also, the above isentropic process equation was implemented in the code using the function Engine kinematics. The function was defined first and was later called for the compression and expansion processes respectively. All other necessary data has been provided in the code itself
Compression ratio(r) is the ratio of the volume of the cylinder & the combustion chamber when the piston is at the bottom, & the volume of the combustion chamber when the piston at the top.For better fuel efficiency & fuel economy automobiles are to be designed with higher compression ratio. However, the compression ratio of Otto cycle engines is limited by the need to prevent the uncontrolled combustion known as knocking. Modern engines have compression ratio in the range of 8 to 11, resulting in ideal efficiency of 56% to 61%.
r = Vmax/Vmin = V1/V2
Specific Heat Ratio(γ) of a gas is the ratio of specific heat at constant pressure Cp to the specific heat at constant volume Cv.
γ = Cp/Cv
The heat supplied to the working fluid during constant-volume heating(combustion) = Qin = Cv(T3-T2)
The heat rejected from the working fluid during constant-volume cooling(exhaust)= Qout = Cv(T4-T1)
Efficiency(η) = Wnet/Qin = 1-Qout/Qin
PYTHON CODE FOR OTTO CYCLE
#0tto cycle using engine kinematics
#importing necessary libraries
import math
import matplotlib.pyplot as plt
#Defining the function for engine kinematics
def otto_standard_cycle (bore, stroke, con_rod, cr, start_crank, end_crank):
a = stroke/2
R = con_rod/a
# Volume parameters
V_s = math.pi*(1/4)*pow(bore, 2)*stroke
V_c = V_s/(cr-1)
# Crank angle
SC = math.radians(start_crank)
EC = math.radians(end_crank)
#Number of data points to be taken for the varying angle
num_values = 50
#Calculating theta
dtheta = EC-SC/ (num_values-1)
#creating an empty array
V = []
#Calculating theta in the array
for i in range (0, num_values):
theta = SC + i*dtheta
term1 = 0.5*(cr-1)
term2 = R + 1 - math.cos(theta)
term3 = pow(R, 2) - (pow (math.sin(theta),2))
term4 = pow(term3,0.5)
V.append((1 + term1*(term2-term4)) * V_c)
return V
#Main function
#Inputs
p1 = 101325
t1 = 600
gamma = 1.4
t3 = 2600
#Geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 14
#Volume parameters
v_s = math.pi*(1/4)*pow(bore, 2)*stroke
v_c = v_s/(cr-1)
v1 = v_c + v_s
# state process 2
v2 = v_c
p2 = p1*pow( v1,gamma)/pow(v2,gamma)
rhs = p1*v1/t1
t2 = p2*v2/rhs
#Compression process
#Calling the function defined above
V_compression = otto_standard_cycle (bore, stroke, con_rod, cr, 180, 0)
Constant = p1*pow(v1,gamma)
#p_compression*v_compression^gamma = constant
P_compression = []
for V in V_compression:
P_compression.append(Constant/pow(V,gamma))
# state process 3
v3 = v2
rhs =p2*v2/t2
p3= rhs*t3/v3
#expansion process
V_expansion = otto_standard_cycle (bore, stroke, con_rod, cr, 180, 360)
Constant = p3*pow(v3,gamma)
P_expansion = []
for V in V_expansion:
P_expansion.append(Constant/pow(V,gamma))
# state process 4
v4 = v1
p4 = p3*pow(v3, gamma )/pow(v4, gamma)
t4 = p4*v4/rhs
#Thermal Efficiency using temperatures
n = 1 - ((t4-t1)/(t3-t2))
print(n)
#plot PV daigram
plt.plot([v2,v3], [p2,p3],'-b', label='Heat Addition')
plt.plot(V_compression, P_compression,'-r', label='Compression')
plt.plot (V_expansion,P_expansion, '-y', label='Expansion')
plt.plot([v4, v1], [p4,p1], '-g', label='Heat Rejection')
plt.legend()
plt.xlabel( 'Volume, m^3')
plt.ylabel('Pressure, Bar')
plt.title('Otto cycle Constant PV daigram')
plt.grid()
plt.savefig('Otto cycle Constant PV daigramS')
plt.show()
Explanation of code
- First of all import all the libraries & define thr function for Piston_Kinematics and its all the parameters.
- Give all the inputs , state variables and Engine geometric parameters.
- Than define the formula of the swept volume and clearance volume.
- Give the relation between V1 & V2, and define the state inputs of point 2.
- Now with the help of this function define compression, and than define the state points of state 3 using property equation & mention them in comments.
- Now similarly define the expansion with the help of same function & give the state points of state 4.
- Mention the thermal efficiency formula.
- Now using plot command write the variables, color of line, legends, labels and title of the plot.
- Now save the program & run thr program.
- Record the output plot displayed and find out thermal efficiency
Results- The above program generates the following plots
Conclusion
- The thermal efficiency was calculated to be 65.202%.
- P-V diagram clearly shows that changes in isentropic processes are a curve not a straight line.