Week 2 Air standard Cycle
AIM: To Visualize P-V diagram of Otto Cycle and to calculate the thermal efficiency of heat engine using PYTHON.
OTTO CYCLE :
An Otto cycle is an idealized thermodynamic cycle that describes the functioning of a typical spark ignition piston 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 as it is subjected to changes of pressure, temperature, volume, addition of heat, and removal of heat. The mass of gas that is subjected to those changes is called the system. The system, in this case, is defined to be the fluid (gas) within the cylinder. By describing the changes that take place within the system, it will also describe in inverse, the system's effect on the environment. In the case of the Otto cycle, the effect will be to produce enough net work from the system so as to propel an automobile and its occupants in the environment.
The Otto cycle is constructed from:
- Top and bottom of the loop: a pair of quasi-parallel and isentropic processes (frictionless, adiabatic reversible).
- Left and right sides of the loop: a pair of parallel isochoric processes (constant volume).
The isentropic process of compression or expansion implies that there will be no inefficiency (loss of mechanical energy), and there be no transfer of heat into or out of the system during that process. The cylinder and piston are assumed to be impermeable to heat during that time. Work is performed on the system during the lower isentropic compression process. Heat flows into the Otto cycle through the left pressurizing process and some of it flows back out through the right depressurizing process. The summation of the work added to the system plus the heat added minus the heat removed yields the net mechanical work generated by the system.

PROCESS :
- Process 0–1 a mass of air is drawn into piston/cylinder arrangement at constant pressure.
- Process 1–2 is an adiabatic (isentropic) compression of the charge as the piston moves from bottom dead center (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 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.

Process 1-2 Compression stroke
Piston moves from crank end (BDC, bottom dead centre and maximum volume) to cylinder head end (TDC, top dead centre and minimum volume) as the working gas with initial state 1 is compressed isentropically to state point 2, through compression ratio (V1/V2). Mechanically this is the isentropic compression of the air/fuel mixture in the cylinder, also known as the compression stroke. This isentropic process assumes that no mechanical energy is lost due to friction and no heat is transferred to or from the gas, hence the process is reversible.
Process 2-3 ignition phase
The piston is momentarily at rest at TDC. During this instant, which is known as the ignition phase, the air/fuel mixture remains in a small volume at the top of the compression stroke. Heat is added to the working fluid by the combustion of the injected fuel, with the volume essentially being held constant.
Process 3-4 expansion stroke
The increased high pressure exerts a force on the piston and pushes it towards the BDC. Expansion of working fluid takes place isentropically and work is done by the system on the piston. Mechanically this is the expansion of the hot gaseous mixture in the cylinder known as expansion stroke.
Process 4-1 heat rejection
The piston is momentarily at rest at BDC. The working gas pressure drops instantaneously from point 4 to point 1 during a constant volume process as heat is removed to an idealized external sink that is brought into contact with the cylinder head.
FORMULAS :
1.Swept Volume = The volume swept by the piston during its motion is known as swept volume.It is given by
`V_s=pi/4*d^2*l`
where,
d= diameter or bore of piston
l= stroke or height of piston
2.Clearance Volume= The volume which is left between piston and top dead center of cylinder during combustion or exhaust stroke is called as clearance volume.
`V_c=V_s/(r_c−1)`
where,
`r_c`= Compression ratio of cylinder
3. Total Volume = The sum of swept volume and clearance volume is total volume.
`V=V_s+V_c`
4. Adiabatic Process= An adiabatic process is a type of thermodynamic process which occurs without transferring heat or mass between the system and its surroundings.
`PV^γ=Constant`
where,
P=Pressure of system
V= Volume of system
`gamma`=Ratio of specific heats of fluid
5.Universal gas law stating `PV/T=Constant`
6.Trace volume inside the engine combustion chamber is given by
`V/V_c=1+1/2(r_c-1)[R+1-cos(θ)-(R^2-sin^2(θ))^(1/2)]`
where,
V=Volume inside cylinder when piston is at an angle θ
R=Ratio of length of connecting rod to crank pin radius(a)
a=crank pin radius =stroke length/2= l/2
7.Thermal efficiency of Otto cycle is given by
`eta=1-r_c^(1-gamma)`
Python Program:
#OTTO CYCLE SIMULATOR
import math
import matplotlib.pyplot as plt
#Inputs
p1=101325
t1=500
gamma=1.4
t3=2300
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
"""
ENGINE KINEMATICS
"""
#Geometric Parameters
a=stroke/2 #Crankpin radius
R=con_rod/a
#Volume parameters
v_s=(math.pi/4)*pow(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=pow(R,2)-pow(math.sin(theta),2)
term3=pow(term3,0.5)
V.append((1+term1*(term2-term3))*v_c)
return V
#Geometric Parameters
bore=0.1
stroke=0.1
con_rod=0.15 #connecting rod
cr=12 #compression ratio
v_s=(math.pi/4)*pow(bore,2)*stroke #swept volume
v_c= v_s/(cr-1) #clearance volume
#Volume at state point 1 | v1
v1= v_s+v_c
#At State point 2
v2=v_c #after compression v2=clearance volume
#p2v2^gamma=p1v1^gamma since 1 to 2 is an adiabatic compression| p2 = p1v1^gamma/v2^gamma
p2=p1*pow(v1,gamma)/pow(v2,gamma)
#p2v2/t2=p1v1/t1|p1v1/t1=rhs| t2= p2*v2/rhs
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=[]
for v in V_compression:
P_compression.append(constant/pow(v,gamma))
#At State point 3
v3=v2 # heat addition at constant volume
#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,0,180)
constant= p3*pow(v3,gamma)
P_expansion=[]
for v in V_expansion:
P_expansion.append(constant/pow(v,gamma))
#At State point 4| 3 to 4 is adiabatic expansion
v4=v1
p4= p3*pow(v3,gamma)/pow(v4,gamma)
# Temperature t4| p4v4/t4=p3v3/t3=rhs|t4=p4v4/rhs
t4=p4*v4/rhs
#Thermal Efficiency
TE=1-pow(cr,(1-gamma))
print(TE)
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("Volume")
plt.ylabel("Pressure")
plt.title("Pressure vs Volume")
plt.show()
Explanation:
- Importing math and mathplotlib.pyplot modules
- Inputs required are declared.
- Engine kiematics function has been called .
- Geometric parameters and Volumetric parameters has been declared.
- An empty volume array has been created and the number of theta values taken was given as 50.
- Using the for loop and theta values, the volume array has been appended.
- The respective State point variables has been found out at state1, state2,state3, state4 respectively.
- Respective plots has been made using plot commands and given labels and titles.
- plt.show command is used to show these plots.
Function Code:
"""
ENGINE KINEMATICS
"""
import math
#Geometric Parameters
bore=0.1
stroke=0.1
con_rod=0.15
cr=12
a=stroke/2 #Crankpin radius
R=con_rod/a
#Volume parameters
v_s=(math.pi/4)*pow(bore,2)*stroke
v_c=v_s/(cr-1)
theta=math.radians(180)
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)
#Volume V
V = (1+term1*(term2-term3))*v_c
Explanation:
- Math module has been imported.
- Geometric parameters required are declared.
- Volume parameters like swept volume and clearance volume has been found out using the formulas.
- Volume is found out by making the formula into three terms and finding volume finally
- This is the function thus defined in the main function and then made changes.
Plot:

Result:
- The P-V diagram for all the process has been plotted
- The Thermal efficiency of engine is 62.99%. Thermal effieciency mainly depends upon compression ratio of engine and the type of fluid.So it can be concluded that engines with high compression ration will have high thermal efficiency.