Week 2 Air standard Cycle
AIM: To write a Python program to plot the PV diagram of an Otto cycle and determine the thermal efficiency of the cycle.
THEORY AND GOVERNING EQUATIONS:
Otto cycle consists of two adiabatic processes and two isochoric processes.
1-2: Adiabatic Compression Process
`p1v1^gamma = p2v2^gamma`
`(p1v1)/(t1) = (p2v2)/(t2)`
2-3: Isochoric Heat Addition Process
`v2 = v3`
`(p2v2)/(t2) = (p3v3)/(t3)`
3-4: Adiabatic Expansion Process
`p3v3^gamma = p4v4^gamma`
`(p3v3)/(t3) = (p4v4)/(t4)`
4-1: Isochoric Heat Rejection Process
`v4 = v1`
Given,
1. Engine Geometric Parameters:-
bore diameter, b = 0.1
stroke length, s = 0.2
connecting rod length, c = 0.15
Crank radius, a = stroke length / 2
2. Other parameters
adiabatic constant, `gamma = 1.4`
compression ratio, cr = 8
Equations:-
Swept Volume, `v_(swept) = pi/4 *b^2 * s`
Clearance Volume, `v_(cl) = v_(swept) / (cr - 1)`
The equation for calculating volume during the adiabatic processes:
`V = (1 + 1/2(cr - 1)[ R + 1 - cos(theta) - (R^2 - sin^2(theta))^(1/2)])*v_(cl)`
Where,
`theta` is the crank angle.
cr is the compression ratio.
`R = c / a` c is the connecting rod length, a is the crank radius.
All 'v' denotes volume in `m^3`
All 'p' denotes pressure in kPa
All 't' denotes temperature in K
OBJECTIVES:
1. To plot the PV diagram of an Otto cycle.
2. To determine the thermal efficiency of the cycle.
PYTHON CODE:
"""
Otto Cycle Simulator
"""
import math
import matplotlib.pyplot as plt
# Function to calculate volume during compression and expansion process
def engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
# Engine Geometric parameters
a = stroke / 2
R = con_rod / a
# Volume Computation
v_s = (math.pi/4) * pow(bore,2) * stroke
v_c = v_s / (cr - 1)
# Converting theta values to radian
sc = math.radians(start_crank)
ec = math.radians(end_crank)
num_values = 50
dtheta = (ec - sc)/(num_values - 1)
# Calculating Volume
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
# Main Program
# inputs
p1 = 101325
t1 = 500
gamma = 1.4
t3 = 2300
# Geometric Parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 8
# 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
# p2*(v2^gamma) = p1*(v1^gamma) | p2 = p1*(v1/v2)^gamma = p1*cr^gamma
p2 = p1 * pow(cr,gamma)
# p1*v1/t1 = p2*v2/t2 | t2 =t1*(p2*v2/p1v1)
t2 = p2 * v2 * t1 / (p1 * v1)
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
v3 = v2
# p3*v3/t3 = p2*v2/t2 | p3 =t3*(p2/t2)
p3 =t3 * (p2 / t2)
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 * (v3/v4)^gamma
p4 = p3 * pow((v3/v4),gamma)
# p4*v4/t4 = p3*v3/t3 | t4 = t3 * (p4*v4/p3*v3)
t4 = t3 * p4 * v4/(p3*v3)
# Plotting
plt.plot([v2,v3],[p2,p3])
plt.plot(v_compression,p_compression)
plt.plot(v_expansion,p_expansion)
plt.plot([v4,v1],[p4,p1])
# Axis Label
plt.xlabel('Volume (m^3)')
plt.ylabel('Pressure (Pa)')
# Title of the Plot
plt.title('PV diagram of an Otto Cycle')
plt.grid()
plt.text(v1,p1,'1')
plt.text(v2,p2,'2')
plt.text(v3,p3,'3')
plt.text(v4,p4,'4')
plt.show()
# Efficiency
eff = 1 - 1/pow(cr,(gamma - 1))
print('The efficiency of the cycle is ' + str(eff * 100) + ' %')
GRAPH:
OUTPUT:
CONCLUSION:
The efficiency of the cycle is found to be 56.47 %.