All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Otto cycle - Python OBJECTIVE Introduction to IC engine and air standard cycle Plotting PV graph of Otto cycle using Python THEORY IC Engine It is a heat engine that converts the chemical energy of fuel into mechanical energy. The chemical energy of the fuel gets converted to thermal energy through the combustion of an…
Vidu Bansal
updated on 26 Dec 2022
Otto cycle - Python
OBJECTIVE
THEORY
IC Engine
It is a heat engine that converts the chemical energy of fuel into mechanical energy. The chemical energy of the fuel gets converted to thermal energy through the combustion of an air-fuel mixture inside the engine. This thermal energy raises the temperature and pressure of the gases inside the engine, and then this high-pressure gas expands and makes the crankshaft rotate with the help of mechanical linkage.
Swept volume – It is defined as the volume of oil that is swept or displaced by the actuator piston during an opening or closing cycle.
Clearance volume – The clearance volume of the engine is the volume between the cylinder head and the piston when the piston is at TDC. The ratio of this volume to the swept volume determines the compression ratio of the engine.
4-stroke engines
The top dead centre (TDC) of a piston is the position where it is nearest to the valves; the bottom dead centre (BDC) is the opposite position where it is furthest from them. While an engine is in operation, the crankshaft rotates continuously at a nearly constant speed. In a 4-stroke ICE, each piston experiences 2 strokes per crankshaft revolution in the following order.
Air Standard Cycle
The operation of an IC engine occurs over several thermodynamic processes which are complicated tasks to evaluate. To make it simple, we consider an idealized case for the cycle, which is considered the Air Standard cycle. The air standard cycle is used to estimate engine performance.
Assumption
Types
Otto Cycle
This cycle describes the functioning of a typical spark ignition piston engine. It is also known as the constant volume cycle.
PV diagram layout
Thermodynamic Relations
Piston Kinematics equation
CODE EXPLANATION
CODE
"""
otto cycle simulator
"""
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
"""
Engine Kinematics function which traces the volume for expansion and compression for varying crank angles.
"""
# Geometric parameters
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)
s_c = math.radians(start_crank)
e_c = math.radians(end_crank)
num_value = 50
dtheta = (e_c-s_c)/(num_value-1)
V = []
for i in range(0,num_value):
theta = s_c + 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
# inputs
p1 = 101325
t1 = 500
t3 = 2300
gamma = 1.4
# geometric parameters
bore = 0.1 # cylinder diameter
stroke = 0.1 # vertical distance in which the piston slides
con_rod = 0.15 # length of connecting rod
cr = 12 # compression ratio - ratio of volume before compression to the volume after compression
# Volume computation
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_c + v_s # volume before compression is the sum of swept volume(v_s) and clearance volume (v_c)
# state point 2
v2 = v_c # v_c refers to clearance volume or volume after compression
# p2v2^gamma = p1v1^gamma
p2 = p1*pow(v1,gamma)/pow(v2,gamma)
# p2v2/t2 = p1v1/t1 | rhs = p1v1/t1 | p2v2/t2 = rhs | t2 = p2v2/rhs
rhs = p1*v1/t1
t2 = p2*v2/rhs
# engine kinematics
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
# engine kinematics
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^gammma
p4 = p3*pow(v3,gamma)/pow(v4,gamma)
# p4v4/t4 = p3v3/t3 = rhs
t4 = p4*v4/rhs
# Thermal Efficiency
e = 1 - (t4 - t1)/(t3 - t2)
print(e)
# Plot
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(m^3)')
plt.ylabel('Pressure(Pa)')
plt.title('PV plot for Otto Cycle')
plt.legend(['constant volume heat addition','adiabatic compression','adiabatic expansion','constant volume heat rejection'])
plt.grid()
plt.show()
OUTPUT
PV Plot
Thermal Efficiency
Output Value
REFERENCES
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 6 - Data analysis
Data Analysis OBJECTIVE Data Visualizer Compatibility check Basic performance calculation THEORY Data analysis Data analysis is a process of inspecting, cleansing, transforming and modelling data with the goal of discovering useful information, informing conclusions, and supporting decision-making. This deals with the…
29 Dec 2022 05:23 PM IST
Week 2 Air standard Cycle
Otto cycle - Python OBJECTIVE Introduction to IC engine and air standard cycle Plotting PV graph of Otto cycle using Python THEORY IC Engine It is a heat engine that converts the chemical energy of fuel into mechanical energy. The chemical energy of the fuel gets converted to thermal energy through the combustion of an…
26 Dec 2022 06:52 PM IST
Week 5 - Curve fitting
CURVE FITTING – Python OBJECTIVE How to change the experimental data into a mathematical equation. Ways to measure the goodness of fit To fit Cp data according to the given Cp vs temperature data file THEORY Curve Fitting It is one of the techniques of data analysis to validate and find the mathematical relation…
25 Dec 2022 04:57 PM IST
Week 3 - Solving second order ODEs
Solving Second Order ODE Using PYTHON OBJECTIVE To create a simulation of simple pendulum with python as a solution for second-order ODE with damping. THEORY ODE is used to describe the transient behavior of a system. Example; PENDULUM The path of pendulum depends on the Newton’s second law. ODE representing the…
25 Dec 2022 07:30 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.