Project

Otto cycle PYTHON code

Otto cycle is a gas power cycle that is used in spark-ignition internal combustion engines (modern petrol engines).

An Otto cycle consists of four processes:

Two isentropic (reversible adiabatic) processes
Two isochoric (constant volume) processes

\"\"

\"\"

In the above diagrams,

p → Pressure

V → Volume

T → Temperature

s → Entropy

Vc → Clearance Volume

Vs → Stroke Volume

Processes in Otto Cycle:

As stated earlier, Otto cycle consists of four processes. They are as follows:

Process 1-2: Isentropic compression
In this process, the piston moves from bottom dead centre (BDC) to top dead centre (TDC) position. Air undergoes reversible adiabatic (isentropic) compression. We know that compression is a process in which volume decreases and pressure increases. Hence, in this process, volume of air decreases from V1 to V2 and pressure increases from p1 to p2. Temperature increases from T1 to T2. As this an isentropic process, entropy remains constant (i.e., s1=s2). Refer p-V and T-s diagrams for better understanding.

Process 2-3: Constant Volume Heat Addition:
Process 2-3 is isochoric (constant volume) heat addition process. Here, piston remains at top dead centre for a moment. Heat is added at constant volume (V2 = V3) from an external heat source. Temperature increases from T2 to T3, pressure increases from p2 to p3 and entropy increases from s2 to s3. (See p-V and T-s diagrams above).

In this process,

Heat Supplied = mCv(T3 – T2)

where,

m → Mass

Cv → Specific heat at constant volume

Process 3-4: Isentropic expansion
In this process, air undergoes isentropic (reversible adiabatic) expansion. The piston is pushed from top dead centre (TDC) to bottom dead centre (BDC) position. Here, pressure decreases fro p3 to p4, volume rises from v3 to v4, temperature falls from T3 to T4 and entropy remains constant (s3=s4). (Refer p-V and T-s diagrams above).

Process 4-1: Constant Volume Heat Rejection
The piston rests at BDC for a moment and heat is rejected at constant volume (V4=V1). In this process, pressure falls from p4 to p1, temperature decreases from T4 to T1 and entropy falls from s4 to s1. (See diagram above).

In process 4-1,

Heat Rejected = mCv(T4 – T1)

Thermal efficiency (air-standard efficiency) of Otto Cycle,

\"\"

Here,

We assume the temperature at combustion cycle,t3=2300K

gamma=1.4,t1=500K

#ottocyclesimulator

import math
import matplotlib.pyplot as plt

#geometric parameters
bore=0.1
stroke=0.1
con_rod=0.15
cr=12
gamma=1.4
p1=10125
t1=500
t3=2300
#volume computation
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
v1 = v_c + v_s


#point2
v2=v_c
#p1v1gamma=p2v2gamma
p2=p1*pow(v1,gamma)/pow(v2,gamma)

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


#point3
v3=v2
p3=rhs*t3/v3

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

eff=1-(t4-t1)/(t3-t2)
plt.plot([v1,v2,v3,v4,v1],[p1,p2,p3,p4,p1])
plt.xlabel(\'volume\')
plt.ylabel(\'pressure\')
plt.show()
print(eff*100)



This will result in the display of PV plot of otto cycle in the following form

\"\"

The iso-entropic lines are also approximated as straight lines.

And the efficiency gets also printed in percentage form.

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.