Challenge

Week 2 Air standard Cycle

Aim: To write a program to simulate otto cycle using python, Considering the volume change w.r.t crank angle.

Objective: To trace the volumetric compression and expansion with respect to crank angle.

Otto cycle:

The Otto cycle is a description of what happens to a mass of gas as it is subjected to changes of pressure, temperature, volume, addition of heat, and removal of heat. The mass of gas that is subjected to those changes is called the system. The system, in this case, is defined to be the fluid (gas) within the cylinder.

PV daugram for otto cycle

Program:

import math
import matplotlib.pyplot as plt
def engine_kinematics(bore,stroke,con_rod,cr,stark_crank,end_crank):
	a=stroke/2
	R=con_rod/a
	v_s=math.pi*(1/4)*pow(bore,2)*stroke
	v_c=v_s/(cr-1)

	sc=math.radians(stark_crank)
	ec=math.radians(end_crank)
	num_values=50

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

	v=[]

	for i in range(0,num_values):
		theta=sc+i*dtheta
		print(theta)
		term1=0.5*(cr-1)
		term2=R+1-math.cos(theta)
		term3=pow(R,2)-pow(math.sin(theta),2)
		term4=pow(term3,0.5)
		v.append((1+term1*(term2-term4))*v_c)
	return v
#inputs
p1=101325
t1=500
gamma=1.4
t3=2300
#geometric parameter
bore=0.1
stroke=0.1
con_rod=0.15
cr=12
#volume computation
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
v1=v_s+v_c

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

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

#adiabatic compression cycle
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, constant volume
v3=v2

#p3v3/t3=p2v2/t2
#rhs=p2v2/t2, and p3=rhs*t3/v3

rhs=p2*v2/t2
p3=rhs*t3/v3

#adiabatic expansion cycle
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

 #p4v4^gamma=p3v3^gamma

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

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

#thermal effciency of otto cycle
def ther_eff(cr,gamma):
	t_effy=1-(1/pow(cr,gamma-1))
	return(t_effy)
t_efficiency=ther_eff(12,1.4)
print(t_efficiency)



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.xlabel('v')
plt.ylabel('p')
plt.show()	

1.The def function is used to return the value that is the equation that is the volume of the piston cylinder determined as a function of crank angle from the compression ratio, the stroke, bore and connecting rod length.

V=vc*(1+0.5*(cr-1)*[R+1-cos(theta)-((R^2-sin^2(theta))^0.5)])

With out considering the above equation the pv daigram of cycle will show linear varition of pressure and volume as it will not consider the variation of volume in cylinder wrt to crank position(theta)

2.The value of volume is stored in empty array v[] for both compression and expansion cycle. For compression cycle the crank moves from 180 to 0 degree and similary it traces 0 to 180 degree in expansion cycle. 

3.The math.radians converts the start crank and end crank angke into radians as we give input in degres in the function defined as 

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

4.The volume and pressure at each point in cycle is calculated using adiabatic relation ships for pressure and volume as commented in above program

5.The thermal effciency is calculated as a function of compression ration and K = cp/cv.

Plot:

Output

The thermal effciency=0.629892

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.