Air standard Cycle using PYTHON
Aim: - Write a Python program that can solve engine kinematics using basic engine geometry operating on the OTTO cycle. Create a PV diagram and find the thermal efficiency of the engine.
Governing equation: -
Here this equation is used to show the relationship between crank angle and volume inside crank angle and volume inside the crank chamber
And another governing equation is this, the formula for thermal efficiency
`η_(th)= 1- ((T_4- T_1 ))/((T_3- T_2 ) ) = η_o`
Objective: - our main objective is to find thermal efficiency and plot the PV diagram of the cycle.
Processes: -
- Process 1-2 mass of air is drawn into the cylinder.
- Process 2-3 is an isentropic compression, as the piston moves from BDC (bottom dead center) to TDC (top dead center).
- Process 3-4 is a constant volume heat addition in this the air-fuel mixture inside the cylinder pushes the piston from TDC to BDC.
- Process 4-5 is an isentropic expansion (Power stroke). That is, the air-fuel mixture gets ignited by the spark plug.
- Process 5-6 is constant volume heat rejection; in this process the cycles complete and it’s the blowdown.
- Process 6-1 the mass of air is released into the atmosphere in a constant pressure process.
Compression Ratio:
Compression ratio (cr) is the ration of total cylinder volume to the clearance volume
`Cr = v_1/v_2 = v_4/v_3`
Now that we know the basic term, let us derive the expression for and. These expressions will be useful for us to derive the expression for air standard efficiency of the Otto cycle. For finding, we take process 1-3 and for finding, we take the process 3-4.
Process 1-2:
This process is an isentropic (reversible adiabatic) process. For this process, the relation between T and V is:
`T_2/T_1 = (V_1/V_2 )^(γ-1) = cr^(γ-1)`
`T_2 = T_1 × cr^(γ-1) ………. (i)`
Process 3-4:
This is also an isentropic process. The relation between T and V in the process is similar to the relation between T and V in process 1-2.
`T_3/T_4 = (V_4/V_3 )^(γ-1) = cr^(γ-1)`
`T_3 = T_4 × cr^(γ-1) ………. (ii)`
Air-standard Efficiency (thermal efficiency) of Otto cycle,
`η_(th)= (mC_v (T_3- T_2 ) - mC_v (T_4- T_1 ))/(mC_v (T_3- T_2 ) )`
`η_(th)= 1 - ((T_4- T_1 ))/((T_3- T_2 ) ) = η_o`
Thermal efficiency can also be calculated by using the relation,
`η_(th)= 1 - ((T_4- T_1 ))/((T_(4 ) (cr)^(γ-1)- T_1 (cr)^(γ-1) ) )`
`η_(th)= 1 - ((T_4- T_1 ))/((T_4- T_1 ) (cr)^(γ-1) )`
`η_(th)= 1 - 1/cr^((γ-1) ^(nth )`
The Geometric parameters of Engine: -
- Bore = 0.1
- Stroke = 0.1
- Con_rod = 0.15
- Cr = 12
- A = stroke/2
- R = con_rod/a
- Gamma = 1.4
INPUTS: -
State point 1: -
- P1 = 101325 pa
- T1= 500 k
- V1 = v_swpet = v_clearance , where,(swept volume and clearance volume respectively)
State point 3: -
- T3 = 2300k
Explanation: -
- First, we have to define inputs like bore, stroke, connecting rod, compression ratio, gamma and, temperature, and pressure at state point 1 and temp at state point 3.
- Now we define a function by which we can change the angle and find the actual volume in the engine.
- Then using formula like p1v1^gamma = p2v2^gamma and ideal gas law p1v1/t1 = p2v2/v3. By using this equation, we can find the value of pressure, temp, and volume at different state points.
- And, after that, we call that function in our code and find the different value to volume at different angles for compression and expansion.
- By this, we get the value of pressure, temp, and volume at different state points from 1 to 4.
- And we get an accurate PV diagram as shown below.
Python Code For Air Standard Cycle:
#Python Program to Calculate Thermal Efficiency Of Otto Cycle And plotting PV Diagram.
#By Vishal Bhardwaj
#Importing Libraries
import math
import matplotlib.pyplot as plt
def engine_kinematics(bore,stroke,con_rod,cr,start_crank,end_crank):
#Inputs
a=stroke/2
R=con_rod/a
#Defining Angles
sc=math.radians(start_crank) # starting crank angle
ec=math.radians(end_crank) # ending crank angle
num_values = 50
dtheta = (ec-sc)/(num_values-1) #ec = End Crank Angle & sc = Start Crank Angle
v_s = (math.pi/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
V= []
#Loop For tracing curves
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
#Inputs
p1=101325 #Pressure At State Point 1
t1=500 #Temperature At State Point 1
gamma=1.4 #Constant
t3=2300 #Temperature At State Point 3
#Engine Geometric Parameters
bore=0.1
stroke=0.1
con_rod=0.15
cr=10
v_s = math.pi*(1/4)*pow(bore,2)*stroke
v_c = v_s/(cr-1)
v1 = v_s + v_c
v2 = v_c
#State point 2
#p1v1/t1 = p2v2/t2=rhs
#p1v1^gamma = p2v2^gamma
p2=p1*pow(v1/v2,gamma)
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))
#State point 3
v3 = v2
rhs = p2*v2/t2
p3 = rhs*t3/v3
#State point 4
v4 = v1
p4=p3*pow(v3,gamma)/pow(v4,gamma)
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))
#Plotting the PV Diagram
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.title('Otto Cycle PV Diagram')
plt.xlabel('Volume (m^3)')
plt.ylabel('Pressure (Pa)')
plt.savefig('PV Diagram')
plt.show()
#To find Efficiency
E = 1 - (t1/t2)
print('Thermal Efficiency is',E)
RESULTS:
THERMAL EFFICIENCY:
PV Diagram Plot: