Challenge

Week 2 Air standard Cycle

Goal: A program in Python to solve and graph the Otto cycle.

Objective:

1. Solve and understand the various state variables of the Otto cycle and draw its p-V diagram.
2. Calculates the thermal efficiency of a given Otto cycle.


Theory: The Otto cycle is the ideal cycle for an Otto piston engine. In most spark-ignited engines, the piston completes four strokes (two mechanical cycles) in the cylinder, and the crankshaft completes two revolutions in each thermodynamic cycle. These engines are called 4-stroke internal combustion engines.

Initially, both the intake and exhaust valves are closed and the piston is in its lowest position (BDC). On the compression stroke, the piston rises and compresses the air-fuel mixture. Just before the piston reaches maximum position (TDC), the spark plug fires, igniting the
mixture and increasing system pressure and temperature. High pressure gas pushes the piston down, which rotates the crankshaft, creating useful work during the expansion or power stroke. At the end of this stroke, the piston is in its lowest position (completion of the first mechanical cycle) and the cylinder is filled with combustion products. Here, the piston rises again, sweeping the exhaust gases out of the exhaust valve (exhaust stroke), and descends a second time to draw in a fresh air-fuel mixture through the intake valve (
's
intake stroke). Note that the pressure in the cylinder is slightly higher than atmospheric pressure during the exhaust stroke and slightly lower during the intake stroke.

Fig.1 -Actual and ideal cycles in spark-ignition engines and their p-V diagram

The four processes of the Otto cycle are:

  1. (Process 1-2),Isentropic compression process or Reversible adiabatic compression of air.
  2. (Process 2-3),Constant volume heat addition process .
  3. (Process 3-4),Isentropic expansion process or Reversible adiabatic expansion of air.
  4. (Process 4-1) Constant volume heat rejection process.


BASIC EQUATIONS :

This project contains various equations for the Otto cycle.

These are:

Compression ratio (rc) , rc=(V1V2) or 1+VsVc,


*Displacement (Vs) = π4⋅d2⋅l, d is bore diameter, l is stroke length,


VVc = 1 + 12 (rc−1)[R+1−cosθ−(R2−sin2θ)12],
where R = connecting rod length/crank radius ,

*adiabatic process equation = p vγ = constant,


*ideal gas equation = p・v =m・R・T,
Otto cycle thermal efficiency (η)= 1−1rγ−1c,


v1 = vs+vc , v2=vc.


PYTHON Code Description:

  1. import the necessary modules.
  2. Based on the relationship between crank angle and volume inside the chamber we make a function named engine _kinematics, which takes the following inputs - stroke,con_rod,cr,v_clearence,start_crank_angle,end_crank_angle And it returns an array of the volumes inside the chamber as an output for the variation of crank angle.
  3. Assign the input values.
  4. Calculate the swept volume, clearance volume, v1 & v2.
  5. Calculate of static variables based on the derived formulas using the data.
  6. Calculate the p pressure & v volume during compression and expansion calling the engine_kinematics function.
  7. Plot of the curves which represent the thermal process based on the p & v values of four states.
  8. Give name and label to the graph.
  9. Calculation of thermal efficiency using formula.
'''
Air standard Cycle
by shiek hafeez 
'''
#importing required libraries
import math
import matplotlib.pyplot as plt 

#Engine Kinematics function
def engine_kinematics(bore,stroke,con_rod,cr,start_angle,end_angle):
	#Engine 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)

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

	sc = math.radians(start_angle)
	ec = math.radians(end_angle)

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

 

#INPUTS
p1 = 101325
t1 = 500
gamma = 1.4
t3 = 2300
#Engine parameters
bore = 0.1
stroke = 0.1
con_rod = 0.15
cr = 8

#Volume calculation
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 = 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

#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])
plt.title('P-V DIAGRAM OF OTTO CYCLE')
plt.xlabel('Volume (m^3/s)')
plt.ylabel('Pressure (Pa)')
plt.show()

#THERMAL EFFICIENCY
n = 1 - (pow(cr,(1-gamma)))
print(n)

RESULTS

OUTPUT:-

Output in the command window –

P-V Diagram –

CONCLUSION:-

  1. The thermal efficiency of the otto cycle is 0.5647 or 56.47 %.. Efficiency is typically less than 100% because there are such as friction and heat loss that convert the energy into alternative forms.
  2. The graph which we get is the ideal otto cycle p-v diagram. The actual otto cycle diagram is different but for the ease of calculation we generally use the ideal diagram.
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.