Challenge

Week 2 Air standard Cycle

Objective:

To write a code to plot the ideal otto Cycle

To calculate the thermal efficacy of the process

Introduction:

(Initially, I had written a program for diesel cycle but I read the question later and changed it to otto cycle. I would have loved to have plotted that)

There are two isentropic compressions and expansion processes, constant volume heat addition, and constant volume heat rejection. I have given the user of the program to make all the choices including shifting the process from isentropic to polytropic and I want the grader to try with a different index for the polytropic process.

The program is given below:

"""
Otto cyle simulator 
"""
import math
import matplotlib.pyplot as plt

def ocycle(V_C,R,CR,S_C,E_C):

	sc = math.radians(S_C)
	ec = math.radians(E_C)

	count = int(input('Enter the value of finess index for polytropic process: '))

	dt = (ec-sc)/(count-1)

	V=[]

	for i in range(0,count):
		theta = sc + i*dt
		part1 = 0.5*(CR-1)
		part2 = R+1-math.cos(theta)
		part3 = pow(pow(R,2)-pow(math.sin(theta),2),0.5)
		V.append(V_C*(1+(part1*(part2-part3))))

	return(V)


#All Inputs


B_D = float(input('Enter the Bore Dia. in m: ')) # Diameter of the bore in m
S_L = float(input('Enter the Stroke Length in m: ')) #Stroke length in m 
C_Rod = float(input('Enter the Length of the Connecting Rod in m: ')) #Length of the connecting rod in m 
CR = float(input('Enter the Compressrion Ratio: ')) #compression ratio 

V_S = 0.25*math.pi*pow(B_D,2)*S_L #Volume of the cylinder
V_C = V_S/(CR-1)

Cr_pin = S_L/2 # Crank Pin Radius in m 
R =C_Rod/Cr_pin


#Computaion at point 1 
V1 = V_S + V_C
P1 = float(input('Enter Inet air pressure into the cylinder in Pa: ')) # Pressure a point 1 in Pa
T1 = float(input('Enter Inet air Temp. into the cylinder in K: '))   # Temperaure at point 1 in K
Gamma = float(input('Enter the index of compression & Expansion process: '))


#Compuation at point 2 
V2 = V_C
P2 = P1*pow(V1/V2,Gamma)
T2 = P2*V2*T1/(P1*V1)

Vol_Comp = ocycle(V_C,R,CR,180,0)
Const1 = P1 * pow(V1,Gamma)

Pre_Comp = []

for j in Vol_Comp:
	Pre_Comp.append(Const1/pow(j, Gamma))


#Computation at point 3
V3 = V2 #Constant volume combustion
T3 = float(input('Enter the Max Combustion Temp in : ')) #Combustion Temperature 
P3 = P2*V2*T3/(T2*V3)

Vol_exp = ocycle(V_C,R,CR,0,180)
Const2 = P3 * pow(V3,Gamma)

Pre_exp = []

for k in Vol_exp:
	Pre_exp.append(Const2/pow(k, Gamma))

#Computation at point 4
V4 = V1
P4 = P3*pow(V3/V4, Gamma)
T4 = P4*V4*T3/(P3*V3)


print('Pressure, Temperature and Volume at 1 are :', P1*pow(10,-5),'bar,', T1-273,'°C and', V1,'m\u00b3')
print('Pressure, Temperature and Volume at 2 are :', P2*pow(10,-5),'bar,', T2-273,'°C and', V2,'m\u00b3')
print('Pressure, Temperature and Volume at 3 are :', P3*pow(10,-5),'bar,', T3-273,'°C and', V3,'m\u00b3')
print('Pressure, Temperature and Volume at 4 are :', P4*pow(10,-5),'bar,', T4-273,'°C and', V4,'m\u00b3')

#Calculation of thermal efficiency 

TE = 1-((T4-T1)/(T3-T2))
print('Thermal Effecieny', TE*100,'%')

plt.figure()
plt.title('Ideal plot of ideal otto cycle')
plt.plot([V1,V2,V3,V4,V1],[P1*pow(10,-5),P2*pow(10,-5),P3*pow(10,-5),P4*pow(10,-5),P1*pow(10,-5)])
plt.xlabel('Volume in m\u00b3')
plt.ylabel('Pressure in bar')

plt.figure()
plt.title('Real plot of ideal otto cycle')
plt.plot([V2,V3],[P2,P3])
plt.plot(Vol_Comp,Pre_Comp)
plt.plot(Vol_exp,Pre_exp)
plt.plot([V4,V1],[P4,P1])
plt.xlabel('Volume')
plt.ylabel('Pressure')
plt.show()


The inputs and results are given next followed by the graph and the thermal efficiency.

(Comment: thermal efficacy of otto cycle is hardly 30% rest is lost in cooling water and exhaust gases. I had the time to read some of the students' projects in the forum where the thermal efficiency is 65%. If the inputs are realistic this is impossible. So I have provided more realistic inputs for a big-sized engine.)

I urge the grader to try 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.