Project

Air Standard Cycle using Python

Aim: To plot a P-V diagram for the Air Standard Cycle or Otto cycle and to compute the thermal efficiency of the engine using Python.

Introduction:

OTTO CYCLE- The Otto cycle consists of isentropic compression, heat addition at constant volume, isentropic expansion, and heat rejection at constant volume.

It measures the thermal efficiency of a typical spark-ignition piston engine. This is a cycle most commonly found in automobiles.
An Otto cycle is a definition of what happens to a mass of gas when it is subject to changes in pressure, temperature, volume, heat supplement and heat removal.
The mass of gas that undergoes these changes is called the system.
In this case, the system is defined as the fluid (gas) within the cylinder.
By describing the changes that take place within the system, it will also describe in the inverse, the system's effect on the environment.
In the case of a four-stroke Otto cycle, there are technically two more processes; one for exhausting waste heat and combustion products at constant pressure (isobaric); and one for the intake of constant pressure cool oxygen air; however, these are often omitted in a simplified review.
PROCESS OF OTTO CYCLE AND IT'S P-V DIAGRAM:
The different processes are described by-
Process 0-1: A mass of air is drawn into the piston/ cylinder arrangement at constant pressure.
Process 1-2: This process is an adiabatic(isentropic) compression of the charge as the piston moves from the bottom dead centre (BDC) to top dead centre (TDC).
Process 2-3: This 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: This is an adiabatic(isentropic) expansion(power stroke).
Process 4-1: This process completes the cycle by a constant-volume process in which heat is rejected from the air while the piston is at the bottom dead centre.
Process 1-0: Here, the mass of the air is released to the atmosphere in a constant pressure process.
In an Otto cycle, the compression ratio is the crucial factor.
For this project, I have made use of Python as a scripting language.
FORMULAE USED:
Swept Volume= pi/4*bore^2*stroke
Clearance Volume= Swept Volume/ (cr-1)
pressure*volume^gamma=constant
pressure*volume/temperature=constant
Efficiency=(1-(1/cr)^gamma))*10
CODE:
#Otto cycle simulator
#Importing the basic libraries/ modules
import math

import matplotlib.pyplot as plot

def engine_kinematics(bore,stroke,conrod,cr,start_crankangle,end_crankangle):
	"""
	EngineKinematics

	"""

	#Input engine parameters
	a=stroke/2
	R=conrod/a

	#defining angles
	sc=math.radians(start_crankangle)
	ec=math.radians(end_crankangle)

	numvalues=100
	dtheta=(ec-sc)/(numvalues-1)

	#Volume computation
	vs=(math.pi/4)*pow(bore,2)*stroke
	vc=vs/(cr-1)
	V=[]

#tracing the volume curve
	for i in range(0,numvalues):
		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))*vc)
	return V

#Inputs Point1
p1=101325
t1=500
gamma=1.4
t3=2500

#Engine parameters
bore=0.1
stroke=0.1
conrod=0.15
cr=10

#Volume Computation
vs=(math.pi/4)*pow(bore,2)*stroke
vc=vs/(cr-1)
v1=vc+vs

#point2
v2=vc
p2=p1*pow(v1/v2,gamma)

#p2v2/t2=p1v1/t1 
t2=p2*v2*t1/(p1*v1)

Vcompress=engine_kinematics(bore,stroke,conrod,cr,180,0)
constant=p1*pow(v1,gamma)
pcompress=[]

#Point3
for v in Vcompress:
	pcompress.append(constant/pow(v,gamma))
v3=v2

#p3v3/t3=p2v2/t2
p3=p2*v2*t3/(v3*t2)

Vexpand=engine_kinematics(bore,stroke,conrod,cr,180,0)
constant=p3*pow(v3,gamma)
pexpand=[]

#point4
for v in Vexpand:
	pexpand.append(constant/pow(v,gamma))
v4=v1
p4=p3*pow(v3/v4,gamma)
t4=p4*v4*t3/(p3*v3)

#Plotting the P-V diagram
plot.plot([v2,v3],[p2,p3])
plot.plot(Vcompress,pcompress)
plot.plot(Vexpand,pexpand)
plot.plot([v4,v1],[p4,p1])
plot.show()

#Thermal Efficiency
n=1-(pow(cr,(1-gamma)))
point(n)

EXPLANATION OF CODE:

1. Importing the libraries/modules for the successful execution of the code

2. Defining thermodynamic properties

3. Defining engine geometric parameters

4. Pressure and temperature at state point 1

5. Computation of swept volume and clearance volume

6. Calculating thermodynamic properties at state point 1

7. Calling the function to determine various points between state 1 and 2

8. Calculating thermodynamic properties at state point 2 and 3

9. Calling the function to determine various points between states 3 and 4.

10. Properties at state point 4

11. Plotting the graph

12. Calculating thermal efficiency

OUTPUT:

CONCLUSION:

Hence, Efficiency of Otto cycle is 60.18%

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.