Challenge

Week 2 Air standard Cycle

  • Objective:

 To write a python code for a air standard cycle (otto cycle) and plot a pv diagram for four different processes, and find the thermal efficiency of the cycle

  • Problem Statement:

 Ideal gas equation:

`[p1v1]/[t1] = [p2v2]/[t2]`

`[p3v3]/[t3] = [p4v4]/[t4]`

p1,p2,p3,p4 = pressure's at different positions of cycle

v1,v2,v3,v4 = volume's at different stages of cycle

t1,t2,t3,t4 = temperature's at  different stages of cycle

Thermal efficiency:

`1-1/[cr^gamma-1]`

cr = compression ratio of the engine

Formula for volume trace:

`[V] =1+[1/2][rc-1][R+1-COStheta-(R^2-SIN^2theta)^(1/2)]*Vc`

V = volume trace

rc = compression ratio 

Vc = volume of compression

R = connecting rod /[stroke/2]

by using above formulas we calculate the volume trace of otto cycle which finds the volume of compression and expansion along the line thus gives the smooth curve.

  • Solution Procedure:
  1.  import required libraries
  2. define the terms used in the progran
  3. give the basic, geometric and volume parameters
  4. give number of theta values based on required valus between 0,90
  5. give the required basic input values
  6. find the volume trace using the formula and append the values
  7. find out the thermal effeciency of the cycle
  8. open loops to store data for p-compression,p-expansion,v-compression,v-expansion
  9. plot the values of p,v using plot command
  10. use show command to display the graph
  • Results and Discussion:

 Hence using above formula and procedure required graph is produce and also the thermal effenciency is also found using compression ratio

THERMAL EFFICIENCY:

  • Python code:
# otto cycle simulator
import math
import matplotlib.pyplot as plt

def engine_kinamatics(bore,stroke,con_rod,cr,start_crank,end_crank):
	"""
		ENGINE KINAMATICS
	"""
	
	#geometric parameters
	a=stroke/2
	R=con_rod/a

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

	sc = math.radians(start_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
		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))*v_c)
	return v
#inputs
p1 =101325
t1=500
gamma = 1.4
t3=t3 = 2300
#geometric parameters
bore=0.1
stroke=0.1
con_rod=0.15
cr = 5

#thermal effeciency
term5=pow(cr,(gamma-1))
Teffeciency=(1-(1/term5))
print(Teffeciency*100)

# 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)

#p1v1/t1 =p2v2/t2 |rhs= p1v1/t1|rhs =p2v2/t2 |t2=p2v2/rhs
rhs = p1*v1/t1
t2 = p2*v2/rhs
V_compression = engine_kinamatics(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))

#print(p_compression)

# state point3
v3 = v2

#p3v3/t3 =p2v2/t2 | rhs = p2v2/t2 | p3 =rhs*t3/v3

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

V_expansion = engine_kinamatics(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
plt.plot(V_compression,p_compression,'.-', label='icentropic compression')
plt.plot([v2,v3],[p2,p3],'.-', label='constant volume combustion')
plt.plot(V_expansion,p_expansion,'.-', label='icentropic expansion')
plt.plot([v4,v1],[p4,p1],'.-', label='constant volume heat rejection')
plt.legend()
plt.title('ideal otto cycle')
plt.xlabel('volume')
plt.ylabel('pressure')
plt.show()
  • PV diagram of otto cycle:

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.