Week 2 Air standard Cycle
AIM: -
To solve an otto cycle and plots for it by using python program
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines
The Otto cycle is the ideal cycle for spark-ignition engines, in honor of Nikolaus Otto, who invented it in 1867. In ideal Otto cycles, air-standard assumption is used. The ideal Otto cycle consists of four internal reversible processes:
1-2 Isentropic compression
2-3 Constant volume heat addition
3-4 Isentropic expansion
4-1 Constant volume heat rejection
Python code to find thermal efficiency and plotting graphs:-
'''
Otto Cycle simulation by rahematulla kaladagi
'''
#t- Temperature
#p - Pressure
#V & v - Volume
# import the required library and module
import math
import matplotlib.pyplot as plt
# defining a function for kinematics of engine
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
"""
Engine kinematics
"""
# Geomatric parameters
a = stroke/2
R = con_rod/a
# Volume parameter
v_s = math.pi*0.25*pow(bore,2)*stroke #swept volume
v_c = v_s/(cr-1) # clearance volume
# Conversion to radians
sc = math.radians(start_crank)
ec = math.radians(end_crank)
num_values = 50 #Number of division
dtheta = (ec-sc)/(num_values-1) #Spacing between each division
V = [] #array for volume
for i in range(0,num_values): #updating V
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
#Inputs
p1 = 101325
t1 = 510
gamma = 1.4
t3 = 2280
#Geometric parameter
bore = 0.1
con_rod = 0.15
stroke = 0.1
cr = 8
# 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 | 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) #calling function for Compression Volume
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,180,0) #Calling function for expansion Volume
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 efficiency
eff = 1 - (1/pow(cr,(gamma-1)))
eff = str(eff*100)
print("Thermal Efficiency = " + eff + " %")
#Plotting PV diagram
plt.figure()
plt.plot(V_compression,P_compression, label = 'isentropic compression')
plt.plot([v2,v3],[p2,p3], label = 'Heat addition')
plt.plot(V_expansion,P_expansion, label = 'isentropic expansion')
plt.plot([v4,v1],[p4,p1], label = 'Heat rejection')
plt.xlabel('volume')
plt.ylabel('pressure')
plt.title('P-V diagram of Otto cycle')
plt.legend()
plt.show()
Explanation:-
The code begins with defining a function for Volume
variation that depends on factors like the bore,
stroke, compression ratio, and the start and end
positions of the crank. An array of Volume data is
returned wherever the function is called.
In the code p1,t1,t3 are three input values are known to find the output parameters v1,v2,p2,p3,p4,t2,t4.
In actually code starts from the importing libraries and modules. Then I have define the function which returns volume variation that depends on factors like the bore, stroke,comression ratio, and the start and end is returned wherever the fuction is called
Thereafter, all the inputs are defined and the
unknown temperatures, pressures, and volumes at
different points are found using the process
formulae. Also, the thermal efficiency of the process
is calculated and displayed.
At the end I have plotted the graphs as shown by using matplotlib.pyplot as plt as shown below
Results:-
Thermal efficiency = 56.472471835193794%