Air Standard Cycle Simulator Using Python
Air Standard Cycle Simulator Using Python
Aim: Plotting P-V diagram and efficiency calculation of the Otto Cycle.
GOVERNING EQUATIONS:
Otto cycle is a gas power cycle that is used in a spark-ignition Internal combustion engine (modern petrol
engines). It is an air standard cycle which approximates the processes in petrol or diesel engines.
These processes can be easily understood if we understand p-V (Pressure-Volume) and T-s (Temperature-
Entropy) diagrams of the Otto cycle.
• P = Pressure
• V= volume
• T = Temperature
• S = Entropy
• Vc= Clearance volume
• V = Stroke volume
Processes in Otto Cycle:
Process 1-2: Isentropic compression
In this process, the piston moves from the 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, the 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).
Process 2-3 is isochoric (constant volume) heat addition process. Here, piston remains at the top dead
centre for a moment. Heat is added at constant volume (V 2 = V3) from an external heat source. Temperature
increases from T2 to T3, pressure increases from p2 to p3 and entropy increases from s₂ to s3.
In process 4-1
A = (0.5)*(cr-1)
B = R+1-cosd(theta)
C = ((R^2)-((sind(theta))^2))^0.5
V=(1+(A*(B-C)))*Vc
GIVEN:
bore=0.8 meters
stroke=0.2 meters
p1=101325
Ɣ=1.4
T1=450
T3=3050
Simulation Code
# Otto cycle simulator
import math
import numpy as np
import matplotlib.pyplot as plt
#Engine geometrical parameters
bore=0.8
stroke=0.2
con_rod=0.15
cr=10
def engine_kinematics(bore,stroke,con_rod,cr,theta1,theta2):
v_stroke=(math.pi*pow(bore,2)*stroke)/4
v_clear=v_stroke/(cr-1)
a=stroke/2;
R=con_rod/a
theta=np.linspace(theta1,theta2,180)
V=[]
for t in theta:
A=(0.5)*(cr-1)
B=R+1-math.cos(math.radians(t))
C=pow((R**2)-(math.sin(math.radians(t))**2),0.5)
V.append((1+(A*(B-C)))*v_clear)
return V
#known state variables
p1=101325
#gamma
Ɣ=1.4
t1=450
t3=3050
#calculation of volumes
v_stroke=(math.pi*pow(bore,2)*stroke)/4
v_clear=v_stroke/(cr-1)
#state 1
v1=v_stroke+v_clear
#state 2
v2=v_clear
p2=pow(v1/v2,y)*p1
t2=pow(v1/v2,y-1)*t1
#state 3
v3=v2
p3=p2*(t3/t2)
#state 4
v4=v1
p4=pow(v3/v4,y)*p3
t4=pow(v3/v4,y-1)*t3
for v in v_comp:
p_comp.append(c1/(pow(v,y)))
for ve in v_exp:
p_exp.append(c2/(pow(ve,y)))
#Calculation efficiency
n=1-((t4-t1)/(t3-t2))
print('Efficiency of engine = ', n);
plt.xlabel('Volume (m^3)')
plt.ylabel('Pressure (pa)')
plt.legend()
plt.title('OTTO CYCLE')
plt.grid()
plt.show()
STEPS:
1. All known engine geometry parameters and state variable were defined.
2. The formula for volume swept and volume clearance was given.
3. With the help of Isentropic formulate for process 1-2 and 3-4, all state variable was calculated.
4. By this, we got all four-point of the p-v diagram but for tracing isentropic volume we need to define how
the volume changes in the engine piston.
5. For this, we define a function, engine_kinematics which calculates the volume swept for isentropic
processes for each value of angle covered by the connecting rod.
6. For this function, bore, stroke, length of connecting rod (cr), and swept angle were given as arguments.
7. After this P-V diagram plot was completed by the help of plotting command.
8. The efficiency formula was also defined to get the efficiency of the cycle.
OUTPUT:
The program outputs the efficiency of the Otto cycle and plots P-V diagram. In the P-V diagram
we can see that for heat addition and heat removal process, the volume is constant and for the
isentropic processes, the graph is following an isentropic path.