Week 2 Air standard Cycle
Project Link
https://skill-lync.com/student-projects/pv-diagram-of-air-standard-cycle-3
Code for PV and Efficiency Digram of Otto Cycle
#Air standard Cycle
import matplotlib.pyplot as plt
import math
def engine_kinematics(bore, stroke, con_rod, start_crank, end_crank, n):
#volumetric parameter
vs = math.pi*(1/4)*pow(bore,2)*stroke
vc = vs/(cr-1)
#crankpin radius,a
a = stroke/2
R = con_rod/a
sc = math.radians(start_crank)
ec = math.radians(end_crank)
num_values = n
d_theta = (ec-sc)/(num_values-1)
v = []
for i in range (0,num_values):
theta = sc + i*d_theta
term1 = pow(R,2) - pow(math.sin(theta),2)
term2 = pow(term1,0.5)
term3 = R + 1 - math.cos(theta)
term4 = 0.5 * (cr - 1)
v.append((1 + (term4 * (term3-term2)))*vc)
return(v)
#print(v)
#print(vc)
#print(vc+vs)
#Geogmatric parameters
bore = 0.10
stroke = 0.1
con_rod = 0.15
cr = 8
#input
p1 = 101325
t1 = 500
t3 = 2300
gamma = 1.4
#Volume Computation
vs = math.pi*(1/4)*pow(bore,2)*stroke
vc = vs/(cr-1)
v1 = vc+vs
#state point 2
v2 = vc
#presure point | p2v2^gamma = p1v1^gamma
p2 = (p1*pow(v1,gamma))/pow(v2,gamma)
#tempersture point | p1v1/t1 = p2v2/t2 | constant,c = p1v1/t1
c = (p1 * v1)/t1
t2 = (p2*v2) / cr
v_compression = engine_kinematics(bore, stroke, con_rod, 180, 0, 100)
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 = constant
p3 = (c*t3)/v3
v_expansion = engine_kinematics(bore, stroke, con_rod, 0, 180, 100)
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)
#efficiency of Otto engine cuycle | efficiency = 1-(1/cr^(gamma-1))
efficiency = []
k1 = []
for k in range(1,12):
efficiency.append(1-(1/pow(k,(gamma-1))))
k1.append(k)
plt.plot(k1,efficiency)
plt.savefig('Air standard Cycle efficiency')
plt.show()
#PV diagram of Air standard Cycle
print(p_compression)
print(v_compression)
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.savefig('Air standard Cycle')
plt.show()