Project

Plotting Air Standard Cycle (Otto Cycle) in Python

Air Standard Cycle (Otto Cycle)

1.AIM:

To plot the Air standard cycle (Otto cycle) for Pressure v/s Volume using Python

2. GOVERNING EQUATIONS IF ANY:

For Isentropic process 1-2 and 3-4: `P_1V_1^γ=P_2V_2^γ`​ and `(P_1V_1)/(T_1)=(P_2V_2)/(T_2)`

where numbers indicate the process state.

Assumptions:

- Sp. Heat Ratio (γ) = 1.4

- Temp. after compression (`T_3`) = 2500K

- `P_1`​= 101325 Pa

- `T_1`​= 400K

Geometric assumptions:

- Bore Diameter = 0.2m

- Stroke = 0.2m

- Compression Ratio (CR) = 12

- Connecting rod length = 0.23m

- `V/(Vc​)=1+1/2(CR−1) [R+1−cos(θ)−(R^2−sin^2(θ))^(1/2)]`

Where θ is the crank angle

- Thermal efficiency = `η_(th)`= `1−1/(CR)^(γ−1)`

3. OBJECTIVES OF THE PROJECT:

- To plot the air standard (Otto) cycle for Pressure v/s Volume in Python.

- To find the thermal efficiency of the engine.

4.FLOW OF THE PROJECT:

  1. Assume critical geometric components and initial values of pressure and temperature.
  2. Calculate values of pressure and temperature at different stages of the cycle i.e. 1 to 4 using governing equations of different types of processes being used.
  3. Plot the graphs mentioned in the objectives.
  4. Find the thermal efficiency.

5.PYTHON CODE:

Code for the function used: (Function is written in main code after importing modules.)

def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
                                                    #Creating a new function
	a = stroke/2                                    #Geometric Parameters inputs
	R = con_rod/a

	V_S = math.pi*(1/4)*pow(bore,2)*stroke          #Volume parameters
	V_C = V_S/(cr-1)

	sc = math.radians(start_crank)                  #Taking start crank angle in radians
	ec = math.radians(end_crank)                    #Taking end crank angle in radians

	num_values = 50                                 #Determining the number of points to be plotted (curve accuracy)
	dtheta = (ec-sc)/(num_values-1)                 #Dividing starting and ending crank angles (into num_values-1) divisions i.e num_values number of dtheta
	V=[]                                            #Creating empty array to store values of volume

	for i in range(0,num_values):
		theta = sc + i*dtheta                       #Refer governing equation section in the report to understand this!!
		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)       #adding values in the empty array
	return V                                        #Returns the value of V to the function

Code for main program (function is used in same file only)

import math
import matplotlib.pyplot as plt


#Inputs
p1 = 101325                                         #Pressure at state point 1
t1 = 500											#Temperature at state point 1
gamma = 1.4
t3 = 2300											#temperature at state point 3 (after addition of heat)

#Geometric Parameters
bore = 0.1                                          #Geometric parameters in metres except cr
stroke = 0.1
con_rod = 0.15
cr = 5

#Volume computation
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_c + v_s

#State point 2
v2 = v_c

#p2v2^gamma = p1v1^gamma
p2 = p1*pow(v1,gamma)/pow(v2,gamma)

#p2v2/t2 = p1v1/t1
rhs = p1*v1/t1
t2 = p2*v2/rhs

V_comp=engine_kinematics(bore,stroke,con_rod,cr,180,0)
constant = p1*pow(v1,gamma)
p_comp=[]
for v in V_comp:
	p_comp.append(constant/pow(v,gamma))


#state point 3
v3 = v2

#p3v3/t3 = p2v2/t2
rhs = p2*v2/t2
p3 = rhs*t3/v3

V_exp=engine_kinematics(bore,stroke,con_rod,cr,0,180)
constant = p3*pow(v3,gamma)
p_exp=[]
for v in V_exp:
	p_exp.append(constant/pow(v,gamma))


#state point 4
v4 = v1
#p4v4^gamma = p3v3^gamma
p4 = p3*pow(v3,gamma)/pow(v4,gamma)
#p4v4/t4 = rhs
t4 = p4*v4/rhs

#Thermal Efficiency
th_eff = 1 - 1/pow(cr,(gamma-1))
print(th_eff*100)


plt.plot([v2,v3],[p2,p3])                           #Plotting heat addition line
plt.plot(V_comp,p_comp)								#plotting compression stroke curve
plt.plot(V_exp,p_exp)                               #Plotting the expansion stroke curve
plt.plot([v4,v1],[p4,p1])                           #Plotting heat rejection line
plt.xlabel('Volume')
plt.ylabel('Pressure')
plt.grid(True)
plt.show()


Code Explaination:

  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.

6. OBSERVATION:

- P-V plot when Compression Ratio is 5. We can see Isentropic and Isochoric lines and curves.

7. CONCLUSION:

- Correct P-V chart of Otto cycle was plotted in Python.

- Obtained thermal efficiency is 47.46%

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.