Challenge

Week 2 Air standard Cycle

Aim:

A python code that can solve an otto cycle.

THEORY:

The thermal efficiency of the otto cycle:

Step-wise explanation of code:

1. Initially declaring the input values along with state variables which are known

2.Using initial values calculating the swept volume and clearance volume

3.Now calculating remaining state variables (like v,p,t)at each state i.e, at 1,2,3,4 using following thermodynamic relations

they are 1.p*v^gama=constant

2.(p*v/t)i=(p*v/t)j

4. Now involving piston kinematics to determine how the value changes from TDC to BDC i.e, using the existing formulae which determines the piston kinematics

5. Plotting various state points with marker '*'

6. joining the points with the help of piston kinematics and the technique we used at Robert's arm

7. Finally calculating the efficiency using formulae with simple PYTHON coding

import math
import matplotlib.pyplot as plt 

def engine_kinematics(bore,stroke,con_rod,start_crank,end_crank):
	a=stroke/2
	radius=con_rod/a
	start_crank=math.radians(start_crank)
	end_crank=math.radians(end_crank)

	n=50

	d_theta=(end_crank-start_crank)/(n-1)

	v=[]

	for i in range(n):
		theta=(start_crank+i*d_theta)
		t1=0.5*(c_r-1)
		t2=radius+1-math.cos(theta)
		t3=pow(pow(radius,2)-pow(math.sin(theta),2),0.5)
		v.append((1+t1*(t2-t3))*v_c)
	return v
# state variable and inputs
p1=101325
t1=300
gama=1.4
t3=2300
# engine geometric properties
bore=0.1
stroke=0.1
con_rod=0.15
c_r=12
# calculating the swept volume and clearance volume 
v_s=math.pi/4*pow(bore,2)*stroke
v_c=v_s/(c_r-1)

# state variables at state point 1
v1=v_s+v_c
# state variables at state point 2
v2=v_c
p2=(p1*pow(v1,gama))/pow(v2,gama)
t2=(p2*v2)/(p1*v1/t1)
v_compression=engine_kinematics(bore,stroke,con_rod,180,0)
p_compression=[]
constant=p1*pow(v1,gama)
for v in v_compression:
	p_compression.append(constant/pow(v,gama))
#state variables at state point 3
v3=v2
p3=(p2*v2*t3)/(v3*t2)
v_expansion=engine_kinematics(bore,stroke,con_rod,0,180)
p_expansion=[]
constant=p3*pow(v3,gama)
for v in v_expansion:
	p_expansion.append(constant/pow(v,gama))
#state variables at state point 4
v4=v1
p4=(p3*pow(v3,gama))/pow(v4,gama)
t4=(p4*v4)/(p1*v1/t1)

#plotting
plt.figure()
plt.plot([v2,v3],[p2,p3],label='Heat addition')
plt.plot(v_compression,p_compression,label='Isentropic compression')
plt.plot(v_expansion,p_expansion,label='Isentropic expansion')
plt.plot([v4,v1],[p4,p1],label='Heat rejection')
plt.xlabel('volume')
plt.ylabel('pressure')
plt.title('p_v diagram of otto cycle')
plt.legend()
plt.savefig('p_v diagram.png')
#thermal efficiency calculation
TE=(1-1/pow(c_r,(gama-1)))*100
print('thermal efficiency of given otto cycle is',TE,'%')
plt.show()

The plot of pressure and velocity diagram:

OBSERVATIONS:

Thermal efficiency is 62.98%

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.