Challenge

Air standard Cycle

Air Standard Cycle

Objective:

To write a program to plot PV diagram for Otto cycle and to calculate the thermal efficiency.

Otto Cycle:

The otto cycle is an air-standard cycle which approximates the processes in petrol or diesel engines. It is based on constant volume heat addition (combustion) and heat rejection processes, and isentropic compression and expansion. The diagram is shown below, where it is superimposed on an actual p–V diagram for a diesel engine.

The actual p–V diagram for an engine has rounded corners because of the processes of combustion take place at a finite rate. The Otto cycle has sharp corners because the ‘combustion’ is switched on and off instantaneously. It can be seen from Fig that the area of the Otto cycle is larger than that of the actual cycle, and this has to be taken into account when analyzing engine cycles – the actual engine cycle will always produce less work output than the Otto cycle.

The basic Otto cycle is made up of four processes:

  • Isentropic compression;
  • Constant volume heat addition;
  • Isentropic expansion and
  • Constant volume heat rejection.

Steps Involved in coding:

  1. Firstly, importing the math library and matplotlib for the required calculations while writing the program.
  2. Writing a function called engine_kinematics to evaluate the volume inside the combustion chamber and store it in a variable v and also append function is used.
  3. Inside the function, swept volume and the clearance volume is also calculated using the formulas with the help of the math library.
  4. Start crank and the end crank angles are varied according to the constant volume heat addition or rejection and their angles are converted into radians and stored in sc and ec variables respectively.
  5. As per the formula we are calculating the volume inside the chamber and returning the value v.
  6. With the inputs and the geometric parameters like bore and stroke, also the at the state point 2 there is the constant volume heat addition. So v2=v_c. Similarly, at state point 4, v4=v1.
  7. As per the ideal gas law, the values are computed for p3,p4 ,t4.
  8. Finally, the thermal efficiency is computed using the required formulae.

1-1/(cr)^(gamma-1)

V1 is the volume at the bottom dead centre.

V2 is the volume at the top dead centre.

To join points 1, 2,3,4 which are isentropic process we need geometric relations

V/Vc = (1+0.5*(cr-1)*[n+1-cos(theta)-(n^2-sin(theta)^2)^0.5)]

Where

V – Volume inside the cylinder at various crank angles

Vc – clearance volume

cr – compression ratio

Theta is the crank angle

N is the ratio of connecting rod

a = stroke/2

For v_expansion the starting crank-angle will be 0 and ending crank angle weill be 180

For v-compression starting crank-angle will be 180 and ending crank-angle will be 0

Finally, we can plot p_compression and v_compression as well as p_expansion and v_expansion

# Engine Kinematics

import math
import matplotlib.pyplot as plt 

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

 # 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(R,2) - pow(math.sin(theta),2)
     term3 = pow(term3, 0.5)
     
     v.append((1 + term1*(term2 - term3))*v_c)
 return v


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

#geometric parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 12

# 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

p2 = p1*pow(v1,gamma)/pow(v2,gamma)

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

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

p4 = p3*pow(v3,gamma)/pow(v4,gamma)

t4 = p4*v4/rhs

#thermal efficiency

eth = 1-((t4-t1)/(t3-t2))
print(eth)

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.show()

Result : (p-v diagram)

References:

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.