Challenge

Week 2 Air standard Cycle

Objective- Write a program in python to find out the PV Diagram of the Otto cycle and also find the thermal efficiency of the engine.

An Otto cycle is an idealized thermodynamics cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines.

This cycle has two isentropic processes and two isochoric processes.

Process 1-2= Isentropic compression process

Process 2-3= Constant volume heat addition process

Process 3-4= Isentropic expansion process

Process 4-1= Constant volume heat rejection process

The thermal efficiency of the engine is given by

where the CR= compression ratio

k= Gamma=1.4

n otto= efficiency.

The formula used for the calculation and plot the graph

Swept vol=pi/4*bore^2*stroke

Clearance vol=Swept vol/(CR-1)

Pressure*Volume^gamma=Constant (for isentropic process)

Pressure*Volume/Temperature= Constant (Ideal gas equation)

The expression used the plot the ideal isentropic processes

where rc= compression ratio

R= connecting rod/crank radius

theta= crank angle

Data assumed

Bore=0.1m

Stroke length=0.1m

Connecting Rod length= 0.15m

Compression ratio= 8

P1= 101325 pa

T1= 500 k

T3= 2300 k

gamma=1.4

SOLUTION-

CODE-

#otto cycle simulator
#by Vinod Kumar
import math
import matplotlib.pyplot as plt 

#inputs
#pressure in pascal and temperature in kelvin and volume in m^3
p1=101325
t1=500
gamma=1.4
t3=2300

#Engine Kinematics
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
	a=stroke/2 #crank radius
	R=con_rod/a 
	n=100
	Vs=(math.pi/4)*pow(bore,2)*stroke
	Vc=Vs/(cr-1)
	start=math.radians(start_crank)
	end=math.radians(end_crank)
	delta=(start-end)/(n-1)
	v=[]
	for i in range(0,n):
		theta=start-i*delta
		term1=0.5*(cr-1)
		term2=R+1-math.cos(theta)
		term3=pow(((pow(R,2)-pow(math.sin(theta),2))),0.5)

		v.append((1+term1*(term2-term3))*Vc)
	return(v)
#Geometeic Parameters
bore=0.1
stroke=0.1
con_rod=0.15
cr=8
#volumetric computation, vs(swept volume), vc(clearence volume)
Vs=(math.pi/4)*pow(bore,2)*stroke
Vc=Vs/(cr-1)
v1=Vs+Vc

#state point 2
v2=Vc
#p2*v2^gamma= p1*v1^gamma
p2=p1*pow(v1,gamma)/pow(v2,gamma)
rhs=p1*v1/t1
t2=(p2*v2)/rhs
v_compresssion=engine_kinematics(bore, stroke, con_rod, cr, 180, 0)

constant=p1*pow(v1,gamma)
p_compression=[]
for v in v_compresssion:
	p_compression.append(constant/pow(v, gamma))
	
#p2v2/t2=p1*v1/t1=rhs
rhs=p1*v1/t1
t2=p2*v2/rhs

#state point 3
v3=v2
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*v4^gamma=p3*v3^gamma
p4=p3*pow(v3,gamma)/pow(v4,gamma)
t4=p4*v4/rhs
#PV diagram
plt.plot([v2,v3],[p2,p3])
plt.plot(v_compresssion, p_compression)
plt.plot(v_expansion, p_expansion)
plt.plot([v4,v1],[p4,p1])
plt.xlabel('VOLUME')
plt.ylabel('PRESSURE')
plt.title('PV Diagram of OTTO Cycle')
plt.show()
#Thermal efficiency of otto cycle
n=1-(pow(cr,(1-gamma)))
print(n)

OUTPUT-

PV Diagram-

The thermal Efficiency output is

The thermal efficiency of the otto cycle is 56.40%.

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.