Challenge

Week 2 Air standard Cycle

Aim: Write a code that can solve a otto cycle and plot of it

Objectives:

  • To write a basic code to solve Air standard cycle.
  • To find out an efficiency of Air standard cycle and with trial and error method optimize engine efficiency.
  • To plot a results obtained to visualize actual scenario.

Introduction:

An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston engine

Processes:

  • Process 0–1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
  • Process 1–2 is an isentropic compression of the charge as the piston moves from bottom dead centre (BDC) to top dead center (TDC).
  • Process 2–3 is a constant-volume heat transfer to the working gas from an external source while the piston is at top dead center. This process is intended to represent the ignition of the fuel-air mixture and the subsequent rapid burning.
  • Process 3–4 is an isentropic expansion.
  • Process 4–1 completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at bottom dead center.
  • Process 1–0 the mass of air is exhausted to the atmosphere in a constant pressure process.

Required formula's:

Swept volume:

Vs = n*(pi/4)*(bore)^2*stroke

where,

n= no of cylinder

Vc= cylinder swept volume [cm3 (cc)]

BDC = Bottom Dead Center TDC = Top Dead Center

Clearance volume:

Vc= Vs/(Cr-1)

V1 = Vs+ Vc

V2 = Vc

where,

Cr=compression ratio

Compression ratio:

Cr=(Vs+ Vc)/ Vc

Isentropic proccess:

P*V^γ= constant

Ideal gas equation:

PV=mRT

Efficiency:

η=(Cr-1)/Cr

Steps/logic:

  • Define inputs such as starting temperature, atmospheric pressure, gamma and combustion temperature.
  • Calculate the pressure at compression stroke which is isentropic process with equation PV^gamma = constant.
  • And calculate unknown temperature using ideal gas equation PV=mRT.
  • For compression and expansion phases we have formula to calculate volume at compression and expansion. create a function to calculate values.
  • Call a function and calculate the values of pressure at compression and pressure at expansion.
  • After getting all the values using plot command we should plot all the four phases.
  • At last calculate the efficiency of the processes using formula = 1 - (t2/t1) .

Python code for otto cycle:

#otto cycle simulator
import math
import matplotlib.pyplot as plt
import numpy as np

#geometric parameters
bore = 0.088
stroke = 0.083
cr = 14
con_rod = 0.14
gamma = 1.4

#inputs
p1 = 101325
t1 = 500
t3 = 2500

#swept and clearance volume
v_swp = math.pi/4 *pow(bore,2)*stroke           
v_clr = v_swp/(cr - 1)
v1 = v_swp+v_clr
 
#function to calculate volume at compression and volume at expansion during isentropic process
def engine_kinematics(bore,stroke,cr,con_rod,v_swp,v_clr,start_crank,end_crank):
	"""
	engine kinematics
	"""
	a = stroke/2  #crank pin length
	R = con_rod/a  #constant
	n=50

	sc = math.radians(start_crank)
	ec = math.radians(end_crank)
	theta = np.linspace(sc,ec,n)

	V = []
	for THETA in theta:
		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_clr)
	return(V)
#returning the value of volume

#calling a function
#To calculate the pressure a volume during compression
V_comp = engine_kinematics(bore,stroke,cr,con_rod,v_swp,v_clr,180,0)
constant = p1*pow(v1,gamma)
p_comp = []
for vol in V_comp:
	p_comp.append(constant/pow(vol,gamma))
		 

#compression stroke
v2 = v_clr
#for isentropic process p2*v2^gamma = p1*v1^gamma
rhs = p1*pow(v1,gamma)
p2 = rhs/pow(v2,gamma)
#we will use ideal gas law to calculate the value of t2,p1*v1/t1 = p2*v2/t2
lhs = p1*v1/t1
t2 = p2*v2/lhs

#expansion stroke
#since the process here is constant volume 
v3 = v2
#the temperature after the combustion of fuel is around 2500k
#the ideal gas equation to find pressure can be given by, p2*v2/t2 = p3*v3/t3
rhs = p2*v2/t2
p3 = rhs*t3/v3

#calling a function
#To calculate the pressure a volume during expansion
V_exp = engine_kinematics(bore,stroke,cr,con_rod,v_swp,v_clr,0,180)
constant = p3*pow(v3,gamma)
p_exp = []
for vol in V_exp:
	p_exp.append(constant/pow(vol,gamma))
	

#suction stroke 
v4 = v1
#the equation for isentropic process is given as, p3*v3^gamma = p4*v4^gamma
rhs = p3*pow(v3,gamma)
p4 = rhs/pow(v4,gamma)

#efficiency
eta = 1 - (t1/t2)
print('efficiency','=',eta*100,'%')

#plotting
plt.plot([v2,v3],[p2,p3])
plt.plot(V_comp,p_comp)
plt.plot(V_exp,p_exp)
plt.plot([v4,v1],[p4,p1])
plt.xlabel('volume')
plt.ylabel('pressure')
plt.title('P-V diagram of otto cycle')
plt.savefig('P-V diagram.png')

PLOT:

From the above graph we can see the actual curve during isentropic processes.

Efficency of the proccess:

Conclusion:

The temperature and pressure of the otto cycle increases during compression process and decreases during expansion process.

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.