Python - AIR STANDARD CYCLE
Air Standard Cycle
Objective
To write a program using python to check the engine kinematics of an engine operating on the otto cycle and to make the PV diagram plot and display/print the total thermal efficiency of the engine.
Procedure
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 processes are described by
- Process 0–1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
- Process 1–2 is an adiabatic (isentropic) compression of the charge as the piston moves from bottom dead centre (BDC) to top dead centre (TDC).
- Process 2–3 is a constant-volume heat transfer to the working gas from an external source while the piston is at top dead centre. This process is intended to represent the ignition of the fuel-air mixture and the subsequent rapid burning.
- Process 3–4 is an adiabatic (isentropic) expansion (power stroke).
- Process 4–1 completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at bottom dead centre.
- Process 1–0 the mass of air is released to the atmosphere in a constant pressure process.
Fig : PV relation in an otto cycle
The geometric parameters for the engine chosen are as given:
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr =12
a = stroke/2 #crankpinradius
R = con_rod/a
gamma = 1.4
State point 1 :
p1 = 101325
t1 = 500
v1 = v_swept + v_clearance
State point 3 :
t3 = 2300
Formulae for Thermal efficiency for engine running on otto cycle
``n = 1 - (t4 - t1)/(t3 - t2)`
Program:
"""
otto cycle
"""
import math
import matplotlib.pyplot as plt
def engine(bore,stroke,con_rod,cr,scr,ecr):
sc = math.radians(scr)
ec = math.radians(ecr)
num_values = 1000
V = []
dtheta = (ec-sc)/(num_values-1)
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
#geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr =12
a = stroke/2 #crankpinradius
R = con_rod/a
gamma = 1.4
# volume computation
v_swept = (math.pi/4)*pow(bore,2)*stroke
v_clearance = v_swept/(cr-1)
# state point 1
p1 = 101325
t1 = 500
v1 = v_swept + v_clearance
rhs = p1*v1/t1
# state point 2
v2 = v_clearance
p2 = p1*pow(v1,gamma)/pow(v2,gamma)
t2 =p2*v2/rhs
v_compression = engine(bore,stroke,con_rod,cr,180,0)
constant = p1*pow(v1,gamma)
p_compression = []
for vol in v_compression :
p_compression.append(constant/pow(vol,gamma))
#state point 3
t3 = 2300
v3 = v2
p3 = t3*rhs/v3
v_expansion = engine(bore,stroke,con_rod,cr,0,180)
constant = p3*pow(v3,gamma)
p_expansion = []
for vol in v_expansion :
p_expansion.append(constant/pow(vol,gamma))
#state point 4
v4 = v1
p4 = p3*pow(v3,gamma)/pow(v4,gamma)
t4 = p4*v4/rhs
#thermal efficiency
k = 0.4
eff = 1 - (t4-t1)/(t3-t2)
print(eff)
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.show()
Resulting PV diagram plot:
Thermal Efficiency = 0.6298928275128466
Conclusion
The following code was written in python to give the PV diagram of the air standard cycle and the thermal efficiency is foud to be 0.62989.