All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
INTRODUCTION: - The Otto cycle is the theoretical cycle of interest when one is considering reciprocating SI engines. The four-stroke Otto cycle is made up of the following four internally reversible processes: 1–2, isentropic compression; 2–3, constant-volume heat addition; 3–4, isentropic…
Rajiv Ranjan
updated on 19 May 2021
INTRODUCTION: -
The Otto cycle is the theoretical cycle of interest when one is considering reciprocating SI engines. The four-stroke Otto cycle is made up of the following four internally reversible processes: 1–2, isentropic compression; 2–3, constant-volume heat addition; 3–4, isentropic expansion; and 4–1, constant-volume heat rejection.
P-v and T-s diagram of an ideal Otto cycle.
The four processes of the cycle is -
Process 1-2: Isentropic compression of the working fluid occurs as the piston moves from bottom dead center (BDC) to top dead center (TDC).
Process 2-3: Here, with the SI, a rapid burning occurs inside the piston; therefore, the heat addition takes place at the constant volume.
Process 3-4: In this process, the working fluid expands isentropically and produces the useful work for the cycle.
Process 4-1: Heat removal at constant volume. In practical applications, the heat is removed by expelling the exhaust gas to the atmosphere.
OBJECTIVE: -
Write a python program for an otto cycle so that -
PROCEDURE: -
We will start with importing the Math and Matplotlib modules.
"""
OTTO CYCLE SIMULATOR
"""
import math
import matplotlib.pyplot as plt
We will define the function to store the different values of crank angle rotation as the compression and expansion occur in different cycles.
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
"""
Engine Kinematics
"""
#Geometric Pramaters
cr = 12
a = stroke/2
The number of values for which the program will iterate is 50.
#Volume parameters
v_s = (math.pi/4)* pow(bore,2)*stroke
v_c = v_s/(cr-1)
sc = math.radians(start_crank)
ec = math.radians(end_crank)
num_values = 50
dtheta = (ec-sc)/(num_values-1)
The equation describes the relationship between the crank angle and volume inside the combustion chamber. The whole equation is divided into three terms for the sake of simplicity in coding.A null array 'V' is created to store the new values after every iteration using append command.
V = []
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)
term3 = pow(term3,0.5)
V.append((1+term1*(term2- term3))*v_c)
return V
p1 is defined as the atmospheric pressure,the specific heat of the air(gamma) is taken as 1.4,t1 and t3 are temperatures corresponding to the state point 1 and 3 respectively.
The geometric parameters bore diameter,stroke length and the connecting rod length and compression ratio is defined in the code.
#Inputs
p1 = 101325
t1 = 500
gamma = 1.4
t3 = 2300
#Geometric Parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 12
a = stroke/2
R = con_rod/a
Calculating the swept volume and the clearance volume.
#Volume Computation
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_c + v_s
#state point 2
v2 = v_c
#P2V2^gamma = P1V1^gamma
p2 = p1 * pow(v1,gamma)/pow(v2,gamma)
#P2V2/t2 = P1V1/rhs = P1V1/t1 | P2V2/t2 = rhs | t2 = P2V2/rhs
rhs = p1 * v1/t1
t2 = p2 * v2/rhs
v_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0)
constant = p1*pow(v1,gamma)
p_compression = []
for v in v_compression:
p_compression.append(constant/pow(v,gamma))
#state point 3
v3 = v2
#P3V3/T3 = P2V2/T2 | RHS = P2V2/T2 | P3 = RHS*T3/V3
rhs = p2*v2/t2
p3 = rhs * t3/v3
v_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180)
constant = p3*pow(v3,gamma)
p_expansion = []
for v in v_expansion:
p_expansion.append(constant/pow(v,gamma))
#state point 4
v4 = v1
#P4V4^gamma = P3V3^gamma
p4 = p3 * pow(v3,gamma)/pow(v4,gamma)
#P4V4/t4 = rhs
t4 = p4 * v4/rhs
Finally plotting the P-v diagram
plt.plot([v2,v3],[p2,p3])
plt.plot(v_compression,p_compression)
plt.plot([v1,v4],[p1,p4])
plt.plot(v_expansion,p_expansion)
The Thermal efficiency of the Otto cycle can be calculated using following code.
#Calculating Thermal Efficiency of otto cycle
Thermal_efficiency = (1 - 1/pow(cr,gamma-1))
print (Thermal_efficiency)
OUTPUT: -
The Thermal Efficiency for the Otto Cycle is -
0.6298928275128466.
Leave a comment
Thanks for choosing to leave a comment. Please keep in mind that all the comments are moderated as per our comment policy, and your email will not be published for privacy reasons. Please leave a personal & meaningful conversation.
Other comments...
Week 3 - Solving second order ODEs
import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt import math # function that returns dz/dt def model(theta,t,b,g,l,m): theta1 = theta [0] theta2 = theta [1] dtheta1_dt = theta2 dtheta2_dt = -(b/m)*theta2 - (g/l)* math.sin(theta1) dtheta_dt = [dtheta1_dt,dtheta2_dt] return dtheta_dt…
01 Jul 2021 03:33 AM IST
Week 6 - Data analysis
import matplotlib.pyplot as plt import numpy as np from numpy import trapz fname = input("Enter the filename: ") if fname == 'engine_data.out': print('file is valid') else: print('file is invalid') exit() def compatibility_check(a): if 'CONVERGE' not in a: print('please provide converge output file to process') exit()…
30 Jun 2021 12:37 PM IST
Week 5 - Curve fitting
1. What does popt and pcov mean? The curve_fit function returns two items, which we call popt and pcov.The popt argument are the best fit for 'a' and 'b'. The pcov variable contains the covariance matrix which indicates the uncertainties and corelation between parameters. This is mostly useful when the data has uncertainties.…
30 Jun 2021 12:31 PM IST
Week 2 Air standard Cycle
INTRODUCTION: - The Otto cycle is the theoretical cycle of interest when one is considering reciprocating SI engines. The four-stroke Otto cycle is made up of the following four internally reversible processes: 1–2, isentropic compression; 2–3, constant-volume heat addition; 3–4, isentropic…
19 May 2021 10:07 AM IST
Related Courses
0 Hours of Content
Skill-Lync offers industry relevant advanced engineering courses for engineering students by partnering with industry experts.
© 2025 Skill-Lync Inc. All Rights Reserved.