Week 2 Air standard Cycle
AIM
- Write a code to plot P-V diagram of otto cycle
- Write a code to calculate the thermal efficiency of the engine
THEORY
- Otto Cycle
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition engine. It is the thermodynamic cycle most commonly found in automobile engines. The Otto cycle is a description of what happens to a mass of gas when subjected to changes of pressure, temperature, volume, addition of heat, and removal of heat. There are mainly 4 processes explained by the P-V diagram, which are intake, compression, constant pressure heat addition, expansion and constant pressure heat removal.

This is the P-V diagram of an otto cycle, where
TDC = Top Dead Center
BDC = Bottom Dead Center
- Process 0–1 a mass of air is drawn into cylinder at constant pressure.
- Process 1–2 is an adiabatic (isentropic) compression of the charge as the piston moves from BDC to 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 adiabatic (isentropic) expansion (power stroke).
- 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 released to the atmosphere in a constant pressure process.
- Bore
It is the inner diameter of a cylinder
- Stroke
It is the distance travelled by the piston within the cylinder(BDC toTDC).
- Connecting Rod
It is the rod which connects the piston and crankshaft.
- Compression ratio
It is the ratio of volume of cylinder to volume of combustion chamber in an IC engine.
- Swept Volume
It is the displacement of a cylinder. It is the volume between TDC and BDC. As the piston travels from top to bottom it sweeps its total volume.
`V_s=pi/4d^2L`
where,
d is the bore and L is the stroke.
- Clearance Volume
It is the volume remaining above the piston of an engine when it reaches TDC.
`V_c=V_s/(C_r-1)`
where, `C_r`=Compression ratio
- Total Volume
Total Volume = Swept volume + Clearance Volume
- Thermal Efficiency

where, CR=compression ratio
`gamma`=Specific heat ratio
PYTHON CODE
"""
otto cycle
"""
import math
import matplotlib.pyplot as plt
# defining function
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
# crank pin radius
a=stroke/2
#constant
r=con_rod/a
# swept volume
v_s=(math.pi/4)*pow(bore,2)*stroke
#clearance volume
v_c=v_s/(cr-1)
# theta array and v
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
# equation
term1=0.5*(cr-1)
term2=r+1-math.cos(theta)
term3=pow(r,2)-pow(math.sin(theta),2)
term3=pow(term3,0.5)
v.append((1+term1*(term2-term3))*v_c)
return v
# inputs
bore=0.1
stroke=0.1
con_rod=0.15
cr=8
gamma=1.4
# swept volume
v_s=(math.pi/4)*pow(bore,2)*stroke
#clearance volume
v_c=v_s/(cr-1)
# state1 - intake
p1=101325
t1=500
v1=v_s+v_c
#state2 - compression
v2=v_c
"""
from relation, p1v1^gamma=p2v2^gamma
"""
p2=p1*pow(v1,gamma)/pow(v2,gamma)
"""
from relation, p1v1/t1=p2v2/t2
"""
rhs=p1*v1/t1
t2=p2*v2/rhs
v_compression=engine_kinematics(bore,stroke,con_rod,cr,180,0)
constant=p1*pow(v1,gamma)
# p_compression*v_compression^gamma=constant
p_compression=[]
for v in v_compression:
p_compression.append(constant/pow(v,gamma))
#state3 - constant volume heat addition
#let
t3=2300
v3=v2
"""
from relation, p2v2/t2=p3v3/t3
"""
p3=rhs*t3/v3
v_expansion=engine_kinematics(bore,stroke,con_rod,cr,0,180)
constant=p3*pow(v3,gamma)
# p_compression*v_compression^gamma=constant
p_expansion=[]
for v in v_expansion:
p_expansion.append(constant/pow(v,gamma))
#state4 - constant volume heat rejection
v4=v1
"""
from relation, p4v4^gamma=p3v3^gamma
"""
p4=p3*pow(v3,gamma)/pow(v4,gamma)
"""
from relation, p4v4/t4=p3v3/t3
"""
rhs=p3*v3/t3
t4=p4*v4/rhs
# plotting
plt.plot([v2,v3],[p2,p3])
plt.plot(v_compression,p_compression)
plt.plot(v_expansion,p_expansion)
plt.plot([v4,v1],[p4,p1])
plt.xlabel('P')
plt.ylabel('V')
plt.show()
# thermal efficiency
thermal_eff = 1-(1/pow(cr,gamma-1))
print(thermal_eff)
CODE EXPLANATION
- def - This command is used to define a function.
- math.radians() - This command used to converts a degree value into radians.
- pow() - pow() function returns the power of the given numbers.
- return - A return statement is used to end the execution of the function call and “returns” the result to the caller.
- append - The append() command in python adds a single item to the existing list.
- for - for command is used to start the for loop.The for loop in Python is used to iterate over a sequence.
- range - The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and stops before a specified number.
- Line number 76 and 98 are calling the predefined functions.
RESULTS
- P-V Diagram

- Thermal Efficiency
We get the thermal efficiency of the engine as 0.56472.(56.472%)
