Project

Analysis Of Air Standard Cycle Using Python

Aim: Python program to obtain the presssure-volume curve of a otto - cycle.

Introduction:

  • Process 1-2 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
  • Process 2-3 is an adiabatic (isentropic) compression of the charge as the piston moves from the bottom dead center (BDC) to top dead center (TDC).
  • Process 3-4 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 4-5 is an adiabatic (isentropic) expansion (power stroke).
  • Process 5-6 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 6-1 the mass of air is released to the atmosphere in a constant pressure process.
    The Otto cycle consists of isentropic compression, heat addition at constant volume, isentropic expansion, and rejection of heat at constant volume. In the case of a four-stroke Otto cycle, technically there are two additional processes: one for the exhaust of waste heat and combustion products at constant pressure (isobaric), and one for the intake of cool oxygen-rich air also at constant pressure; however, these are often omitted in a simplified analysis.

Equations:

Relation between crank angle and Volume:

`V/V_c =1+ 1/2(r_c-1)[R+1-cos⁡θ- (R^2-sin^2⁡θ)^(1/2)]`

Where,

V = Compression or Expansion Volume

v_c=Clearance volume

r_c=Compression Ratio

R = Crankpin Radius

`θ`= Crank Angle

Ideal gas law:

`PV=nRT`

Where,

P = Pressure of the Gas

V= Volume of the Gas

n = Number of moles.

R = Universal Gas Constant

T = Absolute Temperature of the gas

Thermal Efficiency of Engine:

η=1-1/r_c^((γ-1))

Where,

η = Thermal Efficiency of the Engine.

Clearance Volume (V_c):.

V_c=V_s/((r_c-1))

Program:

import math 
import matplotlib.pyplot as plt 

def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):

	a= stroke/2					#crank Pin Radius
	R= con_rod/a 					#Constant
	v_s= ((math.pi)/4)*pow(bore,2)*stroke 	        #Swept Volume
	v_c= v_s/(cr-1) 				#Clearance Volume

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

	num_value= 100

	dtheta= (ec-sc)/(num_value-1)

	V=[]
	for i in range (0, num_value):
		theta = sc+ i*dtheta


		term1= (1/2)*(cr-1)
		term2= R + 1- math.cos(theta)
		term3= pow(R,2) - pow(math.sin(theta),2)
		term3 = pow(term3, (1/2))

		V.append((1 + term1*(term2-term3))*v_c)
	return V



#Inputs
p1= 101325	#Pressure at state 1(pascal)
t1= 450	        #Temperature at state (kelvin)
gamma=1.4	#Adiabatic Index
t3= 2400 	#Temperature at State 3(kelvin)/combustion temperature

#Geometric parameters
bore=0.2 	
stroke=0.1	
con_rod=0.15
cr=10		

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

#Volume at State 1
v1=v_c + v_s

#State 2 
v2= v_c

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

#Temperature at 2, Ideal Gas Law | p2v2/t2= P1V1/T1 == rhs= P1V1/T1
#rhs= P2V2/T2== T2=P2V2/rhs
rhs= p1*v1/t1
t2= p2*v2/rhs
V_compression= engine_kinematics(bore, stroke, con_rod, cr, 180,0)
constant= p1*pow(v1,gamma)
P_compression=[]
for v in V_compression:
	P_compression.append(constant/pow(v,gamma))

#State 3 
v3 = v2

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

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


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

#t4= p4v4/rhs
t4=(p4*v4)/rhs

#Thermal Efficiency of the engine 
x= 1 - (1/pow(cr,(gamma-1)))
Eff = x*100
print(\"The Thermal Efficiency of the Engine is \", Eff, \"%\")

#Plotting the P-V graph

plt.plot(V_compression, P_compression)
plt.plot([v2,v3],[p2,p3])
plt.plot(V_expansion,P_expansion)
plt.plot([v4,v1],[p4,p1])
plt.xlabel(\'Volume\')
plt.ylabel(\'Pressure\')
plt.title(\'P-V Diagram of the Four Stroke Otto Cycle Engine\')		
plt.annotate(\'1\', xy=(v1,p1), ha= \'left\', va= \'top\')	
plt.annotate(\'2\', xy=(v2,p2), ha= \'right\', va= \'top\')
plt.annotate(\'3\', xy=(v3,p3), ha= \'right\', va=\'bottom\')
plt.annotate(\'4\', xy=(v4,p4))
plt.savefig(\'PV Diagram\')
plt.show()

Output:

Thermal efficiency:60.20%

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.