Otto Cycle Visualisation
OTTO CYCLE VISUALISATION
Aim :
To create a Python program that can solve an Otto cycle and make plots for the Otto cycle
Objective:
To create a PV Diagram for the otto cycle and find the thermal efficiency of the engine.
Theory:
Otto Cycle:
The Otto cycle is the ideal cycle of a spark-ignition combustion engines, each of these kind of engines go through four strokes named as,
- Suction stroke
- Compression Stroke
- Power/Expansion stroke
- Exhaust stroke
Similarly, an otto cycle has 4 thermodynamic processes named as,
- Isentropic Compression
- Constant-Volume heat addition
- Isentropic expansion
- Constant-Volume heat rejection
In real-life scenarios, the plots obtained for an otto cycle of an engine will be same as the one obtained through theoretical calculations and below image shows clearly the difference obtained in various fields of calculations.
In this project, an ideal Otto cycle is considering which has certain assumptions, few factors are neglected and the calculations will be proceeded ahead in this program with those considerations.
Geometric Parameters of Engine :
A listed number of geometric parameters are given as inputs as these measurements are obtained practically from the engine specsheets and the other parameters are dependent on these geometric parameters and they are listed below
- Bore
- Stroke
- Connecting Rod
- Compression Ratio
Formulas used :
Piston Kinematics Equation:
The below mentioned kinematic equation is used to analyse the position of the piston between the Top Dead center and Bottom dead center with respect to the applicable situations
Where,
Rc -> Compression Ratio
R -> Ratio of connecting rod length to crank pin radius
Vc -> Clearance volume
Thermal Efficiency:
It is the efficieny of a heat engine measured by the ratio of the work done by the engine to the heat supplied to it.
Working of the program:
The Program is mainly divided into 2 parts namely the function part and the main part,
The function part which is the function names engine_kinematics takes arguments as inputs from various parameters like bore, stroke connecting rod length, crank ratio, starting and ending crank angle and the volume is calculated for expansion and compression processes using the Piston Kinematics equation and the value stored in array is returned to the calling statement
The main part of the program provides inputs to various independent engine parameters and the state variables such as 1,2,3,4 are initialised depending upon the various stroke scenarios for pressure, volume and temperature. Formulas such as Pressure*Volume raised to gamma, Pressure*volume/temperature helps in enhancing the values at different states. Pressure during compression and expansion strokes are calculated using the volumes at compression and expansion strokes respectively.
Program Code :
"""
Progrm to create a Otto cycle visualisation
and find the thermal efficiency of the engine
"""
import math
import matplotlib.pyplot as plt
#function definition for engine kinematics
def engine_kinematics(bore,stroke,con_rod,cr,s_crank,e_crank):
a=stroke/2 #crank pin radius
r=con_rod/a
#volume parameters
v_s = math.pi*(1/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
s_c = math.radians(s_crank)
e_c = math.radians(e_crank)
num = 50
theta = []
dtheta = (e_c-s_c)/(num-1)
vol=[]
for i in range(0,num):
theta = s_c+i*dtheta
term1 = 0.5*(cr-1)
term2 = r+1-math.cos(theta)
ac = pow(r,2) - pow(math.sin(theta),2)
term3 = pow(ac,0.5)
vol.append((1+term1*(term2-term3))*v_c)
return vol #returning the vol array
#inputs
p1 = 101325
t1 = 500
t3 = 2300
gamma = 1.4
#geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 12
#volume calculations
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_s+v_c #volume for State 1
#State 2 variable
v2 = v_c
#p2*v2^gamma =p1*v1^gamma
p2 = p1*pow(v1,gamma)/pow(v2,gamma)
#Temperature Calculation
cvalue = p1*v1/t1
t2 = (p2*v2)/cvalue
v_compression = [] #initialising an empty array
v_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0)
p_compression = []
for v in v_compression :
p_compression.append((p1*pow(v1,gamma))/pow(v,gamma))
#State 3 variable
v3 = v2 #constant value
#pressure computaion => p3v3/t3 = p2v2/t2
cvalue = (p2*v2)/t2
p3 = cvalue*t3/v3
v_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180)
p_expansion = []
for v in v_expansion :
p_expansion.append((p3*pow(v3,gamma))/pow(v,gamma))
#State 4 variable
v4 = v1 #v_s+v_c because the piston is at BDC
p4 = p3*pow(v3,gamma)/pow(v4,gamma)
#Temperature Calculation
t4 = p4*v4/cvalue
efficiency = round((1-(1/math.pow(cr,(gamma-1)))),3)*100
print("Thermal efficiency of Engine = ",efficiency,"%\n\n")
#Plots
plt.plot([v2,v3],[p2,p3])
plt.plot(v_compression , p_compression)
plt.plot(v_expansion, p_expansion)
plt.plot([v4,v1],[p4,p1])
plt.xlabel('Volume')
plt.ylabel('Pressure')
plt.show()
Output :
Value obtained for Thermal efficiency of engine
Plot for Otto Cycle