Challenge

Week 2 Air standard Cycle

AIM : Write code and solve an otto cycle and make plots for it and create a PV diagram through Python

OBJECTIVE : create a PV diagram of otto cycle and output the thermal efficiency of the engine.

EXPLANATION : 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

The processes are described by:

  • Process 0–1 (intake stroke)

A mass of air is drawn into piston/cylinder arrangement at constant pressure.

  • Process 1–2 (compression stroke)

It is an adiabatic (isentropic) compression of the charge as the piston moves from bottom dead centre (BDC) to top dead centre (TDC).

  • Process 2–3 (ignition phase)

It is a constant-volume heat transfer to the working gas from an external source while the piston is at top dead centre. This process is intended to represent the ignition of the fuel-air mixture and the subsequent rapid burning.

  • Process 3–4 (expansion stroke)

It is an adiabatic (isentropic) expansion (power stroke).

  • Process 4–1(idealized heat rejection)

It completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at bottom dead centre.

  • Process 1–0 (exhaust stroke)

The mass of air is released to the atmosphere in a constant pressure process.

INPUTS AND PROCEDURE :

  • First thing we have to doing is importing math module and import mathplotlib.pyplot as plt
  • define the function with parameters and in the function state the all inputs
  • Volume at state one V1
  • Temperature at state one T1’
  • With these two we can calculate pressure at state one P1
  • Compression ratio (CR) with these we can calculate V2 and P2 .With these two we can calculate temperature T2
  • Either T3 or P3 are assumed to calculate V3 ,because V1 and V2 are same volume addition
  • When T3 and V3 is known P3 is calculated
  • We will able to known hoe volume changes from one to two. This is depend on engine kinematics
  • In this particular problem instead of starting from V1 . We are going to join from the engine geometric parameters
  • The expansion and the compression curves of the otto cycle can be traced by engine by engine kinematics function i.e an user defined function. In the engine kinematics, we are solving an eqaution through which the compression volume can be calculated. The formula is given below.
  • `V/(Vc) = 1+ 1/2 (rc - 1)[R + 1 - cos(theta)-(R^2 - (sin(theta))^2)^(1/2))`

Engine geometric parameters :

  • Bore
  • Stroke
  • Connecting rod length
  • Compression ratio
  • We will able to solve the kinematics equation for the piston and we will able to calculate swept volume and clearance volume which information required to calculate volume at each state.

PROGRAM :

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

def engine_kinematics(bore,stroke,cond_rod,cr,start_crank,end_crank):
    #Geometric Parameters
	a = stroke/2
	R = cond_rod/a
	# Volume Computation
	v_s = (math.pi/4)*pow(bore,2)*stroke #Swept volume
	v_c = v_s/(cr-1) #clearance volume
    #conversion  to radians
	sc=math.radians(start_crank)
	ec=math.radians(end_crank)
	num_values = 100 #number of divisions
	dtheta = (ec-sc)/(num_values-1) #spacing between each division
	V = [] #Array for volume

	for i in range(0,num_values): #updating V
		theta = sc+i*dtheta
		V.append((1 + 0.5*(cr-1)*(R+1-math.cos(theta)-(pow((pow(R,2)-pow(math.sin(theta),2)),0.5))))*v_c)

	return V
#inputs
p1 = 95000
t1 = 288
gamma = 1.4
t3 = 1473
# Geometric parameters
bore = 0.1
stroke = 0.1
cond_rod = 0.15
cr = 12

# swept volume and clearance volume
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_s+v_c

#point 2
v2 = v_c

p2 = p1*pow(v1,gamma)/pow(v2,gamma)
rhs = p1*v1/t1
t2 = p2*v2/rhs
#calling the function for compression volume
V_compression = engine_kinematics(bore,stroke,cond_rod,cr,180,0)
constant = p1*pow(v1,gamma)
P_compression = []

for v in V_compression: #updating compression pressure
	P_compression.append(constant/pow(v,gamma))

#point 2-3: const vol heat addition
v3 = v2
rhs = p2*v2/t2
p3 = rhs*t3/v3
#calling the function for expansion volume
V_expansion = engine_kinematics(bore,stroke,cond_rod,cr,0,180)

constant = p3*pow(v3,gamma)
P_expansion = []

for v in V_expansion: #updating ecpansion pressure
	P_expansion.append(constant/pow(v,gamma))
#Point 4

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

#efficiency
efficiency = (1-(1/pow(cr,(gamma-1))))*100
print('efficiency = {}%'.format(efficiency))

#plotting the PV Diagram
plt.figure()
plt.plot(V_compression,P_compression,label = 'Isentropic compression')
plt.plot([v2,v3],[p2,p3],label = 'Heat addition')
plt.plot(V_expansion,P_expansion,label = 'isentropic expansion')
plt.plot([v4,v1],[p4,p1],label = 'Heat rejection')
plt.xlabel('Volume (m^3)')
plt.ylabel('Pressure (pa)')
plt.title('P-V Diagram of otto cycle')
plt.legend()
plt.show()
r = []
crr = []
eta = []
print(len(V_expansion))
print(len(V_compression))
r = np.divide(V_expansion,V_compression)
# calculating thermal efficinecy
for i in r:
 	t_1 = pow(i,(gamma-1))
 	t_2 = 1/t_1
 	t = (1-t_2)*100
 	eta.append(t)
print(eta)
plt.figure(2)
plt.plot(r,eta,'r')
plt.title('Compression ratio vs Thermal efficiency of otto cycle')
plt.xlabel('Compression Ratio')
plt.ylabel('Thermal Efficiency')
plt.xlim(0,14)
plt.show()

OUTPUT :

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.