Week 2 Air standard Cycle
PROJECT REPORT
AIR STANDARD CYCLE
OBJECTIVE :
To obtain a P-V diagram of Air Standard Otto cycle using PYTHON.
THEORY :
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 constructed from:
- Top and bottom of the loop: a pair of quasi-parallel and isentropic processes(frictionless, adiabatic reversible).
- Left and right sides of the loop: a pair of parallel isochoric processes (constant volume)

PYTHON CODE :
#OTTO CYCLE SIMULATOR
import math
import matplotlib.pyplot as plt
#State_Variables
p1 = 101325
t1 = 500
#Inputs
gamma = 1.4
t3 = 2300
#Engine geomatric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 12
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
#Geometric parameters
a = stroke/2
R = con_rod/a
#Volume parameters
v_swept = (math.pi/4)*pow(bore,2)*stroke
v_clearance = v_swept/(cr-1)
sc = math.radians(start_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
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_clearance)
return V
#Calculating the swept volume and the clearance volume
v_swept = (math.pi/4)*pow(bore,2)*stroke
v_clearance = v_swept/(cr-1)
v1 = v_swept +v_clearance
v2 = v_clearance
#state variable at state point 2
#p1v1^gamma = p2v2^gamma
#p2 = p1*(v1/v2)^gamma = p1*cr^gamma
p2 = p1*pow(cr,gamma)
#ideal gas equation
#p1v1/t1 = p2v2/t2 | t2 = p2*v2*t1/(p1*v1)
t2 = p2*v2*t1/(p1*v1)
v_c = engine_kinematics(bore,stroke,con_rod,cr,180,0)
const_c = p1*pow(v1, gamma)
p_c = []
for v in v_c:
p_c.append(const_c/pow(v,gamma))
#state variable at state point 3
v3 = v2
#ideal gas equation
#p3v3/t3 = p2v2/t2 | p3 = p2*t3/(t2)
p3 = p2*t3/(t2)
v_e = engine_kinematics(bore,stroke,con_rod,cr,0,180)
const_c = p3*pow(v3, gamma)
p_e = []
for v in v_e:
p_c.append(const_c/pow(v,gamma))
#state variable at state point 4
v4 = v1
#p3v3^gamma = p4v4^gamma
#p4 = p3*(v3/v4)^gamma = p3*(v3/v4)^gamma
p4 = p3*pow(v3,gamma)/pow(v4,gamma)
#ideal gas equation
#p3v3/t3 = p4v4/t4 | t4 = p4*v4*t3/(p3*v3)
t4 = p4*v4*t3/(p3*v3)
#thermal efficiency of the cycle
etta = 1 - (1/pow(cr,(gamma-1)))
print ("Thermal Efficiency = ", etta)
plt.plot([v2,v3],[p2,p3])
plt.plot(v_c,p_c)
plt.plot(v_e,p_e)
plt.plot([v4,v1],[p4,p1])
plt.xlabel("Volume")
plt.ylabel("Pressure")
plt.title("Pressure vs Volume")
plt.show()
RESULTS :
1. Otto cycle plot
2. Efficency of the cycle
CONCLUSION :
The P-V diagram for the Air Standard Otto cycle is plotted and the thermal efficiency of the cycle comes out to be 62.98%.