Week 2 Air standard Cycle
This project involves calculating and visualizing the behaviour of pressure and volume change in an Otto cycle engine. The code calculates the variables p,v,t at all 4 state points. The first process (exhaust stroke) is isentropic where in p1v1^gamma = p2v2^gamma. The second process is constant volume heat rejection. The third process (intake stroke) is again an isentropic one following the same relationship as the first process. Finally the last process is a constant volume heat addition. The temperatures at respective state points was calculated using p1v1/t1 = p2v2/t2. The empirical relationship for calculating volume during the first and third process was coded into a function. This function was used to calculate the volume change behaviour accurately for the first and third processes. The code is as follows
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
# Geometric Parameters
a = stroke/2
R = con_rod/a
sc = math.radians(start_crank)
ec = math.radians(end_crank)
n = 50
dtheta = (ec-sc)/(n-1)
V = []
for i in range(0,n):
theta = sc +i*dtheta
term1 = 0.5*(cr-1)
term2 = R + 1 - math.cos(theta)
term3 = pow(pow(R,2)-pow(math.sin(theta),2),0.5)
V.append((1 + term1*(term2-term3))*v_c)
return V
# Inputs
p1 = 101325
t1 = 500
gamma = 1.4
t3 = 2500
# Geometric Parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 8
# Volume Parameters
v_s = math.pi*(1/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_s + v_c
#State point 2
v2 = v_c
#Pressure is given by p1v1^gamma = p2v2^gamma
p2 = p1*pow(v1,gamma)/pow(v2,gamma)
#Temperature at state point 2 is given by p1v1/t1 = p2v2/t2
tmp = p1*v1/t1
t2 = p2*v2/tmp
#Calculating the actual volume change for state 1-2
V_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0)
const = p1*pow(v1,gamma)
P_compression = []
for v in V_compression:
P_compression.append(const/pow(v,gamma))
#State point 3
v3 = v2
#Pressure is given by p2v2/t2 = p3v3/t3
tmp = p2*v2/t2
p3 = tmp*t3/v3
#Calculating the actual volume change for state 3-4
V_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180)
const = p3*pow(v3,gamma)
P_expansion = []
for v in V_expansion:
P_expansion.append(const/pow(v,gamma))
#State point 4
v4 = v1
#Pressure is given by p3v3^gamma = p4v4^gamma
p4 = p3*pow(v3,gamma)/pow(v4,gamma)
#Temperature can be calculated using p3v3/t3 = p4v4/t4
t4 = p4*v4/tmp
eta = (1 - (1/pow(cr,(gamma-1))))*100
print("Thermal efficiency of the Otto cycle engine is :",eta,"%")
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("Otto Cycle")
plt.show()
The thermal efficiency of the Otto cycle was found to be 56%.