All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Objective: - Develop a code that can solve an otto cycle and make plots for it. Principle: - An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark-ignition engine. It is the thermodynamic cycle most commonly found in automobile engines. The Otto Cycle…
Saransh Dimri
updated on 29 Nov 2020
Objective: -
Develop a code that can solve an otto cycle and make plots for it.
Principle: -
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark-ignition engine. It is the thermodynamic cycle most commonly found in automobile engines. The Otto Cycle is an air-standard cycle that approximates the processes in petrol or diesel engines. It is based on constant volume heat addition (combustion) and heat rejection processes, and Isentropic compression and expansion
There are three air-standard cycles:
Solution Procedure: -
The basic Otto cycle has four processes:
Processes: -
Governing Equations: -
VVc=1+0.5(CR−1)[R+1−cosθ−(R2−sin2θ)0.5]
PVr=constant
PT=constant
CR=Vs+VcVc
η=1−1(RC)γ−1
CODE for the Function used: -
def engine_kinematics(bore , stroke, con_rod , cr ,start_crank , end_crank):
# a is crank pin radius
a=stroke/2
#R is the ratio for the connecting rod to the crank pin radius
R = con_rod/a
#swepth volume and clearance volume
v_swept =math.pi*(1/4)*pow(bore,2)*stroke
v_c= v_swept/(cr-1)
st_cr=math.radians(start_crank)
en_cr = math.radians(end_crank)
num_val= 50
dtheta = (en_cr - st_cr)/(num_val - 1)
V=[]
for i in range (0,num_val):
theta = st_cr + 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)
#Equation
V.append((1+term1*(term2 -term3))*v_c)
return V
Explanation of the above code: -
def engine_kinematics(bore, stroke, con_rod, cr,start_crank, end_crank) - function is used to make the code easy to implement, it is a group of statements that together perform a task
# - comment makes a program user friendly
a=stroke/2 - a is crankpin radius
R = con_rod/a - R is the ratio for the connecting rod to the crank pin radius
#swepth volume and clearance volume - comments
v_swept =math.pi*(1/4)*pow(bore,2)*stroke - calculation of the swept volume(m^3)
v_c= v_swept/(cr-1) - calculation of the clearance volume (m^3)
st_cr=math.radians(start_crank) - initializing value in radians to crank start angle
en_cr = math.radians(end_crank) - initializing value in radians to crank end angle
num_val= 50 - initializing the num val
dtheta = (en_cr - st_cr)/(num_val - 1)
V=[] - assigning a volume array
for i in range (0,num_val): - execution of the statements in the for loop till the value
theta = st_cr + i*dtheta - initializing the value of the theta
term1 = 0.5*(cr-1) - term 1 according to the equation
term2 = R + 1-math.cos(theta) - term 2 according to the equation
term3 = pow(R,2) - pow(math.sin(theta),2) - term 3 according to the equation
Code of the Otto cycle Program including the above function: -
#Otto cycle simulator
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore , stroke, con_rod , cr ,start_crank , end_crank):
# a is crank pin radius
a=stroke/2
#R is the ratio for the connecting rod to the crank pin radius
R = con_rod/a
#swepth volume and clearance volume
v_swept =math.pi*(1/4)*pow(bore,2)*stroke
v_c= v_swept/(cr-1)
st_cr=math.radians(start_crank)
en_cr = math.radians(end_crank)
num_val= 50
dtheta = (en_cr - st_cr)/(num_val - 1)
V=[]
for i in range (0,num_val):
theta = st_cr + 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)
#Equation
V.append((1+term1*(term2 -term3))*v_c)
return V
#inputs
gamma =1.4
t3 =2300
#State variable 1
p1 = 101325
t1 = 500
#Engine geometric parameters
bore= 0.1
stroke = 0.1
con_rod = 0.15 #lenght of the connecting rod
cr= 12
#calculating the swept volume and clearence volume
v_swept =(math.pi/4)*pow(bore,2)*stroke
v_clearance= v_swept/(cr-1)
v1= v_clearance+v_swept
#state point 2
v2 = v_clearance
#v1/v2 is the compression ratio
'''p2v2^gamma = p1v1^gamma
p2 = p1*(v1/v2)^gamma = p1*cr^gamma'''
p2= p1*pow(cr,gamma)
#p1v1/t1 = p2v2/t2 | t2 =p2*v2*t1/(p1*v1)
#temperature at state point 2 is t2
t2 =p2*v2*t1/(p1*v1)
v_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0)
constant_c = p1*pow(v1,gamma)
p_compression = []
for v in v_compression:
p_compression.append(constant_c/pow(v,gamma))
#state point 3 determing pressure
v3=v2
#p3v3/t3=p2v2/t2 | p3 =p2*t3/t2
p3 = p2*t3/t2
v_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180)
constant_exp = p3*pow(v3,gamma)
p_expansion = []
for v in v_expansion:
p_expansion.append(constant_exp/pow(v,gamma))
# state variables at state point 4
v4=v1
#p3v3^gamma = p4v4^gamma | p4 = p3(v3/v4)^gamma
k=v3/v4
p4 = p3*pow(k,gamma)
#p4v4/t4 = p3v3/t3
t4 = (p4*v4*t3)/(p3*v3)
#Thermal Efficiency
x=1-gamma
thermal_effi = 1-pow(cr,x)
print('Thermal efficiency = ',thermal_effi)
#plotting
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.title('Air standard cycle(otto cycle)')
plt.show()
Explanation of the above code: -
#State variable 1 - comments
#Engine geometric parameters - comments
#calculating the swept volume and clearence volume - comments
#state point 2
#v1/v2 is the compression ratio - comments
'''p2v2^gamma = p1v1^gamma
p2 = p1*(v1/v2)^gamma = p1*cr^gamma''' - comments
#p1v1/t1 = p2v2/t2 | t2 =p2*v2*t1/(p1*v1) - comments for making the program user friendly
#temperature at state point 2 is t2 - comments
#state point 3 determing pressure - comments
#p3v3/t3=p2v2/t2 | p3 =p2*t3/t2 - comments
# state variables at state point 4
#p3v3^gamma = p4v4^gamma | p4 = p3(v3/v4)^gamma
#p4v4/t4 = p3v3/t3
#Thermal Efficiency
#plotting
Output: -
Thermal efficiency in the command window
Thermal efficiency = 0.6298 or 62.98%
The output of the otto cycle plot: -
Conclusion and Discussion: -
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 11 Project 2- MATLAB Module to calculate Forces and Displacements for a 3D Frame Structure(nonlinear analysis)
Objective: MATLAB Module to calculate Forces and Displacements for a 3D Frame Structure(nonlinear analysis) Solution procedure: 1) Develop a Matlab function to accept Node information: Node numbers, Node coordinates, and information on nodes to perform analysis on a 3D planar frame structure. 2) Based on the Matlab…
08 Aug 2022 02:32 PM IST
Week 1-Model Creation in DesignModeler Challenge
Objective: Model a butterfly valve Solution Procedure: 1 - Main Housing 2)SHAFT 3) UPPER PLATE:- 4) LOWER PLATE:- 5) BUTTERFLY VALVE ASSEMBLY IMPORT THE GEOMETRY FILE 6)BOLT AND NUT CONCLUSION AND LEARNING:- Learned about using design modeller learned about components sketch tools learned about…
18 Apr 2022 04:56 PM IST
Week 6 Project 1- MATLAB Module to calculate Forces and Displacements for a 3D Frame Structure(Linear analysis)
Objective: MATLAB Module to calculate Forces and Displacements for a 3D Frame Structure(Linear analysis) Solution procedure: 1) Develop a Matlab function to accept Node information: Node numbers, Node coordinates, and information on nodes to perform analysis on a 3D planar frame structure. 2) Based on the Matlab module…
08 Apr 2022 08:33 AM IST
Week 10 Challenge- Frame analysis and MATLAB Module for Gauss Elimination Method
OBJECTIVE:- 1) Assume a structure frame. Write down a displacement matrix with variables corresponding to pre-selected degrees of freedom and degrees of freedom to be eliminated. Mathematically, derive the process that takes the original set of equations and condense it to the form shown below Equtaion given is[k][δ]=[p]The `[delta(b)…
03 Apr 2022 08:03 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.