Air Standard Cycle using Python
Aim: To plot a P-V diagram for the Air Standard Cycle or Otto cycle and to compute the thermal efficiency of the engine using Python.
Introduction:
OTTO CYCLE- The Otto cycle consists of isentropic compression, heat addition at constant volume, isentropic expansion, and heat rejection at constant volume.
#Otto cycle simulator
#Importing the basic libraries/ modules
import math
import matplotlib.pyplot as plot
def engine_kinematics(bore,stroke,conrod,cr,start_crankangle,end_crankangle):
"""
EngineKinematics
"""
#Input engine parameters
a=stroke/2
R=conrod/a
#defining angles
sc=math.radians(start_crankangle)
ec=math.radians(end_crankangle)
numvalues=100
dtheta=(ec-sc)/(numvalues-1)
#Volume computation
vs=(math.pi/4)*pow(bore,2)*stroke
vc=vs/(cr-1)
V=[]
#tracing the volume curve
for i in range(0,numvalues):
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))*vc)
return V
#Inputs Point1
p1=101325
t1=500
gamma=1.4
t3=2500
#Engine parameters
bore=0.1
stroke=0.1
conrod=0.15
cr=10
#Volume Computation
vs=(math.pi/4)*pow(bore,2)*stroke
vc=vs/(cr-1)
v1=vc+vs
#point2
v2=vc
p2=p1*pow(v1/v2,gamma)
#p2v2/t2=p1v1/t1
t2=p2*v2*t1/(p1*v1)
Vcompress=engine_kinematics(bore,stroke,conrod,cr,180,0)
constant=p1*pow(v1,gamma)
pcompress=[]
#Point3
for v in Vcompress:
pcompress.append(constant/pow(v,gamma))
v3=v2
#p3v3/t3=p2v2/t2
p3=p2*v2*t3/(v3*t2)
Vexpand=engine_kinematics(bore,stroke,conrod,cr,180,0)
constant=p3*pow(v3,gamma)
pexpand=[]
#point4
for v in Vexpand:
pexpand.append(constant/pow(v,gamma))
v4=v1
p4=p3*pow(v3/v4,gamma)
t4=p4*v4*t3/(p3*v3)
#Plotting the P-V diagram
plot.plot([v2,v3],[p2,p3])
plot.plot(Vcompress,pcompress)
plot.plot(Vexpand,pexpand)
plot.plot([v4,v1],[p4,p1])
plot.show()
#Thermal Efficiency
n=1-(pow(cr,(1-gamma)))
point(n)
EXPLANATION OF CODE:
1. Importing the libraries/modules for the successful execution of the code
2. Defining thermodynamic properties
3. Defining engine geometric parameters
4. Pressure and temperature at state point 1
5. Computation of swept volume and clearance volume
6. Calculating thermodynamic properties at state point 1
7. Calling the function to determine various points between state 1 and 2
8. Calculating thermodynamic properties at state point 2 and 3
9. Calling the function to determine various points between states 3 and 4.
10. Properties at state point 4
11. Plotting the graph
12. Calculating thermal efficiency
OUTPUT:
CONCLUSION:
Hence, Efficiency of Otto cycle is 60.18%