Challenge

Week 2 Air standard Cycle

AIM : Python program to achieve the following 2 objectives :

  1. Create an Otto Cycle on P-V graph.
  2. Calculation of thermal efficiency in the output.

BACKGROUND : An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine. It is the thermodynamic cycle most commonly found in automobile engines. Four distinct processes are followed in the Otto cycle: reversible adiabatic compression, addition of heat at constant volume, reversible adiabatic expansion, and rejection of heat at constant volume as follows:

1. Air enters the cycle at point 1 when compression starts and it ends at point 2. The air is compressed in an isentropic process through a volume ratio v1/v2, known as the compression ratio rc (the ratio of the volume of the working fluid before the compression process to its volume after).

2. Heat addition starts at point 2 and ends at point 3. A quantity of heat is added at constant volume, and the working fluid temperature rises.

3. The isentropic expansion process starts at point 3 and it ends at point 4 to the original volume.

4. The heat is rejected at constant volume from point 4 to point 1. Air gets cooled and the working fluid temperature goes down at a constant volume until the cycle is completed.

GOVERNING EQUATION : The following equations will be used extensively while calculating different state variables and thermal efficiency.

  1. For an adiabatic process,

PVγ = constant

P= pressure

V= volume

γ = ratio of the specific heat.

  1. Ideal gas equation,

PV= nRT

P= pressure, V= volume, m= no. of moles, R= Boltzmann constant, T= temperature.

  1. For a constant volume process,

P/T = constant.

  1. The thermal efficiency of an otto cycle is given as,

η= 1-`frac{1}{r^gamma-1}`

η= thermal efficiency

r= compression ratio.

  • An ideal otto cycle is represented as :

SOLUTION ALGORITHM

  • We will begin by defining some input variables namely pressure and temeperature at state point 1; temperature at state point 3; value of γ(which for air is taken as 1.4) and engine geometric parameters namely bore, stroke, compression ratio, ratio of connecting rod length to crank pin radius.
  • Swept volume will be calculated from engine geometric parameters using the relation,

Swept_volume= pi/4 * d2 * L

d= bore, l= stroke length.

  • Clearance volume will be calculated using the relation,

Clearance volume=`frac{swept volume}{r-1}`

  • Then we will calculate the state variables using equations described above.
  • However, to trace the paths of the curve during compression and expansion process, we will calculate the volume change during these processes using the relation,

`frac{V}{Vc}= 1+ frac{1}{2}(r-1)[R+1-costheta-(R^2-sin^2theta)^frac{1}{2}]`

R= ratio of connecting rod length to crank pin radius

θ= crank angle

Vc= clearance volume

  • The calculation above will be done in a separate function file and the function will be called in the main script file to calculate compression and expansion volume.
  • Finally, the P-V plot will be made using the state variables at the points 1,2,3 and 4 respectively.
  • The thermal efficiency will be calculated using the formula above and will be displayed in the output.
  • The script of the entire program will be written in Python.

PYTHON CODE :

"""
program to perform engine kinematics to construct an otto cycle

By Abhishek Arora

"""

import math
import matplotlib.pyplot as plt
import numpy as np

#function to perform path tracing during compression and expansion
def engine_kinematics(c_r,v_clearance,R,cs,ce):
	theta= np.linspace(ce,cs,180)
	volume=[]

#the formula to calculate the volume during compression
#and expansion for path tracing is split into 3 parts
	for t in theta:
		term1= 0.5 * (c_r-1)
		term2= R + 1 - math.cos(t)
		term3= pow((pow(R,2)-pow(math.sin(t),2)),0.5)
		volume.append((1 + (term1 * (term2 - term3))) * v_clearance)
	return volume 

#engine geometric parameters
#all dimensions in metre
bore=0.08
stroke= 0.0795

#compression ratio
c_r= 12

#ratio of connecting rod length to crank pin radius
R= 3.5

#as the crank angle changes during piston movement
#defining starting and ending crank angle
cs= 0
ce= math.pi

#specific heat ratio
gamma= 1.4

#calculation of swept volume and clearance volume
v_swept= math.pi/4 * pow(bore,2) * stroke
v_clearance= v_swept/(c_r-1)

#variables at state point 1
#pressure(in pascals) and temperature(in kelvin) are assumed
p1= 101325
t1= 300
v1= v_clearance + v_swept

#variables at state point 2
v2= v_clearance
p2= (p1 * pow(v1,gamma))/(pow(v2,gamma))
t2= (p2 * v2 * t1)/(p1 * v1)

#calling the function to trace the path during compression
v_compression= engine_kinematics(c_r,v_clearance,R,math.pi,0)
constant= p1 * pow(v1,gamma)
p_compression=[]
for v in v_compression:
	p_compression.append(constant/(pow(v,gamma))) 

#variables at state point 3
#assuming temperature(in kelvin) after compression
t3= 1700
v3= v_clearance
p3= (p2 * t3)/t2

#calling the function to trace the path during expansion
v_expansion= engine_kinematics(c_r,v_clearance,R,0,math.pi)
constant= p3 * pow(v3,gamma)
p_expansion=[]
for v in v_expansion:
	p_expansion.append(constant/(pow(v,gamma))) 

#variables at state point 4
v4= v1
p4= (p3 * pow(v3,gamma))/(pow(v4,gamma))
t4= (p4 * v4 * t3)/(p3 * v3)

#plotting the otto cycle
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.xlabel('volume(m^3)')
plt.ylabel('pressure(Pa)')
plt.show()

#calculating the thermal efficiency 
therm_eff= (1- (1/(pow(c_r,0.4))))* 100
print('thermal efficiency of the cycle is ',therm_eff,' %')



OUTPUT

The following outputs are obtained after running the code :

REMARKS

  • The above script can be used to develop P-V graphs for different engine geometries by simply changing a few variables.
  • The above graph is extremely useful in determining the area under the curve which is an important factor to determine the +ve work that can be obtained from the cycle.

NOTE

  • The engine geometric parameters are taken for a Renault single cylinder engine.
  • Few other reasonable assumptions are made while doing the calculations.
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.