AIR STANDARD CYCLE USING PYTHON
Otto cycle
The operation of the Otto cycle comprises four processes: adiabatic compression 1 → 2, isochoric heat addition 2 → 3, adiabatic expansion 3 → 4, and isochoric heat removal 4 → 1. Thus, for the Otto cycle, we have V2 = V3, V4 = V1, CR = V1/V3, and PR = p3/p1. The thermal efficiency of the Otto cycle is η=1−T1T2
Applying the first law to the adiabatic
compression process 1 → 2 gives
(T1/T2)=(V1/V2)1−γ.
Thus, Eq may be rewritten as
η=1−V1V21−γ=1−CR1−γ
For the Otto cycle, Tmax = T3 and Tmin = T1. So, from the relation p1V1/T1=p3V3/T3, one finds v4 =v1
PROGRAM TO OBTAIN PRESSURE VOLUME VARIATION:
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
a= stroke/2
r= con_rod/a
v_s= (math. pi/4)*pow(bore,2)*stroke
v_c= v_s/(cr-1)
sc=math.radians(start_crank)
ec=math.radians(end_crank)
num_values=10
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_c)
return (V)
p1= 101325
t1 =400
t3 =2500
#engine parameter
bore= 0.2
stroke =0.2
con_rod=0.23
cr=12
gamma =1.4
#calculating the swept volume
v_swept= (math.pi/4)*pow(bore,2)*stroke
v_clearence= v_swept/(cr -1)
v1 = v_swept + v_clearence
v2= v_clearence
v3= v2
#state variable point 2
#from p2v2^gamma = p1v1^gamma
#p2 = p1*(v1/v2)^gamma
p2=p1*pow(cr,gamma)
#from p1v1/t1 = p2v2/t2
t2= p2*v2*t1/(p1*v1)
v_comp= engine_kinematics(bore,stroke,con_rod,cr,180,0)
p_comp= [ ]
for v in v_comp :
p_comp.append(p1*(pow(v1/v),gamma)
#state point3
#p3v3/t3 = p2v2/t2
p3= p2*(t3/t2)
constant_c=p3*v3^gamma;
v_exp= engine_kinematics(bore,stroke,con_rod,cr,0,180)
p_exp= []
for e in v_exp:
p_exp.append(p3*(pow(v3/e),gamma)
#state variable at point 4
v4 = v1
#p3v3^gamma = p4v4^gamma
p4 = p3*pow((v3/v4),gamma)
plt.figure('otto cycle')
plt.plot,([v2,v3],[p2,p3])
plt.plot(v_comp ,p_comp)
plt.plot(v_exp,p_exp)
plt.plot([v4,v1],[p4,p1])
plt.show()
plt.grid on
plt.xlabel('pressure')
plt.ylabel('volume')
OUTPUT PLOT:
Code explanation:
1. We first assume some important parameters such as sp. Heat ratio (gamma) and Temperature at state 3 i.e. after heat addition.
2. We also assume initial pressure, temperature, and geometrical parameters.
3. Using the formula of volume of cylinder and clearance volume, we find out the swept and clearance volume.
4. Using governing equation of isentropic process, we thus find out pressure and temperature at state point 2.
5. After this, we call our function to help us to find the compression volume and pressure.
6. Similar thing is done in the case of state 3-4.
7. Thermal efficiency is found out and graph is plotted between pressure and volume.
CONCLUSION:
1. hence we plotted pv diagram of otto cycle.
2. also we find out the thermal efficiency is about 68%