Challenge

Week 2 Air standard Cycle

Objective: To plot a PV diagram for standard otto cycle and calculate the thermal efficiency for the same

Theory: The Otto cycle is the ideal cycle for spark-ignition engines, in honor of Nikolaus Otto, who invented it in 1867. In ideal Otto cycles, the air-standard assumption is used. The ideal Otto cycle consists of four internal reversible processes:

  • 1-2 Isentropic compression
  • 2-3 Constant volume heat addition
  • 3-4 Isentropic expansion
  • 4-1 Constant volume heat rejection

Following are the process of the Otto cycle:-

  • Process (0–1) a mass of air is drawn inside the engine cylinder at constant pressure.
  • Process (1–2) is an adiabatic (isentropic) compression in this process the piston moves from the bottom (BDC) to top dead center (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 center. 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 center.
  • Process (1–0) the mass of air is released to the atmosphere in a constant pressure process.

Code: The main object to write a code on the Otto Cycle is to investigate its thermodynamic properties & also to analyze its thermal efficiency & to plot PV diagram

  • In the code, first, we have defined all the thermodynamics inputs parameters like pressure & temperature & also geometrical parameters of the engine.
  • Then by using thermodynamic relation parameters like pressure, volume & temperature is computed
  • Also, we have defined a function in order to consider piston kinematics during compression and expansion
#Plotting P-V digram of Otto cycle

import math                      #Importing math library 
import matplotlib.pyplot as plt  #Importing plotting library

#Writting function for piston kinematics
def engine_kinematics(bore,stroke,conn_rod,cr,v_s,v_c,start_crank,end_crank):
	a=stroke/2      #Crank pin
	R=conn_rod/a


	v=[]       #Empty array for volume trace

	sc=math.radians(start_crank)
	ec=math.radians(end_crank)

	n_values=180
	dtheta=(ec-sc)/(n_values-1)

	for i in range(0,n_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)
		term4=pow(term3,0.5)

		#Volume trace i.e how volume change when piston movesfrom TDC to BDC
		v.append((1+term1*(term2-term4))*v_c)
	return v

#Inputs
p1=101325  		#inlet pressure
t1=500          #inlet temperature
gamma=1.4
t3=2300			#Peak temperature
term=(gamma-1)

#Geoetric parameter
bore=0.1
stroke=0.1
conn_rod=0.15 #connecting rod
cr=12         #Compression ratio

#Volume compuation
v_s=(math.pi/4)*pow(bore,2)*stroke     #Swept volume
v_c=v_s/(cr-1)						   #clearance volume
v1=v_c+v_s                             #inlet volume

#Process(1-2) isentrpoic compression
v2=v_c

#t2=t1*t1*pow(cr,term)
t2=t1*pow(cr,term)

#p1v1^gamma=p2v2^gamma
p2=p1*pow(cr,gamma)

#Calling function 
v_compression=engine_kinematics(bore,stroke,conn_rod,cr,v_s,v_c,180,0)
constant=p1*pow(v1,gamma)
p_compression=[]   #Empty array for p_compression
	
for v in v_compression:
		p_compression.append(constant/pow(v,gamma))

#Process(2-3) constant volume heat addition

#v2=v3..constant volume
v3=v2

#p3=p2*(t3/t2)
p3=p2*(t3/t2)

#Process(3-4) isentrpoic compression
#v4=v1..constant volume
v4=v1

#t4=t3/(pow(r,term))
t4=t3/(pow(cr,term))

#p3v3^gamma=p4v4^gamma
p4=p3*pow(v3,gamma)/pow(v4,gamma)

#Calling function 
v_expansion=engine_kinematics(bore,stroke,conn_rod,cr,v_s,v_c,0,180)
constant=p3*pow(v3,gamma)
p_expansion=[]         #Empty array for p_expansion
	
for v in v_expansion:
		p_expansion.append(constant/pow(v,gamma))



#Air standard efficiency of Otto cycle
efficiency=1-1/pow(cr,term)
print(efficiency*100)

#Plotting all the process
plt.figure()
plt.plot(v_compression,p_compression,color='orange',linewidth=2)
plt.plot([v2,v3],[p2,p3],color='green',linewidth=2)
plt.plot(v_expansion,p_expansion,color='red',linewidth=2)
plt.plot([v4,v1],[p4,p1],color='brown',linewidth=2)
plt.xlim([0,0.001])
plt.ylim([0,6e6])
plt.xlabel('Volume in m^3',color='Black',Fontsize=12)
plt.ylabel('Pressure in Pa',color='Black',Fontsize=12)
plt.legend(['Process (1-2) Isentrpoic compression',
	        'Process (2-3) Isochoric heat addition',
	        'Process (3-4) Isentrpoic expansion',
	        'Process (4-1) Isochoric heat rejection'])
plt.title('PV digram of Otto cycle which having 62.98% Efficiency',
		   color='Black',Fontsize=10)
plt.savefig("Otto cycle.png")
plt.show()

Result:

Conclusion:

Successfully plotted the PV diagram of the otto cycle and also calculated the thermal efficiency for the same.

Thermodynamic properties like pressure, volume & temperature are computed at a different stages.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.