Challenge

Week 2 Air standard Cycle

Aim :To write a program to determine the thermal efficiency of otto cycle and hence to draw its presssure-volume diagram.

Theory:

Otto Cycle is the theoretical thermodynamic cycle which describes the working of a spark ignition engine. This type of spark ignition engines is the most common type of engines used in automobiles.

This cycle mainly consists of four processes. They are,

Isentropic compression

Constant Volume heat addition

Isentropic expanision

Constant volume heat rejection

Formulas Used:

The formulas used in this program are as follows

1.`p1*v1^gamma=p2*v2^gamma`(isentrpic compression)

2. `p2*(v2)/(t2)=p3*(v3)/(t3)` (constant volume heat addition)

3. `p3*v3^gamma=p4*v4^gamma` (isentropic expansion)

4. `p4*(v4)/t4=p1*(v1)/(t1)` (constant volume heat rejection)

5. gamma =cp/cv

6. efficiency =``1−[t4−t1t3−t2]1-[t4-t1t3-t2]``

7. v _swept=`(π4)⋅(bore).2⋅stroke(π4)⋅(bore).2⋅stroke`

8. v_clearence=v_swept/(cr-1)

where, p1 p2 p3 p4 are the pressure values at point 1 2 3 and 4 respectievely

v1 v2 v3 v4 are the values of volume at point 1 2 3 4 respectievely

cp=specific heat constant at constant pressure

cv = specific heat constant at constant volume

v_swept= swept volume

v_clearence=clearence volume

Code:

#otto cycle simulator


import math
import matplotlib.pyplot as plt 


#engine geometric parameteres
gamma =1.4                          #ratio of specific heat constants
bore=0.1                            #diameter of the cylinder in meteres
stroke=0.1                          #length of the cylinder in meteres
cr=8                            #compression ratio
con_rod=0.15                        #length of the connnectiong rod in meteres
#parameters at first point
p1=101325                           #pressure at point1
t1=500                              #temparature at point1
t3=2300                             #temparture at point3(assumed)






#calculating the swept volume and clearence volume

v_swept=(math.pi/4)*pow(bore,2)*stroke #swept volume 
v_clearence=v_swept/(cr-1)              #clearence volume

#volume at point 1 and 2
v1=v_swept+v_clearence                 #initial volume
v2=v_clearence                        #volume after compression
#calculating the parameters at second point
#p1v1^gamma=p2v2^gamma
#p1v1/t1=p2v2/t2



def engine_kinematics(bore,stroke,cr,con_rod,crank_start,end_crank):          #defining a function

#geometric parameters
	a=stroke/2              #Crank radius
	R=con_rod/a
	 
	sc=math.radians(crank_start)
	ec=math.radians(end_crank)
	num_values=40
	dtheta=(ec-sc)/(num_values-1)
	V_compression=[]	 
	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)
			 
		temp=(1+term1*(term2-term3))*(v_clearence)
		V_compression.append(temp)   
	return(V_compression)
	
		 
		 
p2=p1*pow(cr,gamma)
t2=p2*v2*t1/(p1*v1)



#calculating parameters in third point
#p2/t2=p3/t3

v3=v2
p3=p2*t3/t2

#calculating the parameters at point 4
#p3v3^gamma=p4v4^gamma
#p3v3/t3=p4v4/t4

p4=p3/pow(cr,gamma)
v4=v1
t4=p4*v4*t3/(p3*v3)


V_compression=engine_kinematics(bore,stroke,cr,con_rod,180,0)        #calling the function
V_expansion=engine_kinematics(bore,stroke,cr,con_rod,0,180)
P_compression=[]
P_expansion=[]

for v in V_compression:                                               #filling the volume of compression array
	constant=p1*pow(v1,gamma)
	temp=constant/pow(v,gamma)
	P_compression.append(temp)

for v1 in V_expansion:                                                #Filling the volume of expansion array    
	constant1=p3*pow(v3,gamma)
	tmp=constant1/pow(v1,gamma)
	P_expansion.append(tmp)



plt.plot(V_compression,P_compression,label='Adiabatic compression')     #plotting 1 to 2
plt.plot([v2,v3],[p2,p3],label='Constant volume heat addition')         #plotting 2 to 3
plt.plot(V_expansion,P_expansion,label='Adiabatic expansion')           #plotting 3 to 4
plt.plot([v4,v1],[p4,p1],label='Constant volume heat rejection')        #plotting 4 to 1
plt.plot(v4,p4,'*') #point 4
plt.plot(v1,p1,'*') #point 1
plt.plot(v2,p2,'*') #point 2
plt.plot(v3,p3,'*') #point 3
plt.xlabel('Volume')
plt.ylabel('Pressure')
plt.title('Volume vs Pressure graph of OTTO Cycle')
plt.legend(loc='best')         #providing the legend
plt.show()

efficiency=(1-(t4-t1)/(t3-t2))*100
print('Thermal Efficiency= ',efficiency,'%')                            #efficiency


Code explanation:

  • Engine parameters such as bore, storke, length of the connecting rod is specified
  • The value of the compression ratio and the value of gamma is specified

compression ratio= 8

gamma =1.4

  • The initial conditios such as p1,t1,t3, are assumed.
  • The swept volume and the clearence volume are calculated using above mentioned formulas.
  • The values of p2,v2 , t2,p3,v3,p4,v4,t4 are calculated using above formulas.
  • A function named engine_kinematics is called inorder to determine the nature of the graph between point 1 and 2 an point 3 and 4.
  • This function contains the formula to find the geometric parameters such as crank radius.
  • The start crank angle and end crank angles are specified in radians.
  • Then an array theta is made using the for loop, which also contains the general volume formula of otto cycle.
  • All the values of the volume are stored in a array named V_compression which was an empty array befor the starting of the for loop.
  • Using return command, the value is returned to the function
  • Later P_compression and P_expansion are found out using a for loop.
  • Once after all the parameters are found graphs are plotted for each process, the x and y label are made.
  • The title is also specified
  • The legend is generated using the command plt.legend(loc='best')
  • This will be reflected in the graph.
  • The efficiency is calculated and also printed.

Result:

The efficiency is found to be 56.4724 % and is specified with the name Thermal Efficiency

Plots:

Graph of pressure(Pa) vs Volume(m^3)

Errors faced:

There was a error while applying the legend to the graph.The legend was not shown properly as shown below

The corresponding program was

After some research, the correct syntax was found and resolved.

Reference:https://www.nuclear-power.net/nuclear-engineering/thermodynamics/thermodynamic-cycles/otto-cycle-otto-engine/thermal-efficiency-for-otto-cycle/

Conclusion:Python is avery good software which helps to plot graphs in a easier way and also calculate different values.

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.