Challenge

Week 2 Air standard Cycle

Objective:

  • To create python code for the Air standard cycle- Otto cycle.
  • To find the thermal efficiency of the SI engine which runs based on the Otto cycle.

Problem Statement:

  • By considering the Engine kinematics, Geometric parameters, and Volumetric parameters.
  • We need to find the Thermal efficiency of the Otto cycle and to plot the PV diagram for the Otto cycle.

Solution Procedure:

  • As Otto cycle consists of 4 thermodynamics reversible cycles. They are...

1. Suction stroke; 2.) Compression stroke; 3.) Expansion or power stroke; 4.) Exhaust stroke.

credited: https://wiki.ucl.ac.uk/display/MechEngThermodyn/Gas+Power+Cycles

Process 1-2: Is an Isentropic compression of the charges from the bottom dead center (BDC) to top dead center (TDC).

Process 2-3: Is a constant-volume heat transfer to the working gas from the external source. In this process, the ignition of the fuel-air mixture is intended to happen.

process 3-4: Is an Isentropic expansion of the fuel-air mixture and considered as the power stroke.

process 4-1: This is a constant-volume process in which heat rejected from the air.

Formulas used:

  • For isentropic process

`PV^gamma`= constant

where, P = pressure; V = volume; `gamma = (Cp)/(Cv)`

  • Ideal gas equation

`(PV)/T`= constant

  • The gas equation for all the ideal gases undergoing any process.

`V/(Vc) = 1 + 1/2(Cr - 1)[R +1-costheta-(sqrt(R^2 - (sintheta)^2))`

where V = volume during expansion or compression.

`Vc` = clearance volume

`theta`= crank angle

`Cr`= compression ratio

`R = (Cr)/a`, where a = crank pin radius

`eta = 1- (1/(Cr^(gamma-1)))`

where `eta`= efficiency

  • I hereby used the manually define Engine_kinemtaics function to calculate volume during expansion and compression.
  • I also do plot the PV diagram obtained from my below code and along with thermal efficiency also calculated.
  • I hereby attached my PV graph which I obtained from code.
  • Below Python code will execute the graph alongwith the thermal efficiency.
  • The thermal efficiency obtained is 47.46944391%
""" 
  Otto cycle simulator
"""
# Importing the required modules
import math
import matplotlib.pyplot as plt

def Engine_kinematics(bore, stroke, con_rod, cr, start_crank, end_crank):
	"""
	Engine kinematics
	"""
	# Geometrics paramter
	a = stroke/2
	R = con_rod/a

	# volume parameters
	v_s = (math.pi/4)*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 = R**2 - (math.sin(theta)**2)
		term3 = term3**0.5
		V.append((1 + term1*(term2 - term3))*v_c)
	return V

#inputs.......

# Pressure in state 1 (pascal)
p1 = 101325
# Temperature in state 1 (kelvin)
t1 = 500
# Temperature in state 3 (kelvin)
t3 = 2300
# Specific heat ratio assumed to be constant (unitless)
gamma = 1.4

# geometric parameters....

# It is diameter of cylinder (meter)
bore = 0.1
# The distance between TDC and BDC (meter)
stroke = 0.1
# Length of connecting rod (meter)
con_rod = 0.15
# Compression ratio (unitless)
cr = 5

# volume computation
v_s = (math.pi/4)*bore**2*stroke
v_c = v_s/(cr-1)
v1 = v_c + v_s

# state of point 2
v2 = v_c
# p2v2^gamma = p1v1^gamma
p2 = p1*(v1**gamma/v2**gamma)

#p2v2/t2 = p1v1/t1 | 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*v1**gamma
p_compression = []

for v in v_compression:
	p_compression.append(constant/(v**gamma))

# state of 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, 180, 0)
constant = p3*v3**gamma
p_expansion = []

for v in v_expansion:
	p_expansion.append(constant/(v**gamma))

# state of point 4
v4 = v1
#p4v4^gamma = p3v3^gamma
p4 = p3*(v3**gamma/v4**gamma)
# p4v4/t4 = rhs
t4 = p4*v4/rhs
# Here "Eta" is Thermal efficiency of Otto cycle engine
Eta = 1-(1/pow(cr,(gamma-1)))
Eta_percent = Eta*100
print(Eta_percent)

# Plotting a graph 
plt.plot(v_compression,p_compression, label = 'Isentropic compression')
plt.plot([v2,v3],[p2,p3], label = 'Constant volume heat addition')
plt.plot(v_expansion,p_expansion, label = 'Isentropic expansion')
plt.plot([v4,v1],[p4,p1], label = 'Constant volume heat rejection')
# Giving a title to my graph
plt.title('Pressure Vs Volume \n Otto cycle', color = 'blue')
# Naming the X-axis and Y-axis
plt.xlabel('Volume', color = 'maroon')
plt.ylabel('Pressure', color = 'maroon')
# Showing a legend on the plot
plt.legend()
# Function to show the plot
plt.show()
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.