Challenge

Week 2 Air standard Cycle

INTRODUCTION: -

The Otto cycle is the theoretical cycle of interest when one is considering reciprocating SI engines. The four-stroke Otto cycle is made up of the following four internally reversible processes: 1–2, isentropic compression; 2–3, constant-volume heat addition; 3–4, isentropic expansion; and 4–1, constant-volume heat rejection.

P-v and T-s diagram of an ideal Otto cycle.

The four processes of the cycle is -

Process 1-2: Isentropic compression of the working fluid occurs as the piston moves from bottom dead center (BDC) to top dead center (TDC).

Process 2-3: Here, with the SI, a rapid burning occurs inside the piston; therefore, the heat addition takes place at the constant volume.

Process 3-4: In this process, the working fluid expands isentropically and produces the useful work for the cycle.

Process 4-1: Heat removal at constant volume. In practical applications, the heat is removed by expelling the exhaust gas to the atmosphere.

OBJECTIVE: -

Write a python program for an otto cycle so that -

  1. The code should create a PV diagram.
  2. The code should output the thermal efficiency of the engine.

PROCEDURE: -

We will start with importing the Math and Matplotlib modules.

"""
OTTO CYCLE SIMULATOR
"""

import math
import matplotlib.pyplot as plt

We will define the function to store the different values of crank angle rotation as the compression and expansion occur in different cycles.

def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
	"""
	Engine Kinematics
	"""

	#Geometric Pramaters
	cr = 12
	a = stroke/2

The number of values for which the program will iterate is 50.

	#Volume parameters
	v_s = (math.pi/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)

The equation describes the relationship between the crank angle and volume inside the combustion chamber. The whole equation is divided into three terms for the sake of simplicity in coding.A null array 'V' is created to store the new values after every iteration using append command.

	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(R,2) - pow(math.sin(theta),2)
		term3 = pow(term3,0.5)

		V.append((1+term1*(term2- term3))*v_c)

	return V

p1 is defined as the atmospheric pressure,the specific heat of the air(gamma) is taken as 1.4,t1 and t3 are temperatures corresponding to the state point 1 and 3 respectively.

The geometric parameters bore diameter,stroke length and the connecting rod length and compression ratio is defined in the code.

#Inputs
p1 = 101325
t1 = 500
gamma = 1.4
t3 = 2300

#Geometric Parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 12
a = stroke/2
R = con_rod/a

Calculating the swept volume and the clearance volume.

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

#P2V2/t2 = P1V1/rhs = P1V1/t1 | P2V2/t2 = rhs | t2 = P2V2/rhs
rhs = p1 * v1/t1
t2 = p2 * v2/rhs

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

#P3V3/T3 = P2V2/T2 | RHS = P2V2/T2 | P3 = RHS*T3/V3
rhs = p2*v2/t2
p3 = rhs * t3/v3

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

Finally plotting the P-v diagram

plt.plot([v2,v3],[p2,p3])
plt.plot(v_compression,p_compression)
plt.plot([v1,v4],[p1,p4])
plt.plot(v_expansion,p_expansion)

The Thermal efficiency of the Otto cycle can be calculated using following code.

#Calculating Thermal Efficiency of otto cycle

Thermal_efficiency = (1 - 1/pow(cr,gamma-1))

print (Thermal_efficiency)

OUTPUT: -

The Thermal Efficiency for the Otto Cycle is -

0.6298928275128466.

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.