Challenge

Air standard Cycle (IC engine) Otto cycle

Objective - Script the code that can solve an (IC engine) Otto cycle and plot the P-V digram and show the themal efficency of the engine

Problem statement - Looking for pressure, volume graph of Otto cycle

Solution procedure - Code and explaination has attachent in form of (.py) and (.png)

Results: Succesfuly the code gernerated, and working. To support my statement I have attached Otto cycle PV digram.

As I'm currently learning about Otto cycle in my semester, and I got some notes of formulas and derivation to support my code. And justify why we are using and how we are scripted. And also it explains the process and its behaviour at stages.

Here I have attached the python file for the reference of invigilator

INSERT CODE SAMPLE

import math
import matplotlib.pyplot as plt

def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
# engine kinematics

#Crank pin radius(a) and radius of crank wheel(R)
a = stroke/2
R = con_rod/a


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

#Strating position of crank cycle(sc) in form of radians angle and ending position angle(ec)

sc = math.radians(start_crank)
ec = math.radians(end_crank)

num_values = 50

#crank angle spacing
d_theta = (ec-sc)/(num_values-1)
v = []
for i in range(0,num_values):
theta = sc+i*d_theta

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)


#Stated the variables
g = 1.4 #g = gamma
t3 = 2300 #Maximum temperature inside the engine cyclinder

#Engine geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15 #connecting road
cr = 12 #compression ratio


#Variables of the inlet to engine, which is at atmospheric conition
p1 = 101325 #p = Pressure
t1 = 500

#calculating the swept volume(v_s) and clearance volume(v_c)
v_s = (math.pi/4)*bore*bore*stroke
v_c = v_s/(cr-1)
v1 = v_s + v_c
v2 = v_c

#State variable at state point 2, p2 = p1(v1/v2)^gamma which is (cr=[v1/v2]) so p1*cr^gamma
v = v1/v2
p2 = p1*pow(v,g)

#p1v1/t1 = p2v2/t2 So
rhs = p1*(v1/t1)
t2 = p2*(v2/rhs)

v_compression = engine_kinematics(bore,stroke,con_rod,cr,180,0)
constant = p1*pow(v1,g)

p_compression = []
for v in v_compression:
p_compression.append(constant/pow(v,g))


#State point 3
v3 = v2

#Now calculate the pressure and volume at point 3. By using pv/t = consant(nR)
rhs = p2*(v2/t2)
p3 = rhs*(t3/v3)


v_expansion = engine_kinematics(bore,stroke,con_rod,cr,0,180)
constant = p3*pow(v3,g)

p_expansion = []
for v in v_expansion:
p_expansion.append(constant/pow(v,g))


#State point 4
v4 = v1

#p4v4^gamma = p3v3^gamma
p4 = p3*pow(v3/v4,g)

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

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.title('P-V digram of Otto cycle')
plt.xlabel('Volume(m^3)')
plt.ylabel('Pressure(Pa)')
plt.savefig('PV digram.png')
plt.show()

#Thermal efficiency of the engine
thermal_efficiency = 1-(1/pow(cr,(g-1)))
percentage = thermal_efficiency*100
print('Thermal efficiency:', thermal_efficiency)
print('In percentage:', percentage,'%')
plt.savefig('PV digram.png')

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.