Otto Cycle Simulator
Objectives:
- To solve an otto cycle for given parameters and create a PV diagram for it
- To calculate and output the thermal efficiency of the cycle for the given parameters
Initial Conditions:
- Inlet pressure at start of stroke (P1) = 101325 Pa
- Initial Cylinder temperature (T1) = 500 K
- Ratio of specefic heats (gamma) = 1.4
- Bore = 0.1 m
- Stroke = 0.1 m
- Connecting Rod Length = 0.15 m
- Compression Ratio = 12
- Target temperature assumed after the constant volume heat addition process (T3) = 2300 K
Process Description: Otto Cycle
The otto cycle is an idealized cycle which describes the functioning of a spark ignition engine.
The processes involved in an otto cycle are as follows:
- Air is initially sucked into the cylinder at a constant pressure
- This charge then undergoes isentropic compression as the piston moves from the BDC to the TDC (Process 1-2)
- The next process ( Process 2-3 ) represents the constant volume heat addition process to the charge which in turn represents the ignition and subsequent rapid burning stage of the charge
- This is then followed by the isentropic exanpison process or the power stroke ( Process 3-4 )
- The cycle is then completed by the process of constant volume heat rejection ( Process 4-1 )
Code Methodology:
- Import the required packages
- A function is defined which represents the final form of the slider crank mechanism which is used to compute the volume at each point during the stroke
- The initial conditions at state point 1 are defined as well as the geometric parameters for the engine through which the swept volume, compression volume and the volume at point 1 are calculated
- The volume at state point 2 is equal to the clearance volume as seen in the above figure. The pressure and temperature at this point is then computed through the isentropic equations and ideal gas law as shown in code.
- In order to define the curve to connect the points 1 and 2, the initially defined function is called to calculate the volumes at various points during the process 1-2.
- To calulate the parameters at point 3, a target temperature is assumed at state point 3. The volume at point 3 is equal to that of point 2 as seen. Through this the pressure is then computed using the ideal gas law equations.
- Once again the above procedures are repeated to calcluate the parameters at state point 4 and to define the curve between points 3 and 4. In defining the curve, it is important to specify the correct values for the start and end crank angles during these processes.
- The efficiency of the cycle is then calculated from the data calculated previously and the PV Diagram for the cycle is plotted.
Remark - The thermal efficiency calculated is 62.98 %
#
import math
import matplotlib.pyplot as plt
import numpy as np
def engine_kinematics(bore,stroke,connecting_rod_length,compression_ratio,crank_start,crank_end):
\"\"\"
Engine Kinematics
\"\"\"
# Geometric parameters
a=stroke/2 # Crank Radius
R= connecting_rod_length/a
# Volumetric Parameters
V_s=(math.pi/4)*pow(bore,2)*stroke # Swept Volume
V_c=V_s/(compression_ratio-1) # Clearance Volume
angles=np.linspace(math.radians(crank_start),math.radians(crank_end),100)
Volume=[]
for theta in angles:
term1=0.5*(compression_ratio-1)
term2=R+1-math.cos(theta)
term3=pow(R,2)-pow(math.sin(theta),2)
term3=pow(term3,0.5)
Volume.append((1+term1*(term2-term3))*V_c) # Volume computation at any point during stroke
return Volume
# At state point 1
p1=101325 # Air is sucked in at atmospheric pressure
t1=500 # Initial cylinder Temperature
gamma=1.4 # Ratio of specefic heats
# Geometric parameterws
bore=0.1
stroke=0.1
connecting_rod_length=0.15
compression_ratio=12
# Volumetric Parameters
V_s=(math.pi/4)*pow(bore,2)*stroke # Swept Volume
V_c=V_s/(compression_ratio-1) # Clearance Volume
V1 = V_s+V_c # Total Volume with piston at BDC at start of compression
# At state point 2
V2= V_c # At the end of compression the volume is equal to clerance volume
p2=p1*pow(V1,gamma)/pow(V2,gamma) # Isentropic equations (p1*V1^gamma=p2*V2^gamma)
# For Temperature at point 2 # Ideal Gas Law(p2*v2/t2=p1*v1/t1)
rhs=p1*V1/t1
t2=p2*V2/rhs
Volume_Compression=engine_kinematics(bore,stroke,connecting_rod_length,compression_ratio,180,0)
constant=p1*pow(V1,gamma) # P_compression*Volume_Compression^gamma=constant
P_compression=[]
for V in Volume_Compression:
P_compression.append(constant/pow(V,gamma))
# At state point 3
t3=2300 # Assumed temperature after constant volume heat addition
V3=V2 # Since it is constant volume heat addition
# For pressure at state 3 # Ideal Gas Law(p2*v2/t2=p1*v1/t1)
rhs=p2*V2/t2
p3=rhs*t3/V3
# At state point 4
V4=V1 # Constant volume heat rejection
p4=p3*pow(V3,gamma)/pow(V4,gamma) # Isentropic equations (p4*V4^gamma=p3*V3^gamma)
# For Temperature at point 4 # Ideal Gas Law(p4*v4/t4=p3*v3/t3)
rhs=p3*V3/t3
t4=p4*V4/rhs
Volume_Expansion=engine_kinematics(bore,stroke,connecting_rod_length,compression_ratio,0,180)
constant=p3*pow(V3,gamma) # P_compression*Volume_Compression^gamma=constant
P_Expansion=[]
for V in Volume_Expansion:
P_Expansion.append(constant/pow(V,gamma))
# Thermal Efficiency calculation
Efficiency= 1-((t4-t1)/(t3-t2))
print(\'Thermal Efficiency is=\', Efficiency*100)
plt.xlabel(\'Volume\')
plt.ylabel(\'Pressure\')
plt.title(\"PV Diagram of air standard Otto Cycle\")
plt.plot([V2,V3],[p2,p3])
plt.plot([V4,V1],[p4,p1])
plt.plot(Volume_Expansion,P_Expansion)
plt.plot(Volume_Compression,P_compression)
plt.show()