Challenge

Week 2 Air standard Cycle

AIM: To plot the P-V Daigram & thermal efficiency through Python.

Objective:

To use Engine Kinematics as function to plot the P-V Diagram.

To plot a smooth curve in PV Diagram.

Introduction:

An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine.

It is the thermodynamic cycle most commonly found in automobile engines.

The Otto cycle is constructed from:

Top and bottom of the loop: a pair of quasi-parallel and isentropic processes (frictionless, adiabatic reversible).
Left and right sides of the loop: a pair of parallel isochoric processes (constant volume).

The isentropic process of compression or expansion implies that there will be no inefficiency (loss of mechanical energy), and there be no transfer of heat into or out of the system during that process.

The cylinder and piston are assumed to be impermeable to heat during that time. Work is performed on the system during the lower isentropic compression process.

Heat flows into the Otto cycle through the left pressurizing process and some of it flows back out through the right depressurizing process.

The summation of the work added to the system plus the heat added minus the heat removed yields the net mechanical work generated by the system.

Formula to be used:

For the isenthalpic Process, we know that P`V^gamma`= Constant

Also, for the thermodynamic process,`(PV)/T` = constant

Compression Ratio = `(clearance volume)/(stroke volume)`

Note, in above graph:

  • A->B is Isenthalpic Compression process
  • B->C is Constant Volume Heat Addition
  • C->D is Isenthalpic Expansion process
  • D->A is Constant Volume Heat Rejection

Program:

#Program to plot the Pressure Vs Volume Diagram using Python.
#Created by Abhishek Dhardwivedi
import math
import matplotlib.pyplot as plt 

#here we are Defining a function to add a smooth curvature in PV Daigram
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
	#Volume Formula used here are:
	v_s = (math.pi/4)*pow(bore,2)*stroke #Stroke Volume
	v_c = v_s/(cr-1) #Clearnce Volume
	v1 = v_c + v_s #volume at point 1 or A in the P-V graph
	a = stroke/2
	R = con_rod/a
	

	#Here we are taking a different values of the crank angles 
	sc = math.radians(start_crank) #We are taking here initial value of crank starting
	ec = math.radians(end_crank) #We are taking here end value of crank ending

	num_values = 50
	dtheta = (ec-sc)/(num_values-1)

	V =[]

	for i in range(0,num_values):
		theta = sc + i*dtheta
		#The below terms1,2,3 are terms of the volume curve
		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)
		
	return V

#Input Variables
p1 = 101325
t1 = 500
t3 = 2300

gamma = 1.4

#Geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 12
R = con_rod
a = stroke/2

#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

# formula to be used: p2v2^gamma = p1v1^gamma
p2 =p1*pow(v1,gamma)/pow(v2,gamma)
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 point 3
v3 = v2
rhs = p2*v2/t2

#p3v3/t3 
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 point 4
v4 = v1

p4 = p3*pow(v3, gamma)/pow(v4, gamma)

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

#Thermal Efficiency of the Otto Cycle:
t_h =  1 - (t4-t1)/(t3-t2)
print(t_h)


#plotting the vlaues in graph

plt.plot([v2,v3],[p2,p3])
plt.plot(V_compression,P_compression)
plt.plot(V_expansion,P_expansion)
plt.plot([v4,v1],[p4,p1])
plt.show()

Output:

The Thermal Efficiency of the otto cycle is found to be 0.629 or 63 %

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.