All Courses
All Courses
Courses by Software
Courses by Semester
Courses by Domain
Tool-focused Courses
Machine learning
POPULAR COURSES
Success Stories
Aim: To write a program to simulate otto cycle using python, Considering the volume change w.r.t crank angle. Objective: To trace the volumetric compression and expansion with respect to crank angle. Otto cycle: The Otto cycle is a description of what happens to a mass of gas as it is subjected to changes of pressure,…
Vinay Omase
updated on 28 Jul 2021
Aim: To write a program to simulate otto cycle using python, Considering the volume change w.r.t crank angle.
Objective: To trace the volumetric compression and expansion with respect to crank angle.
Otto cycle:
The Otto cycle is a description of what happens to a mass of gas as it is subjected to changes of pressure, temperature, volume, addition of heat, and removal of heat. The mass of gas that is subjected to those changes is called the system. The system, in this case, is defined to be the fluid (gas) within the cylinder.
PV daugram for otto cycle
Program:
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore,stroke,con_rod,cr,stark_crank,end_crank):
a=stroke/2
R=con_rod/a
v_s=math.pi*(1/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
sc=math.radians(stark_crank)
ec=math.radians(end_crank)
num_values=50
dtheta=(ec-sc)/(num_values-1)
v=[]
for i in range(0,num_values):
theta=sc+i*dtheta
print(theta)
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
#inputs
p1=101325
t1=500
gamma=1.4
t3=2300
#geometric parameter
bore=0.1
stroke=0.1
con_rod=0.15
cr=12
#volume computation
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
v1=v_s+v_c
#state point 2
v2=v_c
#p2v2^gamma=p1v1^gamma
p2=p1*pow(v1,gamma)/pow(v2,gamma)
#p2v2/t2=p1v1/t1
#rhs=p1v1/t1, then t2=p2v2/rhs
rhs=p1*v1/t1
t2=p2*v2/rhs
#adiabatic compression cycle
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, constant volume
v3=v2
#p3v3/t3=p2v2/t2
#rhs=p2v2/t2, and p3=rhs*t3/v3
rhs=p2*v2/t2
p3=rhs*t3/v3
#adiabatic expansion cycle
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
#thermal effciency of otto cycle
def ther_eff(cr,gamma):
t_effy=1-(1/pow(cr,gamma-1))
return(t_effy)
t_efficiency=ther_eff(12,1.4)
print(t_efficiency)
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('v')
plt.ylabel('p')
plt.show()
1.The def function is used to return the value that is the equation that is the volume of the piston cylinder determined as a function of crank angle from the compression ratio, the stroke, bore and connecting rod length.
V=vc*(1+0.5*(cr-1)*[R+1-cos(theta)-((R^2-sin^2(theta))^0.5)])
With out considering the above equation the pv daigram of cycle will show linear varition of pressure and volume as it will not consider the variation of volume in cylinder wrt to crank position(theta)
2.The value of volume is stored in empty array v[] for both compression and expansion cycle. For compression cycle the crank moves from 180 to 0 degree and similary it traces 0 to 180 degree in expansion cycle.
3.The math.radians converts the start crank and end crank angke into radians as we give input in degres in the function defined as
def engine_kinematics(bore,stroke,con_rod,cr,stark_crank,end_crank):
4.The volume and pressure at each point in cycle is calculated using adiabatic relation ships for pressure and volume as commented in above program
5.The thermal effciency is calculated as a function of compression ration and K = cp/cv.
Plot:
Output
The thermal effciency=0.629892
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
Aim: To simulate the motion of simple pendulum by solvind 2nd order differential equation using python considering damping coefffcient. Objective: 1)To Understand the concept of converting 2nd order ODE to first order linear system. 2) To understand the odeint function to solve the diffential equation when provided…
12 Aug 2021 09:32 AM IST
Week 3 - Adiabatic Flame Temperature calculation
AIM:To calculate the abiabatic flame temperature for the combustion of fuel using pyhton. Objective: 1. Use the concept of newton raphsons method to solve the enthapy equation of products and reactants at constant pressure. 2.To monitor the effect of equivalence ratio on adiabatic flame temperature Adiabatic flame temperature:…
09 Aug 2021 02:19 PM IST
Week 2 Air standard Cycle
Aim: To write a program to simulate otto cycle using python, Considering the volume change w.r.t crank angle. Objective: To trace the volumetric compression and expansion with respect to crank angle. Otto cycle: The Otto cycle is a description of what happens to a mass of gas as it is subjected to changes of pressure,…
28 Jul 2021 09:59 AM IST
Week 10 - Simulating Combustion of Natural Gas.
Aim: The aim of the challeneg is to carry out combustion simulation and also consider the effect of water added in fuel on emmisions. Objective: The objective of the challenege is to understand chemical kinetics and its use to simulate the process of combustion using computer program. The reactant and product are discritized…
29 Apr 2021 03:12 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.